Spaces:
Sleeping
Sleeping
use duckduckgo search
Browse files
app.py
CHANGED
|
@@ -4,9 +4,8 @@ import requests
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
from smolagents.tools import WebSearchTool
|
| 10 |
|
| 11 |
# (Keep Constants as is)
|
| 12 |
# --- Constants ---
|
|
@@ -16,12 +15,10 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 16 |
class MyAgent:
|
| 17 |
def __init__(self):
|
| 18 |
print("MyAgent initialized.")
|
| 19 |
-
# Standard tools
|
| 20 |
-
self.tools =
|
| 21 |
-
#
|
| 22 |
-
self.tools.
|
| 23 |
-
# Create the agent with tools
|
| 24 |
-
self.agent = smolagents.Agent(tools=self.tools)
|
| 25 |
|
| 26 |
def __call__(self, question: str) -> str:
|
| 27 |
# Use the agent to answer the question
|
|
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
+
# Updated smolagents import
|
| 8 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
|
|
|
| 9 |
|
| 10 |
# (Keep Constants as is)
|
| 11 |
# --- Constants ---
|
|
|
|
| 15 |
class MyAgent:
|
| 16 |
def __init__(self):
|
| 17 |
print("MyAgent initialized.")
|
| 18 |
+
# Standard tools for CodeAgent
|
| 19 |
+
self.tools = [DuckDuckGoSearchTool()]
|
| 20 |
+
# You can add more tools if needed
|
| 21 |
+
self.agent = CodeAgent(tools=self.tools, model=HfApiModel())
|
|
|
|
|
|
|
| 22 |
|
| 23 |
def __call__(self, question: str) -> str:
|
| 24 |
# Use the agent to answer the question
|