Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,31 @@ 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 |
-
|
| 14 |
-
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +72,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def get_cities_in_timezone(timezone: str) -> list[str]:
|
| 13 |
+
"""A tool that fetches a list of cities in a specified timezone.
|
| 14 |
+
|
| 15 |
Args:
|
| 16 |
+
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
| 17 |
+
|
| 18 |
+
Returns:
|
| 19 |
+
A list of cities in the specified timezone or an error message.
|
| 20 |
"""
|
| 21 |
+
search_tool = DuckDuckGoSearchResults()
|
| 22 |
+
|
| 23 |
+
# Make a query to DuckDuckGo
|
| 24 |
+
query = f"cities in {timezone} timezone"
|
| 25 |
+
search_results = search_tool.run(query)
|
| 26 |
+
|
| 27 |
+
# Process the search results to extract city names
|
| 28 |
+
cities = []
|
| 29 |
+
for result in search_results:
|
| 30 |
+
if 'Text' in result:
|
| 31 |
+
cities.append(result['Text'])
|
| 32 |
+
|
| 33 |
+
if not cities:
|
| 34 |
+
return [f"No cities found for the specified timezone '{timezone}'."]
|
| 35 |
+
|
| 36 |
+
return cities
|
| 37 |
|
| 38 |
@tool
|
| 39 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 72 |
|
| 73 |
agent = CodeAgent(
|
| 74 |
model=model,
|
| 75 |
+
tools=[final_answer, get_current_time_in_timezone, get_cities_in_timezone], ## add your tools here (don't remove final answer)
|
| 76 |
max_steps=6,
|
| 77 |
verbosity_level=1,
|
| 78 |
grammar=None,
|