XXSg559 commited on
Commit
cbb269d
·
verified ·
1 Parent(s): 20fae49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -7,16 +7,6 @@ from tools.final_answer import FinalAnswerTool
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
@@ -26,7 +16,16 @@ def my_custom_tool(city_lat:float, city_lon:float)-> str: #it's import to specif
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:
 
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(city_lat:float, city_lon:float)-> str: #it's import to specify the return type
 
16
  city_lat: the city latitude
17
  city_lon: the city longitude
18
  """
19
+
20
+ url = f"https://api.open-meteo.com/v1/forecast?latitude={city_lat}&longitude={city_lon}&current_weather=true"
21
+ response = requests.get(url)
22
+ data = response.json()
23
+
24
+ if "current_weather" in data:
25
+ weather = data["current_weather"]
26
+ return f"温度: {weather['temperature']}°C, 风速: {weather['windspeed']} km/h, 天气情况: {weather['weathercode']}"
27
+
28
+ return "无法获取天气数据"
29
 
30
  @tool
31
  def get_current_time_in_timezone(timezone: str) -> str: