Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,16 +7,28 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
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:
|
|
@@ -51,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 51 |
|
| 52 |
agent = CodeAgent(
|
| 53 |
model=model,
|
| 54 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 55 |
max_steps=6,
|
| 56 |
verbosity_level=1,
|
| 57 |
grammar=None,
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
| 10 |
@tool
|
| 11 |
+
def convert_to_utc(local_time: str, timezone: str) -> str:
|
| 12 |
+
"""A tool that converts a given local time from a specified timezone to UTC.
|
| 13 |
+
|
| 14 |
Args:
|
| 15 |
+
local_time: A string representing the local time in the format 'YYYY-MM-DD HH:MM:SS'.
|
| 16 |
+
timezone: A string representing the valid timezone of the provided local time (e.g., 'America/New_York').
|
| 17 |
"""
|
| 18 |
+
try:
|
| 19 |
+
# Parse the local time string
|
| 20 |
+
local_dt = datetime.datetime.strptime(local_time, "%Y-%m-%d %H:%M:%S")
|
| 21 |
+
|
| 22 |
+
# Assign the specified timezone
|
| 23 |
+
tz = pytz.timezone(timezone)
|
| 24 |
+
localized_dt = tz.localize(local_dt)
|
| 25 |
+
|
| 26 |
+
# Convert to UTC
|
| 27 |
+
utc_dt = localized_dt.astimezone(pytz.utc)
|
| 28 |
+
|
| 29 |
+
return f"The UTC equivalent of {local_time} in {timezone} is {utc_dt.strftime('%Y-%m-%d %H:%M:%S')} UTC."
|
| 30 |
+
except Exception as e:
|
| 31 |
+
return f"Error converting time '{local_time}' from timezone '{timezone}' to UTC: {str(e)}"
|
| 32 |
|
| 33 |
@tool
|
| 34 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 63 |
|
| 64 |
agent = CodeAgent(
|
| 65 |
model=model,
|
| 66 |
+
tools=[final_answer, get_current_time_in_timezone, convert_to_utc], ## add your tools here (don't remove final answer)
|
| 67 |
max_steps=6,
|
| 68 |
verbosity_level=1,
|
| 69 |
grammar=None,
|