rchrdgwr commited on
Commit
bf475fb
·
verified ·
1 Parent(s): 14da8ca
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -3,6 +3,7 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
@@ -46,6 +47,23 @@ def get_population(country:str)-> str: #it's import to specify the return type
46
 
47
  @tool
48
  def get_weather(city:str) -> str:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
 
51
  final_answer = FinalAnswerTool()
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import os
7
  from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
 
47
 
48
  @tool
49
  def get_weather(city:str) -> str:
50
+ API_KEY = os.getenv("WAPI")
51
+ CITY = "New York"
52
+ URL = f"http://api.weatherapi.com/v1/current.json?key={API_KEY}&q={CITY}&aqi=no
53
+ response = requests.get(URL)
54
+ if response.status_code == 200:
55
+ data = response.json()
56
+ temperature = data["current"]["temp_f"]
57
+ condition = data["current"]["condition"]["text"]
58
+ humidity = data["current"]["humidity"]
59
+ wind_speed = data["current"]["wind_kph"]
60
+
61
+ print(f"Weather in {CITY}: {temperature}°C, {condition}")
62
+ print(f"Humidity: {humidity}%")
63
+ print(f"Wind Speed: {wind_speed} km/h")
64
+ else:
65
+ print(f"Error fetching weather data: {response.status_code}")
66
+ return f"The temperature is {temperature}"
67
 
68
 
69
  final_answer = FinalAnswerTool()