Multi-format Document Parsing Skill (Mijuan Room)
Usage
- Invoked by the Mijuan Room Worker when it receives a file that has passed the security scan.
- Three-level fallback is attempted in sequence, outputting the final structured result and confidence.
Input
file_path: local file path that has passed security-scan
formats: (optional) whitelist of expected supported formats, 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 took 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 degrade to the next tier, until all have been tried.
- All three tiers fail → mark
人工介入, do not output incomplete results, 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 be reused directly.
- Transparent confidence: downstream (Tongzhengsi four-color cards) can decide based on it whether manual review is needed, reducing hallucination risk.
Semifinal 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 result + confidence + fallback information).