抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台
  • JS API 列表
  • 基础
  • TTML
  • 网络
  • 媒体
  • 地图
  • 文件
  • 数据缓存
  • 地理位置
  • 设备
  • 画布
  • 界面
  • 页面导航
  • 开放接口
  • 行业开放
  • 第三方平台
  • 其它
  • 生活服务(即将废弃)
  • 小程序智能体
  • tt.createAgentManager
  • AgentManager
  • 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 类型,属性如下:

    属性名类型默认值必填说明最低支持版本
    agentIdstring
    智能体ID
    3.74.0
    agentVersionstring
    智能体版本
    3.74.0
    modeenumonline
    运行模式
    3.74.0

    mode 的合法值

    说明最低支持版本
    online
    线上模式
    3.74.0
    preview
    预览模式
    3.74.0

    返回值

    属性名类型说明最低支持版本
    agentIdstring
    智能体ID
    3.74.0
    agentVersionstring
    智能体版本
    3.74.0
    modestring
    运行模式
    3.74.0
    initfunction
    初始化管理器
    3.74.0
    getAgentInfofunction
    获取智能体信息
    3.74.0
    getChatHistoryfunction
    获取历史记录
    3.74.0
    deleteMessagefunction
    删除消息
    3.74.0
    createConversationfunction
    开启新对话
    3.74.0
    onBoardingfunction
    拉取开场白
    3.74.0
    sendMessagefunction
    发送消息
    3.74.0

    错误码

    errorCodeerrMsgerrorType说明最低支持版本
    182801internal server errorF
    小程序框架内部错误,有需要请创建工单咨询
    3.74.0
    182802invalid authD
    3.74.0
    182803invalid paramD
    3.74.0
    182804rate limitD
    3.74.0
    182805invalid agent infoD
    3.74.0
    182806agent manager not initializedD
    3.74.0
    182807conversation not initializedD
    3.74.0
    182808query message is riskyU
    3.74.0
    182809answer message is riskyU
    3.74.0
    182810user cancelU
    3.74.0

    代码示例

    创建智能体管理器
    const agentManager = tt.createAgentManager({ agentId: 'ttbc02cabf230bd48016', agentVersion: '1.38.0', mode: 'preview', });