Duplicated gradio app receives "Task exception was never retrieved"

I duplicated an app with https://huggingface.co/spaces/innev/ChatGLM-6B-INT4 and also tried theminimal app from the tutorial: https://www.gradio.app/guides/creating-a-chatbot
Both of them do not require a GPU while a same error pops out, anyone knows what is happening?

Task exception was never retrieved
future: <Task finished name='tsbawo0iq9m_1' coro=<Queue.process_events() done, defined at /home/user/.local/lib/python3.10/site-packages/gradio/queueing.py:343> exception=1 validation error for PredictBody
event_id
  Field required [type=missing, input_value={'fn_index': 1, 'data': [...on_hash': 'tsbawo0iq9m'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.1.2/v/missing>
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 347, in process_events
    client_awake = await self.gather_event_data(event)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 220, in gather_event_data
    data, client_awake = await self.get_message(event, timeout=receive_timeout)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 456, in get_message
    return PredictBody(**data), True
  File "/home/user/.local/lib/python3.10/site-packages/pydantic/main.py", line 150, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for PredictBody
event_id
  Field required [type=missing, input_value={'fn_index': 1, 'data': [...on_hash': 'tsbawo0iq9m'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.1.2/v/missing
Task exception was never retrieved
future: <Task finished name='24iy8opwivr_1' coro=<Queue.process_events() done, defined at /home/user/.local/lib/python3.10/site-packages/gradio/queueing.py:343> exception=1 validation error for PredictBody
event_id
  Field required [type=missing, input_value={'fn_index': 1, 'data': [...on_hash': '24iy8opwivr'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.1.2/v/missing>
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 347, in process_events
    client_awake = await self.gather_event_data(event)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 220, in gather_event_data
    data, client_awake = await self.get_message(event, timeout=receive_timeout)
  File "/home/user/.local/lib/python3.10/site-packages/gradio/queueing.py", line 456, in get_message
    return PredictBody(**data), True
  File "/home/user/.local/lib/python3.10/site-packages/pydantic/main.py", line 150, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for PredictBody
event_id
  Field required [type=missing, input_value={'fn_index': 1, 'data': [...on_hash': '24iy8opwivr'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.1.2/v/missing

The app.py in the tutorial I used is

import gradio as gr
import random
import time

# Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text.

def add_text(history, text):
    history = history + [(text, None)]
    return history, gr.update(value="", interactive=False)


def add_file(history, file):
    history = history + [((file.name,), None)]
    return history


def bot(history):
    response = "**That's cool!**"
    history[-1][1] = ""
    for character in response:
        history[-1][1] += character
        time.sleep(0.05)
        yield history


with gr.Blocks() as demo:
    chatbot = gr.Chatbot([], elem_id="chatbot").style(height=750)

    with gr.Row():
        with gr.Column(scale=0.85):
            txt = gr.Textbox(
                show_label=False,
                placeholder="Enter text and press enter, or upload an image",
            ).style(container=False)
        with gr.Column(scale=0.15, min_width=0):
            btn = gr.UploadButton("๐Ÿ“", file_types=["image", "video", "audio"])

    txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
        bot, chatbot, chatbot
    )
    txt_msg.then(lambda: gr.update(interactive=True), None, [txt], queue=False)
    file_msg = btn.upload(add_file, [chatbot, btn], [chatbot], queue=False).then(
        bot, chatbot, chatbot
    )

demo.queue()
demo.launch()

e76bb435d2a6c0f13028b93d7c086adb15659552-1

the same issue happened suddenly. Have you solved it?

hi @jingwang and @umiuni
My guess is it could be due to Gradio version and Python version,
You can set booth versions on the README.md

sdk_version: 3.36.1 
python_version: 3.9.17

Same issue here, from local it works

It solves the problem. Thank you so much! :smiling_face_with_three_hearts:

thsnks it works

Hi there,

Iโ€™m sorry to hear youโ€™re having trouble. It seems like you might be experiencing a known issue related to older Gradio versions (<3.36.1) on Spaces. This is caused by a breaking change in Pydantic 2.0 that was recently adopted by FastAPI, causing Spaces to potentially crash upon restart.

The good news is we have a solution. We request you to upgrade Gradio to 3.36.1 across all your Spaces (the gradio sdk in a Spaceโ€™s readme.md file), which should eliminate this issue. For local usage, youโ€™ll only need to upgrade Gradio if youโ€™ve updated to the latest FastAPI/Pydantic versions.

I strongly recommend updating to Gradio 3.36.1 to avoid future problems. We have issued an announcement on our Discord to remind users about this important update. You can find it here - Discord

I hope this helps!

1 Like