Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import requests
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
from agent import LangGraphAgent
|
|
|
|
| 7 |
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
|
@@ -74,13 +75,19 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 74 |
results_log = []
|
| 75 |
answers_payload = []
|
| 76 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 77 |
-
for item in questions_data:
|
| 78 |
task_id = item.get("task_id")
|
| 79 |
question_text = item.get("question")
|
| 80 |
if not task_id or question_text is None:
|
| 81 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 82 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
try:
|
|
|
|
| 84 |
agent_response = agent(question_text)
|
| 85 |
# Extract everything after "FINAL ANSWER:" as the submitted answer
|
| 86 |
if "FINAL ANSWER:" in agent_response:
|
|
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
from agent import LangGraphAgent
|
| 7 |
+
import time
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
|
|
| 75 |
results_log = []
|
| 76 |
answers_payload = []
|
| 77 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 78 |
+
for i, item in enumerate(questions_data):
|
| 79 |
task_id = item.get("task_id")
|
| 80 |
question_text = item.get("question")
|
| 81 |
if not task_id or question_text is None:
|
| 82 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 83 |
continue
|
| 84 |
+
|
| 85 |
+
# Add delay to avoid rate limits
|
| 86 |
+
if i > 0: # Don't delay the first request
|
| 87 |
+
time.sleep(2) # Wait 2 seconds between requests
|
| 88 |
+
|
| 89 |
try:
|
| 90 |
+
print(f"Processing question {i+1}/{len(questions_data)}: {task_id}")
|
| 91 |
agent_response = agent(question_text)
|
| 92 |
# Extract everything after "FINAL ANSWER:" as the submitted answer
|
| 93 |
if "FINAL ANSWER:" in agent_response:
|