From ac527144981c30bc4f8dd15ada04ea83d8bd5bd1 Mon Sep 17 00:00:00 2001 From: Sakura-RanChen <1908198662@qq.com> Date: Wed, 14 May 2025 16:30:53 +0800 Subject: [PATCH 1/4] weather-fix --- main/xiaozhi-server/config.yaml | 2 +- .../xiaozhi-server/plugins_func/functions/get_weather.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index 36e61ec9..f251f423 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -101,7 +101,7 @@ plugins: # 这个密钥是项目共用的key,用多了可能会被限制 # 想稳定一点就自行申请替换,每天有1000次免费调用 # 申请地址:https://console.qweather.com/#/apps/create-key/over - get_weather: { "api_key": "a861d0d5e7bf4ee1a83d9a9e4f96d4da", "default_location": "广州" } + get_weather: {"api_host":"mj7p3y7naa.re.qweatherapi.com", "api_key": "a861d0d5e7bf4ee1a83d9a9e4f96d4da", "default_location": "广州" } # 获取新闻插件的配置,这里根据需要的新闻类型传入对应的url链接,默认支持社会、科技、财经新闻 # 更多类型的新闻列表查看 https://www.chinanews.com.cn/rss/ get_news_from_chinanews: diff --git a/main/xiaozhi-server/plugins_func/functions/get_weather.py b/main/xiaozhi-server/plugins_func/functions/get_weather.py index dc7976dd..0294559c 100644 --- a/main/xiaozhi-server/plugins_func/functions/get_weather.py +++ b/main/xiaozhi-server/plugins_func/functions/get_weather.py @@ -107,8 +107,8 @@ WEATHER_CODE_MAP = { } -def fetch_city_info(location, api_key): - url = f"https://geoapi.qweather.com/v2/city/lookup?key={api_key}&location={location}&lang=zh" +def fetch_city_info(location, api_key, api_host): + url = f"https://{api_host}/geo/v2/city/lookup?key={api_key}&location={location}&lang=zh" response = requests.get(url, headers=HEADERS).json() return response.get("location", [])[0] if response.get("location") else None @@ -151,8 +151,10 @@ def parse_weather_info(soup): @register_function("get_weather", GET_WEATHER_FUNCTION_DESC, ToolType.SYSTEM_CTL) def get_weather(conn, location: str = None, lang: str = "zh_CN"): + api_host = conn.config["plugins"]["get_weather"]["api_host"] api_key = conn.config["plugins"]["get_weather"]["api_key"] default_location = conn.config["plugins"]["get_weather"]["default_location"] + print(api_host,api_key) client_ip = conn.client_ip # 优先使用用户提供的location参数 if not location: @@ -164,8 +166,7 @@ def get_weather(conn, location: str = None, lang: str = "zh_CN"): else: # 若IP解析失败或无IP,使用默认位置 location = default_location - - city_info = fetch_city_info(location, api_key) + city_info = fetch_city_info(location, api_key, api_host) if not city_info: return ActionResponse( Action.REQLLM, f"未找到相关的城市: {location},请确认地点是否正确", None From 1efaf048f56e1b905983ee8a23c31f439a7705ef Mon Sep 17 00:00:00 2001 From: Sakura-RanChen <1908198662@qq.com> Date: Wed, 14 May 2025 16:48:35 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=99=A8=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ProviderDialog.vue | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/main/manager-web/src/components/ProviderDialog.vue b/main/manager-web/src/components/ProviderDialog.vue index 52b19b06..844282ee 100644 --- a/main/manager-web/src/components/ProviderDialog.vue +++ b/main/manager-web/src/components/ProviderDialog.vue @@ -49,7 +49,7 @@
- + @@ -60,7 +60,7 @@ @@ -70,7 +70,7 @@ @@ -89,6 +89,16 @@ + + +