Coze

[English]

  • 组件注册表: espressif/brookesia_agent_coze

  • 辅助头文件: #include "brookesia/agent_helper/coze.hpp"

  • 辅助类: esp_brookesia::agent::helper::Coze

概述

brookesia_agent_coze 是基于 ESP-Brookesia Agent Manager 框架实现的 Coze 智能体。

功能特性

  • Coze API 集成:通过 WebSocket 与 Coze 平台进行实时通信,支持语音对话和文本交互。

  • OAuth2 认证:支持 Coze 平台的 OAuth2 认证机制,自动获取和管理访问令牌。

  • 多机器人支持:支持配置多个机器人,可以动态切换当前激活的机器人。

  • 音频编解码:内置音频编解码支持,默认使用 G711A 格式,支持 16kHz 采样率。

  • 表情支持:支持接收和显示 Coze 平台的表情事件。

  • 事件处理:支持 Coze 平台事件(如余额不足等)的监听和处理。

  • 持久化存储:可选搭配 brookesia_service_nvs 服务持久化保存鉴权信息和机器人等信息。

服务接口

函数

SetActiveRobotIndex

描述

Set active robot index.

执行要求
  • 是否需要调度器: 不需要

参数
  • Index

    • 类型: Number

    • 是否必填: 必填

    • 描述: Robot index to activate.

Schema JSON
展开查看 JSON

{
  "name": "SetActiveRobotIndex",
  "description": "Set active robot index.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "Index",
      "description": "Robot index to activate.",
      "type": "Number",
      "required": true,
      "default_value": null
    }
  ]
}
CLI 命令
svc_call AgentCoze SetActiveRobotIndex {"Index":null}

GetActiveRobotIndex

描述

Get active robot index. Return type: number. Example: 0

执行要求
  • 是否需要调度器: 不需要

参数
  • 无。

Schema JSON
展开查看 JSON

{
  "name": "GetActiveRobotIndex",
  "description": "Get active robot index. Return type: number. Example: 0",
  "require_scheduler": false,
  "parameters": []
}
CLI 命令
svc_call AgentCoze GetActiveRobotIndex

GetRobotInfos

描述

Get robot info list. Return type: JSON array<object>. Example: [{“name”:”robot1”,”bot_id”:”bot_id1”,”voice_id”:”voice_id1”,”description”:”description1”},{“name”:”robot2”,”bot_id”:”bot_id2”,”voice_id”:”voice_id2”,”description”:”description2”}]

执行要求
  • 是否需要调度器: 不需要

参数
  • 无。

Schema JSON
展开查看 JSON

{
  "name": "GetRobotInfos",
  "description": "Get robot info list. Return type: JSON array<object>. Example: [{\"name\":\"robot1\",\"bot_id\":\"bot_id1\",\"voice_id\":\"voice_id1\",\"description\":\"description1\"},{\"name\":\"robot2\",\"bot_id\":\"bot_id2\",\"voice_id\":\"voice_id2\",\"description\":\"description2\"}]",
  "require_scheduler": false,
  "parameters": []
}
CLI 命令
svc_call AgentCoze GetRobotInfos

事件

CozeEventHappened

描述

Emitted when a Coze event occurs.

执行要求
  • 是否需要调度器: 需要

参数
  • CozeEvent

    • 类型: String

    • 描述: Coze event. Allowed values: [InsufficientCreditsBalance]

Schema JSON
展开查看 JSON

{
  "name": "CozeEventHappened",
  "description": "Emitted when a Coze event occurs.",
  "require_scheduler": true,
  "items": [
    {
      "name": "CozeEvent",
      "description": "Coze event. Allowed values: [InsufficientCreditsBalance]",
      "type": "String"
    }
  ]
}
CLI 命令
svc_subscribe AgentCoze CozeEventHappened