Update app.py
Browse files
app.py
CHANGED
@@ -81,12 +81,13 @@ with gr.Blocks() as demo:
|
|
81 |
# Automatically handle submission on Enter key press with streaming
|
82 |
def handle_submit(message, history, system_message, max_tokens, temperature, top_p):
|
83 |
history.append((message, None)) # Append user's message first
|
84 |
-
|
|
|
85 |
for response in respond(message, history, system_message, max_tokens, temperature, top_p):
|
86 |
-
history[-1] = (message, response)
|
87 |
-
|
88 |
-
return history, ""
|
89 |
|
|
|
90 |
msg.submit(
|
91 |
handle_submit,
|
92 |
inputs=[msg, chatbot, system_msg, max_tokens, temperature, top_p],
|
|
|
81 |
# Automatically handle submission on Enter key press with streaming
|
82 |
def handle_submit(message, history, system_message, max_tokens, temperature, top_p):
|
83 |
history.append((message, None)) # Append user's message first
|
84 |
+
|
85 |
+
# Stream the assistant's response and update the history
|
86 |
for response in respond(message, history, system_message, max_tokens, temperature, top_p):
|
87 |
+
history[-1] = (message, response)
|
88 |
+
yield history, "" # Yield updated history to display in the chatbox
|
|
|
89 |
|
90 |
+
# Use the new Gradio `chatbot.update` pattern by returning the updated value
|
91 |
msg.submit(
|
92 |
handle_submit,
|
93 |
inputs=[msg, chatbot, system_msg, max_tokens, temperature, top_p],
|