gprasanna commited on
Commit
fdc6408
·
verified ·
1 Parent(s): 7958841

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -1,18 +1,18 @@
1
- from smolagents.default_tools import ApiWebSearchTool
2
- from smolagents import CodeAgent, InferenceClientModel
3
- import os
4
 
5
- model = InferenceClientModel()
 
6
 
7
- search_tool = ApiWebSearchTool()
 
8
 
 
9
  agent = CodeAgent(
10
  tools=[search_tool],
11
  model=model,
12
- verbosity_level=1 # Optional: set verbosity_level to 1 to see the agent's steps
13
  )
14
 
15
- task = "How many seconds would it take for a leopard at full speed to run through the Pont des Arts?"
16
- result = agent.run(task)
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)