Ali2206 commited on
Commit
d1d213e
·
verified ·
1 Parent(s): 1d7ca02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -154,8 +154,7 @@ def create_ui(agent: TxAgent):
154
  def analyze_potential_oversights(message: str, history: list, conversation: list, files: list):
155
  start_time = time.time()
156
  try:
157
- history.append({"role": "user", "content": message})
158
- history.append({"role": "assistant", "content": "⏳ Analyzing records for potential oversights..."})
159
  yield history, None
160
 
161
  extracted_data = ""
@@ -191,8 +190,8 @@ Medical Records:\n{extracted_data[:15000]}
191
  elif isinstance(chunk, list):
192
  response += "".join([c.content for c in chunk if hasattr(c, 'content')])
193
 
194
- history[-1]["content"] = response.replace("[TOOL_CALLS]", "").strip()
195
- yield history, None
196
 
197
  final_output = response.replace("[TOOL_CALLS]", "").strip()
198
  if not final_output:
@@ -204,7 +203,7 @@ Medical Records:\n{extracted_data[:15000]}
204
  if os.path.exists(possible_report):
205
  report_path = possible_report
206
 
207
- history[-1] = {"role": "assistant", "content": final_output}
208
  yield history, report_path
209
 
210
  except Exception as e:
 
154
  def analyze_potential_oversights(message: str, history: list, conversation: list, files: list):
155
  start_time = time.time()
156
  try:
157
+ history = history + [{"role": "user", "content": message}, {"role": "assistant", "content": "⏳ Analyzing records for potential oversights..."}]
 
158
  yield history, None
159
 
160
  extracted_data = ""
 
190
  elif isinstance(chunk, list):
191
  response += "".join([c.content for c in chunk if hasattr(c, 'content')])
192
 
193
+ cleaned = response.replace("[TOOL_CALLS]", "").strip()
194
+ yield history[:-1] + [{"role": "assistant", "content": cleaned}], None
195
 
196
  final_output = response.replace("[TOOL_CALLS]", "").strip()
197
  if not final_output:
 
203
  if os.path.exists(possible_report):
204
  report_path = possible_report
205
 
206
+ history = history[:-1] + [{"role": "assistant", "content": final_output}]
207
  yield history, report_path
208
 
209
  except Exception as e: