Skip to content
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

Chatbot can't properly render markdown #9717

Closed
1 task done
scd10 opened this issue Oct 16, 2024 · 1 comment
Closed
1 task done

Chatbot can't properly render markdown #9717

scd10 opened this issue Oct 16, 2024 · 1 comment
Labels
bug Something isn't working Priority High priority issues

Comments

@scd10
Copy link

scd10 commented Oct 16, 2024

Describe the bug

Chatbot stream output can't render markdown properly. It seems that '\n' char is stripped during streaming.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr
import time

with gr.Blocks() as demo:
    chatbot = gr.Chatbot(type="messages", render_markdown=True)
    msg = gr.Textbox()
    clear = gr.Button("Clear")

    def user(user_message, history: list):
        return "", history + [{"role": "user", "content": user_message}]

    def bot(history: list):
        bot_message = "What's your choice?\n  - A\n  - B\n  - C\n"
        history.append({"role": "assistant", "content": "One time output: "+bot_message+"\n\nStream output: "})
        for character in bot_message:
            history[-1]['content'] += character
            time.sleep(0.05)
            yield history

    msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
        bot, chatbot, chatbot
    )
    clear.click(lambda: None, None, chatbot, queue=False)

demo.launch(server_name='0.0.0.0')

Screenshot

image

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 5.1.0
gradio_client version: 1.4.0

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

aiofiles: 23.2.1
anyio: 4.6.0
fastapi: 0.115.0
ffmpy: 0.4.0
gradio-client==1.4.0 is not installed.
httpx: 0.27.2
huggingface-hub: 0.25.1
jinja2: 3.1.4
markupsafe: 2.1.5
numpy: 2.1.2
orjson: 3.10.7
packaging: 24.1
pandas: 2.2.3
pillow: 10.4.0
pydantic: 2.9.2
pydub: 0.25.1
python-multipart: 0.0.12
pyyaml: 6.0.2
ruff: 0.6.9
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.5
typing-extensions: 4.12.2
urllib3: 2.2.3
uvicorn: 0.31.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2024.9.0
httpx: 0.27.2
huggingface-hub: 0.25.1
packaging: 24.1
typing-extensions: 4.12.2
websockets: 12.0

Severity

I can work around it

@scd10 scd10 added the bug Something isn't working label Oct 16, 2024
@abidlabs abidlabs added the Priority High priority issues label Oct 16, 2024
@freddyaboulton
Copy link
Collaborator

freddyaboulton commented Oct 17, 2024

Thanks for filing! This is a duplicate of #9679

@freddyaboulton freddyaboulton closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority High priority issues
Projects
None yet
Development

No branches or pull requests

3 participants