Spaces:
Sleeping
Sleeping
added prod level Duckduckgo_search
Browse fileshttps://pypi.org/project/duckduckgo-search/
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
|
|
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -21,13 +22,13 @@ def ddg_tool(query:str, city:str, max_results:int=5)-> list: # it's important to
|
|
| 21 |
Returns: List of dictionaries with Restaurant Name, city, and URL.
|
| 22 |
"""
|
| 23 |
# Instantiate the tool
|
| 24 |
-
ddg_tool =
|
| 25 |
|
| 26 |
# Modify query to include city for better results
|
| 27 |
full_query = f"{query} restaurant in {city}"
|
| 28 |
|
| 29 |
# Fetch results
|
| 30 |
-
search_results =
|
| 31 |
|
| 32 |
results = []
|
| 33 |
for result in search_results:
|
|
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
+
from duckduckgo_search import DDGS
|
| 3 |
import datetime
|
| 4 |
import requests
|
| 5 |
import pytz
|
|
|
|
| 22 |
Returns: List of dictionaries with Restaurant Name, city, and URL.
|
| 23 |
"""
|
| 24 |
# Instantiate the tool
|
| 25 |
+
ddg_tool = DDGS()
|
| 26 |
|
| 27 |
# Modify query to include city for better results
|
| 28 |
full_query = f"{query} restaurant in {city}"
|
| 29 |
|
| 30 |
# Fetch results
|
| 31 |
+
search_results = DDGS().text(full_query, max_results=max_results)
|
| 32 |
|
| 33 |
results = []
|
| 34 |
for result in search_results:
|