cooldown on error + smarter again
Browse files
app.py
CHANGED
|
@@ -99,27 +99,30 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 99 |
|
| 100 |
submitted_answer = agent(question_text, additional_data=additional_data)
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
|
| 114 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 115 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 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 |
if not answers_payload:
|
| 124 |
print("Agent did not produce any answers to submit.")
|
| 125 |
return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
|
|
|
|
| 99 |
|
| 100 |
submitted_answer = agent(question_text, additional_data=additional_data)
|
| 101 |
|
| 102 |
+
cooldown_attempts = 2
|
| 103 |
+
while cooldown_attempts > 0:
|
| 104 |
+
try:
|
| 105 |
+
submitted_answer = agent(question_text, additional_data=additional_data)
|
| 106 |
+
break
|
| 107 |
+
except RateLimitError as e:
|
| 108 |
+
print(f"cooldown due to {e}")
|
| 109 |
+
sleep(65)
|
| 110 |
+
cooldown_attempts -= 1
|
| 111 |
+
if cooldown_attempts == 0:
|
| 112 |
+
raise e
|
| 113 |
|
| 114 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 115 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 116 |
|
| 117 |
+
sleep(10)
|
| 118 |
+
|
| 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 |
+
# cooldown
|
| 124 |
+
sleep(65)
|
| 125 |
+
|
| 126 |
if not answers_payload:
|
| 127 |
print("Agent did not produce any answers to submit.")
|
| 128 |
return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
|