Chat
智能体接口
Chat
Chat with agent (streaming or non-streaming)
POST
Chat
智能体对话聊天
URL:/v1/agent/conversations/{conversation_id}/chat方法:
POST描述: 与智能体进行对话聊天,支持流式和非流式响应。
路径参数
请求参数
documents 对象结构
响应参数(流式 SSE)
响应为 Server-Sent Events (SSE) 流,每个事件包含以下字段。 响应头:X-REPORTIFY-ASSISTANT-MESSAGE-ID:助手消息 ID,可用于后续调用获取消息事件接口
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_type 为 tool_start 时,input 字段包含工具的输入参数:
output 对象结构
tool_end 事件的 output: 当event_type 为 tool_end 时,output 字段包含工具的输出结果:
agent_end 事件的 output:
当
event_type 为 agent_end 时,output 字段包含智能体的输出结果:
node_end 事件的 output:
当
event_type 为 node_end 时,output 字段包含节点的输出结果:
注意:当workflow_end 事件的 output: 当node_type为end时,output 通常只包含content字段;当node_type为agent时,output 可能包含完整的文件信息。
event_type 为 workflow_end 时,output 字段包含工作流的最终输出结果:
注意:output是一个字典,其 key 对应工作流中最后一个节点的node_id。例如,如果最后一个节点的node_id为generate_daily_report,则 output 结构为{"generate_daily_report": {...}}。
请求示例
cURL响应示例(SSE 流)
1. init 事件示例:事件流程说明
一个完整的对话流程通常包含以下事件序列:- init → 初始化会话
- workflow_start → 工作流开始执行
- node_start → 节点开始(如”开始”节点)
- agent_start → 智能体开始执行(当节点类型为 agent 时)
- stream_start → 流式输出开始(智能体开始思考)
- streaming → 流式内容输出(多次,逐步输出内容)
- stream_end → 流式输出结束
- tool_start → 工具调用开始(如新闻搜索)
- tool_end → 工具调用结束(返回结果)
- agent_end → 智能体执行结束(包含智能体输出结果)
- node_end → 节点结束(包含节点输出结果)
- workflow_end → 工作流执行完成(包含最终输出结果)
run_id 关联机制
run_id 是用于关联一组 start 和 end 事件的标识符,帮助追踪事件的配对关系:
- workflow_start 和 workflow_end 共享同一个
run_id - node_start 和 node_end 共享同一个
run_id - agent_start 和 agent_end 共享同一个
run_id - stream_start 和 stream_end 共享同一个
run_id - tool_start 和 tool_end 共享同一个
run_id
注意:
- 实际流程中可能包含多个节点、多个智能体、多个工具调用,事件会按照执行顺序依次返回
- 通过
run_id可以准确匹配每个start事件对应的end事件- 当节点类型为
agent时,会触发agent_start和agent_end事件- 同一个智能体内可能有多个流式输出(stream_start/streaming/stream_end)和多个工具调用(tool_start/tool_end)
agent_end事件的output字段包含智能体的输出内容node_end事件的output字段包含节点的输出内容(可能包含文件信息)workflow_end事件的output字段包含工作流的最终输出结果(如生成的报告)
错误响应
Authorizations
Enter your Bearer token
Path Parameters
对话 ID
Body
application/json
Response
Successful Response (Server-Sent Events stream)
工作流流式事件对象
唯一事件标识符
Example:
"019b24ef23a1f4da18256b402868fae31764"
事件类型
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"
事件时间戳(毫秒)
Example:
1765851210657
响应标识符,用于分组事件
Example:
"019b24ef238cc97730971a9a0080c99c"
工作流标识符
Example:
"11887655289749510"
执行标识符
Example:
"1dfccd9d-c365-4b7a-adae-aa9123684ec4"
运行标识符,用于关联一组 start 和 end 事件(如 workflow_start 和 workflow_end、tool_start 和 tool_end),用于分组相关的开始/结束事件对
Example:
""
节点标识符
节点显示名称
节点类型(start, tool, agent, end)
智能体标识符
智能体显示名称
智能体类型(builtin_agent, react_agent 等)
工具标识符
工具显示名称
组件的输入数据
Example:
组件的输出数据。
- 对于 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:
事件内容(用于思考/流式输出)
Example:
""
错误信息(如果事件类型为 error)
事件偏移量
Example:
9195
