naman1102 commited on
Commit
09721c1
·
1 Parent(s): ebc7e51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -316,7 +316,7 @@ class BasicAgent:
316
 
317
  def _perform_search(self, state: AgentState) -> AgentState:
318
  try:
319
- results = simple_search(state["search_query"], max_results=10)
320
  print("\nSearch Results:")
321
  for i, s in enumerate(results, 1):
322
  print(f"[{i}] {s[:120]}…")
@@ -328,17 +328,11 @@ class BasicAgent:
328
  state["needs_search"] = False
329
 
330
  state["history"].append({"step": "search", "results": results})
331
- state["logs"]["search"] = {
332
- "query": state["search_query"],
333
- "results_count": len(results),
334
- "results": results
335
- }
336
 
337
  except Exception as e:
338
  print(f"Search error: {str(e)}")
339
  state["needs_search"] = True
340
  state["history"].append({"step": "search", "error": str(e)})
341
- state["logs"]["search_error"] = str(e)
342
 
343
  state["current_step"] = "recheck"
344
  return state
@@ -401,7 +395,6 @@ Think step-by-step. Write ANSWER: <answer> on its own line.
401
 
402
  state["final_answer"] = answer
403
  state["history"].append({"step": "answer", "output": raw})
404
- state["logs"]["final_answer"] = {"prompt": prompt, "response": raw}
405
  state["current_step"] = "done"
406
  return state
407
 
@@ -561,16 +554,12 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
561
  final_state = agent.workflow.invoke(state)
562
  answer = final_state["final_answer"]
563
 
564
- # Format logs for display
565
- logs_text = json.dumps(final_state["logs"], indent=2)
566
-
567
  # Add to results
568
  answers_payload.append({"task_id": task_id, "submitted_answer": answer})
569
  results_log.append({
570
  "Task ID": task_id,
571
  "Question": question_text,
572
- "Submitted Answer": answer,
573
- "Processing Logs": logs_text
574
  })
575
 
576
  print(f"Completed question {task_id}")
@@ -580,8 +569,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
580
  results_log.append({
581
  "Task ID": task_id,
582
  "Question": question_text,
583
- "Submitted Answer": f"ERROR: {e}",
584
- "Processing Logs": f"Error occurred: {str(e)}"
585
  })
586
 
587
  if not answers_payload:
 
316
 
317
  def _perform_search(self, state: AgentState) -> AgentState:
318
  try:
319
+ results = simple_search(state["search_query"], max_results=6) # Reduced to 6 results
320
  print("\nSearch Results:")
321
  for i, s in enumerate(results, 1):
322
  print(f"[{i}] {s[:120]}…")
 
328
  state["needs_search"] = False
329
 
330
  state["history"].append({"step": "search", "results": results})
 
 
 
 
 
331
 
332
  except Exception as e:
333
  print(f"Search error: {str(e)}")
334
  state["needs_search"] = True
335
  state["history"].append({"step": "search", "error": str(e)})
 
336
 
337
  state["current_step"] = "recheck"
338
  return state
 
395
 
396
  state["final_answer"] = answer
397
  state["history"].append({"step": "answer", "output": raw})
 
398
  state["current_step"] = "done"
399
  return state
400
 
 
554
  final_state = agent.workflow.invoke(state)
555
  answer = final_state["final_answer"]
556
 
 
 
 
557
  # Add to results
558
  answers_payload.append({"task_id": task_id, "submitted_answer": answer})
559
  results_log.append({
560
  "Task ID": task_id,
561
  "Question": question_text,
562
+ "Submitted Answer": answer
 
563
  })
564
 
565
  print(f"Completed question {task_id}")
 
569
  results_log.append({
570
  "Task ID": task_id,
571
  "Question": question_text,
572
+ "Submitted Answer": f"ERROR: {e}"
 
573
  })
574
 
575
  if not answers_payload: