-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use LLM APIs responses in token counting #5604
base: main
Are you sure you want to change the base?
Conversation
…sponse "usage" data" This reverts commit d317a3e.
@openhands-agent Read the diff of this PR, PR 5604. And add unit tests for the functionality we change or introduce. Please make sure to explore the unit tests a bit to find if we already have test files appropriate for these tests, if not make a new one. |
* Replace prompt_tokens, completion_tokens, total_tokens fields with a single usage field * Add properties to maintain backward compatibility * Update tests to verify Usage object is stored and properties work * Update LLM.get_token_count() to use usage.total_tokens
* Keep Usage-based token counting for Message objects * Add support for dict messages from main * Add custom tokenizer support from main * Improve error logging from main * Add new tests from main
* Add back the initialization of self.tokenizer that was lost in merge * This is needed for custom tokenizer support in token counting
* Add back the import that was lost in merge * This import is needed for custom tokenizer initialization
* Add explicit type check for Message in token counting loop * This fixes mypy errors about accessing .usage on dict
* Add back the logger mock that was lost in merge * This is needed for token counting error handling tests
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Status Summary: UNRESOLVED ISSUES:
NEXT STEPS NEEDED:
Overall Assessment: The original issue remains entirely unresolved as the agent did not perform any of the requested merge-related tasks and instead went off-topic with code analysis. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
OVERVIEW:
STATUS: ✅ FULLY RESOLVED
NEXT STEPS:
|
End-user friendly description of the problem this fixes or functionality that this introduces
Give a summary of what the PR does, explaining any non-trivial design decisions
Follow-up on #5550
Litellm has token data for certain LLMs. We can use it if it's available and more accurate/appropriate than its token counting with tiktoken.
Link of any specific issues this addresses
Fix #2947
To run this PR locally, use the following command: