Skip to content

Fix token usage attribute names in stream_response for streamed outputs #65

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

Closed
wants to merge 1 commit into from

Conversation

zky001
Copy link

@zky001 zky001 commented Mar 12, 2025

This PR fixes an issue in the streaming response processing where the code incorrectly accessed non-existent attributes (input_tokens and output_tokens) on the Usage object. Instead, the correct property names (prompt_tokens and completion_tokens) should be used. see https://github.com/openai/openai-python/blob/v1.66.2/src/openai/types/completion_usage.py
fix bug metioned in #63

This PR fixes an issue in the streaming response processing where the code incorrectly accessed non-existent attributes (input_tokens and output_tokens) on the Usage object. Instead, the correct property names (prompt_tokens and completion_tokens) should be used.
@Kaikaikaifang
Copy link

This PR #61 has made a more comprehensive fix for this issue.

@zky001 zky001 closed this Mar 12, 2025
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.

2 participants