Skip to main content
GET
/
v1
/
agent
/
conversations
/
{conversation_id}
/
messages
/
{assistant_message_id}
Get Assistant Message Events
curl --request GET \
  --url https://api.reportify.cn/v1/agent/conversations/{conversation_id}/messages/{assistant_message_id} \
  --header 'Authorization: Bearer <token>'
{
  "event_id": "019b24ef23a1f4da18256b402868fae31764",
  "event_type": "init",
  "timestamp": 1765851210657,
  "response_id": "019b24ef238cc97730971a9a0080c99c",
  "workflow_id": "11887655289749510",
  "execution_id": "1dfccd9d-c365-4b7a-adae-aa9123684ec4",
  "run_id": "",
  "node_id": "<string>",
  "node_name": "<string>",
  "node_type": "<string>",
  "agent_id": "<string>",
  "agent_name": "<string>",
  "agent_type": "<string>",
  "tool_id": "<string>",
  "tool_name": "<string>",
  "input": {
    "query": "NVIDIA AMD Intel GPU 半导体 最新动态",
    "symbols": [
      "US:NVDA",
      "US:AMD",
      "US:INTC"
    ],
    "start_datetime": "2025-12-15T00:00:00",
    "end_datetime": "2025-12-16T02:14:15",
    "num": 15,
    "filetype": "json"
  },
  "output": {
    "content": "{\"docs\": [{\"doc_id\": \"1197862772277383168\", \"title\": \"示例文档\"}], \"total_count\": 10}"
  },
  "content": "",
  "error": {},
  "offset": 9195
}

获取助手消息事件

URL: /v1/agent/conversations/{conversation_id}/messages/{assistant_message_id} 方法: GET 描述: 获取指定助手消息的所有事件,支持从指定的 offset 开始批量获取,可选择流式(SSE)或非流式(JSON)响应模式。

使用场景

  • 断点续传:当客户端断开连接后,可以从上次接收到的 offset 继续获取事件
  • 历史回放:获取已完成对话的完整事件历史
  • 事件查询:查询特定消息的所有事件,用于调试或分析

路径参数

参数名类型必填描述
conversation_idinteger对话 ID
assistant_message_idstring助手消息 ID(从 chat 接口响应头 X-REPORTIFY-ASSISTANT-MESSAGE-ID 获取)

查询参数

参数名类型必填默认值描述
streambooleantrue是否使用流式响应(SSE)
timeoutinteger1800流式模式的超时时间(秒)
from_offsetinteger0从指定偏移量开始获取事件(最小值:0)

响应参数

流式响应(stream=true)

返回 text/event-stream 格式的 SSE 流,每个事件的结构与 智能体对话聊天接口 相同。

非流式响应(stream=false)

返回 JSON 格式的事件数组:
参数名类型描述
assistant_eventsarray事件列表,每个元素为 WorkflowStreamEvent

示例代码

cURL 示例(流式响应)

curl -X GET "https://api.example.com/v1/agent/conversations/683242877840089/messages/019b24ef238cc97730971a9a0080c99c?stream=true&from_offset=9200" \
  -H "Authorization: Bearer YOUR_API_KEY"

cURL 示例(非流式响应)

curl -X GET "https://api.example.com/v1/agent/conversations/683242877840089/messages/019b24ef238cc97730971a9a0080c99c?stream=false&from_offset=9200" \
  -H "Authorization: Bearer YOUR_API_KEY"

Python 示例(流式响应)

import requests

url = "https://api.example.com/v1/agent/conversations/683242877840089/messages/019b24ef238cc97730971a9a0080c99c"
headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}
params = {
    "stream": True,
    "from_offset": 9200
}

response = requests.get(url, headers=headers, params=params, stream=True)

for line in response.iter_lines():
    if line:
        line = line.decode('utf-8')
        if line.startswith('data: '):
            event_data = line[6:]  # 去掉 "data: " 前缀
            print(event_data)

Python 示例(非流式响应)

import requests

url = "https://api.example.com/v1/agent/conversations/683242877840089/messages/019b24ef238cc97730971a9a0080c99c"
headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}
params = {
    "stream": False,
    "from_offset": 9200
}

response = requests.get(url, headers=headers, params=params)
data = response.json()

for event in data['assistant_events']:
    print(f"Event: {event['event_type']}, Offset: {event['offset']}")

响应示例

非流式响应示例

{
  "assistant_events": [
    {
      "event_id": "019b24ef3046f157db389ee55a0a670a3797",
      "event_type": "streaming",
      "timestamp": 1765851213894,
      "response_id": "019b24ef238cc97730971a9a0080c99c",
      "workflow_id": "11887655289749510",
      "execution_id": "",
      "run_id": "019b24ef25015b3e6e9b3d2363cfb36c",
      "node_id": "start",
      "agent_id": "workflow_planner",
      "content": "项目的具体信息,并将这些信息整合到一份专业的AI行业每日深度报告中。",
      "offset": 9200
    },
    {
      "event_id": "019b24ef49d95c616af6a7b4953fc70a1129",
      "event_type": "node_start",
      "timestamp": 1765851220441,
      "response_id": "019b24ef238cc97730971a9a0080c99c",
      "workflow_id": "11887655289749510",
      "execution_id": "",
      "run_id": "019b24ef49d8a5997ea7d63b8344bfaa",
      "node_id": "define_report_scope",
      "node_name": "确定报告范围",
      "node_type": "agent",
      "offset": 9216
    }
  ]
}

注意事项

  • assistant_message_id 可从对话聊天接口(stream=true)的 HTTP 响应头 X-REPORTIFY-ASSISTANT-MESSAGE-ID 中获取
  • from_offset 参数用于指定从哪个偏移量开始获取事件,可以用于断点续传
  • 流式模式下,事件会实时推送;非流式模式下,会一次性返回所有事件
  • 建议在需要实时更新时使用流式模式,在需要批量处理历史数据时使用非流式模式

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

conversation_id
integer
required

对话 ID

assistant_message_id
string
required

助手消息 ID(从 chat 接口响应头 X-REPORTIFY-ASSISTANT-MESSAGE-ID 获取)

Query Parameters

stream
boolean
default:true

是否使用流式响应(SSE) Stream events via SSE when true

timeout
integer
default:1800

流式模式的超时时间(秒) Timeout in seconds for streaming mode

from_offset
integer
default:0

从指定偏移量开始获取事件 Start streaming from specific offset

Required range: x >= 0

Response

Successful Response (Server-Sent Events stream or JSON array)

工作流流式事件对象

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:
{
"query": "NVIDIA AMD Intel GPU 半导体 最新动态",
"symbols": ["US:NVDA", "US:AMD", "US:INTC"],
"start_datetime": "2025-12-15T00:00:00",
"end_datetime": "2025-12-16T02:14:15",
"num": 15,
"filetype": "json"
}
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": "{\"docs\": [{\"doc_id\": \"1197862772277383168\", \"title\": \"示例文档\"}], \"total_count\": 10}"
}
content
string

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

Example:

""

error
Error · object

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

offset
integer

事件偏移量

Example:

9195