hp1318 commited on
Commit
177a6bf
·
verified ·
1 Parent(s): 180d089

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -4
app.py CHANGED
@@ -9,7 +9,14 @@ 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. Uses wttr.in (No API key required)."""
 
 
 
 
 
 
 
13
  try:
14
  url = f"https://wttr.in/{city}?format=%C+%t+%h+%w"
15
  response = requests.get(url)
@@ -22,7 +29,14 @@ def get_weather(city: str) -> str:
22
  # Tool to fetch AQI (Air Quality Index) - No API Key Needed (Uses waqi.info with a demo token)
23
  @tool
24
  def get_air_quality(city: str) -> str:
25
- """Fetches air quality index (AQI) for a city using waqi.info."""
 
 
 
 
 
 
 
26
  try:
27
  url = f"https://api.waqi.info/feed/{city}/?token=demo" # Demo token (no key needed)
28
  response = requests.get(url).json()
@@ -35,7 +49,14 @@ def get_air_quality(city: str) -> str:
35
  # Tool to get local time
36
  @tool
37
  def get_local_time(city: str) -> str:
38
- """Fetches the current local time for a city."""
 
 
 
 
 
 
 
39
  try:
40
  tz = pytz.timezone(city.replace(" ", "_")) # Handle spaces in city names
41
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
@@ -46,7 +67,14 @@ def get_local_time(city: str) -> str:
46
  # Tool to fetch top 5 restaurants using DuckDuckGo Search
47
  @tool
48
  def get_top_restaurants(city: str) -> str:
49
- """Finds top 5 restaurants in a city using DuckDuckGo search."""
 
 
 
 
 
 
 
50
  try:
51
  search_tool = DuckDuckGoSearchTool()
52
  results = search_tool.run(f"Top 5 restaurants in {city}")
@@ -87,3 +115,4 @@ agent = CodeAgent(
87
 
88
  # Launch Gradio UI
89
  GradioUI(agent).launch()
 
 
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 to fetch weather for.
16
+
17
+ Returns:
18
+ str: The weather information including temperature, humidity, and wind speed.
19
+ """
20
  try:
21
  url = f"https://wttr.in/{city}?format=%C+%t+%h+%w"
22
  response = requests.get(url)
 
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 to fetch AQI for.
36
+
37
+ Returns:
38
+ str: The AQI value and air quality status.
39
+ """
40
  try:
41
  url = f"https://api.waqi.info/feed/{city}/?token=demo" # Demo token (no key needed)
42
  response = requests.get(url).json()
 
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 in YYYY-MM-DD HH:MM:SS format.
59
+ """
60
  try:
61
  tz = pytz.timezone(city.replace(" ", "_")) # Handle spaces in city names
62
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
 
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 to find restaurants in.
74
+
75
+ Returns:
76
+ str: A list of the top 5 restaurants with their names and links.
77
+ """
78
  try:
79
  search_tool = DuckDuckGoSearchTool()
80
  results = search_tool.run(f"Top 5 restaurants in {city}")
 
115
 
116
  # Launch Gradio UI
117
  GradioUI(agent).launch()
118
+