Allow image url as ChatBot response (#3953)

* fix(chatbot): allow url as chatbot response

* chore(changelog): update changelog

* fix: update per review

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
Tyé singwa 2023-04-24 18:45:04 +03:00 committed by GitHub
parent 4c0410579b
commit 6b854eefd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,7 @@ No changes to highlight.
- Fix issue where requesting for a non-existing file would trigger a 500 error by [@micky2be](https://github.com/micky2be) in `[PR 3895](https://github.com/gradio-app/gradio/pull/3895)`.
- Fix bugs with abspath about symlinks, and unresolvable path on Windows by [@micky2be](https://github.com/micky2be) in `[PR 3895](https://github.com/gradio-app/gradio/pull/3895)`.
- Fixes type in client `Status` enum by [@10zinten](https://github.com/10zinten) in [PR 3931](https://github.com/gradio-app/gradio/pull/3931)
- Fix `gr.ChatBot` to handle image url [tye-singwa](https://github.com/tye-signwa) in [PR 3953](https://github.com/gradio-app/gradio/pull/3953)
## Documentation Changes:

View File

@ -4581,9 +4581,13 @@ class Chatbot(Changeable, Selectable, IOComponent, JSONSerializable):
if chat_message is None:
return None
elif isinstance(chat_message, (tuple, list)):
filepath = chat_message[0]
file_uri = chat_message[0]
if utils.validate_url(file_uri):
filepath = file_uri
else:
filepath = self.make_temp_copy_if_needed(file_uri)
mime_type = client_utils.get_mimetype(filepath)
filepath = self.make_temp_copy_if_needed(filepath)
return {
"name": filepath,
"mime_type": mime_type,