Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,20 @@ def my_custom_tool(search_topic: str, max_results: int) -> str:
|
|
16 |
search_topic: The topic to search for
|
17 |
max_results: Number of results to return (1-3)
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
16 |
search_topic: The topic to search for
|
17 |
max_results: Number of results to return (1-3)
|
18 |
"""
|
19 |
+
try:
|
20 |
+
# Use DuckDuckGo to search for weather
|
21 |
+
search_tool = DuckDuckGoSearchTool()
|
22 |
+
results = search_tool(f"current weather in {city}")
|
23 |
+
|
24 |
+
if not results:
|
25 |
+
return f"Could not find weather information for {city}"
|
26 |
+
|
27 |
+
# Get first result which should contain weather info
|
28 |
+
weather_info = results[0]
|
29 |
+
return f"Current weather in {city}: {weather_info['snippet']}"
|
30 |
+
|
31 |
+
except Exception as e:
|
32 |
+
return f"Error getting weather for {city}: {str(e)}"
|
33 |
|
34 |
@tool
|
35 |
def get_current_time_in_timezone(timezone: str) -> str:
|