Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,24 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def find_top_rated_places_to_eat(location:str, number_of_places:int = 3)-> str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
"""A tool that finds top rated places to eat in selected area
|
| 15 |
Args:
|
| 16 |
location: A string repressenting user's required place for eating(e.g., 'England/London')
|
| 17 |
-
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def find_top_rated_places_to_eat(location:str, type_of_meal:str = "meal", number_of_places:int = 3)-> str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
"""A tool that finds top rated places to eat in selected area
|
| 15 |
Args:
|
| 16 |
location: A string repressenting user's required place for eating(e.g., 'England/London')
|
| 17 |
+
type_of_meal: A string repressentin user's required meal to eat (e.g., 'breakfast/lunch/dinner' if user specifies it, if not, default is 'meal')
|
| 18 |
+
number_of_places: An integer representing the number of places user wants to receive (if the user provides it, if not, default is top'3')
|
| 19 |
"""
|
| 20 |
+
try:
|
| 21 |
+
search= DuckDuckGoSearchTool(number_of_places)
|
| 22 |
+
query = f"Top rated restaurants to eat {type_of_meal} in {location}"
|
| 23 |
+
result= search.forward(query)
|
| 24 |
+
|
| 25 |
+
in number_of_places = 1
|
| 26 |
+
return f"Top rated place to eat {type_of_meal} in {location}: {result}"
|
| 27 |
+
return f"Top rated places to eat {type_of_meal} in {location}: {result}"
|
| 28 |
+
except Exception as e:
|
| 29 |
+
return f"Error searching the web with query: '{query}': {str(e)}"
|
| 30 |
|
| 31 |
@tool
|
| 32 |
def get_current_time_in_timezone(timezone: str) -> str:
|