Skip to main content

文档处理状态与异步任务

文档从上传到可检索,需经过异步处理流水线。本页详解状态机、webhook 通知和监控策略。

文档处理状态机

状态字段

字段值域说明
statuspending/processing/completed/failed/quarantined/cancelled主状态
current_stageparsing/chunking/embedding/vector_write/completed处理子阶段
processing_progress0-100百分比进度
error_messagetext失败时的错误详情

状态查询接口

方法路径说明
GET/{document_id}/status返回 DocumentStatus(轻量)
GET/{document_id}返回 DocumentDetail(完整)
GET/{document_id}/timeline处理时间线事件列表

前端轮询策略

轮询建议
  • 初始间隔 2 秒,逐步退避到 5 秒
  • processing_progress 可驱动进度条
  • 到达终态(completed/failed/quarantined/cancelled)后停止轮询
  • 批量上传场景建议用 GET /documents/?dataset_id=X&status=processing 统一查询

操作控制

操作路径前置条件
取消POST /{id}/cancelstatus 为 pending 或 processing
重试POST /{id}/retrystatus 为 failed
重新入库POST /batch/reingeststatus 为 completed
批量重试POST /batch/retry批量操作失败文档

Timeline 事件

GET /{document_id}/timeline 返回按时间排序的处理事件列表(DocumentTimelineResponse),每个事件包含:

字段说明
event事件类型
stage关联阶段
timestamp事件时间
details事件详情(JSON)

相关链接