Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,14 +10,30 @@ 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 |
-
print("BasicAgent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 18 |
-
|
| 19 |
-
print(f"Agent returning
|
| 20 |
-
return
|
| 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 |
+
from smolagents import CodeAgent, HfApiModel
|
| 14 |
+
from tools.wikipedia_tool import WikipediaTool
|
| 15 |
+
from tools.text_transformer_tool import TextTransformerTool
|
| 16 |
+
|
| 17 |
class BasicAgent:
|
| 18 |
def __init__(self):
|
| 19 |
+
print("Initializing BasicAgent with tools...")
|
| 20 |
+
|
| 21 |
+
model = HfApiModel()
|
| 22 |
+
wiki_tool = WikipediaTool()
|
| 23 |
+
text_tool = TextTransformerTool()
|
| 24 |
+
|
| 25 |
+
self.agent = CodeAgent(
|
| 26 |
+
model=model,
|
| 27 |
+
tools=[wiki_tool, text_tool],
|
| 28 |
+
add_base_tools=True,
|
| 29 |
+
planning_interval=2
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
def __call__(self, question: str) -> str:
|
| 33 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 34 |
+
answer = self.agent(question)
|
| 35 |
+
print(f"Agent returning answer: {answer}")
|
| 36 |
+
return answer
|
| 37 |
|
| 38 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 39 |
"""
|