Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,19 +19,19 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
@tool
|
| 22 |
-
def get_current_time_in_timezone(
|
| 23 |
-
"""A tool that fetches the current local time in a specified
|
| 24 |
Args:
|
| 25 |
-
|
| 26 |
"""
|
| 27 |
try:
|
| 28 |
-
# Create
|
| 29 |
-
tz = pytz.timezone(
|
| 30 |
-
# Get current time in that
|
| 31 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 32 |
-
return f"The current local time in {
|
| 33 |
except Exception as e:
|
| 34 |
-
return f"Error fetching time for
|
| 35 |
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
|
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
@tool
|
| 22 |
+
def get_current_time_in_timezone(timezone: str) -> str:
|
| 23 |
+
"""A tool that fetches the current local time in a specified timezone.
|
| 24 |
Args:
|
| 25 |
+
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
| 26 |
"""
|
| 27 |
try:
|
| 28 |
+
# Create timezone object
|
| 29 |
+
tz = pytz.timezone(timezone)
|
| 30 |
+
# Get current time in that timezone
|
| 31 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 32 |
+
return f"The current local time in {timezone} is: {local_time}"
|
| 33 |
except Exception as e:
|
| 34 |
+
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|