You need to enable JavaScript to run this app.
文档中心
数据智能体 DataAgent(私有化)

数据智能体 DataAgent(私有化)

复制全文
下载 pdf
数据问答
返回参数
复制全文
下载 pdf
返回参数

本文档介绍异步任务API的两种返回模式:阻塞返回和流式返回。该API旨在帮助开发者处理耗时较长的后台任务(如AI内容生成、数据分析等),通过提供灵活的返回机制,优化前端应用的响应体验。本文将详细解释两种模式的数据结构及处理方式。

阻塞返回(stream=false
{
  "code": "llm/ok",
  "data": { "taskId": "8d06d22ced4d4b449cc414c9283cde56" },
  "msg": {}
}

说明

阻塞模式下只立即返回 taskId,最终答案需通过 taskStatus / taskDetail 拉取。
例如,通过以下API轮询任务状态和获取最终结果:

  1. 查询任务状态
    ````http GET /v1/taskStatus?taskId={taskId}`
2. 获取任务详情(包含最终产物)
````http`
`GET /v1/taskDetail?taskId={taskId}`

流式返回(stream=true
  • Content-Type: text/event-stream
  • 事件格式:data: {json}\n\n,结束 data: [DONE]\n\n
  • 每条事件的顶层 key 三选一:

顶层 key

出现时机

内容

task

流的第 1 条

任务初始化(id / contextId / 回显 metadata)

artifactUpdate

中间多次

单个产物增量

statusUpdate

中间 + 末尾

任务状态:submittedworkingcompleted/failedfinal=true 表示终止

task(首条)

{
  "task": {
    "kind": "task",
    "id": "8d06d22ced4d4b449cc414c9283cde56",
    "contextId": "e3dda1cf238147b094fb7aa9bfea0fee",
    "status": { "state": "submitted", "timestamp": "2026-05-21T14:07:33.304538" },
    "metadata": { "agentId": 17368, "enableKnowledgeQa": true, "enableRunningStepOutput": true, "fileList": [], "toolList": [] }
  }
}

artifactUpdate(产物增量)

{
  "artifactUpdate": {
    "kind": "artifact-update",
    "taskId": "8d06d22ced4d4b449cc414c9283cde56",
    "contextId": "e3dda1cf238147b094fb7aa9bfea0fee",
    "artifact": {
      "artifactId": "c5595ef9-b556-5310-8390-d06045779791",
      "name": "思考推理",
      "description": "任务执行中:思考推理",
      "parts": [ { "kind": "text", "text": "iDA(intelligent Data Analysis)是…" } ],
      "metadata": { "type": "deep_research_running_step", "stepType": "executor_think", "stepId": 66482, "parentStepId": 0 }
    },
    "lastChunk": false
  }
}

字段

说明

artifact.artifactId

产物唯一 ID(同一产物多片段共用)

artifact.parts[].text

产物文本(前端拼接)

artifact.metadata.type

主要为 deep_research_running_step

artifact.metadata.stepType

子类型,详见「附表:产物定义」

lastChunk

true 表示该产物本次输出已结束

statusUpdate(状态更新)

{
  "statusUpdate": {
    "kind": "status-update",
    "taskId": "8d06d22ced4d4b449cc414c9283cde56",
    "contextId": "e3dda1cf238147b094fb7aa9bfea0fee",
    "status": { "state": "completed", "timestamp": "2026-05-21T14:09:58.160050" },
    "final": true,
    "metadata": { "...": "回显的元信息" }
  }
}
最近更新时间:2026.05.22 16:21:54
这个页面对您有帮助吗?
有用
有用
无用
无用