mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 04:43:56 +08:00
"fix: 修复MCP工具调用参数类型错误问题,无参调用时提供默认空字典"
This commit is contained in:
@@ -84,9 +84,11 @@ async def process_intent_result(conn, intent_result, original_text):
|
|||||||
if not funcItem:
|
if not funcItem:
|
||||||
conn.func_handler.function_registry.register_function("play_music")
|
conn.func_handler.function_registry.register_function("play_music")
|
||||||
|
|
||||||
function_args = None
|
function_args = {}
|
||||||
if "arguments" in intent_data["function_call"]:
|
if "arguments" in intent_data["function_call"]:
|
||||||
function_args = intent_data["function_call"]["arguments"]
|
function_args = intent_data["function_call"]["arguments"]
|
||||||
|
if function_args is None:
|
||||||
|
function_args = {}
|
||||||
# 确保参数是字符串格式的JSON
|
# 确保参数是字符串格式的JSON
|
||||||
if isinstance(function_args, dict):
|
if isinstance(function_args, dict):
|
||||||
function_args = json.dumps(function_args)
|
function_args = json.dumps(function_args)
|
||||||
|
|||||||
@@ -76,6 +76,14 @@ class IntentProvider(IntentProviderBase):
|
|||||||
'返回: {"function_call": {"name": "get_battery_level", "arguments": {"response_success": "当前电池电量为{value}%", "response_failure": "无法获取Battery的当前电量百分比"}}}\n'
|
'返回: {"function_call": {"name": "get_battery_level", "arguments": {"response_success": "当前电池电量为{value}%", "response_failure": "无法获取Battery的当前电量百分比"}}}\n'
|
||||||
"```\n"
|
"```\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"
|
"用户: 我想结束对话\n"
|
||||||
'返回: {"function_call": {"name": "handle_exit_intent", "arguments": {"say_goodbye": "goodbye"}}}\n'
|
'返回: {"function_call": {"name": "handle_exit_intent", "arguments": {"say_goodbye": "goodbye"}}}\n'
|
||||||
"```\n"
|
"```\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user