- Updated LocalDocumentParser to include raw_layouts and artifact_prefix from settings. - Added new documents with failure reasons and metadata to documents.json for better error tracking. - Created a new documentation file detailing the Aliyun ingest implementation process. - Updated RFC to reflect changes in the parsing backend and embedding dimensions. - Modified tests to accommodate the new embedding dimension of 1024 and updated parser and chunk builder assertions. - Verified migration configurations to ensure correct settings for embedding model and backend.
2.1 KiB
2.1 KiB
阿里云解析主链路实现说明
本文档描述当前仓库已经落地的文档 ingest 主链路实现,作为迁移设计到代码实现之间的收口说明。
1. 当前默认链路
- 上传入口保持为
/api/v1/documents/upload - 默认
PARSER_BACKEND=aliyun - 默认
CHUNK_BACKEND=aliyun - 默认 Milvus collection 为
regulations_dense_1536_v2 - 解析产物落到 MinIO
artifacts/{doc_id}/
完整主链路如下:
- 原始文件上传到 MinIO
AliyunDocmindGateway提交阿里云异步解析任务- 轮询任务状态直到成功或超时
- 分页拉取
layouts - 转换为
structure_nodes / semantic_blocks / vector_chunks - 三层结构 JSON 回写 MinIO
- 使用
vector_chunks[*].embedding_text调 embedding API - 写入
regulations_dense_1536_v2 - 文档状态更新为
indexed
运行时转换逻辑位于 backend/app/infrastructure/parser/aliyun_layout_normalizer.py。
旧的 backend/app/aliyun_parser/ 示例目录已移除,不参与生产运行时。
2. 解析产物持久化
每个文档会额外写入以下对象:
artifacts/{doc_id}/layouts.jsonartifacts/{doc_id}/structure_nodes.jsonartifacts/{doc_id}/semantic_blocks.jsonartifacts/{doc_id}/vector_chunks.json
documents.json 仅保留对象 key、统计信息和处理阶段,不保存完整大 JSON。
3. 失败策略
- 当前
PARSER_FAILURE_MODE=fail - 阿里云解析失败不自动回退到本地 parser
- 失败时保留原始文件与已写入的 artifacts,便于排障
4. 运行参数
关键环境变量如下:
ALIBABA_ACCESS_KEY_IDALIBABA_ACCESS_KEY_SECRETALIBABA_ENDPOINTALIYUN_PARSE_POLL_INTERVAL_SECONDSALIYUN_PARSE_TIMEOUT_SECONDSALIYUN_PARSE_LAYOUT_STEP_SIZEALIYUN_LLM_ENHANCEMENTALIYUN_ENHANCEMENT_MODEDOCUMENT_PARSE_ARTIFACT_PREFIXPARSER_BACKENDCHUNK_BACKEND
5. 运行态确认
可通过 /api/v1/status/config 确认以下字段:
parser_backendchunk_backendmilvus_collectionartifact_prefixparser_failure_mode
这几个值用于确认服务是否实际运行在迁移后的默认链路上。