Make BasicAgent inherit from CodeAgent
Browse files
app.py
CHANGED
|
@@ -11,10 +11,16 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 11 |
|
| 12 |
model = HfApiModel()
|
| 13 |
|
|
|
|
|
|
|
| 14 |
# --- Basic Agent Definition ---
|
| 15 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 16 |
-
class BasicAgent:
|
| 17 |
-
def __init__(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
print("BasicAgent initialized.")
|
| 19 |
def __call__(self, question: str) -> str:
|
| 20 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
|
@@ -43,7 +49,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 43 |
|
| 44 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 45 |
try:
|
| 46 |
-
agent = BasicAgent()
|
| 47 |
except Exception as e:
|
| 48 |
print(f"Error instantiating agent: {e}")
|
| 49 |
return f"Error initializing agent: {e}", None
|
|
|
|
| 11 |
|
| 12 |
model = HfApiModel()
|
| 13 |
|
| 14 |
+
tools = []
|
| 15 |
+
|
| 16 |
# --- Basic Agent Definition ---
|
| 17 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 18 |
+
class BasicAgent(CodeAgent):
|
| 19 |
+
def __init__(self, tools, model, planning_interval):
|
| 20 |
+
self.tools = tools
|
| 21 |
+
self.model = model
|
| 22 |
+
self.add_base_tools = True # Add any additional base tools
|
| 23 |
+
self.planning_interval = planning_interval # Enable planning every 3 steps
|
| 24 |
print("BasicAgent initialized.")
|
| 25 |
def __call__(self, question: str) -> str:
|
| 26 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
|
|
|
| 49 |
|
| 50 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 51 |
try:
|
| 52 |
+
agent = BasicAgent(tools=tools, model=model, planning_interval=3)
|
| 53 |
except Exception as e:
|
| 54 |
print(f"Error instantiating agent: {e}")
|
| 55 |
return f"Error initializing agent: {e}", None
|