Skip to content

Conversation

@niklub
Copy link
Contributor

@niklub niklub commented Mar 31, 2025

No description provided.

@niklub niklub requested a review from Copilot March 31, 2025 15:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces message type counters in the MessageBuilder functionality and updates tests and usage reporting accordingly. Key changes include:

  • Adding "message_counts" to expected results in tests.
  • Adjusting LLM usage functions to include message type counts.
  • Updating dependencies and refactoring message parsing code.

Reviewed Changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_stream_inference.py Added "message_counts" field to the expected output dictionary.
tests/test_multiimage_support.py Updated test assertions and added message trimming test logic.
tests/test_llm.py Updated expected cost values and "message_counts" in test outputs.
pyproject.toml Added mypy dependency.
adala/utils/parse.py Refactored message parsing models and removed the split function.
adala/utils/llm_utils.py Incorporated message counters into usage data and refactored LLM calls.
Files not reviewed (2)
  • .cursor/rules/common-rules.mdc: Language not supported
  • .cursorignore: Language not supported

@codecov-commenter
Copy link

codecov-commenter commented Mar 31, 2025

Codecov Report

Attention: Patch coverage is 94.71154% with 11 lines in your changes missing coverage. Please review.

Project coverage is 70.23%. Comparing base (9bb28c2) to head (6e8a1b4).

Files with missing lines Patch % Lines
adala/utils/message_builder.py 94.77% 7 Missing ⚠️
adala/utils/llm_utils.py 91.66% 3 Missing ⚠️
adala/utils/token_counter.py 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #369      +/-   ##
==========================================
+ Coverage   69.07%   70.23%   +1.15%     
==========================================
  Files          49       51       +2     
  Lines        2862     2980     +118     
==========================================
+ Hits         1977     2093     +116     
- Misses        885      887       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@niklub niklub requested a review from Copilot April 1, 2025 06:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements message type counter support in the MessageBuilder and updates tests and related utilities to track message counts. Key changes include:

  • Adding a "_message_counts" field to usage data in multiple test files and LLM utility functions.
  • Updating tests in various modules to assert the presence and correctness of message counts.
  • Removing legacy functions (e.g. split_message_into_chunks) and updating return types in MessagesBuilder.

Reviewed Changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_stream_inference.py Adds a "_message_counts" entry to the expected test output
tests/test_multiimage_support.py Adds a new test to validate message trimming and confirms message counts
tests/test_llm_utils.py Adds tests for message type counting
tests/test_llm.py Updates expected test outputs; removes split_message_into_chunks test
tests/conftest.py Updates VCR configuration to filter additional query parameters
pyproject.toml Upgrades pytest and adds mypy for code quality checks
adala/utils/token_counter.py Introduces a new token counter implementation using LiteLLM
adala/utils/parse.py Removes legacy message chunk splitting code, streamlining template parsing
adala/utils/llm_utils.py Modifies usage dict creation to include message counts and adjusts message extraction from MessagesBuilder
Files not reviewed (2)
  • .cursor/rules/common-rules.mdc: Language not supported
  • .cursorignore: Language not supported
Comments suppressed due to low confidence (4)

tests/test_llm.py:148

  • Removal of the test_split_message_into_chunks function may reduce test coverage for the message chunk splitting functionality. Consider retaining or replacing these tests if the functionality is still required.
def test_split_message_into_chunks():

adala/utils/llm_utils.py:351

  • The usage of messages_builder.get_messages(payload).messages assumes that get_messages now returns an object with a 'messages' attribute. Ensure that this change is consistent throughout the codebase and that the return type is properly documented.
messages = messages_builder.get_messages(payload).messages

adala/utils/llm_utils.py:420

  • The change to access a 'messages' attribute from get_messages(payload) needs consistency checks across all consumers of this method. Please verify that all related code and documentation are updated accordingly.
messages = messages_builder.get_messages(payload).messages

adala/utils/llm_utils.py:492

  • Ensure that returning an object with a 'messages' property from get_messages(payload) is the intended design, and that all invocations are updated consistently to prevent potential runtime errors.
messages = messages_builder.get_messages(payload).messages

@robot-ci-heartex robot-ci-heartex marked this pull request as draft April 1, 2025 22:05
@niklub niklub marked this pull request as ready for review April 3, 2025 16:26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no abstract classes here :( keep it to the minimum layers of abstraction necessary, here you can just use the litellm token count functions directly https://docs.litellm.ai/docs/completion/token_usage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're trying to build the codebase using SOLID principles to resolve potential dependency inversion problems. Specifically, every time you design a new token system, a method of tokenizing, or rely on different ways of counting tokens, you end up with a tightly coupled dependency on litellm. I envision a more sophisticated token management scenario in the future; therefore, decoupling and abstracting this component is essential, as well as in general following the standards of code development.

@robot-ci-heartex robot-ci-heartex marked this pull request as draft April 4, 2025 03:17
@niklub niklub marked this pull request as ready for review April 4, 2025 09:45
@robot-ci-heartex robot-ci-heartex marked this pull request as draft April 5, 2025 04:06
@niklub niklub marked this pull request as ready for review April 7, 2025 11:03
@robot-ci-heartex robot-ci-heartex marked this pull request as draft April 7, 2025 21:05
Copy link
Contributor

@matt-bernstein matt-bernstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove cursorrules from this PR so we can review it separately?

@niklub niklub marked this pull request as ready for review April 9, 2025 09:18
@niklub niklub merged commit a20f2e6 into master Apr 9, 2025
17 of 21 checks passed
@niklub niklub deleted the fb-dia-2067 branch April 9, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants