Skip to content

refactor(core): 添加 MCP工具调用前的回应,提升用户体验 #1684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions main/xiaozhi-server/core/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ def chat(self, query, tool_call=False):
elif hasattr(self, "mcp_client") and self.mcp_client.has_tool(
function_name
):
speak_txt(self, "好的, 请稍等")
# 如果是小智端MCP工具调用
self.logger.bind(tag=TAG).debug(
f"调用小智端MCP工具: {function_name}, 参数: {function_arguments}"
Expand Down Expand Up @@ -1025,3 +1026,7 @@ async def _check_timeout(self):
break
except Exception as 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))
1 change: 1 addition & 0 deletions main/xiaozhi-server/core/handle/intentHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def process_function_call():
elif hasattr(conn, "mcp_client") and conn.mcp_client.has_tool(
function_name
):
speak_txt(conn, "好的, 请稍等")
# 如果是小智端MCP工具调用
conn.logger.bind(tag=TAG).debug(
f"调用小智端MCP工具: {function_name}, 参数: {function_args}"
Expand Down