mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
update:在设备端显示工具调用信息
This commit is contained in:
@@ -316,3 +316,13 @@ async def send_stt_message(conn: "ConnectionHandler", text):
|
|||||||
await send_tts_message(conn, "start")
|
await send_tts_message(conn, "start")
|
||||||
# 发送start消息后客户端状态会处于说话中状态,同步服务端状态
|
# 发送start消息后客户端状态会处于说话中状态,同步服务端状态
|
||||||
conn.client_is_speaking = True
|
conn.client_is_speaking = True
|
||||||
|
|
||||||
|
|
||||||
|
async def send_display_message(conn: "ConnectionHandler", text):
|
||||||
|
"""发送纯显示消息"""
|
||||||
|
message = {
|
||||||
|
"type": "stt",
|
||||||
|
"text": text,
|
||||||
|
"session_id": conn.session_id
|
||||||
|
}
|
||||||
|
await conn.websocket.send(json.dumps(message))
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from .server_mcp import ServerMCPExecutor
|
|||||||
from .device_iot import DeviceIoTExecutor
|
from .device_iot import DeviceIoTExecutor
|
||||||
from .device_mcp import DeviceMCPExecutor
|
from .device_mcp import DeviceMCPExecutor
|
||||||
from .mcp_endpoint import MCPEndpointExecutor
|
from .mcp_endpoint import MCPEndpointExecutor
|
||||||
|
from core.handle.sendAudioHandle import send_display_message
|
||||||
|
|
||||||
|
|
||||||
class UnifiedToolHandler:
|
class UnifiedToolHandler:
|
||||||
@@ -167,6 +168,12 @@ class UnifiedToolHandler:
|
|||||||
|
|
||||||
self.logger.debug(f"调用函数: {function_name}, 参数: {arguments}")
|
self.logger.debug(f"调用函数: {function_name}, 参数: {arguments}")
|
||||||
|
|
||||||
|
# 发送工具调用显示消息到设备
|
||||||
|
try:
|
||||||
|
await send_display_message(self.conn, f"% {function_name}")
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.warning(f"发送工具调用显示消息失败: {e}")
|
||||||
|
|
||||||
# 执行工具调用
|
# 执行工具调用
|
||||||
result = await self.tool_manager.execute_tool(function_name, arguments)
|
result = await self.tool_manager.execute_tool(function_name, arguments)
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user