wangzhibo
2026-09-11 659c470eba542383987aad227b7f918100f131fa
xiaozhi-esp32-server/main/xiaozhi-server/plugins_func/functions/switch_app.py
@@ -9,14 +9,23 @@
    "type": "function",
    "function": {
        "name": "switch_app",
        "description": "切换设备当前 App。打开翻译、打开英语学习/复读、回到聊天、退出翻译时调用。app_id 只能是 chat、english_learning、english_translation。",
        "description": (
            "切换设备当前 App。"
            "chat=对话;english_translation=翻译;english_conversation=中英对话;"
            "english_learning 需配合 task_id:repeater=复读机,shadowing=跟读。"
            "退出当前模式、回到聊天时 app_id=chat。"
        ),
        "parameters": {
            "type": "object",
            "properties": {
                "app_id": {
                    "type": "string",
                    "description": "目标 App:chat(聊天)、english_learning(复读)、english_translation(翻译)",
                }
                    "description": "chat、english_learning、english_translation、english_conversation",
                },
                "task_id": {
                    "type": "string",
                    "description": "可选。english_learning 下 repeater 或 shadowing;其它 App 可空",
                },
            },
            "required": ["app_id"],
        },
@@ -25,10 +34,10 @@
@register_function("switch_app", switch_app_function_desc, ToolType.SYSTEM_CTL)
async def switch_app(conn: "ConnectionHandler", app_id: str):
async def switch_app(conn: "ConnectionHandler", app_id: str, task_id: str = ""):
    from core.app_runtime.runtime import switch_app as runtime_switch
    result = await runtime_switch(conn, app_id, source="voice")
    result = await runtime_switch(conn, app_id, source="voice", task_id=task_id or "")
    if result.action == Action.ERROR:
        return ActionResponse(
            action=Action.RESPONSE,