mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
refactor(core): 优化 MCP工具调用响应
- 在 connection.py 和 intentHandler.py 中添加 speak_txt 函数调用 - 在执行 MCP 工具调用前播放 "好的, 请稍等" 语音提示 -优化了与用户的交互体验
This commit is contained in:
parent
8c1a8f7d55
commit
8d7f72d913
2 changed files with 6 additions and 0 deletions
|
|
@ -740,6 +740,7 @@ class ConnectionHandler:
|
||||||
elif hasattr(self, "mcp_client") and self.mcp_client.has_tool(
|
elif hasattr(self, "mcp_client") and self.mcp_client.has_tool(
|
||||||
function_name
|
function_name
|
||||||
):
|
):
|
||||||
|
speak_txt(self, "好的, 请稍等")
|
||||||
# 如果是小智端MCP工具调用
|
# 如果是小智端MCP工具调用
|
||||||
self.logger.bind(tag=TAG).debug(
|
self.logger.bind(tag=TAG).debug(
|
||||||
f"调用小智端MCP工具: {function_name}, 参数: {function_arguments}"
|
f"调用小智端MCP工具: {function_name}, 参数: {function_arguments}"
|
||||||
|
|
@ -1025,3 +1026,7 @@ class ConnectionHandler:
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.bind(tag=TAG).error(f"超时检查任务出错: {e}")
|
self.logger.bind(tag=TAG).error(f"超时检查任务出错: {e}")
|
||||||
|
|
||||||
|
def speak_txt(conn, text):
|
||||||
|
conn.tts.tts_one_sentence(conn, ContentType.TEXT, content_detail=text)
|
||||||
|
conn.dialogue.put(Message(role="assistant", content=text))
|
||||||
|
|
@ -112,6 +112,7 @@ async def process_intent_result(conn, intent_result, original_text):
|
||||||
elif hasattr(conn, "mcp_client") and conn.mcp_client.has_tool(
|
elif hasattr(conn, "mcp_client") and conn.mcp_client.has_tool(
|
||||||
function_name
|
function_name
|
||||||
):
|
):
|
||||||
|
speak_txt(conn, "好的, 请稍等")
|
||||||
# 如果是小智端MCP工具调用
|
# 如果是小智端MCP工具调用
|
||||||
conn.logger.bind(tag=TAG).debug(
|
conn.logger.bind(tag=TAG).debug(
|
||||||
f"调用小智端MCP工具: {function_name}, 参数: {function_args}"
|
f"调用小智端MCP工具: {function_name}, 参数: {function_args}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue