-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Description
- I have searched to see if a similar issue already exists.
- Problem: When interacting with
gr.Chatbot(), the progress timer stops after the first assistant message. - Why this is a problem: Stopping the timer prematurely gives the user the false impression that the interaction has completed.
- Solution: The progress timer should keep going until the assistant stops responding.
- Additional context: This behavior shows up during consecutive
yieldstatements for agent interactions: https://www.gradio.app/guides/agents-and-tool-usage
Reproduction (see demo at HF Spaces: jedick/chatbot-progress):
import gradio as gr
import time
def interact_with_agent(prompt, messages=[]):
"""Simulate generation of two assistant messages after delays"""
time.sleep(2)
messages.append(
gr.ChatMessage(
role="assistant", content="Progress timer stops here (or becomes invisible)"
)
)
yield messages
time.sleep(2)
messages.append(
gr.ChatMessage(role="assistant", content="But I want it to stop here")
)
yield messages
def str_to_message(content, role="user"):
return [gr.ChatMessage(role=role, content=content)]
with gr.Blocks() as demo:
chatbot = gr.Chatbot(
type="messages",
)
input = gr.Textbox(
"Start the simulation with two assistant messages after 2-second delays",
autofocus=True,
)
input.submit(
# Update chatbot UI with user message immediately
str_to_message,
input,
chatbot,
).then(
# Update chatbot UI with assistant messages
interact_with_agent,
[input, chatbot],
chatbot,
)
demo.launch()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels