Update app.py
Browse files
app.py
CHANGED
|
@@ -34,6 +34,7 @@ SmolagentsInstrumentor().instrument()
|
|
| 34 |
from smolagents import CodeAgent,DuckDuckGoSearchTool,GoogleSearchTool,VisitWebpageTool, InferenceClientModel, PromptTemplates, EMPTY_PROMPT_TEMPLATES
|
| 35 |
from tools.final_answer import FinalAnswerTool
|
| 36 |
import yaml
|
|
|
|
| 37 |
|
| 38 |
# (Keep Constants as is)
|
| 39 |
# --- Constants ---
|
|
@@ -60,7 +61,8 @@ class BasicAgent:
|
|
| 60 |
tools=[FinalAnswerTool(), GoogleSearchTool(), VisitWebpageTool()], ## add your tools here (don't remove final answer),
|
| 61 |
additional_authorized_imports=['pandas'],
|
| 62 |
max_steps=6,
|
| 63 |
-
verbosity_level=1
|
|
|
|
| 64 |
)
|
| 65 |
|
| 66 |
#self.agent.prompt_templates['']
|
|
@@ -73,6 +75,13 @@ class BasicAgent:
|
|
| 73 |
print(f"Agent returning answer: {answer}")
|
| 74 |
return answer
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 77 |
"""
|
| 78 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
|
| 34 |
from smolagents import CodeAgent,DuckDuckGoSearchTool,GoogleSearchTool,VisitWebpageTool, InferenceClientModel, PromptTemplates, EMPTY_PROMPT_TEMPLATES
|
| 35 |
from tools.final_answer import FinalAnswerTool
|
| 36 |
import yaml
|
| 37 |
+
import time
|
| 38 |
|
| 39 |
# (Keep Constants as is)
|
| 40 |
# --- Constants ---
|
|
|
|
| 61 |
tools=[FinalAnswerTool(), GoogleSearchTool(), VisitWebpageTool()], ## add your tools here (don't remove final answer),
|
| 62 |
additional_authorized_imports=['pandas'],
|
| 63 |
max_steps=6,
|
| 64 |
+
verbosity_level=1,
|
| 65 |
+
step_callbacks=[delay_execution_10]
|
| 66 |
)
|
| 67 |
|
| 68 |
#self.agent.prompt_templates['']
|
|
|
|
| 75 |
print(f"Agent returning answer: {answer}")
|
| 76 |
return answer
|
| 77 |
|
| 78 |
+
def delay_execution_10(self) -> bool:
|
| 79 |
+
"""
|
| 80 |
+
Delays the execution for 10 seconds.
|
| 81 |
+
"""
|
| 82 |
+
time.sleep(10)
|
| 83 |
+
return True
|
| 84 |
+
|
| 85 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 86 |
"""
|
| 87 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|