tt.createAgentManager
基础库 3.74.0 开始支持本方法,这是一个同步方法。
创建智能体管理器
前提条件 | 无 |
业务背景 | 无 |
使用限制 | 使用本能力前请前往 小程序智能体概述 查看接入指引,未接入的小程序无法使用本能力。 |
注意事项 | 无 |
支持沙盒 | 否 |
相关教程 | https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/tutorial/open-capabilities/ai-agent/ai-session-api-guide |
语法
tt.createAgentManager(options)
参数说明
options 类型说明
object 类型,属性如下:
属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|---|
agentId | string | 是 | 智能体ID | 3.74.0 | |
agentVersion | string | 是 | 智能体版本 | 3.74.0 | |
mode | enum | online | 否 | 运行模式 | 3.74.0 |
mode 的合法值
值 | 说明 | 最低支持版本 |
---|---|---|
online | 线上模式 | 3.74.0 |
preview | 预览模式 | 3.74.0 |
返回值
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
agentId | string | 智能体ID | 3.74.0 |
agentVersion | string | 智能体版本 | 3.74.0 |
mode | string | 运行模式 | 3.74.0 |
init | function | 初始化管理器 | 3.74.0 |
getAgentInfo | function | 获取智能体信息 | 3.74.0 |
getChatHistory | function | 获取历史记录 | 3.74.0 |
deleteMessage | function | 删除消息 | 3.74.0 |
createConversation | function | 开启新对话 | 3.74.0 |
onBoarding | function | 拉取开场白 | 3.74.0 |
sendMessage | function | 发送消息 | 3.74.0 |
错误码
errorCode | errMsg | errorType | 说明 | 最低支持版本 |
---|---|---|---|---|
182801 | internal server error | F | 小程序框架内部错误,有需要请创建工单咨询 | 3.74.0 |
182802 | invalid auth | D | 3.74.0 | |
182803 | invalid param | D | 3.74.0 | |
182804 | rate limit | D | 3.74.0 | |
182805 | invalid agent info | D | 3.74.0 | |
182806 | agent manager not initialized | D | 3.74.0 | |
182807 | conversation not initialized | D | 3.74.0 | |
182808 | query message is risky | U | 3.74.0 | |
182809 | answer message is risky | U | 3.74.0 | |
182810 | user cancel | U | 3.74.0 |
代码示例
创建智能体管理器
const agentManager = tt.createAgentManager({ agentId: 'ttbc02cabf230bd48016', agentVersion: '1.38.0', mode: 'preview', });