Tijmen2 commited on
Commit
013011c
·
verified ·
1 Parent(s): bfab850

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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
- chatbot.update(history) # Display user's message before response
 
85
  for response in respond(message, history, system_message, max_tokens, temperature, top_p):
86
- history[-1] = (message, response) # Update the last response with streaming content
87
- chatbot.update(history)
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],