Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool,
|
| 2 |
-
import datetime
|
|
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
|
| 8 |
|
| 9 |
|
| 10 |
@tool
|
| 11 |
-
def DuckDuckGoSearchTool (
|
| 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 |
-
|
| 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 |
|