Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,33 @@ 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 |
-
|
| 13 |
-
|
| 14 |
-
"""A tool that checks local time
|
|
|
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
@tool
|
| 13 |
+
def time_greeting_tool(time_zone: str, hour: int = None) -> str:
|
| 14 |
+
"""A tool that checks local time and greets you accordingly.
|
| 15 |
+
|
| 16 |
Args:
|
| 17 |
+
time_zone: A string representing the time zone (e.g., 'EAT', 'EST', 'PST')
|
| 18 |
+
hour: An optional integer representing the current hour (0-23).
|
| 19 |
+
If not provided, uses current system time.
|
| 20 |
+
|
| 21 |
+
Returns:
|
| 22 |
+
A greeting message based on the time of day in the specified time zone.
|
| 23 |
"""
|
| 24 |
+
# If hour is not provided, use current system time
|
| 25 |
+
if hour is None:
|
| 26 |
+
hour = datetime.now().hour
|
| 27 |
+
|
| 28 |
+
# Simple time-based greetings
|
| 29 |
+
if 5 <= hour < 12:
|
| 30 |
+
time_of_day = "morning"
|
| 31 |
+
elif 12 <= hour < 17:
|
| 32 |
+
time_of_day = "afternoon"
|
| 33 |
+
elif 17 <= hour < 21:
|
| 34 |
+
time_of_day = "evening"
|
| 35 |
+
else:
|
| 36 |
+
time_of_day = "night"
|
| 37 |
+
|
| 38 |
+
return f"Good {time_of_day}! It's currently hour {hour} in {time_zone} time zone."
|
| 39 |
|
| 40 |
@tool
|
| 41 |
def get_current_time_in_timezone(timezone: str) -> str:
|