expandme commited on
Commit
826e9dc
1 Parent(s): 54081a3

Fixing question repetition ? - What wind.surf will do ?

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -164,15 +164,16 @@ with gr.Blocks() as demo:
164
 
165
  def submit_message(message, chat_history, model_name, system_message, max_tokens, temperature, top_p):
166
  history = [] if chat_history is None else chat_history
 
167
 
168
- # Add user message first
169
- history = history + [{"role": "user", "content": message}]
170
-
171
- # Then stream the assistant's response
172
- for response in respond(message, history[:-1], model_name, system_message, max_tokens, temperature, top_p):
173
- history[-1] = {"role": "user", "content": message}
174
- history = history + [{"role": "assistant", "content": response}]
175
- yield history, ""
176
 
177
  submit_event = submit.click(
178
  fn=submit_message,
 
164
 
165
  def submit_message(message, chat_history, model_name, system_message, max_tokens, temperature, top_p):
166
  history = [] if chat_history is None else chat_history
167
+ current_response = ""
168
 
169
+ # Stream the assistant's response
170
+ for response in respond(message, history, model_name, system_message, max_tokens, temperature, top_p):
171
+ current_response = response
172
+ new_history = history + [
173
+ {"role": "user", "content": message},
174
+ {"role": "assistant", "content": current_response}
175
+ ]
176
+ yield new_history, ""
177
 
178
  submit_event = submit.click(
179
  fn=submit_message,