Skip to main content
POST
Chat

智能体对话聊天

URL: /v1/agent/conversations/{conversation_id}/chat
方法: POST
描述: 与智能体进行对话聊天,支持流式和非流式响应。

路径参数

请求参数

documents 对象结构

响应参数(流式 SSE)

响应为 Server-Sent Events (SSE) 流,每个事件包含以下字段。 响应头
  • X-REPORTIFY-ASSISTANT-MESSAGE-ID:助手消息 ID,可用于后续调用获取消息事件接口
响应体(SSE 事件)

event_type 枚举值

  • init - 初始化
  • workflow_start - 工作流开始
  • workflow_end - 工作流结束
  • node_start - 节点开始
  • node_end - 节点结束
  • agent_start - 智能体开始
  • agent_end - 智能体结束
  • tool_start - 工具开始
  • tool_end - 工具结束
  • stream_start - 流式开始
  • streaming - 流式输出中
  • stream_end - 流式结束
  • usage - 使用情况
  • cancel - 取消
  • error - 错误

input 对象结构(tool_start 事件)

event_typetool_start 时,input 字段包含工具的输入参数:

output 对象结构

tool_end 事件的 output: event_typetool_end 时,output 字段包含工具的输出结果: agent_end 事件的 output: event_typeagent_end 时,output 字段包含智能体的输出结果: node_end 事件的 output: event_typenode_end 时,output 字段包含节点的输出结果:
注意:当 node_typeend 时,output 通常只包含 content 字段;当 node_typeagent 时,output 可能包含完整的文件信息。
workflow_end 事件的 output: event_typeworkflow_end 时,output 字段包含工作流的最终输出结果:
注意output 是一个字典,其 key 对应工作流中最后一个节点的 node_id。例如,如果最后一个节点的 node_idgenerate_daily_report,则 output 结构为 {"generate_daily_report": {...}}

请求示例

cURL
Python

响应示例(SSE 流)

1. init 事件示例:
2. workflow_start 事件示例:
3. node_start 事件示例:
4. agent_start 事件示例:
5. stream_start 事件示例:
6. streaming 事件示例:
7. stream_end 事件示例:
8. tool_start 事件示例:
9. tool_end 事件示例:
10. agent_end 事件示例:
11. node_end 事件示例:
12. workflow_end 事件示例:

事件流程说明

一个完整的对话流程通常包含以下事件序列:
  1. init → 初始化会话
  2. workflow_start → 工作流开始执行
  3. node_start → 节点开始(如”开始”节点)
  4. agent_start → 智能体开始执行(当节点类型为 agent 时)
  5. stream_start → 流式输出开始(智能体开始思考)
  6. streaming → 流式内容输出(多次,逐步输出内容)
  7. stream_end → 流式输出结束
  8. tool_start → 工具调用开始(如新闻搜索)
  9. tool_end → 工具调用结束(返回结果)
  10. agent_end → 智能体执行结束(包含智能体输出结果)
  11. node_end → 节点结束(包含节点输出结果)
  12. workflow_end → 工作流执行完成(包含最终输出结果)

run_id 关联机制

run_id 是用于关联一组 startend 事件的标识符,帮助追踪事件的配对关系:
  • workflow_startworkflow_end 共享同一个 run_id
  • node_startnode_end 共享同一个 run_id
  • agent_startagent_end 共享同一个 run_id
  • stream_startstream_end 共享同一个 run_id
  • tool_starttool_end 共享同一个 run_id
示例
注意
  • 实际流程中可能包含多个节点多个智能体多个工具调用,事件会按照执行顺序依次返回
  • 通过 run_id 可以准确匹配每个 start 事件对应的 end 事件
  • 当节点类型为 agent 时,会触发 agent_startagent_end 事件
  • 同一个智能体内可能有多个流式输出(stream_start/streaming/stream_end)和多个工具调用(tool_start/tool_end)
  • agent_end 事件的 output 字段包含智能体的输出内容
  • node_end 事件的 output 字段包含节点的输出内容(可能包含文件信息)
  • workflow_end 事件的 output 字段包含工作流的最终输出结果(如生成的报告)

错误响应

Authorizations

Authorization
string
header
required

Enter your Bearer token

Path Parameters

conversation_id
integer
required

对话 ID

Body

application/json

Agent 对话聊天请求(创建新消息)

message
string
required

用户消息内容

Example:

"nvidia 最新业绩分析"

documents
DocumentInput · object[]

关联的文档列表

stream
boolean
default:true

是否使用流式响应

Example:

true

Response

Successful Response (Server-Sent Events stream)

工作流流式事件对象

event_id
string
required

唯一事件标识符

Example:

"019b24ef23a1f4da18256b402868fae31764"

event_type
enum<string>
required

事件类型

Available options:
init,
workflow_start,
workflow_end,
node_start,
node_end,
agent_start,
agent_end,
tool_start,
tool_end,
stream_start,
streaming,
stream_end,
usage,
cancel,
error
Example:

"init"

timestamp
integer
required

事件时间戳(毫秒)

Example:

1765851210657

response_id
string
required

响应标识符,用于分组事件

Example:

"019b24ef238cc97730971a9a0080c99c"

workflow_id
string

工作流标识符

Example:

"11887655289749510"

execution_id
string

执行标识符

Example:

"1dfccd9d-c365-4b7a-adae-aa9123684ec4"

run_id
string

运行标识符,用于关联一组 start 和 end 事件(如 workflow_start 和 workflow_end、tool_start 和 tool_end),用于分组相关的开始/结束事件对

Example:

""

node_id
string

节点标识符

node_name
string

节点显示名称

node_type
string

节点类型(start, tool, agent, end)

agent_id
string

智能体标识符

agent_name
string

智能体显示名称

agent_type
string

智能体类型(builtin_agent, react_agent 等)

tool_id
string

工具标识符

tool_name
string

工具显示名称

input
Input · object

组件的输入数据

Example:
output
Output · object

组件的输出数据。

  • 对于 tool_end 事件:包含 content 字段(JSON 字符串格式)
  • 对于 agent_end 事件:包含 content 字段(Markdown 格式)
  • 对于 node_end 事件:包含 content、filetype、filename、filepath 字段
  • 对于 workflow_end 事件:字典的 key 为最后一个 node 的 node_id,value 包含 title、filetype、content、filename、filepath 字段
Example:
content
string

事件内容(用于思考/流式输出)

Example:

""

error
Error · object

错误信息(如果事件类型为 error)

offset
integer

事件偏移量

Example:

9195