结构体
StateChangeEvent
Java
data class StateChangeEvent(
val state: AgentState,
val turnId: Long,
val timestamp: Long,
)
表示智能体状态变更事件。
用于跟踪会话流程和更新用户界面中的状态指示,包含事件发生的时间戳。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
state | AgentState | 当前智能体状态。包括:silent 、listening 、thinking 、speaking 。详见 AgentState 。 |
turnId | Long | 会话轮次 ID,用于标识特定的对话轮次。 |
timestamp | Long | 事件发生的时间戳(自 1970 年 1 月 1 日 UTC 起的毫秒数)。 |
InterruptEvent
Java
data class InterruptEvent(
val turnId: Long,
val timestamp: Long
)
InterruptEvent
表示中断事件。
通常在用户主动打断 AI 说话或系统检测到高优先级消息时触发,用于记录中断行为并进行相应处理。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
turnId | Long | 被中断的对话轮次 ID。 |
timestamp | Long | 中断事件发生的时间戳(自 1970 年 1 月 1 日 UTC 起的毫秒数)。 |
Metric
Java
data class Metric(
val type: ModuleType,
val name: String,
val value: Double,
val timestamp: Long
)
用于定义系统性能指标数据。
用于记录和传输系统性能数据。该数据可用于性能监控、系统优化和用户体验改进。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
type | ModuleType | 指标类型。详见 ModuleType 。 |
name | String | 指标名称,用于描述具体的性能项。 |
value | Double | 指标值,通常为延迟时间(毫秒)或其他量化指标。 |
timestamp | Long | 指标记录的时间戳(自 1970 年 1 月 1 日 UTC 起经过的毫秒数)。 |
ModuleError
Java
data class ModuleError(
val type: ModuleType,
val code: Int,
val message: String,
val timestamp: Long
)
用于处理和上报智能体相关错误信息。
包含错误类型、错误码和时间戳,便于实现错误监控、日志记录以及故障排查。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
type | ModuleType | 错误类型,例如:LLM 调用失败、TTS 异常等。详见 ModuleType 。 |
code | Int | 用于标识特定错误条件的错误码。 |
message | String | 提供详细错误说明的错误描述信息。 |
timestamp | Long | 错误发生的时间戳(从 1970 年 1 月 1 日 UTC 起的毫秒数)。 |
Transcription
Java
data class Transcription(
val turnId: Long,
val userId: String = "",
val text: String,
var status: TranscriptionStatus,
var type: TranscriptionType
)
Transcription
用于渲染 UI 的完整转录消息。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
turnId | Long | 会话轮次的唯一标识符。 |
userId | String | 与该转录关联的用户标识符。 |
text | String | 转录的实际文本内容。 |
status | TranscriptionStatus | 转录的当前状态。详见 TranscriptionStatus 。 |
type | TranscriptionType | 转录类型,例如 AGENT 或 USER。详见 TranscriptionType 。 |
ConversationalAIAPIConfig
Java
data class ConversationalAIAPIConfig(
val rtcEngine: RtcEngine,
val rtmClient: RtmClient,
val renderMode: TranscriptionRenderMode = TranscriptionRenderMode.Word,
val enableLog: Boolean = false
)
用于配置会话式 AI API 所需的参数。
该类包含初始化会话式 AI API 所需的参数配置,包括用于音频通信的 rtcEngine
、用于实时消息传递的 rtmClient
,以及转写渲染模式设置。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
rtcEngine | RtcEngine | 用于音视频通信的引擎实例。详见 RtcEngine 。 |
rtmClient | RtmClient | 用于实时消息通信的客户端实例。详见 RtmClient 。 |
renderMode | TranscriptionRenderMode | 转写渲染模式,默认为按词渲染。详见 TranscriptionRenderMode 。 |
enableLog | Boolean | 是否启用日志记录:
|
ConversationalAIAPIError
Java
sealed class ConversationalAIAPIError : Exception() {
data class RtmError(val code: Int, val msg: String) : ConversationalAIAPIError()
data class RtcError(val code: Int, val msg: String) : ConversationalAIAPIError()
data class UnknownError(val msg: String) : ConversationalAIAPIError()
val errorCode: Int
get() = when (this) {
is RtmError -> this.code
is RtcError -> this.code
is UnknownError -> -100
}
val errorMessage: String
get() = when (this) {
is RtmError -> this.msg
is RtcError -> this.msg
is UnknownError -> this.msg
}
}
表示会话式 AI API 中的错误类型。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
errorCode | Int | 错误码:
|
errorMessage | String | 错误信息,返回具体的错误描述内容。 |