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

Fixes options in the streaming chatbot case #10123

Merged
merged 5 commits into from
Dec 4, 2024
Merged

Fixes options in the streaming chatbot case #10123

merged 5 commits into from
Dec 4, 2024

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Dec 4, 2024

For reasons I don't fully understand, my previous approach seemed to be triggering a race condition in the frontend. Using reactive props fixes it.

Closes: #10102

Test with:

import gradio as gr
import time

def example(message, history):
    for i in range(len(message)):
        time.sleep(0.1)
        yield {"role": "assistant", "content": message[:i+1]}
    yield {"role": "assistant", "content": message, "options":[{"value": "Yes, that's correct.", "label": "Yes"}, {"value": "No", "label": "No"}]}

demo = gr.ChatInterface(
    example,
    type="messages",
)

if __name__ == "__main__":
    demo.launch()

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 4, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/295c5337dfc92d39007ba1f41b506fb99e1499c3/gradio-5.7.1-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@295c5337dfc92d39007ba1f41b506fb99e1499c3#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/295c5337dfc92d39007ba1f41b506fb99e1499c3/gradio-client-1.8.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/295c5337dfc92d39007ba1f41b506fb99e1499c3/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 4, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/chatbot patch
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fixes options in the streaming chatbot case

Maintainers or the PR author can modify the PR title to modify this entry.

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 update the changelog file directly.

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@abidlabs
Copy link
Member Author

abidlabs commented Dec 4, 2024

Thanks again @freddyaboulton!

@abidlabs abidlabs merged commit 36e9597 into main Dec 4, 2024
24 checks passed
@abidlabs abidlabs deleted the fix-options branch December 4, 2024 22:00
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.

Response options in gr.Chatbot cause frozen / unexpected behavior in streaming scenarios.
3 participants