openapi: 3.0.3
info:
  title: AI Agent 接入
  description: >-
    ### 功能介绍 

    无论你是否有编程基础，都可以在云后台上快速搭建基于 AI 模型的各类问答 Agent。而且你还可以将搭建的 Agent 发布到小程序客服、服务号、公众号、微信客服，让更多的用户与你搭建的 Agent 聊天。
      我们已经将 AI Agent 发布为 API 服务，你可以通过 HTTP 访问方式与 Agent 进行交互。

    该系列开放 API 提供了统一对接 AI Agent 的能力，只需在云开发环境中配置所需 Agent 的 token，即可快速接入 Agent。该系列接对话接口支持 [SSE](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) 格式响应。

    ### 接入指引

    调用以下接口需要传递 AccessToken，格式如`Authorization: Bearer <token>`。Token 获取方式参考： [获取token](https://docs.cloudbase.net/http-api/basic/access-token)

    ### HTTP 状态码

    根据返回结果的不同，可能会出现 `2xx`, `4xx`, `5xx` 状态码。Agent 在 200 状态码中通过响应体指示错误，应当视情况处理。

    ### 错误码

    以下列出了该系列 API 特定的错误码

    <table>
      <thead>
      <tr>
        <td>错误码</td>
        <td>含义</td>
      </tr>
      </thead>
      <tr>
        <td>AGENT_INVALID_PARAM</td>
        <td>调用 Agent 参数不合法</td>
      </tr>
      <tr>
        <td>AGENT_GET_INFO_ERROR</td>
        <td>查询 Agent 信息失败</td>
      </tr>
      <tr>
        <td>AGENT_REQUEST_LLM_ERROR</td>
        <td>Agent 调用大模型异常</td>
      </tr>
      <tr>
        <td>AGENT_REQUEST_KNOWLEDGE_ERROR</td>
        <td>Agent 查询知识库异常</td>
      </tr>
      <tr>
        <td>AGENT_SERVER_ERR</td>
        <td>Agent 系统异常</td>
      </tr>
    </table>
  version: 1.0.0
servers:
  - url: https://{envId}.api.tcloudbasegateway.com
    description: TCB openapi endpoint
    variables:
      envId:
        default: "env-xxxx"
        description: 环境 ID
paths:
  /v1/aibot/bots:
    get:
      summary: "查询 Agent 列表信息"
      operationId: getBotList
      security:
        - JWTAuth: []
      parameters:
        - name: name
          required: false
          in: query
          description: Agent 名称 模糊查询
          example: 名称
          schema:
            type: string
        - name: introduction
          required: false
          in: query
          description: Agent 简介 模糊查询
          example: 简介
          schema:
            type: string
        - name: information
          required: false
          in: query
          description: Agent 信息模糊查询 查询名称和简介
          example: 信息
          schema:
            type: string
        - name: enable
          required: false
          in: query
          description: Agent 是否启用
          example: true
          schema:
            type: boolean
        - name: pageSize
          required: false
          in: query
          description: 分页查询参数，默认为 10
          example: 10
          schema:
            type: number
        - name: pageNumber
          required: false
          in: query
          description: 分页查询参数，默认为 1
          example: 1
          schema:
            type: number
      responses:
        "200":
          description: 查询 AI Agent 成功时返回
          headers:
            X-Request-Id:
              schema:
                type: string
              description: "请求ID"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetBotListRsp"
        "default":
          description: 查询 AI Agent 失败时返回
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrRsp"
      tags:
        - AI Agent
    # post:
    #   summary: "创建 Agent "
    #   operationId: createBot
    #   security:
    #     - JWTAuth: []
    #   parameters: []
    #   requestBody:
    #     required: true
    #     content:
    #       application/json:
    #         schema:
    #           $ref: "#/components/schemas/BotInfo"
    #   responses:
    #     "201":
    #       description: 创建 AI Agent 成功时返回
    #       headers:
    #         X-Request-Id:
    #           schema:
    #             type: string
    #           description: "请求ID"
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/CreateBotRsp"
    #     "default":
    #       description: 创建 AI Agent 失败时返回
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/ErrRsp"
    #   tags:
    #     - AI Agent
  /v1/aibot/bots/{botId}:
    get:
      summary: "查询 Agent 信息"
      operationId: getBotInfo
      security:
        - JWTAuth: []
      parameters:
        - name: botId
          required: true
          in: path
          schema:
            type: string
      responses:
        "200":
          description: 查询 AI Agent 成功时返回
          headers:
            X-Request-Id:
              schema:
                type: string
              description: "请求ID"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BotInfo"
        "default":
          description: 查询 AI Agent 失败时返回
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrRsp"

      tags:
        - AI Agent
    # patch:
    #   summary: "更新 Agent 信息"
    #   operationId: updateBot
    #   security:
    #     - JWTAuth: []
    #   parameters:
    #     - name: botId
    #       required: true
    #       in: path
    #       schema:
    #         type: string
    #   requestBody:
    #     required: true
    #     content:
    #       application/json:
    #         schema:
    #           $ref: "#/components/schemas/BotInfo"
    #   responses:
    #     "200":
    #       description: 更新 AI Agent 成功时返回
    #       headers:
    #         X-Request-Id:
    #           schema:
    #             type: string
    #           description: "请求ID"
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/UpdateBotRsp"
    #     "default":
    #       description: 更新 AI Agent 失败时返回
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/ErrRsp"
    #   tags:
    #     - AI Agent
    # delete:
    #   summary: "删除 Agent "
    #   operationId: removeBot
    #   security:
    #     - JWTAuth: []
    #   parameters:
    #     - name: botId
    #       required: true
    #       in: path
    #       schema:
    #         type: string
    #   responses:
    #     "200":
    #       description: 删除 AI Agent 成功时返回
    #       headers:
    #         X-Request-Id:
    #           schema:
    #             type: string
    #           description: "请求ID"
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/DeleteBotRsp"
    #     "default":
    #       description: 删除 AI Agent 失败时返回
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/ErrRsp"
    #   tags:
    #     - AI Agent
  /v1/aibot/bots/{botId}/records:
    get:
      summary: "查询 Agent 历史对话信息"
      operationId: getChatHistory
      security:
        - JWTAuth: []
      parameters:
        - name: botId
          required: true
          in: path
          description: Agent ID
          example: bot-xxx
          schema:
            type: string
        - name: sort
          required: true
          in: query
          description: 按照创建时间查询顺序 正序:asc 倒序:desc
          example: desc
          schema:
            type: string
        - name: pageSize
          in: query
          description: 分页参数, 默认为10
          example: 10
          schema:
            type: number
        - name: pageNumber
          in: query
          description: 分页参数，默认为1
          example: 1
          schema:
            type: number
      responses:
        "200":
          description: 查询聊天记录成功时返回
          headers:
            X-Request-Id:
              schema:
                type: string
              description: "请求ID"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetChatHistoryRsp"
        "default":
          description: 查询聊天记录失败时返回
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrRsp"
      tags:
        - AI Agent
  # /v1/aibot/bots/{botId}/feedback:
    # post:
    #   summary: "用户反馈"
    #   operationId: userFeedback
    #   security:
    #     - JWTAuth: []
    #   parameters:
    #     - name: botId
    #       required: true
    #       in: path
    #       description: Agent ID
    #       example: bot-xxx
    #       schema:
    #         type: string
    #   requestBody:
    #     required: true
    #     content:
    #       application/json:
    #         schema:
    #           $ref: "#/components/schemas/UserFeedbackDto"
    #   responses:
    #     "201":
    #       description: 反馈成功时返回
    #       headers:
    #         X-Request-Id:
    #           schema:
    #             type: string
    #           description: "请求ID"
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/UserFeedbackRsp"
    #     "default":
    #       description: 反馈失败时返回
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/ErrRsp"
    #   tags:
    #     - AI Agent
    # get:
    #   summary: "查询用户反馈"
    #   operationId: getFeedback
    #   security:
    #     - JWTAuth: []
    #   parameters:
    #     - name: botId
    #       required: true
    #       in: path
    #       description: Agent ID
    #       example: bot-xxx
    #       schema:
    #         type: string
    #     - name: type
    #       in: query
    #       description: 用户反馈类型，点赞 upvote 点踩 downvote
    #       example: upvote
    #       schema:
    #         type: string
    #     - name: sender
    #       in: query
    #       description: 评论创建用户
    #       example: user-xx
    #       schema:
    #         type: string
    #     - name: senderFilter
    #       in: query
    #       description: 评论创建用户过滤关系 include:包含 exclude:不包含 equal:等于 unequal:不等于 prefix:前缀
    #       example: contains
    #       schema:
    #         type: string
    #     - name: minRating
    #       in: query
    #       description: 最高评分
    #       example: "5"
    #       schema:
    #         type: number
    #     - name: maxRating
    #       in: query
    #       description: 最低评分
    #       example: "1"
    #       schema:
    #         type: number
    #     - name: from
    #       in: query
    #       description: 开始时间戳
    #       example: "1721475455"
    #       schema:
    #         type: number
    #     - name: to
    #       in: query
    #       description: 结束时间戳
    #       example: "1721475456"
    #       schema:
    #         type: number
    #     - name: pageSize
    #       in: query
    #       description: 分页参数，默认为10
    #       example: 10
    #       schema:
    #         type: number
    #     - name: pageNumber
    #       in: query
    #       description: 分页参数，默认为1
    #       example: 1
    #       schema:
    #         type: number
    #   responses:
    #     "200":
    #       description: 查询反馈成功时返回
    #       headers:
    #         X-Request-Id:
    #           schema:
    #             type: string
    #           description: "请求ID"
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/GetUserFeedbackRsp"
    #     "default":
    #       description: 查询反馈失败时返回
    #       content:
    #         application/json:
    #           schema:
    #             $ref: "#/components/schemas/ErrRsp"
    #   tags:
    #     - AI Agent
  /v1/aibot/bots/{botId}/speech-to-text:
    post:
      operationId: speechToText
      summary: 语音转文字
      parameters:
        - name: botId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SpeechToTextDto"
      responses:
        "201":
          description: ""
          content:
            application/json:
              schema:
                type: object
      tags:
        - AI Agent
  /v1/aibot/bots/{botId}/text-to-speech:
    post:
      operationId: textToSpeech
      summary: 文字转语音
      parameters:
        - name: botId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TextToSpeechDto"
      responses:
        "201":
          description: ""
          content:
            application/json:
              schema:
                type: object
      tags:
        - AI Agent
    get:
      operationId: getTextToSpeechResult
      summary: 文字转语音结果轮询
      parameters:
        - name: botId
          required: true
          in: path
          schema:
            type: string
        - name: taskId
          required: true
          in: query
          description: 任务id
          example: gz-5faa7bc8-6e78-46b9-90ea-5ebba32aa04c
          schema:
            type: string
        # - name: isPreview
        #   required: false
        #   in: query
        #   description: 是否为预览模式
        #   schema:
        #     default: false
        #     type: boolean
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: object
      tags:
        - AI Agent
  /v1/aibot/bots/{botId}/conversation:
    post:
      operationId: createConversation
      summary: 创建会话
      parameters:
        - name: botId
          required: true
          in: path
          schema:
            type: string
      responses:
        "201":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ConversationEntity"
      tags:
        - AI Agent
    get:
      operationId: getConversation
      summary: 查询会话列表
      parameters:
        - name: botId
          required: true
          in: path
          schema:
            type: string
        - name: limit
          required: false
          in: query
          description: 每页记录数
          example: 10
          schema:
            minimum: 0
            maximum: 100
            default: 10
            type: number
        - name: offset
          required: false
          in: query
          description: 偏移量
          example: 0
          schema:
            minimum: 0
            default: 0
            type: number
        - name: isDefault
          required: false
          in: query
          description: 是否查询默认会话
          schema:
            default: false
            type: boolean
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetConversationRsp"
      tags:
        - AI Agent
  /v1/aibot/bots/{botId}/recommend-questions:
    post:
      summary: "获取推荐问题"
      operationId: getRecommendQuestions
      security:
        - JWTAuth: []
      parameters:
        - name: botId
          required: true
          in: path
          description: Agent ID
          example: bot-xxx
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GetRecommendQuestionsDto"
      responses:
        "200":
          description: 获取推荐问题成功时返回, 返回格式为 SSE 格式
          headers:
            X-Request-Id:
              schema:
                type: string
              description: "请求ID"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SSERsp"
        "default":
          description: 获取推荐问题失败时返回
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrRsp"
      tags:
        - AI Agent
  # /v1/aibot/generate-bot:
  #   post:
  #     summary: "获取生成 Agent 文案"
  #     operationId: generateBot
  #     security:
  #       - JWTAuth: []
  #     parameters: []
  #     requestBody:
  #       required: true
  #       content:
  #         application/json:
  #           schema:
  #             $ref: "#/components/schemas/GenerateBotDto"
  #     responses:
  #       "200":
  #         description: 生成 Agent 信息成功时返回, 返回格式为 SSE 格式
  #         headers:
  #           X-Request-Id:
  #             schema:
  #               type: string
  #             description: "请求ID"
  #         content:
  #           application/json:
  #             schema:
  #               $ref: "#/components/schemas/SSERsp"
  #       "default":
  #         description: 生成 Agent 信息失败时返回
  #         content:
  #           application/json:
  #             schema:
  #               $ref: "#/components/schemas/ErrRsp"
  #     tags:
  #       - AI Agent
  # /v1/aibot/preview:
  #   post:
  #     summary: "预览 Agent 问答对话"
  #     operationId: preview
  #     security:
  #       - JWTAuth: []
  #     parameters: []
  #     requestBody:
  #       required: true
  #       content:
  #         application/json:
  #           schema:
  #             $ref: "#/components/schemas/PreviewBotDto"
  #     responses:
  #       "200":
  #         description: 预览 Agent , 返回格式为 SSE 格式
  #         headers:
  #           X-Request-Id:
  #             schema:
  #               type: string
  #             description: "请求ID"
  #         content:
  #           application/json:
  #             schema:
  #               $ref: "#/components/schemas/SSERsp"
  #       "default":
  #         description: 预览 Agent 失败时返回
  #         content:
  #           application/json:
  #             schema:
  #               $ref: "#/components/schemas/ErrRsp"
  #     tags:
  #       - AI Agent
  # /v1/aibot/generate-image:
  #   post:
  #     summary: "生成图片"
  #     operationId: generateImage
  #     security:
  #       - JWTAuth: []
  #     parameters: []
  #     requestBody:
  #       required: true
  #       content:
  #         application/json:
  #           schema:
  #             $ref: "#/components/schemas/GenerateImageDto"
  #     responses:
  #       "200":
  #         description: 生成图片成功时返回, 返回格式为 SSE 格式
  #         headers:
  #           X-Request-Id:
  #             schema:
  #               type: string
  #             description: "请求ID"
  #         content:
  #           application/json:
  #             schema:
  #               $ref: "#/components/schemas/GenerateImageRsp"
  #       "default":
  #         description: 生成图片失败时返回
  #         content:
  #           application/json:
  #             schema:
  #               $ref: "#/components/schemas/ErrRsp"
  #     tags:
  #       - AI Agent
  /v1/aibot/bots/{botId}/send-message:
    post:
      summary: "进行 Agent 问答对话"
      operationId: sendMessage
      security:
        - JWTAuth: []
      parameters:
        - name: botId
          required: true
          in: path
          description: Agent ID
          example: bot-xxx
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TcbSendMessageDto"
      responses:
        "200":
          description: Agent 对话成功时返回, 返回格式为 SSE 格式
          headers:
            X-Request-Id:
              schema:
                type: string
              description: "请求ID"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SSERsp"
        "default":
          description: Agent 对话失败时返回
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrRsp"
      tags:
        - AI Agent
  /v1/aibot/openai/chat/completions:
    post:
      summary: "进行 Agent 问答对话（OpenAI 协议）"
      operationId: openai-api
      security:
        - JWTAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OpenAIChatDto"
      responses:
        "x-stream:false":
          description: Agent 对话成功时，非流失返回
          headers:
            X-Request-Id:
              schema:
                type: string
              description: "请求ID"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OpenAINotStreamRsp"
        "x-stream:true":
          description: Agent 对话成功时，流失返回
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OpenAIStreamRsp"
        "default":
          description: Agent 对话失败时返回
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrRsp"
      tags:
        - AI Agent
components:
  securitySchemes:
    JWTAuth:
      type: http
      scheme: Bearer
      description: 环境 ID 所对应的 token，使用登录认证(v2)获取
  schemas:
    BotInfo:
      type: object
      properties:
        botId:
          type: string
          description: Agent ID，由系统生成
          example: bot-xxx
        name:
          type: string
          description: Agent 名称
          example: 智能体
        introduction:
          type: string
          description: Agent 简介
          example: 简介
        # agentSetting:
        #   type: string
        #   description: Agent 设定
        #   example: 这是一个智能体
        welcomeMessage:
          type: string
          description: Agent 欢迎语
          example: 欢迎欢迎
        avatar:
          type: string
          description: Agent 头像链接
          example: http://xxx.avatar.image
        background:
          type: string
          description: Agent 聊天背景图链接
          example: http://xxx.background.image
        isNeedRecommend:
          type: boolean
          description: Agent 回答后是否推荐问题
          example: false
        # knowledgeBase:
        #   description: 知识库
        #   example:
        #     - ""
        #   type: array
        #   items:
        #     type: string
        # tags:
        #   description: 标签
        #   example:
        #     - ""
        #   type: array
        #   items:
        #     type: string
        type:
          type: string
          description: Agent 类型, text 或者 image
          example: text
        searchEnable:
          type: boolean
          description: 是否开启联网搜索
          example: false
        # initQuestions:
        #   description: Agent 预置的推荐问题
        #   example:
        #     - 请问有什么可以帮你的嘛？
        #   type: array
        #   items:
        #     type: string
        # enable:
        #   type: boolean
        #   description: 是否启用 Agent
        #   example: true
        # model:
        #   type: string
        #   description: Agent 厂商
        #   example: "hunyuan-beta"
        # modelValue:
        #   type: string
        #   description: Agent 模型
        #   example: "hunyuan-beta"
      required:
        - name
        - introduction
        - agentSetting
    UserFeedbackDto:
      type: object
      properties:
        recordId:
          type: string
          description: 对话记录 ID
          example: record-xxx
        type:
          type: string
          description: 用户反馈类型，点赞 upvote 点踩 downvote
          example: upvote
        botId:
          type: string
          description: Agent ID
          example: bot-xxx
        comment:
          type: string
          description: 用户评论
          example: 回复的好
        rating:
          type: number
          description: 用户评分
          example: 5
        tags:
          description: 用户反馈的标签数组
          example:
            - 回复贴切
          type: array
          items:
            type: string
        input:
          type: string
          description: 用户输入的问题
          example: 你是谁
        aiAnswer:
          type: string
          description: Agent 的回答
          example: 我是一个智能体
      required:
        - recordId
        - type
        - botId
    HistoryMsg:
      type: object
      properties:
        role:
          type: string
          description: 历史信息角色
          example: user
        content:
          type: string
          description: 历史信息内容
          example: 这是一条对话信息
      required:
        - role
        - content
    GetRecommendQuestionsDto:
      type: object
      properties:
        name:
          type: string
          description: Agent 名称
          example: 智能体
        introduction:
          type: string
          description: Agent 简介
          example: 智能体简介
        agentSetting:
          type: string
          description: Agent 设定
          example: 智能体设定
        msg:
          type: string
          description: 用户消息内容
          example: 你好
        history:
          description: 历史对话信息
          type: array
          items:
            $ref: "#/components/schemas/HistoryMsg"
    GenerateBotDto:
      type: object
      properties:
        simple:
          type: boolean
          description: 是否只生成功能描述, 默认为 true
          example: true
        prompt:
          type: string
          description: Agent 描述
          example: 描述
      required:
        - prompt
    # PreviewBotDto:
    #   type: object
    #   properties:
    #     name:
    #       type: string
    #       description: Agent 名称
    #       example: 智能体
    #     introduction:
    #       type: string
    #       description: Agent 简介
    #       example: 智能体简介
    #     agentSetting:
    #       type: string
    #       description: Agent 设定
    #       example: 智能体设定
    #     msg:
    #       type: string
    #       description: 用户发送信息
    #       example: 你好
    #     history:
    #       description: 历史对话信息
    #       type: array
    #       items:
    #         $ref: "#/components/schemas/HistoryMsg"
    #     searchEnable:
    #       type: boolean
    #       description: 是否启用联网查询,当且仅当 Agent 配置的 searchEnable 与本字段都为 true 时，才开启联网搜索
    #       example: true
    #     knowledgeBase:
    #       description: 知识库
    #       type: array
    #       items:
    #         type: string
    #     files:
    #       type: array
    #       description: 文件相关对话所需字段，可以传如云存储的路径 cloud://xxx.xxx 或者 公网可以访问的链接 https://xxxx.xxxx
    #       items:
    #         type: string
    #       example: ["cloud://xxx.xxxx"]
    #   required:
    #     - name
    #     - introduction
    #     - agentSetting
    GenerateImageDto:
      type: object
      properties:
        prompt:
          type: string
          description: 生成图片的描述
          example: 描述
      required:
        - prompt
    TcbSendMessageDto:
      type: object
      properties:
        msg:
          type: string
          description: 用户发送信息
          example: 你好
        history:
          description: 历史对话信息
          type: array
          items:
            $ref: "#/components/schemas/HistoryMsg"
        searchEnable:
          type: boolean
          description: 是否启用联网查询,当且仅当 Agent 配置的 searchEnable 与本字段都为 true 时，才开启联网搜索
          example: true
        files:
          type: array
          description: 文件相关对话所需字段，可以将文件上传到[云存储](https://docs.cloudbase.net/http-api/storage/get-objects-upload-info)中，使用文件的云存储链接 cloud://xxx.xxx 或者使用可访问的文件公网链接 https://xxxx.xxxx
          items:
            type: string
          example: ["cloud://xxx.xxxx"]
        conversationId:
          type: string
          description: 会话ID, 开启多会话功能之后生效，标记本次对话所属的会话，可以从 conversation 相关接口中获取 ID
          example: "conversation-xxx"
      required:
        - msg
    OpenAIChatDto:
      type: object
      properties:
        model:
          type: string
          description: Agent ID
          example: bot-xxxxx
        messages:
          description: 消息
          type: array
          items:
            $ref: "#/components/schemas/HistoryMsg"
        stream:
          type: boolean
          description: 是否流式返回
          example: false
      required:
        - model
        - messages
        - stream
    GetBotListRsp:
      type: object
      properties:
        botList:
          type: array
          description: Agent 列表
          items:
            $ref: "#/components/schemas/BotInfo"
        total:
          type: number
          description: Agent 总数
          example: 10
      required:
        - botList
        - total
    CreateBotRsp:
      type: object
      properties:
        botId:
          type: string
          description: 生成的 Agent ID
          example: "bot-3ee2a8b8"
      required:
        - botId
    UpdateBotRsp:
      type: object
      properties:
        status:
          type: string
          description: 操作结果
          example: "success"
      required:
        - status
    DeleteBotRsp:
      type: object
      properties:
        status:
          type: string
          description: 操作结果
          example: "success"
      required:
        - status
    ChatHistory:
      type: object
      properties:
        botId:
          type: string
          description: Agent ID
          example: bot-xxx
        recordId:
          type: string
          description: 对话ID，由系统生成
          example: record-xxx
        role:
          type: string
          description: 对话中的角色
          example: user
        content:
          type: string
          description: 对话内容
          example: 我是一段内容
        conversation:
          type: string
          description: 用户标识
          example: user
        type:
          type: string
          description: 对话数据类型
          example: text
        image:
          type: string
          description: 对话生成的图片链接
          example: http://xxx.image
        triggerSrc:
          type: string
          description: 对话发起来源
          example: TCB
        replyTo:
          type: string
          description: 对话回复的记录ID
          example: record-xxx
        createTime:
          type: string
          description: 对话时间
          example: "2024-07-25T12:03:59.000Z"
    GetChatHistoryRsp:
      type: object
      properties:
        recordList:
          type: array
          description: 历史对话列表
          items:
            $ref: "#/components/schemas/ChatHistory"
        total:
          type: number
          description: 对话总数
          example: 10
      required:
        - recordList
        - total
    UserFeedbackRsp:
      type: object
      properties:
        status:
          type: string
          description: 操作结果
          example: "success"
      required:
        - status
    # GetUserFeedbackRsp:
    #   type: object
    #   properties:
    #     feedbackList:
    #       type: array
    #       description: 反馈查询结果
    #       items:
    #         $ref: "#/components/schemas/UserFeedbackDto"
    #     total:
    #       type: number
    #       description: 反馈总数
    #       example: 10
    #   required:
    #     - feedbackList
    #     - total
    SpeechToTextDto:
      type: object
      properties:
        engSerViceType:
          type: string
          description: 输入语言类型, 16k_zh:中文通用  16k_zh-PY:中英粤  16k_zh_medical:中文医疗  16k_en:英语  16k_yue:粤语
          example: 16k_zh
        voiceFormat:
          type: string
          description: 识别音频的音频格式，如wav/mp3
          example: mp3
        url:
          type: string
          description: 语音的URL地址
        # isPreview:
        #   type: boolean
        #   description: 是否为预览模式
        #   default: false
      required:
        - voiceFormat
        - url
    TextToSpeechDto:
      type: object
      properties:
        text:
          type: string
          description: 合成语音的源文本
        voiceType:
          type: number
          description: 音色 ID, 101004:通用男声  101005:通用女声  601004:咨询男声  501001:咨询女声  101010:通用男声（大模型） 101035:通用女声（大模型）
          example: 101008
        # isPreview:
        #   type: boolean
        #   description: 是否为预览模式
        #   default: false
      required:
        - text
    ConversationEntity:
      type: object
      properties:
        conversationId:
          type: string
        title:
          type: string
        createTime:
          type: string
        updateTime:
          type: string
      required:
        - conversationId
        - title
        - createTime
        - updateTime
    GetConversationRsp:
      type: object
      properties:
        data:
          type: array
          description: 会话查询结果
          items:
            $ref: "#/components/schemas/ConversationEntity"
        total:
          type: number
          description: 会话总数
          example: 1
      required:
        - data
        - total
    GenerateImageRsp:
      type: object
      properties:
        url:
          type: string
          description: 生成图片的链接
          example: "https://hunyuan-base-prod-1258344703.cos.ap-guangzhou.myqcloud.com/text2image/result/20240821/20240821145652298/f2c15c49cc45f338daf46d3b9413c18c.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKID0qSq0xJRL7h3A4nIYJFrFOJ1VlnbIm26%26q-sign-time%3D1724223412%3B1724309812%26q-key-time%3D1724223412%3B1724309812%26q-header-list%3Dhost%26q-url-param-list%3D%26q-signature%3D99b6c0f8d8434abf22a06887e2d854223045eaf8"
        content:
          type: string
          description: 生成图片的描述
          example: "这是一幅以超现实主义风格呈现的画面，画面展示一个金属制造的机器人，正以一种挑战的眼神看着一个惊讶的人，机器人的设计有棱有角，手握着一个大大的“对”按钮，背景设定在现代化的办公室，前方的墙壁上挂着一幅世界地图"
    SSERsp:
      type: object
      properties:
        created:
          type: number
          description: 对话时间戳
          example: "1726030224"
        record_id:
          type: string
          description: 对话记录ID
          example: "record-427d3652"
        model:
          type: string
          description: 大模型类型
          example: "hunyuan"
        version:
          type: string
          description: 大模型版本
          example: "202407241700"
        type:
          type: string
          description: "回复类型： text: 主要回答内容，thinking: 思考过程，search: 查询结果，knowledge: 知识库"
          example: "assistant"
        role:
          type: string
          description: 对话角色，响应中固定为 assistant
          example: "assistant"
        content:
          type: string
          description: 对话内容
          example: "你好"
        finish_reason:
          type: string
          description: 对话结束标志，continue 表示对话未结束，stop 表示对话结束
          example: "continue"
        reasoning_content:
          type: string
          description: 深度思考内容（仅deepseek-r1是不为空字符串）
          example: ""
        usage:
          type: object
          description: token使用量
          properties:
            promptTokens:
              type: number
              description: 表示prompt的tokens数，多次返回中保持不变
              example: 10
            completionTokens:
              type: number
              description: 回答的token总数，在流式返回中，表示到目前为止所有 completion 的 tokens 总数，多次返回中持续累加
              example: 20
            totalTokens:
              type: number
              description: 表示 promptTokens 和 completionTokens 之和
              example: 30
        knowledge_base:
          description: 对话中使用到的知识库
          example:
            - ""
          type: array
          items:
            type: string
        search_info:
          type: object
          description: 搜索结果信息，需要开启联网查询
          properties:
            search_results:
              type: array
              description: 搜索引文信息
              items:
                properties:
                  index:
                    type: string
                    description: 搜索引文序号
                    example: "【1】"
                  title:
                    type: string
                    description: 搜索引文标题
                    example: "标题"
                  url:
                    type: string
                    description: 搜索引文链接
                    example: "链接"
    OpenAIStreamRsp:
      type: object
      properties:
        id:
          type: string
          description: 对话记录ID
          example: "record-427d3652"
        object:
          type: string
          description: 接口类型
          example: "chat.completion"
        created:
          type: number
          description: 对话时间戳
          example: "1726030224"
        model:
          type: string
          description: Agent ID
          example: "bot-xxxx"
        choices:
          type: array
          description: choices
          items:
            properties:
              index:
                type: number
                description: index
                example: 0
              delta:
                type: object
                properties:
                  role:
                    type: string
                    description: 消息类型
                    example: "assistant"
                  content:
                    type: string
                    description: 消息内容
                    example: "你好"
              finish_reason:
                type: string
                description: 对话结束标志，continue 表示对话未结束，stop 表示对话结束
                example: "continue"
        usage:
          type: object
          description: token使用量
          properties:
            prompt_tokens:
              type: number
              description: 表示prompt的tokens数，多次返回中保持不变
              example: 10
            completion_tokens:
              type: number
              description: 回答的token总数，在流式返回中，表示到目前为止所有completion的tokens总数，多次返回中持续累加
              example: 20
            total_tokens:
              type: number
              description: 表示prompt_tokens和completion_tokens之和
    OpenAINotStreamRsp:
      type: object
      properties:
        id:
          type: string
          description: 对话记录ID
          example: "record-427d3652"
        object:
          type: string
          description: 接口类型
          example: "chat.completion"
        created:
          type: number
          description: 对话时间戳
          example: "1726030224"
        model:
          type: string
          description: Agent ID
          example: "bot-xxxx"
        choices:
          type: array
          description: choices
          items:
            properties:
              index:
                type: number
                description: index
                example: 0
              message:
                type: object
                properties:
                  role:
                    type: string
                    description: 消息类型
                    example: "assistant"
                  content:
                    type: string
                    description: 消息内容
                    example: "你好"
              finish_reason:
                type: string
                description: 对话结束标志，continue 表示对话未结束，stop 表示对话结束
                example: "continue"
        usage:
          type: object
          description: token使用量
          properties:
            prompt_tokens:
              type: number
              description: 表示prompt的tokens数，多次返回中保持不变
              example: 10
            completion_tokens:
              type: number
              description: 回答的token总数，在流式返回中，表示到目前为止所有completion的tokens总数，多次返回中持续累加
              example: 20
            total_tokens:
              type: number
              description: 表示prompt_tokens和completion_tokens之和

    ErrRsp:
      type: object
      properties:
        code:
          type: string
          description: 错误代码
          example: "INVALID_CREDENTIALS"
        message:
          type: string
          description: 错误信息
          example: "Credentials are invalid"
        requestId:
          type: string
          description: 请求ID
          example: "6360ba4b-f672-434b-9dee-35686a5589a4"
