结构体
MessageReceipt
Kotlin
data class MessageReceipt(
val type: ModuleType,
val chatMessageType: ChatMessageType,
val turnId: Long,
val message: String
)
MessageReceipt
表示消息回执信息,支持通过 MediaInfo
处理多种媒体类型。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
type | ModuleType | 模块类型,详见 ModuleType ,例如 llm 、mllm 、tts 、context 。 |
chatMessageType | ChatMessageType | 消息错误类型。详见 ChatMessageType 。 |
turnId | Long | 消息的轮次 ID。 |
message | String | 消息内容信息。需要根据
|
ChatMessageType
Kotlin
enum class ChatMessageType(val value: String) {
Text("text"),
Image("picture"),
UNKNOWN("unknown");
companion object {
fun fromValue(value: String): ChatMessageType {
return ChatMessageType.entries.find { it.value == value } ?: UNKNOWN
}
}
}
用于区分会话系统中不同类型的消息。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
value | String | 用于匹配的字符串值。 |
MessageError
Kotlin
data class MessageError(
val chatMessageType: ChatMessageType,
val code: Int,
val message: String,
val timestamp: Long
)
用于处理和上报消息错误信息。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
chatMessageType | ChatMessageType | 消息错误类型。详见 ChatMessageType 。 |
code | Int | 用于识别特定错误情况的错误码。 |
message | String | 错误描述信息,提供详细错误解释,通常为包含资源信息的 JSON 字符串。 |
timestamp | Long | 事件发生的时间戳(自 1970 年 1 月 1 日 UTC 起的毫秒数)。 |
ChatMessage
Kotlin
sealed class ChatMessage
用于发送给智能体的所有消息类型的密封基类。
该密封类层级结构为不同内容类型的消息提供类型安全的处理方式。
Transcription
Kotlin
data class Transcription constructor(
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 。 |
ModuleError
Kotlin
data class ModuleError(
val type: ModuleType,
val code: Int,
val message: String,
val timestamp: Long,
val turnId: Long? = null
)
用于处理和上报 ModuleError
类型的智能体相关错误信息。
包含错误类型、错误码、错误描述和时间戳,便于实现错误监控、日志记录以及故障排查。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
type | ModuleType | 错误类型,例如:LLM 调用失败、TTS 异常等。详见 ModuleType 。 |
code | Int | 用于标识特定错误条件的错误码。 |
message | String | 提供详细错误说明的错误描述信息。 |
timestamp | Long | 错误发生的时间戳(从 1970 年 1 月 1 日 UTC 起的毫秒数)。 |
turnId | Long? | (可选)图片对应的 turnId ,用于图像上传错误。 |
ImageMessage
Kotlin
data class ImageMessage(
val uuid: String,
val imageUrl: String,
) : ChatMessage()
用于向智能体发送图像内容。
支持通过 HTTP/HTTPS 链接指定图像文件。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
uuid | String | 图像消息的唯一标识符。 |
imageUrl | String? | HTTP/HTTPS 图像文件链接。 |
StateChangeEvent
Kotlin
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
Kotlin
data class InterruptEvent(
val turnId: Long,
val timestamp: Long
)
InterruptEvent
表示中断事件。
通常在用户主动打断 AI 说话或系统检测到高优先级消息时触发,用于记录中断行为并进行相应处理。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
turnId | Long | 被中断的对话轮次 ID。 |
timestamp | Long | 中断事件发生的时间戳(自 1970 年 1 月 1 日 UTC 起的毫秒数)。 |
Metric
Kotlin
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 起经过的毫秒数)。 |
ConversationalAIAPIConfig
Kotlin
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
Kotlin
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 | 错误信息,返回具体的错误描述内容。 |