Multi-format Document Parsing Skill (Mijuan Fang)
Usage
- Called by the Mijuan Fang Worker when it receives a file that has passed the security scan.
- Three-level fallback is tried in sequence, outputting the final structured result and confidence.
Input
file_path: Local file path that has passed security-scan
formats: (Optional) Desired format whitelist, defaults to all formats
Output
markdown: Structured Markdown body
metadata: Metadata such as title, page count, table count, author, etc.
confidence: 0–1 parsing confidence
fallback_used: Name of the parser that ultimately takes effect
Dependencies
- MinerU (preferred, strong layout restoration)
- PyMuPDF (second choice, fast PDF parsing)
- pdfplumber (fallback, table/text extraction)
python-magic(type detection)
Failure Handling
- Primary parser fails → automatically downgrade to the next tier until all have been tried.
- All three tiers fail → mark
人工介入, do not output incomplete results, and return BLOCKED to the Junjichu.
- Oversized single-page file → parse in chunks and then concatenate to avoid memory overflow; a chunk-level failure only marks that chunk as low confidence.
Reuse Value
- General-purpose parsing foundation: RAG indexing, enterprise knowledge bases, and contract structuring can all reuse it directly.
- Transparent confidence: downstream (Tongzhengsi four-color cards) can use this to decide whether manual review is needed, reducing hallucination risk.
Repechage Code Package Execution (runnable package)
- Real entry point:
scripts/run_doc_parse.py
- Execution is equivalent to
core.runtime.AgentSession.run_stage("doc-parse"), calling archive.mijuanfang.MiJuanFangAgent(three-level parsing fallback, pure Python and offline-capable).
- Run:
python skills/doc-parse/scripts/run_doc_parse.py
- Artifacts:
examples/snse_survey/skill_outputs/doc_parse.json(parsing results + confidence + fallback information).