Update app.py
Browse files
app.py
CHANGED
@@ -105,24 +105,22 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
105 |
results_log = []
|
106 |
answers_payload = []
|
107 |
print(f"Running agent on {len(questions_data)} questions...")
|
108 |
-
for item in questions_data:
|
109 |
task_id = item.get("task_id")
|
110 |
question_text = item.get("question")
|
111 |
if not task_id or question_text is None:
|
112 |
print(f"Skipping item with missing task_id or question: {item}")
|
113 |
continue
|
114 |
try:
|
115 |
-
submitted_answer =
|
116 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
117 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
118 |
-
|
119 |
-
sleep_time = random.uniform(25, 40)
|
120 |
-
print(f"[Rate Limit Control] Sleeping {sleep_time:.1f} seconds after answering to avoid hitting rate limits...")
|
121 |
-
time.sleep(sleep_time)
|
122 |
-
|
123 |
except Exception as e:
|
124 |
print(f"Error running agent on task {task_id}: {e}")
|
125 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
|
|
|
|
|
|
|
126 |
|
127 |
if not answers_payload:
|
128 |
print("Agent did not produce any answers to submit.")
|
|
|
105 |
results_log = []
|
106 |
answers_payload = []
|
107 |
print(f"Running agent on {len(questions_data)} questions...")
|
108 |
+
for idx, item in enumerate(questions_data, start=1):
|
109 |
task_id = item.get("task_id")
|
110 |
question_text = item.get("question")
|
111 |
if not task_id or question_text is None:
|
112 |
print(f"Skipping item with missing task_id or question: {item}")
|
113 |
continue
|
114 |
try:
|
115 |
+
submitted_answer = agent(question_text)
|
116 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
117 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
|
|
|
|
|
|
|
|
|
|
118 |
except Exception as e:
|
119 |
print(f"Error running agent on task {task_id}: {e}")
|
120 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
|
121 |
+
|
122 |
+
print(f"[{idx}/{len(questions_data)}] Waiting 60 seconds before next request...")
|
123 |
+
time.sleep(60)
|
124 |
|
125 |
if not answers_payload:
|
126 |
print("Agent did not produce any answers to submit.")
|