cowrycode commited on
Commit
a5d1805
·
verified ·
1 Parent(s): d47ca3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -35
app.py CHANGED
@@ -104,46 +104,45 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
104
  results_log = []
105
  #answers_payload = []
106
  print(f"Running agent on {len(questions_data)} questions...")
107
- # for item in questions_data:
108
- # task_id = item.get("task_id")
109
- # question_text = item.get("question")
110
- # if not task_id or question_text is None:
111
- # print(f"Skipping item with missing task_id or question: {item}")
112
- # continue
113
- # try:
114
- # submitted_answer = agent(question_text)
115
- # answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
116
- # results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
117
- # except Exception as e:
118
- # print(f"Error running agent on task {task_id}: {e}")
119
- # results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
120
-
121
- # if not answers_payload:
122
- # print("Agent did not produce any answers to submit.")
123
- # return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
124
 
125
  #3A
126
 
127
- def run_all_questions(questions_data):
128
- #--------------------------------------------------
129
- answers_payload = []
130
- for item in questions_data:
131
- task_id = item.get("task_id")
132
- question_text = item.get("question")
133
- if not task_id or question_text is None:
134
- print(f"Skipping item with missing task_id or question: {item}")
135
- continue
136
- try:
137
- answer = agent.run(question_text) # await coroutine
138
- answers_payload.append({"task_id": task_id, "submitted_answer": answer})
139
- print(f"Answered Task {task_id}: {answer[:50]}...")
140
- except Exception as e:
141
- answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
142
- print(f"Error on Task {task_id}: {e}")
143
- return answers_payload
144
 
145
  #answers_payload = asyncio.run(run_all_questions(questions_data))
146
- answers_payload = run_all_questions(questions_data)
147
 
148
  #3B
149
 
 
104
  results_log = []
105
  #answers_payload = []
106
  print(f"Running agent on {len(questions_data)} questions...")
107
+ for item in questions_data:
108
+ task_id = item.get("task_id")
109
+ question_text = item.get("question")
110
+ if not task_id or question_text is None:
111
+ print(f"Skipping item with missing task_id or question: {item}")
112
+ continue
113
+ try:
114
+ submitted_answer = agent(question_text)
115
+ answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
116
+ results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
117
+ except Exception as e:
118
+ print(f"Error running agent on task {task_id}: {e}")
119
+ results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
120
+
121
+ if not answers_payload:
122
+ print("Agent did not produce any answers to submit.")
123
+ return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
124
 
125
  #3A
126
 
127
+ # def run_all_questions(questions_data):
128
+ # answers_payload = []
129
+ # for item in questions_data:
130
+ # task_id = item.get("task_id")
131
+ # question_text = item.get("question")
132
+ # if not task_id or question_text is None:
133
+ # print(f"Skipping item with missing task_id or question: {item}")
134
+ # continue
135
+ # try:
136
+ # answer = agent.run(question_text) # await coroutine
137
+ # answers_payload.append({"task_id": task_id, "submitted_answer": answer})
138
+ # print(f"Answered Task {task_id}: {answer[:50]}...")
139
+ # except Exception as e:
140
+ # answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
141
+ # print(f"Error on Task {task_id}: {e}")
142
+ # return answers_payload
 
143
 
144
  #answers_payload = asyncio.run(run_all_questions(questions_data))
145
+ #answers_payload = run_all_questions(questions_data)
146
 
147
  #3B
148