SaraM2727 commited on
Commit
0217e61
·
verified ·
1 Parent(s): 89490ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -8,6 +8,23 @@ from Gradio_UI import GradioUI
8
 
9
  # Tool: Fetch current time in a given timezone
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # Tool: Fetch real-time weather for a given location
13
  @tool
 
8
 
9
  # Tool: Fetch current time in a given timezone
10
 
11
+ @tool
12
+ def get_current_time_in_timezone(timezone: str) -> str:
13
+ """
14
+ Fetches the current local time in a specified timezone.
15
+
16
+ Args:
17
+ timezone (str): A string representing a valid timezone (e.g., 'America/New_York').
18
+
19
+ Returns:
20
+ str: The current time in the given timezone.
21
+ """
22
+ try:
23
+ tz = pytz.timezone(timezone)
24
+ local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
25
+ return f"The current local time in {timezone} is: {local_time}"
26
+ except Exception as e:
27
+ return f"Error fetching time for timezone '{timezone}': {str(e)}"
28
 
29
  # Tool: Fetch real-time weather for a given location
30
  @tool