Closed redrocket8 closed 1 year ago
Can confirm the issue! We'll look into it @redrocket8.
Here's a repro showing that the latex is working in the fixed case but not in the streaming case:
import gradio as gr
string = "did you know $1+1=2$?"
def latex():
for i in range(len(string)):
yield [("gimme a fact", string[:i+1])]
with gr.Blocks() as demo:
chatbot = gr.Chatbot([("fixed", string)], latex_delimiters=[{ "left": "$", "right": "$", "display": False }])
chatbot = gr.Chatbot(latex_delimiters=[{ "left": "$", "right": "$", "display": False }])
demo.load(latex, None, chatbot)
demo.queue().launch()
Thanks
Similar problem happens with gr.Markdown()
but seems even more severe -- any time Markdown is returned from a function (streaming or not), LaTeX is not rendered. See:
import gradio as gr
import time
string = "did you know $1+1=2$?"
def fixed():
return string
with gr.Blocks() as demo:
chatbot1 = gr.Markdown(string, latex_delimiters=[{ "left": "$", "right": "$", "display": False }])
chatbot2 = gr.Markdown(latex_delimiters=[{ "left": "$", "right": "$", "display": False }])
demo.load(fixed, None, chatbot2)
demo.queue().launch()
Although it is closed. Can't get it working with streaming . Can you give an example to run on colab?
Can you please push this change if it's fixed? An example that it's working would be great too.
We'll do a release soon -- in the meantime, you can install directly from the PR branch by doing:
pip install https://gradio-builds.s3.amazonaws.com/be42a5ded17e725f3227f70fc28877c1dba76780/gradio-3.41.2-py3-none-any.whl
Please see my messages above for repros you can try to confirm that the issue has been fixed.
Describe the bug
When I try to run gradio/chatbot_multimodal then when a string has latex code then the latex rendered equation is not displayed, instead the code is streamed as the rest of the characters.
example string = The square root of 4 is 2 $\sqrt{4}=2 $
I have set
I have also tried example string = The square root of 4 is 2 $\\sqrt{4}=2 $ with no results
Have you searched existing issues? 🔎
Reproduction
Screenshot
No response
Logs
System Info
Severity
I can work around it