Update app.py
Browse filesSleep to avoid the Gemini throttling at 15 RPM
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, LiteLLMModel, load_tool, tool
|
2 |
import datetime
|
3 |
import pytz
|
|
|
4 |
import yaml
|
5 |
from tools.final_answer import FinalAnswerTool
|
6 |
|
@@ -142,6 +143,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
142 |
submitted_answer = agent(question_text)
|
143 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
144 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
|
|
|
|
145 |
except Exception as e:
|
146 |
print(f"Error running agent on task {task_id}: {e}")
|
147 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
|
|
|
1 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, LiteLLMModel, load_tool, tool
|
2 |
import datetime
|
3 |
import pytz
|
4 |
+
import time
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
|
|
|
143 |
submitted_answer = agent(question_text)
|
144 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
145 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
146 |
+
# Sleep to avoid the Gemini throttling at 15 RPM
|
147 |
+
time.sleep(30)
|
148 |
except Exception as e:
|
149 |
print(f"Error running agent on task {task_id}: {e}")
|
150 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
|