Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
-
from smolagents
|
| 2 |
-
from smolagents import CodeAgent, InferenceClientModel
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
|
|
|
|
| 9 |
agent = CodeAgent(
|
| 10 |
tools=[search_tool],
|
| 11 |
model=model,
|
| 12 |
-
|
| 13 |
)
|
| 14 |
|
| 15 |
-
|
| 16 |
-
result = agent.run(
|
| 17 |
-
|
| 18 |
-
print(f"Final Answer: {result}")
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Model using Hugging Face Inference API
|
| 4 |
+
model = HfApiModel() # or HfApiModel("Qwen/Qwen2.5-72B-Instruct", api_key="...")
|
| 5 |
|
| 6 |
+
# Instantiate the DuckDuckGo search tool
|
| 7 |
+
search_tool = DuckDuckGoSearchTool(max_results=10)
|
| 8 |
|
| 9 |
+
# Create an agent that can use the search tool
|
| 10 |
agent = CodeAgent(
|
| 11 |
tools=[search_tool],
|
| 12 |
model=model,
|
| 13 |
+
add_base_tools=False, # you can set True to also add built-in tools
|
| 14 |
)
|
| 15 |
|
| 16 |
+
# Run a query that may trigger web search
|
| 17 |
+
result = agent.run("Who is the CEO of Hugging Face?")
|
| 18 |
+
print(result)
|
|
|