gradio icon indicating copy to clipboard operation
gradio copied to clipboard

gr.Chatbot does not render markdown for HTML properly while streaming.

Open Solomin0 opened this issue 10 months ago • 1 comments

Describe the bug

When streaming characters for the chatbot it does not properly render html. It works as expected if you return the entire tuple without any yields. But yields seem to be breaking it even when trying to return the original tuple.

Have you searched existing issues? 🔎

  • [X] I have searched and found no existing issues

Reproduction

import gradio as gr
import time
def html_fail():
   history = []
   history.append(["",None])
   my_string = [('Hello this is filler text plese click here  <a href="https://www.w3schools.com/">Visit W3Schools.com!</a> goodbye this is filler text', None)]

   for letter in my_string[0][0]:
      history[-1][0] += letter
      time.sleep(0.01)
      yield history
   
   return my_string

with gr.Blocks() as demo:
   button = gr.Button()
   chatbot = gr.Chatbot()
   button.click(html_fail, outputs = chatbot)
   
   
   
demo.queue(default_concurrency_limit=None)
demo.launch()

Screenshot

when yielding by character then returning. image

when returning the history with no yields image

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 4.20.1
gradio_client version: 0.11.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.2.0
fastapi: 0.109.2
ffmpy: 0.3.2
gradio-client==0.11.0 is not installed.
httpx: 0.25.2
huggingface-hub: 0.20.3
importlib-resources: 6.1.1
jinja2: 3.1.3
markupsafe: 2.1.5
matplotlib: 3.8.3
numpy: 1.26.4
orjson: 3.9.14
packaging: 23.2
pandas: 2.2.0
pillow: 10.2.0
pydantic: 2.6.1
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0.1
ruff: 0.3.0
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.9.0
typing-extensions: 4.9.0
uvicorn: 0.27.1
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.

gradio_client dependencies in your environment:

fsspec: 2024.2.0
httpx: 0.25.2
huggingface-hub: 0.20.3
packaging: 23.2
typing-extensions: 4.9.0
websockets: 11.0.3

Severity

Blocking usage of gradio

Solomin0 avatar Apr 01 '24 15:04 Solomin0