Add stream_options property to get token usage. #180
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added the ability to receive token usage based on this object in the OpenAI documentation:
https://platform.openai.com/docs/api-reference/chat/streaming
Added an optional parameter called
streamOptions
to thecreateStream
interface which passes the aforementioned body parameter to the chat endpoint which enables receiving the optional usage statistics.Added tests as well which succeeded during my tests. Some of the new tests might be considered unnecessary and I will be happy to change them if necessary.
Unrelated to the changes I made - I will note the following
expect
s failed so I commented them out during my testing - they don't seem related my code changes:Kept getting
bad state: no element
- presumably because we are using the.first
getter here.Thanks!
This PR is a solution to this issue: #155 (comment)