Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,6 +33,20 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
final_answer = FinalAnswerTool()
|
38 |
|
|
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
36 |
+
@tool
|
37 |
+
def get_sunrise_time_in_location(location: str) -> str:
|
38 |
+
"""A tool that fetches the time of sun rise for a specific location.
|
39 |
+
Args:
|
40 |
+
location: A string representing a valid location (e.g., 'America/New_York').
|
41 |
+
"""
|
42 |
+
try:
|
43 |
+
# Create time of sunrise object
|
44 |
+
tz = DuckDuckGoSearchTool("https://www.timeanddate.com/sun/" +location)
|
45 |
+
# Get sunrise time in that location
|
46 |
+
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
47 |
+
return f"The sunrise time in {location} is: {local_time}"
|
48 |
+
except Exception as e:
|
49 |
+
return f"Error fetching sunrise time for location '{location}': {str(e)}"
|
50 |
|
51 |
final_answer = FinalAnswerTool()
|
52 |
|