from typing import TYPE_CHECKING from plugins_func.register import register_function, ToolType, ActionResponse, Action if TYPE_CHECKING: from core.connection import ConnectionHandler start_shadowing_function_desc = { "type": "function", "function": { "name": "start_shadowing", "description": "开始跟读:设备用语音读一句英语,用户跟着读,录音会上报,但不会进入聊天。用户说退出跟读或回到聊天时结束。", "parameters": { "type": "object", "properties": {}, }, }, } @register_function("start_shadowing", start_shadowing_function_desc, ToolType.SYSTEM_CTL) async def start_shadowing(conn: "ConnectionHandler"): from core.app_runtime.runtime import start_app_task result = await start_app_task( conn, "english_learning", "shadowing", {}, source="voice", ) if result.action in (Action.ERROR, Action.RESPONSE): return ActionResponse( action=Action.RESPONSE, result=result.result, response=result.response or "无法开始跟读", ) return ActionResponse( action=Action.NONE, result=result.result, response=result.response, )