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

Streaming example for the updated OpenAI API #7508

Merged
merged 3 commits into from
Feb 22, 2024
Merged

Conversation

triakshunn
Copy link
Contributor

Description

This PR updates the usage of the OpenAI API in accordance with the changes in version 1.0.0. The deprecated openai.ChatCompletion has been replaced with client.ChatCompletion.create().

Additionally, the way we extract the content from the API response has been updated. Previously, we checked if the length of chunk['choices'][0]['delta'] was not zero. Now, we check if chunk.choices[0].delta.content is not None before appending it to partial_message.

Closes: #7242

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Feb 22, 2024

🪼 branch checks and previews

Name Status URL
Website ready! Website preview
🦄 Changes detected! Details

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Feb 22, 2024

🦄 no changes detected

This Pull Request does not include changes to any packages.

__No changes detected. __

  • Maintainers can select this checkbox to manually select packages to update.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can create the changelog file directly.

Sorry, something went wrong.

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the contribution @triakshunn!

@abidlabs abidlabs enabled auto-merge (squash) February 22, 2024 16:08
@abidlabs abidlabs merged commit 8f050ee into gradio-app:main Feb 22, 2024
7 checks passed
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.

Errors in "A streaming example using openai"
3 participants