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

Need to add the field 'usage' to OpenAIStreamChatCompletionModel #155

Closed
hnvmeta opened this issue Feb 19, 2024 · 2 comments
Closed

Need to add the field 'usage' to OpenAIStreamChatCompletionModel #155

hnvmeta opened this issue Feb 19, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@hnvmeta
Copy link

hnvmeta commented Feb 19, 2024

I need to read the total_tokens field in JSON which is returned from OpenAI. Can you add this field to the OpenAIStreamChatCompletionModel class? Because this class is final, I can't extend it.

@anasfik anasfik self-assigned this Feb 21, 2024
@anasfik anasfik added the enhancement New feature or request label Feb 21, 2024
@anasfik
Copy link
Owner

anasfik commented Feb 21, 2024

The thing is the chat responses chunk object doesn't support having the usage like the asynchronous chat response object

@anasfik anasfik closed this as completed Feb 21, 2024
@dominic-deantonio
Copy link

dominic-deantonio commented Jun 7, 2024

Hi @anasfik I am looking for this feature too. It seems that the chat responses chunk object does include usage according to the page you linked (maybe it didn't before?), just need to include stream_options: {"include_usage": true}. It says it will be null until the final chunk.

Screenshot 2024-06-07 at 3 54 57 PM

I will try to find where to put that in the library, but any help would be appreciated.

Update: I made a PR for this: #180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants