Update agent orchestration and knowledge flow

Add sub-commander orchestration updates, align frontend integrations, and refine knowledge view behavior without including local data artifacts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 21:44:04 +08:00
parent aafa05dc1c
commit 0d89325b09
14 changed files with 529 additions and 650 deletions

View File

@@ -3,6 +3,8 @@
支持多种文档格式 + LlamaIndex 智能分块
"""
from pathlib import Path
import tempfile
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select
from fastapi import UploadFile
@@ -380,7 +382,42 @@ class DocumentService:
if hasattr(mineru, "parse_to_markdown"):
return mineru.parse_to_markdown(file_path)
raise ValueError("PDF 解析失败: MinerU 不支持当前接口")
try:
from mineru.cli.common import do_parse, read_fn
from mineru.utils.enum_class import MakeMode
except Exception as error:
raise ValueError(
"PDF 解析失败: 当前安装的 MinerU 版本接口不兼容,请确认支持 to_markdown / parse_to_markdown或提供 cli.common.do_parse 能力"
) from error
with tempfile.TemporaryDirectory(prefix="mineru-") as output_dir:
pdf_name = Path(file_path).stem
pdf_bytes = read_fn(Path(file_path))
try:
do_parse(
output_dir,
[pdf_name],
[pdf_bytes],
["zh"],
f_draw_layout_bbox=False,
f_draw_span_bbox=False,
f_dump_md=True,
f_dump_middle_json=False,
f_dump_model_output=False,
f_dump_orig_pdf=False,
f_dump_content_list=False,
f_make_md_mode=MakeMode.MM_MD,
)
except ModuleNotFoundError as error:
dependency = getattr(error, "name", None) or str(error).split("'")[-2] if "'" in str(error) else str(error)
raise ValueError(f"PDF 解析依赖缺失: MinerU 运行时依赖 {dependency}") from error
markdown_path = Path(output_dir) / pdf_name / "pipeline" / f"{pdf_name}.md"
if markdown_path.exists():
return markdown_path.read_text(encoding="utf-8")
raise ValueError(
"PDF 解析失败: 当前安装的 MinerU 版本接口不兼容,请确认支持 to_markdown / parse_to_markdown或提供 cli.common.do_parse 能力"
)
async def _parse_pdf(self, file_path: str) -> ParsedDocument:
markdown = await self._parse_pdf_with_mineru(file_path)