-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow Chatbot examples to show more than one image #10111
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/2e228995203dd957cb6a59591605058726d7708d/gradio-5.8.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@2e228995203dd957cb6a59591605058726d7708d#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/2e228995203dd957cb6a59591605058726d7708d/gradio-client-1.8.0.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/2e228995203dd957cb6a59591605058726d7708d/dist/lite.js""></script> |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
… into example-images-chatbot
Wow this looks splendid @hannahblair! My one hesitation is the addition of the "Aa" icon on top of examples without any files. I do like that it makes all of the examples the same vertical height. However, it feels quite unnecessary when all of the examples only consist of text, which is probably the most common case (e.g. see Idea: what if we only show this "Aa" icon if
I don't think we should cascade the image icons. For many VLMs, examples will often consist of a pair of images along with a question like, "what's different between these images", in which case, it'll help to be able to see the images clearly before clicking on the example. For the sake of consistency, I'd suggest we also not cascade the file icons, but open to other folks thoughts about both of these points. cc @aliabid94 @dawoodkhan82 @allisonwhilden |
This is clean! Agree on not cascading the file icons. Also maybe we can show a different icon for audio and video files, like we do in the multimodal textbox. Or even nicer would be to show a thumbnail for video files. |
Agree with @dawoodkhan82 about icons for audio and video files, it'd be good to have consistent icons in the chatbot examples and the multimodal textbox: |
Yep I agree, that's a great idea! |
Not sure if this PR is 100% ready @hannahblair but I noticed that there's a gap on top of the the examples when (see |
@hannahblair not sure if I'm testing wrong, but I just tested with this modified version of import gradio as gr
def echo(message, history):
return message["text"]
demo = gr.ChatInterface(
fn=echo,
type="messages",
examples=[{"text": "hello", "files": ["files/avatar.png"]}, {"text": "hola", "files": ["files/avatar.png", "files/cantina.wav"]}, {"text": "merhaba", "files": ["files/avatar.png", "files/avatar.png", "files/avatar.png"]}],
title="Echo Bot",
multimodal=True,
)
demo.launch() Does this work for you? |
Sorry I'm confused @hannahblair why are adding the |
Ah okay so I understand the reason for creating the There's a couple of approaches we could take instead: (1) The (2) The other possibility would to modify the logic a little bit so that instead of showing the "Aa" icon when the gr.ChatInterface is multimodal, we show it for any text-only example if there are any other examples that include files. This logic could be contained entirely inside My preference is for (1) since it feels less "surprising", but (2) also makes sense as long as we document the behavior appropriately. |
This won't work without some modification in the backend because even when
so I think we need to take option 1 but include the changes to the |
I do think option 1 is the way to go but why do we need to strip the files? There might be some niche cases where a user really wants to pass in files in their example for a non-multimodal chat interface, can we just let them do that? I can't think of any reason for it, but at the same time, it doesn't break anything if they do. On the other hand, it might be a breaking change for certain demos that might be using this feature. |
… into example-images-chatbot
gradio/chat_interface.py
Outdated
"path": "", | ||
"url": "", | ||
"orig_name": "", | ||
"mime_type": "text", # for internal use, not a valid mime type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's the backend implementation i'm using to indicate in the frontend whether the example is text only
- ensure mixed files can be displayed in multiples
gradio/chat_interface.py
Outdated
@@ -324,6 +324,7 @@ def _setup_example_messages( | |||
examples: list[str] | list[MultimodalValue] | list[list] | None, | |||
example_labels: list[str] | None = None, | |||
example_icons: list[str] | None = None, | |||
multimodal: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multimodal: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm @hannahblair looks great! Just left one minor suggestion on the backend implementation
Description
This PR allows the Chatbot to display more files and info in the examples area and adds some design tweaks. Let me know what you think!
Small question, should we cascade the image icons as well like we do for the files? 🤔
Closes: #10111
🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Testing and Formatting Your Code
PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests:
bash scripts/run_backend_tests.sh
Please run these bash scripts to automatically format your code:
bash scripts/format_backend.sh
, and (if you made any changes to non-Python files)bash scripts/format_frontend.sh