Update app.py

#665
by caolvchon - opened
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -33,6 +33,22 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def get_weather(city: str) -> str:
38
+ """
39
+ A tool that fetches the current weather for a specified city.
40
+ Args:
41
+ city: The name of the city to get weather for (e.g., 'London', 'Tokyo').
42
+ """
43
+ try:
44
+ # 这里模拟天气查询逻辑
45
+ # 在实际应用中,你会在这里调用像 OpenWeatherMap 这样的 API
46
+ weather_data = "Sunny, 25°C"
47
+
48
+ return f"The current weather in {city} is {weather_data}."
49
+
50
+ except Exception as e:
51
+ return f"Error fetching weather for city '{city}': {str(e)}"
52
 
53
  final_answer = FinalAnswerTool()
54