Spaces:
Runtime error
Runtime error
fix
Browse files
app.py
CHANGED
|
@@ -12,13 +12,9 @@ class BasicAgent:
|
|
| 12 |
def __init__(self):
|
| 13 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
|
| 14 |
|
| 15 |
-
# Initialize the search tool
|
| 16 |
search_tool = DuckDuckGoSearchTool()
|
| 17 |
-
|
| 18 |
-
# Initialize the model
|
| 19 |
model = InferenceClientModel()
|
| 20 |
|
| 21 |
-
# Create the agent
|
| 22 |
self.agent = CodeAgent(
|
| 23 |
model=model,
|
| 24 |
tools=[search_tool],
|
|
@@ -26,9 +22,13 @@ class BasicAgent:
|
|
| 26 |
|
| 27 |
def __call__(self, question: str) -> str:
|
| 28 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
|
|
| 12 |
def __init__(self):
|
| 13 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
|
| 14 |
|
|
|
|
| 15 |
search_tool = DuckDuckGoSearchTool()
|
|
|
|
|
|
|
| 16 |
model = InferenceClientModel()
|
| 17 |
|
|
|
|
| 18 |
self.agent = CodeAgent(
|
| 19 |
model=model,
|
| 20 |
tools=[search_tool],
|
|
|
|
| 22 |
|
| 23 |
def __call__(self, question: str) -> str:
|
| 24 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 25 |
+
try:
|
| 26 |
+
answer = self.agent.run(question)
|
| 27 |
+
print(f"Agent returned answer: {answer}")
|
| 28 |
+
return answer
|
| 29 |
+
except Exception as e:
|
| 30 |
+
print(f"Error running agent: {e}")
|
| 31 |
+
return f"AGENT ERROR: {e}"
|
| 32 |
|
| 33 |
|
| 34 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|