marin-iuga commited on
Commit
884668a
·
verified ·
1 Parent(s): e572948

Improved logging.

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -40,17 +40,22 @@ class BasicAgent:
40
  print("Core agent has been initialized.")
41
 
42
  def __call__(self, question: str) -> str:
43
- print(f"Agent received question (first 50 chars): {question[:50]}...")
 
 
44
  try:
45
  # send the question content to the agent
46
  answer = self.agent.run(question)
47
- print(f"Agent returning fixed answer: {answer}")
48
-
 
 
49
  # return the answer
50
  return answer
51
  except Exception as e:
52
- print(f"Error running agent {str(e)}")
53
-
 
54
 
55
  def run_and_submit_all( profile: gr.OAuthProfile | None):
56
  """
@@ -106,6 +111,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
106
  results_log = []
107
  answers_payload = []
108
  print(f"Running agent on {len(questions_data)} questions...")
 
109
  for item in questions_data:
110
  task_id = item.get("task_id")
111
  question_text = item.get("question")
@@ -113,13 +119,17 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
113
  print(f"Skipping item with missing task_id or question: {item}")
114
  continue
115
  try:
 
116
  submitted_answer = agent(question_text)
117
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
118
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
 
119
  except Exception as e:
120
- print(f"Error running agent on task {task_id}: {e}")
121
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
122
 
 
 
123
  return
124
 
125
  if not answers_payload:
 
40
  print("Core agent has been initialized.")
41
 
42
  def __call__(self, question: str) -> str:
43
+ print("#"*20)
44
+ print(f"ℹ️ Agent received question: {question}")
45
+ print("#"*20)
46
  try:
47
  # send the question content to the agent
48
  answer = self.agent.run(question)
49
+ print("#"*20)
50
+ print(f"✅ Agent returning the answer: {answer}")
51
+ print("#"*20)
52
+
53
  # return the answer
54
  return answer
55
  except Exception as e:
56
+ print("!"*20)
57
+ print(f"❗Error running agent {str(e)}")
58
+ print("!"*20)
59
 
60
  def run_and_submit_all( profile: gr.OAuthProfile | None):
61
  """
 
111
  results_log = []
112
  answers_payload = []
113
  print(f"Running agent on {len(questions_data)} questions...")
114
+ question_index = 1
115
  for item in questions_data:
116
  task_id = item.get("task_id")
117
  question_text = item.get("question")
 
119
  print(f"Skipping item with missing task_id or question: {item}")
120
  continue
121
  try:
122
+ print(f"ℹ️ Handling question #: {question_index}")
123
  submitted_answer = agent(question_text)
124
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
125
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
126
+ print(f"✅ Successful handling of question #: {question_index}")
127
  except Exception as e:
128
+ print(f"Error running agent on task {task_id}: {e}")
129
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
130
 
131
+ question_index = question_index + 1
132
+
133
  return
134
 
135
  if not answers_payload: