gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
34.11k stars 2.59k forks source link

Add ability to provide preset response options in `gr.Chatbot` / `gr.ChatInterface` #9989

Closed abidlabs closed 21 hours ago

abidlabs commented 3 days ago

Adds an optional options field to MessageDict that can take a list of dictionaries of value and optionally, a separate label, which produces preset options that a user can click on.

To see it in action, please run: demo/chatinterface_options/run.py

https://github.com/user-attachments/assets/ed9b7672-1b5d-41b2-8479-7a5c9326ca56

Closes: https://github.com/gradio-app/gradio/issues/8698 Closes: https://github.com/gradio-app/gradio/issues/4763 Closes: https://github.com/gradio-app/gradio/issues/6372

I'm working on improving the ChatInterface docs so hold off on reviewing those, but once the docs are ready, it'll also close:

Closes: https://github.com/gradio-app/gradio/issues/9917

gradio-pr-bot commented 3 days ago

🪼 branch checks and previews

• Name Status URL
Spaces ready! Spaces preview
Website building...
Storybook ready! Storybook preview
:unicorn: Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/1607c279e37d26f35261449408eaa9fd62a06d5c/gradio-5.6.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/1607c279e37d26f35261449408eaa9fd62a06d5c/gradio-client-1.8.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/1607c279e37d26f35261449408eaa9fd62a06d5c/dist/lite.js""></script>
gradio-pr-bot commented 3 days ago

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/chatbot minor
gradio minor

With the following changelog entry.

Add ability to provide preset response options in gr.Chatbot / gr.ChatInterface

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](https://github.com/gradio-app/gradio/edit/options/.changeset/orange-cobras-suffer.md).
abidlabs commented 1 day ago

Docs are ready too now!

abidlabs commented 1 day ago

Tweaked the styling a bit (cc @hannahblair):

https://github.com/user-attachments/assets/428c47d5-0313-420c-a811-520f75b63b4b

abidlabs commented 1 day ago

Maybe presets or responses would be a better name instead of options? Open to suggestions on the api

abidlabs commented 1 day ago

Thanks @hannahblair for the docs fixes! Had no idea I repeat words that often

abidlabs commented 21 hours ago

Thanks @hysts and @dawoodkhan82 for reviewing!