Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,15 +20,23 @@ def ddg_tool(query:str, city:str, max_results:int=5)-> list: # it's important to
|
|
| 20 |
|
| 21 |
Returns: List of dictionaries with Restaurant Name, city, and URL.
|
| 22 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
results = []
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
return results
|
| 33 |
|
| 34 |
|
|
|
|
| 20 |
|
| 21 |
Returns: List of dictionaries with Restaurant Name, city, and URL.
|
| 22 |
"""
|
| 23 |
+
# Instantiate the tool
|
| 24 |
+
ddg = DuckDuckGoSearchTool()
|
| 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 = ddg.search(full_query, max_results=max_results)
|
| 31 |
+
|
| 32 |
results = []
|
| 33 |
+
for result in search_results:
|
| 34 |
+
results.append({
|
| 35 |
+
"title": result.get("title", "No Title"),
|
| 36 |
+
"url": result.get("href", "No URL"),
|
| 37 |
+
"snippet": result.get("body", "No Description")
|
| 38 |
+
})
|
| 39 |
+
|
|
|
|
| 40 |
return results
|
| 41 |
|
| 42 |
|