Add Markdown support in chatbots#2731
Conversation
|
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2731-all-demos |
|
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
Thanks @aliabd! |
| if self.type == "file": | ||
| if is_file: | ||
| file = processing_utils.create_tmp_copy_of_file(file_name) | ||
| file = processing_utils.create_tmp_copy_of_file( |
There was a problem hiding this comment.
Fixed the UploadButton component to save files in the right location
|
Why markdown support over just supporting certain media discreetly? Does supporting all markdown cause any issues? I also don't think forcing user who want to use images (other other media) in the chatbot to use markdown makes for the best experience. Markdown syntax for some thing is kinda weird, images is definitely one of those cases. |
Because we'd need to add support for each of those media types individually and come up with an appropriate syntax to include them whereas Markdown already does that. I haven't seen any issues when I tried using Markdown, but are there specific things you're concerned about?
A little bit yes, but everything is well-documented which is a big plus over having to figure out gradio-specific documentation |
A path and a file extension could determine how we handle the media, markdown has to be learned too and isn't as ubiquitous and some people say.
Markdown supports pretty much all HTML which could easily break the rendering. Additionally, certain block level constructs could cause issues. Additionally, we should also round the corners of images/ videos to ensure they match the style of the chatbox. |
But keep in mind that the
Let me investigate this more
Sure, I'll try to do this but may need some help on the css side! |
|
Discussed with @pngwn and we'll go with Markdown, but clearly document that only a subset of Markdown is supported (note that audio and videos are not currently supported). Also fixed the images to have a rounded border radius. |
|
Thanks for the reviews @aliabid94 and @pngwn! |
|
Cool change! But it broke my app unfortunately. Is it on the user now to parse the html/markdown output if we want to access the chat history or is there some option to do this? |
|
How did it break your app @johnPertoft? Can you open a new issue with more details and a code example so that we can reproduce? |
|
It's really not a big deal but In In So the app "broke" in the sense that it now requires the user to remove the html/markdown added by this change if depending on the chat history. It's a very small change though so I'm not sure it warrants any action taken. I'll open an issue and you can decide:) |
|
This feels like a bug to me. The history should contain the source you passed in, not the post-processed data. In this case it might be simple enough to work with the markup but some markdown transforms are very complex and will be impossible to do anything with other than appending to the history. |
|
An ergonomic/QoL issue with the multimedia messages: unlike an Happy to contribute a patch to preprocess in a manner similar to that of |
|
Hi @falcondai good catch. Please do open a PR and I'm happy to review |
|
What's your full code @Simon1V? |
The original one, just copy & pasted I just tried with another 350x350 jpg, also named lion.jpg to no avail
in the same folder |
|
Now you should just be able to do this: import gradio as gr
with gr.Blocks(css="#chatbot .overflow-y-auto{height:700px!important}") as demo:
gr.Chatbot([("hi", "hello **abubakar**"), (("lion.jpg", ), "cool pic")], elem_id="chatbot")
demo.launch() |
|
Thank you, this worked : ) |
+1 And is there a way of make the image inline with the text please? (such as we send a images with a comment followed inline) |




Adds support for Markdown in the chatbot component. Closes: #2498
Demo code 1 (supply your own image instead of
lion.jpg):Looks like this:
Demo code 2 (this has been added in the
demo/directory):