jaidesign commited on
Commit
bc37a26
·
verified ·
1 Parent(s): f9266c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -55,24 +55,26 @@ def get_current_time_in_timezone(timezone: str) -> str:
55
 
56
  except Exception as e:
57
  return f"⚠️ Error fetching time for timezone '{timezone}': {str(e)}"
58
-
59
-
60
  @tool
61
- # Code Agent Example: Retrieve Weather Information
62
- def get_weather(city):
63
- import requests
64
- url = f"https://www.accuweather.com/v1/location/{city}?"
65
- response = requests.get(url)
66
- if response.status_code == 200:
67
- data = response.json()
68
- return data.get("weather", "No weather information available")
69
- else:
70
- return "Error: Unable to fetch weather data."
71
-
72
- # Execute the function and prepare the final answer
73
- result = get_weather("New York")
74
- final_ans = f"The current weather in New York is: {result}"
75
- print(final_ans)
 
 
 
 
76
 
77
  @tool
78
  def getMarsWeather() -> str:
 
55
 
56
  except Exception as e:
57
  return f"⚠️ Error fetching time for timezone '{timezone}': {str(e)}"
 
 
58
  @tool
59
+ def get_weather(location: str, zipcode: int) -> str:
60
+ """Fetches the current weather for a specified location or a zip code.
61
+
62
+ Args:
63
+ location: A string representing a valid city name or region (e.g., 'New York').
64
+ zipcode: An integer representing a valid zip code (e.g., 10001 for NYC).
65
+
66
+ Returns:
67
+ A string describing the weather conditions, temperature, and humidity.
68
+ """
69
+
70
+ temperature = data["main"]["temp"]
71
+ conditions = data["weather"][0]["description"]
72
+ humidity = data["main"]["humidity"]
73
+
74
+ return (f"🌤️ Weather in {location} is: {conditions.capitalize()}, "
75
+ f"Temperature: {temperature}°C, Humidity: {humidity}%")
76
+
77
+ #return f"The current weather in {location,zipcode} is: {temperature,}"
78
 
79
  @tool
80
  def getMarsWeather() -> str: