Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,7 @@ def get_weather(city: str) -> str:
|
|
29 |
# Tool to fetch AQI (Air Quality Index) - No API Key Needed (Uses waqi.info with a demo token)
|
30 |
@tool
|
31 |
def get_air_quality(city: str) -> str:
|
32 |
-
"""
|
33 |
|
34 |
Args:
|
35 |
city: The name of the city for which AQI information is needed.
|
@@ -38,11 +38,14 @@ def get_air_quality(city: str) -> str:
|
|
38 |
str: The AQI value along with air quality status.
|
39 |
"""
|
40 |
try:
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
except Exception as e:
|
47 |
return f"Error fetching AQI: {e}"
|
48 |
|
|
|
29 |
# Tool to fetch AQI (Air Quality Index) - No API Key Needed (Uses waqi.info with a demo token)
|
30 |
@tool
|
31 |
def get_air_quality(city: str) -> str:
|
32 |
+
"""Finds the air quality index (AQI) for a city using DuckDuckGo search.
|
33 |
|
34 |
Args:
|
35 |
city: The name of the city for which AQI information is needed.
|
|
|
38 |
str: The AQI value along with air quality status.
|
39 |
"""
|
40 |
try:
|
41 |
+
search_tool = DuckDuckGoSearchTool()
|
42 |
+
query = f"current air quality index AQI in {city}"
|
43 |
+
results = search_tool.forward(query)
|
44 |
+
|
45 |
+
if results:
|
46 |
+
top_result = results.split("\n\n")[0] # Get the first search result
|
47 |
+
return f"Air Quality in {city}:\n{top_result}"
|
48 |
+
return "No AQI data found."
|
49 |
except Exception as e:
|
50 |
return f"Error fetching AQI: {e}"
|
51 |
|