Update app.py
#563
by
SMS87
- opened
app.py
CHANGED
|
@@ -7,16 +7,29 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def my_custom_tool(arg1:str, arg2:int)-> str:
|
| 13 |
-
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""
|
| 15 |
Args:
|
| 16 |
-
arg1:
|
| 17 |
-
arg2: the
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def my_custom_tool(arg1: str, arg2: int) -> str: # it's important to specify the return type
|
| 13 |
+
# Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
+
"""Convert the current time in a given timezone by applying an hour offset.
|
| 15 |
Args:
|
| 16 |
+
arg1: The source timezone name (e.g., 'Europe/Paris')
|
| 17 |
+
arg2: The number of hours to offset the time (positive or negative)
|
| 18 |
"""
|
| 19 |
+
import datetime
|
| 20 |
+
import pytz
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
source_tz = pytz.timezone(arg1)
|
| 24 |
+
now_in_source = datetime.datetime.now(source_tz)
|
| 25 |
+
shifted_time = now_in_source + datetime.timedelta(hours=arg2)
|
| 26 |
+
return (
|
| 27 |
+
f"Current time in {arg1}: {now_in_source.strftime('%Y-%m-%d %H:%M:%S')}\n"
|
| 28 |
+
f"Time after applying offset ({arg2}h): {shifted_time.strftime('%Y-%m-%d %H:%M:%S')}"
|
| 29 |
+
)
|
| 30 |
+
except Exception as e:
|
| 31 |
+
return f"Error: {e}"
|
| 32 |
+
|
| 33 |
|
| 34 |
@tool
|
| 35 |
def get_current_time_in_timezone(timezone: str) -> str:
|