Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,19 @@ 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
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
|
| 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 search_fun_facts(location:str, fact_number:int)-> 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 search for fun facts about a place on the Internet. You can use the arguments to specify the place and the number of facts you want to retrieve.
|
| 15 |
Args:
|
| 16 |
+
location: The location you want to search for (e.g., "Paris", "the Amazon rainforest", "the Moon"). Location is based on the timezone entry and is the second part of the timezone string (e.g., "New_York" for "America/New_York").
|
| 17 |
+
fact_number: The number of fun facts you want to retrieve (e.g., 5).
|
| 18 |
"""
|
| 19 |
+
try:
|
| 20 |
+
web_search = DuckDuckGoSearchTool(max_results=fact_number, rate_limit=None)
|
| 21 |
+
fun_facts = web_search(f"most interesting fun facts in {location}")
|
| 22 |
+
except Exception as e:
|
| 23 |
+
return f"Error fetching fun facts for location '{location}': {str(e)}"
|
| 24 |
+
return fun_facts
|
| 25 |
|
| 26 |
@tool
|
| 27 |
def get_current_time_in_timezone(timezone: str) -> str:
|