Ali2206 commited on
Commit
8e316b5
·
verified ·
1 Parent(s): 6c3f16a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -166,23 +166,23 @@ def create_ui(agent: TxAgent):
166
  max_round=10
167
  )
168
 
169
- final_response = []
170
  for update in generator:
171
  if not update:
172
  continue
173
- if isinstance(update, str):
174
- final_response.append(update)
175
- elif isinstance(update, list):
176
- final_response.extend(msg.content for msg in update if hasattr(msg, 'content'))
177
-
178
- if len(final_response) % 3 == 0:
179
- current_output = "".join(final_response).strip().replace("[TOOL_CALLS]", "")
180
- history[-1] = {"role": "assistant", "content": current_output or "⏳ Generating..."}
181
- yield history
182
-
183
- full_output = "".join(final_response).strip().replace("[TOOL_CALLS]", "")
184
- print("Final model response:\n", full_output)
185
- history[-1] = {"role": "assistant", "content": full_output or "❌ No response."}
186
  print(f"Model processing took: {time.time() - model_start:.2f}s")
187
  yield history
188
 
@@ -232,4 +232,4 @@ if __name__ == "__main__":
232
  server_port=7860,
233
  show_error=True,
234
  share=True
235
- )
 
166
  max_round=10
167
  )
168
 
169
+ final_response = ""
170
  for update in generator:
171
  if not update:
172
  continue
173
+ if isinstance(update, list):
174
+ for msg in update:
175
+ if hasattr(msg, 'content'):
176
+ final_response += msg.content
177
+ elif isinstance(update, str):
178
+ final_response += update
179
+
180
+ cleaned = final_response.strip().replace("[TOOL_CALLS]", "")
181
+ history[-1] = {"role": "assistant", "content": cleaned or "❌ No response."}
182
+ yield history
183
+
184
+ print("Final model response:\n", final_response)
185
+ history[-1] = {"role": "assistant", "content": final_response.strip() or "❌ No response."}
186
  print(f"Model processing took: {time.time() - model_start:.2f}s")
187
  yield history
188
 
 
232
  server_port=7860,
233
  show_error=True,
234
  share=True
235
+ )