faiyazansariusa commited on
Commit
d8f1179
·
verified ·
1 Parent(s): bf49e49

Update app.py

Browse files

added function for weather

Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -35,6 +35,22 @@ def get_current_time_in_timezone(timezone: str) -> str:
35
  except Exception as e:
36
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  final_answer = FinalAnswerTool()
40
 
 
35
  except Exception as e:
36
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
37
 
38
+ @tool
39
+ def get_weather(city):
40
+ import requests
41
+ api_url = f"https://api.weather.com/v1/location/{city}?apiKey=YOUR_API_KEY"
42
+ response = requests.get(api_url)
43
+ if response.status_code == 200:
44
+ data = response.json()
45
+ return data.get("weather", "No weather information available")
46
+ else:
47
+ return "Error: Unable to fetch weather data."
48
+
49
+ # Execute the function and prepare the final answer
50
+ result = get_weather("New York")
51
+ final_answer = f"The current weather in New York is: {result}"
52
+ print(final_answer)
53
+
54
 
55
  final_answer = FinalAnswerTool()
56