Spaces:
Sleeping
Sleeping
Update app.py
#1
by gparitosh007 - opened
app.py
CHANGED
|
@@ -7,16 +7,39 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
search_tool = DuckDuckGoSearchTool()
|
| 11 |
+
# Initialize the DuckDuckGo search tool
|
| 12 |
+
search_tool = DuckDuckGoSearchTool()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
@tool
|
| 16 |
+
def get_top_places(city: str, category: str = "places", n: int = 5) -> list:
|
| 17 |
+
"""
|
| 18 |
+
Get the top N places for a given category in a specified city.
|
| 19 |
+
|
| 20 |
+
Parameters:
|
| 21 |
+
city (str): The name of the city to search for.
|
| 22 |
+
category (str): The category to search (e.g., "places", "food", "museum"). Default is "places".
|
| 23 |
+
n (int): The number of results to return. Default is 5, maximum 100.
|
| 24 |
+
|
| 25 |
+
Returns:
|
| 26 |
+
list: A list of strings containing the title and URL for each result.
|
| 27 |
+
|
| 28 |
+
Raises:
|
| 29 |
+
ValueError: If the category is not one of "places", "food", or "museum".
|
| 30 |
+
|
| 31 |
+
Example:
|
| 32 |
+
>>> get_top_places("Paris", "food", 5)
|
| 33 |
+
['Le Meurice - https://example.com', 'L'Ambroisie - https://example.com']
|
| 34 |
"""
|
| 35 |
+
valid_categories = ["places", "food", "museum"]
|
| 36 |
+
if category not in valid_categories:
|
| 37 |
+
raise ValueError(f"Invalid category. Choose from: {', '.join(valid_categories)}")
|
| 38 |
+
|
| 39 |
+
query = f"top {n} {category} in {city}"
|
| 40 |
+
results = search_tool.search(query, n)
|
| 41 |
+
return [f"{result['title']} - {result['url']}" for result in results]
|
| 42 |
+
|
| 43 |
|
| 44 |
@tool
|
| 45 |
def get_current_time_in_timezone(timezone: str) -> str:
|