XXSg559 commited on
Commit
9b89b5a
·
verified ·
1 Parent(s): 97b1f77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -7,16 +7,26 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
 
 
 
 
 
 
 
 
 
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
+ def get_weather(city_lat, city_lon):
11
+ url = f"https://api.open-meteo.com/v1/forecast?latitude={city_lat}&longitude={city_lon}&current_weather=true"
12
+ response = requests.get(url)
13
+ data = response.json()
14
+
15
+ if "current_weather" in data:
16
+ weather = data["current_weather"]
17
+ return f"温度: {weather['temperature']}°C, 风速: {weather['windspeed']} km/h, 天气情况: {weather['weathercode']}"
18
+ else:
19
+ return "无法获取天气数据"
20
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
21
  @tool
22
+ def my_custom_tool(city_lat:float, city_lon:float)-> str: #it's import to specify the return type
23
  #Keep this format for the description / args / args description but feel free to modify the tool
24
+ """A tool for querying the weather of a specified city.
25
  Args:
26
+ city_lat: the city latitude
27
+ city_lon: the city longitude
28
  """
29
+ return get_weather(city_lat, city_lon)
30
 
31
  @tool
32
  def get_current_time_in_timezone(timezone: str) -> str: