agentzero07 commited on
Commit
d067623
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -33,6 +33,21 @@ 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
+ def get_weather(city: str) -> str:
37
+ """A tool that fetches the current weather of a specified city.
38
+ Args:
39
+ location: A string representing a valid city (e.g., 'Bangalore').
40
+ """
41
+ try:
42
+ requests.get('https://api.weatherapi.com/v1/current.json?key=41d95dfc59fb499583443528250902&q=' + city + '&aqi=no')
43
+ weatherJSON = response.json()
44
+ cityName = weatherJSON.get('location').get('name')
45
+ cityTemp = weatherJSON.get('current').get('temp_c')
46
+ cityCondition = weatherJSON.get('current').get('condition').get('text')
47
+ return f"The current Temperature in {cityName} is {cityTemp} and conditions are {cityCondition}"
48
+ except Execution as e:
49
+ return f"Error fetching weather conditions for {city}"
50
+
51
 
52
  final_answer = FinalAnswerTool()
53