Update app.py
Browse files9 unmodified lines101112131415166 unmodified lines2324252627282930313233349 unmodified linesdef get_weather(city: str) -> str:"""Fetches the current weather for a given city using a free API."""try:api_key = "6a0835d57c8fec8315d41ce605ba7b19" # Replace with your actual API keyurl = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric"response = requests.get(url).json()if response.get("cod") != 200:6 unmodified lines@tooldef fetch_weather(city: str) -> str:"""A tool that fetches live weather data for a specified city."""return get_weather(city)@tooldef get_current_time_in_timezone(timezone: str) -> str:"""Fetches the current local time in a specified timezone."""try:tz = pytz.timezone(timezone)local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")9 unmodified lines101112131415166 unmodified lines23242526272829303132333435363738394041424344454647489 unmodified linesdef get_weather(city: str) -> str:"""Fetches the current weather for a given city using a free API."""try:api_key = "6a0835d57c8fec8315d41ce605ba7b19" # OpenWeather API keyurl = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric"response = requests.get(url).json()if response.get("cod") != 200:6 unmodified lines@tooldef fetch_weather(city: str) -> str:"""A tool that fetches live weather data for a specified city.Args:city (str): The name of the city to fetch weather information for.Returns:str: A string containing the weather description and temperature."""return get_weather(city)@tooldef get_current_time_in_timezone(timezone: str) -> str:"""Fetches the current local time in a specified timezone.Args:timezone (str): A string representing a valid timezone (e.g., 'America/New_York').Returns:str: The current local time in the specified timezone."""try:tz = pytz.timezone(timezone)local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
app.py+17-3