gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.98k stars 2.58k forks source link

Gradio reload mode does not work with Chatbot based app #8576

Closed johannesgiorgis-galvanize closed 4 months ago

johannesgiorgis-galvanize commented 5 months ago

Describe the bug

For local development, we run our Gradio apps via gradio app.py --demo-name main_demo command to take advantage of automatic reloads to speed up our development feedback. This was working well a few months ago when we were using Gradio v4.25.0

Using v4.36.1, I observed an error related to the watch function when I try to load chatbot based apps. The error is coming from https://github.com/gradio-app/gradio/blob/b842f27c806ee63406fa30ef5f4e1117e70e4bd0/gradio/blocks.py#L1377. Refer to the included screenshot.

I did look around the issues list and don't see any mentions of this.

λ  pip list | grep gradio
gradio                    4.36.1
gradio_client             1.0.1

Have you searched existing issues? 🔎

Reproduction

Right now this happens for any Chatbot based app. Below is a minimal working snippet

import gradio as gr

def stream_response(input: str, history: list):
    pass # some code

interface = gr.ChatInterface(
    stream_response,
    title="FAQ Chatbot",
    description="Welcome to our FAQ chatbot.",
    chatbot=gr.Chatbot(height=600),
    fill_height=True,
)

with gr.Blocks(
) as demo:
    with gr.Tabs():
        with gr.TabItem("FAQ Chatbot"):
            interface.render()

Run Gradio via gradio app.py --demo-name demo

Screenshot

image

Logs

Refer to screenshot for logs

System Info

Macbook Pro M1 Pro

λ  gradio environment
Gradio Environment Information:
------------------------------
Operating System: Darwin
gradio version: 4.36.1
gradio_client version: 1.0.1

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

aiofiles: 23.2.1
altair: 5.3.0
fastapi: 0.111.0
ffmpy: 0.3.2
gradio-client==1.0.1 is not installed.
httpx: 0.24.1
huggingface-hub: 0.23.3
importlib-resources: 6.4.0
jinja2: 3.1.4
markupsafe: 2.1.5
matplotlib: 3.9.0
numpy: 1.26.4
orjson: 3.10.5
packaging: 23.2
pandas: 2.2.2
pillow: 10.3.0
pydantic: 2.7.4
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0.1
ruff: 0.4.8
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.3
typing-extensions: 4.12.2
urllib3: 2.2.1
uvicorn: 0.30.1
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.

gradio_client dependencies in your environment:

fsspec: 2024.6.0
httpx: 0.24.1
huggingface-hub: 0.23.3
packaging: 23.2
typing-extensions: 4.12.2
websockets: 11.0.3

Severity

I can work around it

freddyaboulton commented 4 months ago

Will look into this @johannesgiorgis-galvanize

freddyaboulton commented 4 months ago

I can't reproduce the exact error message on main. Instead, the chatbot won't display messages after the reload. Looking into it.