From 6eac25425c2d3d901d0838c72b5c53e5f77b58a0 Mon Sep 17 00:00:00 2001 From: Junsen <66542771+Huang-junsen@users.noreply.github.com> Date: Mon, 17 Mar 2025 09:45:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(docs):=20=E6=96=B0=E5=A2=9EIssues?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=20(#383)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug_report.md | 34 +++++++++++++++++++ .github/ISSUE_TEMPLATE/code_improvement.md | 19 +++++++++++ .../documentation_improvement.md | 16 +++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 19 +++++++++++ 4 files changed, 88 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/code_improvement.md create mode 100644 .github/ISSUE_TEMPLATE/documentation_improvement.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..2d6c173ff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,34 @@ +--- +name: Bug 报告(Bug Report) +about: 反馈项目中的缺陷或问题 +title: "[Bug] 简短描述问题" +labels: bug +assignees: '' +--- + +## 🐛 问题描述 + + +## 🔍 复现步骤 + +1. 打开 '...' +2. 点击 '...' +3. 滚动到 '...' +4. 看到错误 + +## 🤔 预期行为 + + +## 😯 截图 + + +## 🖥️ 环境信息 +- 操作系统: [例如 Windows 10] +- 浏览器: [例如 Chrome 89] +- 项目版本: [例如 1.0.0] +- Python版本: [例如 3.9.13] +- Jdk版本:[例如 java 21.0.5 2024-10-15 LTS] +- Nodejs版本:[例如 v20.14.0] + +## 📋 其他信息 + diff --git a/.github/ISSUE_TEMPLATE/code_improvement.md b/.github/ISSUE_TEMPLATE/code_improvement.md new file mode 100644 index 000000000..0ec0b145f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/code_improvement.md @@ -0,0 +1,19 @@ +--- +name: 代码优化建议(Code Improvement) +about: 提出对现有代码的优化或改进建议 +title: "[Improvement] 简短描述改进内容" +labels: refactor +assignees: '' +--- + +## 💡 改进描述 + + +## 🌟 改进建议 + + +## 🛠️ 相关代码 + + +## 📋 其他信息 + diff --git a/.github/ISSUE_TEMPLATE/documentation_improvement.md b/.github/ISSUE_TEMPLATE/documentation_improvement.md new file mode 100644 index 000000000..9cdc10e08 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_improvement.md @@ -0,0 +1,16 @@ +--- +name: 文档改进建议(Documentation Improvement) +about: 提出对项目文档的改进或补充建议 +title: "[Docs] 简短描述改进内容" +labels: documentation +assignees: '' +--- + +## 📚 改进描述 + + +## ✨ 改进建议 + + +## 📋 其他信息 + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..df1c029d9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,19 @@ +--- +name: 功能请求(Feature Request) +about: 提出新的功能或改进建议 +title: "[Feature] 简短描述功能" +labels: enhancement +assignees: '' +--- + +## 🚀 需求描述 + + +## 🎯 解决方案 + + +## 📝 备选方案 + + +## 📋 其他信息 + From d893de3c87bb3de04edc51319d799c354ef88749 Mon Sep 17 00:00:00 2001 From: xiaowu911 <51016996+xiaowu911@users.noreply.github.com> Date: Mon, 17 Mar 2025 10:58:18 +0800 Subject: [PATCH 2/2] Update get_weather.py (#381) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新天气插件,增加:通过当前IP获取用户实时位置的功能 --- .../plugins_func/functions/get_weather.py | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/main/xiaozhi-server/plugins_func/functions/get_weather.py b/main/xiaozhi-server/plugins_func/functions/get_weather.py index 380e2cc40..3cdb21330 100644 --- a/main/xiaozhi-server/plugins_func/functions/get_weather.py +++ b/main/xiaozhi-server/plugins_func/functions/get_weather.py @@ -1,35 +1,55 @@ import requests from bs4 import BeautifulSoup -from plugins_func.register import register_function,ToolType, ActionResponse, Action +from plugins_func.register import register_function, ToolType, ActionResponse, Action +def get_city_by_ip() -> str: + try: + response = requests.get('http://ip-api.com/json', timeout=5) + if response.status_code != 200: + raise ValueError(f"API error: {response.text}") + data = response.json() + if data['status'] != 'success': + raise ValueError(f"API error: {data.get('message', 'Unknown error')}") + city = data['city'] + province = data['regionName'] + return f"{province}/{city}" + except Exception as e: + print(f"[定位失败] 使用默认位置,错误: {str(e)}") + return None + get_weather_function_desc = { "type": "function", "function": { "name": "get_weather", - "description": "获取某个地点的天气,用户应先提供一个位置,比如用户说杭州天气,参数为:zhejiang/hangzhou,比如用户说北京天气怎么样,参数为:beijing/beijing。如果用户只问天气怎么样,参数是:guangdong/guangzhou", + "description": "获取某个地点的天气,用户应先提供一个位置,比如用户说杭州天气,参数为:zhejiang/hangzhou,比如用户说北京天气怎么样,参数为:beijing/beijing。如果用户只问天气怎么样,则没有参数,系统会自动定位城市。", "parameters": { "type": "object", "properties": { "city": { "type": "string", - "description": "城市,zhejiang/hangzhou" + "description": "可选,格式:省份拼音/城市拼音,如 beijing/beijing" } }, - "required": [ - "city" - ] + "required": [] } } } + @register_function('get_weather', get_weather_function_desc, ToolType.WAIT) -def get_weather(city: str): +def get_weather(city: str = None): """ - "获取某个地点的天气,用户应先提供一个位置,\n比如用户说杭州天气,参数为:zhejiang/hangzhou,\n\n比如用户说北京天气怎么样,参数为:beijing/beijing", + 获取某个地点的天气,用户应先提供一个位置, + 比如用户说杭州天气,参数为:zhejiang/hangzhou, + 比如用户说北京天气怎么样,参数为:beijing/beijing city : 城市,zhejiang/hangzhou """ - url = "https://tianqi.moji.com/weather/china/"+city + if not city: + city = get_city_by_ip() + print(f"[天气查询] 自动定位城市: {city}") + + url = f"https://tianqi.moji.com/weather/china/{city}" headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36' }