Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,6 +33,23 @@ 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 |
+
# Code Agent Example: Retrieve Weather Information
|
38 |
+
def get_weather(city):
|
39 |
+
import requests
|
40 |
+
api_url = f"https://api.weather.com/v1/location/{city}?apiKey=YOUR_API_KEY"
|
41 |
+
response = requests.get(api_url)
|
42 |
+
if response.status_code == 200:
|
43 |
+
data = response.json()
|
44 |
+
return data.get("weather", "No weather information available")
|
45 |
+
else:
|
46 |
+
return "Error: Unable to fetch weather data."
|
47 |
+
|
48 |
+
# Execute the function and prepare the final answer
|
49 |
+
result = get_weather("New York")
|
50 |
+
final_answer = f"The current weather in New York is: {result}"
|
51 |
+
print(final_answer)
|
52 |
+
|
53 |
|
54 |
final_answer = FinalAnswerTool()
|
55 |
|