结构体
Config
type Config struct {
AppID string
HttpTimeout time.Duration
Credential auth.Credential
DomainArea domain.Area
Logger log.Logger
ServiceRegion ServiceRegion
}
对话式 AI 引擎 REST Client 的配置。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
AppID | string | Agora 。 |
HttpTimeout | time.Duration | HTTP 请求的超时时间。 |
Credential | auth.Credential | 访问 Agora 服务的凭证。可用的凭证类型:BasicAuthCredential ,详见 NewBasicAuthCredential 。 |
DomainArea | domain.Area | REST Client 的域区域。详见 Area 。 |
Logger | log.Logger | REST Client 的日志记录器。可以在项目中实现 Logger 接口,将 REST Client 日志输出到你的日志组件。或者,可以使用默认的日志组件,详见 NewDefaultLogger 。 |
ServiceRegion | ServiceRegion | 服务版本。详见 ServiceRegion 。 |
BaseResponse
type BaseResponse struct {
RawResponse *http.Response
RawBody []byte
HttpStatusCode int
}
HTTP 响应的基础结构体。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
RawResponse | Response | HTTP 原始响应。 |
RawBody | byte | 原始响应体。 |
HttpStatusCode | int | HTTP 状态码。 |
JoinPropertiesAdvancedFeaturesBody
type JoinPropertiesAdvancedFeaturesBody struct {
EnableAIVad *bool `json:"enable_aivad,omitempty"`
EnableRtm *bool `json:"enable_rtm,omitempty"`
}
配置智能体加入 RTC 频道时的高级功能。
自 v0.7.0 版本新增。
包括是否启用优雅中断(AIVAD)和实时消息(RTM)模块。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
EnableAIVad | bool | (可选)是否启用优雅中断(AIVAD)。
|
EnableRtm | bool | (可选)是否启用实时消息(RTM)模块。
|
TTSMinimaxVendorParams
type TTSMinimaxVendorParams struct {
GroupId string `json:"group_id"`
Key string `json:"key"`
Model string `json:"model"`
VoiceSetting TTSMinimaxVendorVoiceSettingParam `json:"voice_setting"`
AudioSetting TTSMinimaxVendorAudioSettingParam `json:"audio_setting"`
}
智能体加入 RTC 频道时的 Minimax 语音合成模块供应商参数。
自 v0.7.0 版本新增。
详见 https://platform.minimaxi.com/document/T2A%20V2。
TTSTencentVendorParams
type TTSTencentVendorParams struct {
AppId string `json:"app_id"`
SecretId string `json:"secret_id"`
SecretKey string `json:"secret_key"`
VoiceType int `json:"voice_type"`
Volume int `json:"volume"`
Speed int `json:"speed"`
EmotionCategory string `json:"emotion_category"`
EmotionIntensity int `json:"emotion_intensity"`
}
智能体加入 RTC 频道时的腾讯 TTS 模块参数。
自 v0.7.0 版本新增。
详见 https://cloud.tencent.com/document/product/1073/94308。
TTSBytedanceVendorParams
type TTSBytedanceVendorParams struct {
Token string `json:"token"`
AppId string `json:"app_id"`
Cluster string `json:"cluster"`
VoiceType string `json:"voice_type"`
SpeedRatio float32 `json:"speed_ratio"`
VolumeRatio float32 `json:"volume_ratio"`
PitchRatio float32 `json:"pitch_ratio"`
Emotion string `json:"emotion"`
}
智能体加入 RTC 频道时的 Bytedance 供应商参数。
自 v0.7.0 版本新增。
详见 https://www.volcengine.com/docs/6561/79823。
JoinPropertiesTTSBody
type JoinPropertiesTTSBody struct {
Vendor TTSVendor `json:"vendor"`
Params TTSVendorParamsInterface `json:"params"`
}
配置智能体加入 Stream 频道的文本转语音 (TTS) 模块。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Vendor | TTSVendor | TTS 供应商,详见 TTSVendor 。 |
Params | TTSVendorParamsInterface | TTS 供应商参数描述,详见 TTSMinimaxVendorParams 、TTSTencentVendorParams 、TTSBytedanceVendorParams 。 |
JoinPropertiesCustomLLMBody
type JoinPropertiesCustomLLMBody struct {
Url string `json:"url"`
APIKey string `json:"api_key"`
SystemMessages []map[string]any `json:"system_messages"`
Params map[string]any `json:"params"`
MaxHistory *int `json:"max_history,omitempty"`
GreetingMessage string `json:"greeting_message,omitempty"`
InputModalities []string `json:"input_modalities,omitempty"`
OutputModalities []string `json:"output_modalities,omitempty"`
FailureMessage string `json:"failure_message,omitempty"`
}
配置智能体加入 RTC 频道时的自定义语言模型 (LLM) 设置。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Url | string | (必填)LLM 回调 URL。必须与 OpenAI 协议兼容。 |
APIKey | string | (必填)用于验证的 LLM API 密钥。默认值为空,请确保在生产环境中启用 API 密钥。 |
SystemMessages | []map[string]any | (可选)在每次 LLM 调用开始时附加的一组预定义信息以控制 LLM 输出。可以是角色设置、提示和答案示例,必须与 OpenAI 协议兼容。 |
Params | map[string]any | (可选)在 LLM 消息体中传输的附加信息,例如使用的模型、最大 token 限制等。不同的 LLM 供应商支持不同的配置,详见各自的 LLM 文档。 |
MaxHistory | *int | (可选)LLM 中缓存的短期记忆条目数。默认值为 10。传递 0 表示不缓存短期记忆。智能体和订阅用户将分别记录条目。 |
GreetingMessage | string | (可选)智能体问候消息。如果填写,当 remote_rtc_uids 列表中没有用户时,智能体将自动向第一个加入频道的订阅用户发送问候消息。 |
InputModalities | []string | (可选)LLM 的输入模式。
|
OutputModalities | []string | (可选)LLM 的输出模式。
|
FailureMessage | string | (可选)智能体的失败消息。如果填写,当 LLM 调用失败时,将通过 TTS 模块返回。 |
JoinPropertiesVadBody
type JoinPropertiesVadBody struct {
InterruptDurationMs *int `json:"interrupt_duration_ms,omitempty"`
PrefixPaddingMs *int `json:"prefix_padding_ms,omitempty"`
SilenceDurationMs *int `json:"silence_duration_ms,omitempty"`
Threshold *float64 `json:"threshold,omitempty"`
}
智能体加入 RTC 频道的语音活动检测 (VAD) 配置。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
InterruptDurationMs | int | (可选)人声持续时间阈值(毫秒),范围是 注意 检测到的人声信号的最短持续时间,以避免错误中断。 |
PrefixPaddingMs | int | (可选)前缀填充阈值(毫秒),范围是 注意 开始新的语音段所需的连续语音的最短持续时间,避免非常短的声音触发语音活动检测。 |
SilenceDurationMs | int | (可选)静音持续时间阈值(毫秒),范围是 注意 确保在语音结束时的短暂停顿不会过早结束语音段的最短静音持续时间。 |
Threshold | float64 | (可选)语音识别灵敏度,范围是 (0.0,1.0)。 注意 决定音频信号被视为“语音活动”的程度。较低的值使智能体更容易检测到语音,较高的值可能会忽略微弱的声音。 |
JoinPropertiesAsrBody
type JoinPropertiesAsrBody struct {
Language string `json:"language,omitempty"`
}
智能体加入 Stream 频道的自动语音识别 (ASR) 配置。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Language | string | (可选)用户与智能体之间交互使用的语言。
|
JoinPropertiesReqBody
type JoinPropertiesReqBody struct {
Token string `json:"token"`
Channel string `json:"channel"`
AgentRtcUId string `json:"agent_rtc_uid"`
RemoteRtcUIds []string `json:"remote_rtc_uids"`
EnableStringUId *bool `json:"enable_string_uid,omitempty"`
IdleTimeout *int `json:"idle_timeout,omitempty"`
AgentRtmUId *string `json:"agent_rtm_uid,omitempty"`
AdvancedFeatures *JoinPropertiesAdvancedFeaturesBody `json:"advanced_features,omitempty"`
LLM *JoinPropertiesCustomLLMBody `json:"llm,omitempty"`
TTS *JoinPropertiesTTSBody `json:"tts,omitempty"`
Vad *JoinPropertiesVadBody `json:"vad,omitempty"`
Asr *JoinPropertiesAsrBody `json:"asr,omitempty"`
}
调用对话式智能体引擎 Join
API 的请求体。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Token | string | 用于加入 RTC 频道的 Token,即用于认证的动态密钥(可选)。如果项目启用了 App Certificate,请务必在此字段传入项目的动态密钥。 |
Channel | string | 智能体加入的 RTC 频道名称(必填)。 |
AgentRtcUId | string | 智能体在 RTC 频道中的用户 ID(必填)。填入 "0" 表示随机分配,但需要相应修改 Token。 |
RemoteRtcUIds | []string | 智能体在 RTC 频道中订阅的用户 ID 列表,仅订阅的用户可以与智能体互动(必填)。传入 "*" 表示订阅频道中的所有用户。 |
EnableStringUId | *bool | (可选)是否启用字符串 UID。
|
IdleTimeout | *int | (可选)RTC 频道的最大空闲时间(秒)。检测到 remote_rtc_uids 中指定的所有用户离开频道后的时间视为空闲时间。如果超过设定的最大值,频道中的智能体将自动停止并退出频道。如果设置为 0,智能体将不会停止,直到手动退出。 |
AgentRtmUId | *string | RTM 频道中的智能体用户 ID。仅当 advanced_features.enable_rtm 为 true 时有效。 |
AdvancedFeatures | *JoinPropertiesAdvancedFeaturesBody | (可选)高级功能配置,详见 JoinPropertiesAdvancedFeaturesBody 。 |
LLM | *JoinPropertiesCustomLLMBody | (必填)自定义语言模型(LLM)配置,详见 JoinPropertiesCustomLLMBody 。 |
TTS | *JoinPropertiesTTSBody | (必填)文本转语音(TTS)模块配置,详见 JoinPropertiesTTSBody 。 |
Vad | *JoinPropertiesVadBody | (可选)语音活动检测(VAD)配置,详见 JoinPropertiesVadBody 。 |
Asr | *JoinPropertiesAsrBody | (可选)自动语音识别(ASR)配置,详见 JoinPropertiesAsrBody 。 |
UpdateReqBody
type UpdateReqBody struct {
Token string `json:"token"`
}
调用对话式智能体引擎 Update
API 的请求体。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Token | string | 用于身份验证的动态密钥(Token)。如果你的项目启用了 App Certificate,必须在此字段中传递项目的动态密钥。 |
ErrResponse
type ErrResponse struct {
Detail string `json:"detail"`
Reason string `json:"reason"`
}
调用对话式 AI 引擎 API 返回的错误响应。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Detail | string | 错误详情。 |
Reason | string | 错误原因。 |
Response
type Response struct {
*agora.BaseResponse
ErrResponse ErrResponse
}
调用对话式 AI 引擎 API 返回的响应。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
BaseResponse | BaseResponse | HTTP 基础响应,详见 BaseResponse 。 |
ErrResponse | ErrResponse | 错误响应,详见 ErrResponse 。 |
JoinSuccessResp
type JoinSuccessResp struct {
AgentId string `json:"agent_id"`
CreateTs int `json:"create_ts"`
Status string `json:"status"`
}
调用 Join
API 返回的成功响应。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
AgentId | string | 智能体的唯一标识符。 |
CreateTs | int | 智能体创建时的时间戳。 |
Status | string | 智能体的运行状态。
|
JoinResp
type JoinResp struct {
Response
SuccessResp JoinSuccessResp
}
调用 Join
API 返回的响应。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Response | Response | 对话式 AI 引擎 API 返回的响应,详见 Response 。 |
SuccessResp | JoinSuccessResp | 成功的响应,详见 JoinSuccessResp 。 |
LeaveResp
type LeaveResp struct {
Response
}
调用 Leave
API 返回的响应。
自 v0.7.0 版本新增。
详见 Response
。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Response | Response | 对话式 AI 引擎 API 返回的响应,详见 Response 。 |
ListSuccessResp
type ListSuccessResp struct {
Data struct {
Count int `json:"count"`
List []struct {
StartTs int64 `json:"start_ts"`
Status string `json:"status"`
AgentId string `json:"agent_id"`
} `json:"list"`
}
}
调用 List
API 返回的成功响应。
自 v0.7.0 版本新增。
包含智能体数据的信息。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Data | struct | 智能体数据的信息。 |
Count | int | 本次返回的智能体数量。 |
List | []struct | 符合条件的智能体列表。 |
StartTs | int64 | 智能体创建的时间戳。 |
Status | string | 智能体的运行状态。 注意
|
AgentId | string | 智能体的唯一标识符。 |
Data
type Data struct {
Meta struct {
Cursor string `json:"cursor"`
Total int `json:"total"`
} `json:"meta"`
Status string `json:"status"`
}
调用 API 返回的响应,包含元数据和请求状态。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Meta | struct | 返回列表的元数据。 |
Cursor | string | 分页游标。 |
Total | int | 符合查询条件的智能体总数。 |
Status | string | 请求状态。 |
ListResp
type ListResp struct {
Response
SuccessRes ListSuccessResp
}
ListResp
由对话式 AI 引擎的 List
API 返回。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Response | Response | 对话式 AI 引擎 API 返回的响应,详见 Response 。 |
SuccessRes | ListSuccessResp | 成功的响应,详见 ListSuccessResp 。 |
QuerySuccessResp
type QuerySuccessResp struct {
Message string `json:"message"`
StartTs int64 `json:"start_ts"`
StopTs int64 `json:"stop_ts"`
AgentId string `json:"agent_id"`
Status string `json:"status"`
}
调用 Query
API 返回的成功响应。
自 v0.7.0 版本新增。
包含请求信息、智能体的创建和停止时间戳、智能体的唯一标识符以及智能体的运行状态。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Message | string | 请求信息。 |
StartTs | int64 | 智能体的创建时间戳。 |
StopTs | int64 | 智能体的停止时间戳。 |
AgentId | string | 智能体的唯一标识符。 |
Status | string | 智能体的运行状态。
|
QueryResp
type QueryResp struct {
Response
SuccessRes QuerySuccessResp
}
QueryResp
是对话式 AI 引擎 Query
API 返回的响应。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Response | Response | 对话式 AI 引擎 API 返回的响应,详见 Response 。 |
SuccessRes | QuerySuccessResp | 成功响应,详见 QuerySuccessResp 。 |
UpdateSuccessResp
type UpdateSuccessResp struct {
AgentId string `json:"agent_id"`
CreateTs int `json:"create_ts"`
State string `json:"state"`
}
调用 Update
API 返回的成功响应。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
AgentId | string | 智能体的唯一标识符。 |
CreateTs | int | 智能体创建时的时间戳。 |
State | string | 智能体的运行状态。
|
UpdateResp
type UpdateResp struct {
Response
SuccessResp UpdateSuccessResp
}
调用 Update
API 返回的响应。
自 v0.7.0 版本新增。
成员参数
参数 | 数据类型 | 描述 |
---|---|---|
Response | Response | 对话式 AI 引擎 API 返回的响应,详见 Response 。 |
SuccessResp | UpdateSuccessResp | 成功响应,详见 UpdateSuccessResp 。 |