Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,21 +48,19 @@ def get_air_quality(city: str) -> str:
|
|
| 48 |
|
| 49 |
# Tool to get local time
|
| 50 |
@tool
|
| 51 |
-
def
|
| 52 |
-
"""
|
| 53 |
-
|
| 54 |
Args:
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
Returns:
|
| 58 |
-
str: The current local time formatted as YYYY-MM-DD HH:MM:SS.
|
| 59 |
"""
|
| 60 |
try:
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 63 |
-
return f"
|
| 64 |
except Exception as e:
|
| 65 |
-
return f"Error fetching time: {e}"
|
| 66 |
|
| 67 |
# Tool to fetch top 5 restaurants using DuckDuckGo Search
|
| 68 |
@tool
|
|
@@ -105,7 +103,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 105 |
# Setting up the CodeAgent with the defined tools
|
| 106 |
agent = CodeAgent(
|
| 107 |
model=model,
|
| 108 |
-
tools=[final_answer, get_weather, get_air_quality,
|
| 109 |
max_steps=6,
|
| 110 |
verbosity_level=1,
|
| 111 |
grammar=None,
|
|
|
|
| 48 |
|
| 49 |
# Tool to get local time
|
| 50 |
@tool
|
| 51 |
+
def get_current_time_in_timezone(timezone: str) -> str:
|
| 52 |
+
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 53 |
Args:
|
| 54 |
+
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
|
|
|
|
|
|
|
|
|
| 55 |
"""
|
| 56 |
try:
|
| 57 |
+
# Create timezone object
|
| 58 |
+
tz = pytz.timezone(timezone)
|
| 59 |
+
# Get current time in that timezone
|
| 60 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 61 |
+
return f"The current local time in {timezone} is: {local_time}"
|
| 62 |
except Exception as e:
|
| 63 |
+
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 64 |
|
| 65 |
# Tool to fetch top 5 restaurants using DuckDuckGo Search
|
| 66 |
@tool
|
|
|
|
| 103 |
# Setting up the CodeAgent with the defined tools
|
| 104 |
agent = CodeAgent(
|
| 105 |
model=model,
|
| 106 |
+
tools=[final_answer, get_weather, get_air_quality, get_current_time_in_timezone, get_top_restaurants],
|
| 107 |
max_steps=6,
|
| 108 |
verbosity_level=1,
|
| 109 |
grammar=None,
|