From 3b34d687a67b38b8309795bf37695385894f6aab Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Thu, 12 Jun 2025 10:52:07 +0800 Subject: [PATCH] =?UTF-8?q?"fix:=20=E4=BF=AE=E5=A4=8DMCP=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98=EF=BC=8C=E6=97=A0=E5=8F=82=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E6=8F=90=E4=BE=9B=E9=BB=98=E8=AE=A4=E7=A9=BA?= =?UTF-8?q?=E5=AD=97=E5=85=B8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/handle/intentHandler.py | 4 +++- .../core/providers/intent/intent_llm/intent_llm.py | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/main/xiaozhi-server/core/handle/intentHandler.py b/main/xiaozhi-server/core/handle/intentHandler.py index 027a03a6..de4c36c1 100644 --- a/main/xiaozhi-server/core/handle/intentHandler.py +++ b/main/xiaozhi-server/core/handle/intentHandler.py @@ -84,9 +84,11 @@ async def process_intent_result(conn, intent_result, original_text): if not funcItem: conn.func_handler.function_registry.register_function("play_music") - function_args = None + function_args = {} if "arguments" in intent_data["function_call"]: function_args = intent_data["function_call"]["arguments"] + if function_args is None: + function_args = {} # 确保参数是字符串格式的JSON if isinstance(function_args, dict): function_args = json.dumps(function_args) diff --git a/main/xiaozhi-server/core/providers/intent/intent_llm/intent_llm.py b/main/xiaozhi-server/core/providers/intent/intent_llm/intent_llm.py index 3eafced8..9f9f4c4f 100644 --- a/main/xiaozhi-server/core/providers/intent/intent_llm/intent_llm.py +++ b/main/xiaozhi-server/core/providers/intent/intent_llm/intent_llm.py @@ -76,6 +76,14 @@ class IntentProvider(IntentProviderBase): '返回: {"function_call": {"name": "get_battery_level", "arguments": {"response_success": "当前电池电量为{value}%", "response_failure": "无法获取Battery的当前电量百分比"}}}\n' "```\n" "```\n" + "用户: 当前屏幕亮度是多少?\n" + '返回: {"function_call": {"name": "self_screen_get_brightness"}}\n' + "```\n" + "```\n" + "用户: 设置屏幕亮度为50%\n" + '返回: {"function_call": {"name": "self_screen_set_brightness", "arguments": {"brightness": 50}}}\n' + "```\n" + "```\n" "用户: 我想结束对话\n" '返回: {"function_call": {"name": "handle_exit_intent", "arguments": {"say_goodbye": "goodbye"}}}\n' "```\n"