Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,23 +68,29 @@ def get_local_time(city: str) -> str:
|
|
| 68 |
@tool
|
| 69 |
def get_top_restaurants(city: str) -> str:
|
| 70 |
"""Finds the top 5 restaurants in a specified city using DuckDuckGo search.
|
| 71 |
-
|
| 72 |
Args:
|
| 73 |
city: The name of the city where restaurants are being searched.
|
| 74 |
-
|
| 75 |
Returns:
|
| 76 |
str: A list of the top 5 restaurants including names and website links.
|
| 77 |
"""
|
| 78 |
try:
|
| 79 |
search_tool = DuckDuckGoSearchTool()
|
| 80 |
-
results = search_tool.
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
return f"Top 5 Restaurants in {city}:\n{top_restaurants}"
|
|
|
|
| 84 |
return "No restaurant data found."
|
|
|
|
| 85 |
except Exception as e:
|
| 86 |
return f"Error fetching restaurants: {e}"
|
| 87 |
|
|
|
|
| 88 |
# Final answer tool
|
| 89 |
final_answer = FinalAnswerTool()
|
| 90 |
|
|
|
|
| 68 |
@tool
|
| 69 |
def get_top_restaurants(city: str) -> str:
|
| 70 |
"""Finds the top 5 restaurants in a specified city using DuckDuckGo search.
|
| 71 |
+
|
| 72 |
Args:
|
| 73 |
city: The name of the city where restaurants are being searched.
|
|
|
|
| 74 |
Returns:
|
| 75 |
str: A list of the top 5 restaurants including names and website links.
|
| 76 |
"""
|
| 77 |
try:
|
| 78 |
search_tool = DuckDuckGoSearchTool()
|
| 79 |
+
results = search_tool.search(f"Top 5 restaurants in {city}")
|
| 80 |
+
|
| 81 |
+
if isinstance(results, list) and len(results) > 0:
|
| 82 |
+
top_restaurants = '\n'.join(
|
| 83 |
+
[f"{i+1}. {r.get('title', 'Unknown')} - {r.get('link', 'No link')}"
|
| 84 |
+
for i, r in enumerate(results[:5])]
|
| 85 |
+
)
|
| 86 |
return f"Top 5 Restaurants in {city}:\n{top_restaurants}"
|
| 87 |
+
|
| 88 |
return "No restaurant data found."
|
| 89 |
+
|
| 90 |
except Exception as e:
|
| 91 |
return f"Error fetching restaurants: {e}"
|
| 92 |
|
| 93 |
+
|
| 94 |
# Final answer tool
|
| 95 |
final_answer = FinalAnswerTool()
|
| 96 |
|