Merge pull request #1411 from myifeng/dev

修正错误提交
This commit is contained in:
CGD
2025-05-30 09:47:50 +08:00
committed by GitHub
3 changed files with 7 additions and 9 deletions
+2 -2
View File
@@ -581,7 +581,7 @@ class ConnectionHandler:
functions = None functions = None
if self.intent_type == "function_call" and hasattr(self, "func_handler"): if self.intent_type == "function_call" and hasattr(self, "func_handler"):
functions = self.func_handler.get_functions() functions = self.func_handler.get_functions()
if self.mcp_client is not None: if hasattr(self, "mcp_client"):
mcp_tools = self.mcp_client.get_available_tools() mcp_tools = self.mcp_client.get_available_tools()
if mcp_tools is not None and len(mcp_tools) > 0: if mcp_tools is not None and len(mcp_tools) > 0:
if functions is None: if functions is None:
@@ -707,7 +707,7 @@ class ConnectionHandler:
# 处理MCP工具调用 # 处理MCP工具调用
if self.mcp_manager.is_mcp_tool(function_name): if self.mcp_manager.is_mcp_tool(function_name):
result = self._handle_mcp_tool_call(function_call_data) result = self._handle_mcp_tool_call(function_call_data)
elif self.mcp_client is not None and self.mcp_client.has_tool(function_name): elif hasattr(self, "mcp_client") and self.mcp_client.has_tool(function_name):
# 如果是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}"
@@ -164,8 +164,6 @@ async def handle_mcp_message(conn, mcp_client: MCPClient, payload: dict):
else: else:
await mcp_client.set_ready(True) await mcp_client.set_ready(True)
conn.logger.bind(tag=TAG).info("所有工具已获取,MCP客户端准备就绪") conn.logger.bind(tag=TAG).info("所有工具已获取,MCP客户端准备就绪")
tool_result = await call_mcp_tool(conn, mcp_client, "self.get_device_status", {})
print(f"Tool call result: {tool_result}")
return return
# Handle method calls (requests from the client) # Handle method calls (requests from the client)
@@ -102,11 +102,11 @@ handle_device_function_desc = {
} }
# @register_function( @register_function(
# "handle_speaker_volume_or_screen_brightness", "handle_speaker_volume_or_screen_brightness",
# handle_device_function_desc, handle_device_function_desc,
# ToolType.IOT_CTL, ToolType.IOT_CTL,
# ) )
def handle_speaker_volume_or_screen_brightness( def handle_speaker_volume_or_screen_brightness(
conn, device_type: str, action: str, value: int = None conn, device_type: str, action: str, value: int = None
): ):