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

Usage Stream in Cancelled Streams #1403

Closed
1 task done
rodrigoGA opened this issue May 8, 2024 · 1 comment
Closed
1 task done

Usage Stream in Cancelled Streams #1403

rodrigoGA opened this issue May 8, 2024 · 1 comment

Comments

@rodrigoGA
Copy link

Confirm this is a feature request for the Python library and not the underlying OpenAI API.

  • This is a feature request for the Python library

Describe the feature or improvement you're requesting

I'm unsure whether this should be a feature request or a bug report. But the behavior of the stream's usage in cases where a stream is cancelled is unclear. That is, there are many scenarios in which the response is discarded before it's completed, such as an interruption in a conversation. In these contexts, the stream can be cancelled using

stream = self.client.chat.completions.create(...)
...
stream.response.close()

However, in these cases, I'm unable to read the usage of the stream. How should this be interpreted?

From a developer's standpoint, using the library, it would be more convenient if the usage is available in the response once the response is completed, rather than having to subscribe to the chunks once they're cancelled. That is, stream.response.usage.

Additional context

No response

@rattrayalex
Copy link
Collaborator

usage is not sent from the API if you cancel the stream, so this isn't possible to do in the SDK.

@rattrayalex rattrayalex closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2024
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

No branches or pull requests

2 participants