DTStudios commited on
Commit
cce7bec
·
verified ·
1 Parent(s): 9d5e193

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -1,14 +1,15 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
- import datetime
 
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
- from tools.web_search import DuckDuckGoSearchTool
8
 
9
 
10
  @tool
11
- def DuckDuckGoSearchTool (web_search: str) -> str:
12
  """"Performs a DuckDuckGo web search based on your query (think a Google search) then returns the top search results.Perform a DuckDuckGo search and return formatted results.
13
 
14
  Args:
@@ -18,9 +19,8 @@ def DuckDuckGoSearchTool (web_search: str) -> str:
18
  str: A formatted string containing the search results.
19
  """
20
  # your implementation here
21
- DuckDuckGoSearchTool = DuckDuckGoSearchTool()
22
  results = DuckDuckGoSearchTool.text(web_search, max_results=10)
23
-
24
  if not results:
25
  raise Exception("No results found! Try a less restrictive/shorter query.")
26
 
 
1
+ from smolagents import CodeAgent,DuckDuckGoSearchTool,tool_registry,HfApiModel,load_tool,tool
2
+ import datetime import datetime
3
+ from ddgs import DDGS
4
  import requests
5
  import pytz
6
  import yaml
7
  from tools.final_answer import FinalAnswerTool
8
+
9
 
10
 
11
  @tool
12
+ def DuckDuckGoSearchTool (query: str) -> str:
13
  """"Performs a DuckDuckGo web search based on your query (think a Google search) then returns the top search results.Perform a DuckDuckGo search and return formatted results.
14
 
15
  Args:
 
19
  str: A formatted string containing the search results.
20
  """
21
  # your implementation here
22
+ ddgs = DDGS()
23
  results = DuckDuckGoSearchTool.text(web_search, max_results=10)
 
24
  if not results:
25
  raise Exception("No results found! Try a less restrictive/shorter query.")
26