Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
|
|
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
|
@@ -78,13 +79,18 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 78 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 79 |
continue
|
| 80 |
try:
|
|
|
|
|
|
|
|
|
|
| 81 |
submitted_answer = agent(question_text)
|
| 82 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 83 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 84 |
except Exception as e:
|
| 85 |
print(f"Error running agent on task {task_id}: {e}")
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
| 88 |
if not answers_payload:
|
| 89 |
print("Agent did not produce any answers to submit.")
|
| 90 |
return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
import time
|
| 7 |
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
|
|
|
| 79 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 80 |
continue
|
| 81 |
try:
|
| 82 |
+
# We add to counter the token rate limit usage by openai of 30000 TPM
|
| 83 |
+
time.sleep(2)
|
| 84 |
+
# end insertion
|
| 85 |
submitted_answer = agent(question_text)
|
| 86 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 87 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 88 |
except Exception as e:
|
| 89 |
print(f"Error running agent on task {task_id}: {e}")
|
| 90 |
+
# we limit the error message lentgh so we can still submit the other answers
|
| 91 |
+
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e[:1000]}"})
|
| 92 |
+
# end insertion
|
| 93 |
+
|
| 94 |
if not answers_payload:
|
| 95 |
print("Agent did not produce any answers to submit.")
|
| 96 |
return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
|