Skip to content
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

OpenAI Client Token Usage not being tracked #4769

Open
gziz opened this issue Dec 20, 2024 · 0 comments
Open

OpenAI Client Token Usage not being tracked #4769

gziz opened this issue Dec 20, 2024 · 0 comments
Assignees
Milestone

Comments

@gziz
Copy link
Contributor

gziz commented Dec 20, 2024

What happened?

The BaseOpenAIChatCompletionClient has a total_usage property that's supposed to track the token usage of the client.
However, it looks like the logic to do so is not implemented correctly.

Here's the function responsible of adding usage

def _add_usage(usage1: RequestUsage, usage2: RequestUsage) -> RequestUsage:
    return RequestUsage(
        prompt_tokens=usage1.prompt_tokens + usage2.prompt_tokens,
        completion_tokens=usage1.completion_tokens + usage2.completion_tokens,
    )

Here's how the function is being used

        _add_usage(self._total_usage, usage)

The function returns a RequestUsage object however, we are not even receiving that returned value.

AutoGen version

0.4

Which package was this bug in

Extensions

Model used

No response

Python version

No response

Operating system

No response

Any additional info you think would be helpful for fixing this bug

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants