-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Fix BaseOpenAIChatCompletionClient token usage #4770
base: main
Are you sure you want to change the base?
Conversation
@@ -561,8 +554,7 @@ async def create( | |||
logprobs=logprobs, | |||
) | |||
|
|||
_add_usage(self._actual_usage, usage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering what's the difference between these two...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Traditionally actual vs total is a matter of if the tokens were cached or not. But since we don't have caching atm they should be identical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jackgerrits! I have updated the PR to use both actual_usage
and total_usage
.
@gziz The original issue what that we're not using the returned value of the function where we add usage. I'd rather a smaller change where we just assign that value back to the appropriate variable. This change couples actual and total usage into the same function. If we want to make all this simpler, we can implement
That way we can update the code to simply be: self._actual_usage += usage |
Why are these changes needed?
To correctly track the token usage in
BaseOpenAIChatCompletionClient
, more info on the issue.Related issue number
#4769
Checks