Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +9,13 @@ from Gradio_UI import GradioUI
|
|
| 9 |
# Tool to fetch weather data (No API Key Required, Uses wttr.in)
|
| 10 |
@tool
|
| 11 |
def get_weather(city: str) -> str:
|
| 12 |
-
"""Fetches current weather for a given city.
|
| 13 |
|
| 14 |
Args:
|
| 15 |
-
city (str): The name of the city
|
| 16 |
-
|
| 17 |
Returns:
|
| 18 |
-
str:
|
| 19 |
"""
|
| 20 |
try:
|
| 21 |
url = f"https://wttr.in/{city}?format=%C+%t+%h+%w"
|
|
@@ -29,13 +29,13 @@ 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 |
-
"""Fetches air quality index (AQI) for a city using waqi.info.
|
| 33 |
|
| 34 |
Args:
|
| 35 |
-
city (str): The name of the city
|
| 36 |
|
| 37 |
Returns:
|
| 38 |
-
str: The AQI value
|
| 39 |
"""
|
| 40 |
try:
|
| 41 |
url = f"https://api.waqi.info/feed/{city}/?token=demo" # Demo token (no key needed)
|
|
@@ -49,13 +49,13 @@ def get_air_quality(city: str) -> str:
|
|
| 49 |
# Tool to get local time
|
| 50 |
@tool
|
| 51 |
def get_local_time(city: str) -> str:
|
| 52 |
-
"""Fetches the current local time for a city.
|
| 53 |
|
| 54 |
Args:
|
| 55 |
city (str): The name of the city to fetch the local time for.
|
| 56 |
|
| 57 |
Returns:
|
| 58 |
-
str: The current local time
|
| 59 |
"""
|
| 60 |
try:
|
| 61 |
tz = pytz.timezone(city.replace(" ", "_")) # Handle spaces in city names
|
|
@@ -67,13 +67,13 @@ def get_local_time(city: str) -> str:
|
|
| 67 |
# Tool to fetch top 5 restaurants using DuckDuckGo Search
|
| 68 |
@tool
|
| 69 |
def get_top_restaurants(city: str) -> str:
|
| 70 |
-
"""Finds top 5 restaurants in a city using DuckDuckGo search.
|
| 71 |
|
| 72 |
Args:
|
| 73 |
-
city (str): The name of the city
|
| 74 |
|
| 75 |
Returns:
|
| 76 |
-
str: A list of the top 5 restaurants
|
| 77 |
"""
|
| 78 |
try:
|
| 79 |
search_tool = DuckDuckGoSearchTool()
|
|
@@ -116,3 +116,4 @@ agent = CodeAgent(
|
|
| 116 |
# Launch Gradio UI
|
| 117 |
GradioUI(agent).launch()
|
| 118 |
|
|
|
|
|
|
| 9 |
# Tool to fetch weather data (No API Key Required, Uses wttr.in)
|
| 10 |
@tool
|
| 11 |
def get_weather(city: str) -> str:
|
| 12 |
+
"""Fetches current weather for a given city using wttr.in.
|
| 13 |
|
| 14 |
Args:
|
| 15 |
+
city (str): The name of the city for which weather information is needed.
|
| 16 |
+
|
| 17 |
Returns:
|
| 18 |
+
str: A string containing weather details such as temperature, humidity, and wind speed.
|
| 19 |
"""
|
| 20 |
try:
|
| 21 |
url = f"https://wttr.in/{city}?format=%C+%t+%h+%w"
|
|
|
|
| 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 |
+
"""Fetches air quality index (AQI) for a specified city using waqi.info.
|
| 33 |
|
| 34 |
Args:
|
| 35 |
+
city (str): The name of the city for which AQI information is needed.
|
| 36 |
|
| 37 |
Returns:
|
| 38 |
+
str: The AQI value along with air quality status.
|
| 39 |
"""
|
| 40 |
try:
|
| 41 |
url = f"https://api.waqi.info/feed/{city}/?token=demo" # Demo token (no key needed)
|
|
|
|
| 49 |
# Tool to get local time
|
| 50 |
@tool
|
| 51 |
def get_local_time(city: str) -> str:
|
| 52 |
+
"""Fetches the current local time for a specified city.
|
| 53 |
|
| 54 |
Args:
|
| 55 |
city (str): The name of the city to fetch the local time for.
|
| 56 |
|
| 57 |
Returns:
|
| 58 |
+
str: The current local time formatted as YYYY-MM-DD HH:MM:SS.
|
| 59 |
"""
|
| 60 |
try:
|
| 61 |
tz = pytz.timezone(city.replace(" ", "_")) # Handle spaces in city names
|
|
|
|
| 67 |
# Tool to fetch top 5 restaurants using DuckDuckGo Search
|
| 68 |
@tool
|
| 69 |
def get_top_restaurants(city: str) -> str:
|
| 70 |
+
"""Finds the top 5 restaurants in a specified city using DuckDuckGo search.
|
| 71 |
|
| 72 |
Args:
|
| 73 |
+
city (str): The name of the city where restaurants are being searched.
|
| 74 |
|
| 75 |
Returns:
|
| 76 |
+
str: A list of the top 5 restaurants including names and website links.
|
| 77 |
"""
|
| 78 |
try:
|
| 79 |
search_tool = DuckDuckGoSearchTool()
|
|
|
|
| 116 |
# Launch Gradio UI
|
| 117 |
GradioUI(agent).launch()
|
| 118 |
|
| 119 |
+
|