Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,8 @@ from tools.final_answer import FinalAnswerTool
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
|
|
|
|
10 |
|
11 |
@tool
|
12 |
def get_weather(city:str)-> str:
|
@@ -18,10 +20,13 @@ def get_weather(city:str)-> str:
|
|
18 |
"""
|
19 |
|
20 |
try:
|
21 |
-
url = f"
|
22 |
response = requests.get(url)
|
23 |
if response.status.code == 200:
|
24 |
-
|
|
|
|
|
|
|
25 |
else:
|
26 |
return f"Error fetching weather for {city} (status: {response.status.code})"
|
27 |
except Exception as e:
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
+
WEATHER_API_KEY = "075f7d8548d34872a6b123953252708"
|
11 |
+
|
12 |
|
13 |
@tool
|
14 |
def get_weather(city:str)-> str:
|
|
|
20 |
"""
|
21 |
|
22 |
try:
|
23 |
+
url = f"http://api.weatherapi.com/v1/current.json?key={WEATHER_API_KEY}&q={city}"
|
24 |
response = requests.get(url)
|
25 |
if response.status.code == 200:
|
26 |
+
data = response.json()
|
27 |
+
temp = data["current"]["temp_c"]
|
28 |
+
condition = data["current"]["condtion"]["text"]
|
29 |
+
return f"The current weather in {city} is {temp}°C, {condition}"
|
30 |
else:
|
31 |
return f"Error fetching weather for {city} (status: {response.status.code})"
|
32 |
except Exception as e:
|