wangzhibo
2026-09-11 659c470eba542383987aad227b7f918100f131fa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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,
    )