Update app.py
Browse files
app.py
CHANGED
|
@@ -10,14 +10,22 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 10 |
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
-
print(f"Agent received question
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
|
|
| 10 |
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
+
|
| 14 |
+
from smolagents import CodeAgent
|
| 15 |
+
from smolagents.models import OpenAIChat
|
| 16 |
+
from my_tools import my_tool_list # 你需要新建/补全这个模块和列表
|
| 17 |
+
|
| 18 |
class BasicAgent:
|
| 19 |
def __init__(self):
|
| 20 |
+
model = OpenAIChat(model="gpt-4.1")
|
| 21 |
+
self.agent = CodeAgent(model=model, tools=my_tool_list, max_steps=6)
|
| 22 |
+
|
| 23 |
def __call__(self, question: str) -> str:
|
| 24 |
+
print(f"Agent received question: {question[:80]}...")
|
| 25 |
+
try:
|
| 26 |
+
return self.agent.run(question)
|
| 27 |
+
except Exception as e:
|
| 28 |
+
return f"[Agent Error: {e}]"
|
| 29 |
|
| 30 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 31 |
"""
|