AI 助手
扣子 AI 帮助与支持
你好,我是 扣子 文档问答助手 🎉 你在阅读当前文档的过程中,无论对文档概念的解释,还是文档内容方面的疑问,都可以随时向我提问,我会全力为你解答
推荐问题
扣子 3.0 都有什么新特性?
扣子和扣子编程有什么区别?
扣子如何收费?
Feedback
低代码项目
动态
快速开始
智能体
工作流
应用
资源
发布
模型
协作
开发工具
API 参考
SDK 参考
音视频
推广与变现

消息 type 说明

Copy Page

仅发起对话接口需要在接口传参中添加消息内容(content)和消息类型(type),但不同场景支持传入的消息类型和角色类型(role)不同。本文档介绍各个场景支持的 type 类型及各种类型消息内容示例。

支持的 type 类型

仅发起对话接口支持将此参数作为入参,且:

  • 如果 autoSaveHistory=true,type 支持设置为 question 或 answer。
  • 如果 autoSaveHistory=false,type 支持设置为 question、answer、function_call、tool_output/tool_response。

其中,type=question 只能和 role=user 对应,即仅用户角色可以且只能发起 question 类型的消息。

type

发起对话

Response

Request,且 autoSaveHistory=false

Request,且 autoSaveHistory=true

question

❌

✔️

✔️

answer

✔️

✔️

✔️

function_call

✔️

✔️

❌

tool_output/tool_response

✔️

✔️

❌

follow_up

✔️

❌

❌

knowledge

✔️

❌

❌

verbose

✔️

❌

❌

消息结构示例

创建消息并指定消息类型时,应遵循 type、role 和 content_type 的匹配关系,例如 role 为 user 时,type 只能为 question。详细的匹配关系及消息体示例可参考下表。

消息类型(type)

角色
(role)

内容类型
(content_type)

示例

question

user

  • text
  • object_string
{
    "role": "user",
    "content": "--- 只需要回答最新的这一条问题:搜几个最新的军事新闻",
    "content_type": "text",
    "type": "question"
}

answer

assistant

text

{
    "role": "assistant",
    "content": "以下是最新的体育新闻 ......",
    "content_type": "text",
    "type": "answer"
}

function_call

assistant

text

{
    "role": "assistant",
    "content": "{\"name\":\"toutiaosousuo-search\",\"arguments\":{\"cursor\":0,\"input_query\":\"体育新闻\"...}",
    "content_type": "text",
    "type": "function_call"
}

tool_output/tool_response

assistant

text

{
    "role": "assistant",
    "content": "{\"news\":[{\"title\":\"新闻内容:.....\"}]}",
    "content_type": "text",
    "type": "tool_output"
},

follow_up

assistant

text

{
    "role": "assistant",
    "type": "follow_up",
    "content": "国足将会有哪些变化和调整?",
    "content_type": "text"
}

verbose

assistant

text

{
    "role": "assistant",
    "type": "verbose",
// generate_answer_finish 表示全部 answer 已回复完毕
    "content": "{\"msg_type\":\"generate_answer_finish\",\"data\":\"\",\"from_module\":null,\"from_unit\":null}",
    "content_type": "text"
}