Update app.py
Browse files
app.py
CHANGED
|
@@ -27,21 +27,21 @@ visit_webpage = VisitWebpage()
|
|
| 27 |
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
|
| 28 |
prompt_templates = yaml.safe_load(stream)
|
| 29 |
|
| 30 |
-
agent = CodeAgent(
|
| 31 |
-
model=model,
|
| 32 |
-
tools=[web_search, visit_webpage],
|
| 33 |
-
managed_agents=[],
|
| 34 |
-
max_steps=10,
|
| 35 |
-
verbosity_level=2,
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
class BasicAgent:
|
| 45 |
def __init__(self):
|
| 46 |
print("BasicAgent initialized.")
|
| 47 |
def __call__(self, question: str) -> str:
|
|
@@ -49,7 +49,8 @@ class BasicAgent:
|
|
| 49 |
fixed_answer = "This is a default answer."
|
| 50 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 51 |
return fixed_answer
|
| 52 |
-
|
|
|
|
| 53 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 54 |
"""
|
| 55 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
@@ -71,7 +72,14 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 71 |
|
| 72 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 73 |
try:
|
| 74 |
-
agent = BasicAgent(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
except Exception as e:
|
| 76 |
print(f"Error instantiating agent: {e}")
|
| 77 |
return f"Error initializing agent: {e}", None
|
|
|
|
| 27 |
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
|
| 28 |
prompt_templates = yaml.safe_load(stream)
|
| 29 |
|
| 30 |
+
# agent = CodeAgent(
|
| 31 |
+
# model=model,
|
| 32 |
+
# tools=[web_search, visit_webpage],
|
| 33 |
+
# managed_agents=[],
|
| 34 |
+
# max_steps=10,
|
| 35 |
+
# verbosity_level=2,
|
| 36 |
+
# add_base_tools=True,
|
| 37 |
+
# grammar=None,
|
| 38 |
+
# planning_interval=3,
|
| 39 |
+
# name=None,
|
| 40 |
+
# description=None,
|
| 41 |
+
# prompt_templates=prompt_templates
|
| 42 |
+
#)
|
| 43 |
+
|
| 44 |
+
class BasicAgent(CodeAgent):
|
| 45 |
def __init__(self):
|
| 46 |
print("BasicAgent initialized.")
|
| 47 |
def __call__(self, question: str) -> str:
|
|
|
|
| 49 |
fixed_answer = "This is a default answer."
|
| 50 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 51 |
return fixed_answer
|
| 52 |
+
|
| 53 |
+
# --- from template
|
| 54 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 55 |
"""
|
| 56 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
|
| 72 |
|
| 73 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 74 |
try:
|
| 75 |
+
agent = BasicAgent(
|
| 76 |
+
model=model,
|
| 77 |
+
tools=[web_search, visit_webpage],
|
| 78 |
+
max_steps=10,
|
| 79 |
+
verbosity_level=2,
|
| 80 |
+
add_base_tools=True,
|
| 81 |
+
planning_interval=3,
|
| 82 |
+
prompt_templates=prompt_templates)
|
| 83 |
except Exception as e:
|
| 84 |
print(f"Error instantiating agent: {e}")
|
| 85 |
return f"Error initializing agent: {e}", None
|