Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: add Flash model and update import paths for native PDF handling

myhlolic27c173fd250
diff --git a/mineru/backend/flash/pdf_extractor.py b/mineru/backend/flash/pdf_extractor.py
index 7c57cb12..39911e5b 100644
--- a/mineru/backend/flash/pdf_extractor.py
+++ b/mineru/backend/flash/pdf_extractor.py
@@ -2,7 +2,7 @@
"""Flash PDF 公共提取入口。
-原生文本处理位于 native_pdf 内部包;需要 OCR 时统一委托 Hybrid low。
+原生文本处理由 FlashModel 提供;需要 OCR 时统一委托 Hybrid low。
"""
from __future__ import annotations
@@ -59,12 +59,10 @@ def doc_analyze(
resolved_mode = parse_mode
if resolved_mode == "txt":
- # 延迟加载原生分析流水线,使逐页纯文本接口保持轻量。
- from mineru.backend.flash.native_pdf.pipeline import (
- _analyze_native_document,
- )
+ # 延迟加载 FlashModel,使逐页纯文本和 OCR 路径保持轻量。
+ from mineru.model.flash import FlashModel
- return _analyze_native_document(pdf_doc)
+ return FlashModel().predict(pdf_doc)
# OCR 路径延迟加载 Hybrid,保证原生 Flash 不引入本地视觉模型运行时。
from mineru.backend.hybrid.analyze import doc_analyze as hybrid_doc_analyze
diff --git a/mineru/backend/office/docx_analyze.py b/mineru/backend/office/docx_analyze.py
index 584a9781..1e2ba252 100644
--- a/mineru/backend/office/docx_analyze.py
+++ b/mineru/backend/office/docx_analyze.py
@@ -5,7 +5,7 @@ from typing import Any
from loguru import logger
-from ...model.docx.main import convert_binary
+from ...model.flash.docx.main import convert_binary
from ...types import PageInfo
from ...utils.image_payload import ImagePayloadCache
from .model_output_to_middle_json import result_to_middle_json
diff --git a/mineru/backend/office/pptx_analyze.py b/mineru/backend/office/pptx_analyze.py
index b3d23fcd..bbc61ff4 100644
--- a/mineru/backend/office/pptx_analyze.py
+++ b/mineru/backend/office/pptx_analyze.py
@@ -7,7 +7,7 @@ from typing import Any
from loguru import logger
-from ...model.pptx.main import convert_binary
+from ...model.flash.pptx.main import convert_binary
from ...types import PageInfo
from ...utils.image_payload import ImagePayloadCache
from .model_output_to_middle_json import result_to_middle_json
diff --git a/mineru/backend/office/xlsx_analyze.py b/mineru/backend/office/xlsx_analyze.py
index d03bd272..e1705d95 100644
--- a/mineru/backend/office/xlsx_analyze.py
+++ b/mineru/backend/office/xlsx_analyze.py
@@ -7,7 +7,7 @@ from typing import Any
from loguru import logger
-from ...model.xlsx.main import convert_binary
+from ...model.flash.xlsx.main import convert_binary
from ...types import PageInfo
from ...utils.image_payload import ImagePayloadCache
from .model_output_to_middle_json import result_to_middle_json
diff --git a/mineru/model/flash/__init__.py b/mineru/model/flash/__init__.py
new file mode 100644
index 00000000..3126d171
--- /dev/null
+++ b/mineru/model/flash/__init__.py
@@ -0,0 +1,7 @@
+# Copyright (c) Opendatalab. All rights reserved.
+
+"""Flash 原生 PDF 模型入口。"""
+
+from .model import FlashModel
+
+__all__ = ["FlashModel"]
diff --git a/mineru/model/docx/__init__.py b/mineru/model/flash/docx/__init__.py
similarity index 100%
rename from mineru/model/docx/__init__.py
rename to mineru/model/flash/docx/__init__.py
diff --git a/mineru/model/docx/docx_converter.py b/mineru/model/flash/docx/docx_converter.py
similarity index 99%
rename from mineru/model/docx/docx_converter.py
rename to mineru/model/flash/docx/docx_converter.py
index 8d66afd7..de45ae27 100644
--- a/mineru/model/docx/docx_converter.py
+++ b/mineru/model/flash/docx/docx_converter.py
@@ -21,9 +21,9 @@ from mineru.backend.utils.office_chart import extract_chart_html_from_ooxml
from mineru.backend.utils.office_image import (
serialize_office_image,
)
-from mineru.model.docx.package_normalizer import normalize_docx_package
-from mineru.model.docx.tools.math.omml import oMath2Latex
-from mineru.model.docx.tools.office_xml import read_str
+from mineru.model.flash.docx.package_normalizer import normalize_docx_package
+from mineru.model.flash.docx.tools.math.omml import oMath2Latex
+from mineru.model.flash.docx.tools.office_xml import read_str
from mineru.types import BlockType
from mineru.utils.docx_formatting import Formatting, Script
from mineru.utils.office_rich_text import (
diff --git a/mineru/model/docx/main.py b/mineru/model/flash/docx/main.py
similarity index 96%
rename from mineru/model/docx/main.py
rename to mineru/model/flash/docx/main.py
index fe5a2315..16905185 100644
--- a/mineru/model/docx/main.py
+++ b/mineru/model/flash/docx/main.py
@@ -1,7 +1,7 @@
# Copyright (c) Opendatalab. All rights reserved.
from typing import BinaryIO
-from mineru.model.docx.docx_converter import DocxConverter
+from mineru.model.flash.docx.docx_converter import DocxConverter
def convert_path(file_path: str):
diff --git a/mineru/model/docx/package_normalizer.py b/mineru/model/flash/docx/package_normalizer.py
similarity index 100%
rename from mineru/model/docx/package_normalizer.py
rename to mineru/model/flash/docx/package_normalizer.py
diff --git a/mineru/model/docx/tools/__init__.py b/mineru/model/flash/docx/tools/__init__.py
similarity index 100%
rename from mineru/model/docx/tools/__init__.py
rename to mineru/model/flash/docx/tools/__init__.py
diff --git a/mineru/model/docx/tools/math/__init__.py b/mineru/model/flash/docx/tools/math/__init__.py
similarity index 100%
rename from mineru/model/docx/tools/math/__init__.py
rename to mineru/model/flash/docx/tools/math/__init__.py
diff --git a/mineru/model/docx/tools/math/latex_dict.py b/mineru/model/flash/docx/tools/math/latex_dict.py
similarity index 100%
rename from mineru/model/docx/tools/math/latex_dict.py
rename to mineru/model/flash/docx/tools/math/latex_dict.py
diff --git a/mineru/model/docx/tools/math/omml.py b/mineru/model/flash/docx/tools/math/omml.py
similarity index 100%
rename from mineru/model/docx/tools/math/omml.py
rename to mineru/model/flash/docx/tools/math/omml.py
diff --git a/mineru/model/docx/tools/office_xml.py b/mineru/model/flash/docx/tools/office_xml.py
similarity index 100%
rename from mineru/model/docx/tools/office_xml.py
rename to mineru/model/flash/docx/tools/office_xml.py
diff --git a/mineru/model/flash/model.py b/mineru/model/flash/model.py
new file mode 100644
index 00000000..f8bd204b
--- /dev/null
+++ b/mineru/model/flash/model.py
@@ -0,0 +1,20 @@
+# Copyright (c) Opendatalab. All rights reserved.
+
+"""Flash 原生 PDF 提取模型。"""
+
+from __future__ import annotations
+
+from typing import Any
+
+from mineru.utils.pdf_document import PDFDocument
+
+from .native_pdf import pipeline
+
+
+class FlashModel:
+ """将 Flash 原生 PDF 流水线包装为无状态模型。"""
+
+ def predict(self, pdf_doc: PDFDocument) -> list[list[dict[str, Any]]]:
+ """分析调用方持有的 PDFDocument,并原样返回分页 model_list。"""
+
+ return pipeline._analyze_native_document(pdf_doc)
diff --git a/mineru/backend/flash/native_pdf/__init__.py b/mineru/model/flash/native_pdf/__init__.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/__init__.py
rename to mineru/model/flash/native_pdf/__init__.py
diff --git a/mineru/backend/flash/native_pdf/auxiliary_text.py b/mineru/model/flash/native_pdf/auxiliary_text.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/auxiliary_text.py
rename to mineru/model/flash/native_pdf/auxiliary_text.py
diff --git a/mineru/backend/flash/native_pdf/code_blocks.py b/mineru/model/flash/native_pdf/code_blocks.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/code_blocks.py
rename to mineru/model/flash/native_pdf/code_blocks.py
diff --git a/mineru/backend/flash/native_pdf/formulas.py b/mineru/model/flash/native_pdf/formulas.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/formulas.py
rename to mineru/model/flash/native_pdf/formulas.py
diff --git a/mineru/backend/flash/native_pdf/geometry.py b/mineru/model/flash/native_pdf/geometry.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/geometry.py
rename to mineru/model/flash/native_pdf/geometry.py
diff --git a/mineru/backend/flash/native_pdf/graphics.py b/mineru/model/flash/native_pdf/graphics.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/graphics.py
rename to mineru/model/flash/native_pdf/graphics.py
diff --git a/mineru/backend/flash/native_pdf/index_blocks.py b/mineru/model/flash/native_pdf/index_blocks.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/index_blocks.py
rename to mineru/model/flash/native_pdf/index_blocks.py
diff --git a/mineru/backend/flash/native_pdf/line_layout.py b/mineru/model/flash/native_pdf/line_layout.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/line_layout.py
rename to mineru/model/flash/native_pdf/line_layout.py
diff --git a/mineru/backend/flash/native_pdf/line_merging.py b/mineru/model/flash/native_pdf/line_merging.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/line_merging.py
rename to mineru/model/flash/native_pdf/line_merging.py
diff --git a/mineru/backend/flash/native_pdf/models.py b/mineru/model/flash/native_pdf/models.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/models.py
rename to mineru/model/flash/native_pdf/models.py
diff --git a/mineru/backend/flash/native_pdf/native_text.py b/mineru/model/flash/native_pdf/native_text.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/native_text.py
rename to mineru/model/flash/native_pdf/native_text.py
diff --git a/mineru/backend/flash/native_pdf/pipeline.py b/mineru/model/flash/native_pdf/pipeline.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/pipeline.py
rename to mineru/model/flash/native_pdf/pipeline.py
diff --git a/mineru/backend/flash/native_pdf/tables.py b/mineru/model/flash/native_pdf/tables.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/tables.py
rename to mineru/model/flash/native_pdf/tables.py
diff --git a/mineru/backend/flash/native_pdf/text_blocks.py b/mineru/model/flash/native_pdf/text_blocks.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/text_blocks.py
rename to mineru/model/flash/native_pdf/text_blocks.py
diff --git a/mineru/backend/flash/native_pdf/titles.py b/mineru/model/flash/native_pdf/titles.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/titles.py
rename to mineru/model/flash/native_pdf/titles.py
diff --git a/mineru/backend/flash/native_pdf/visual_annotations.py b/mineru/model/flash/native_pdf/visual_annotations.py
similarity index 100%
rename from mineru/backend/flash/native_pdf/visual_annotations.py
rename to mineru/model/flash/native_pdf/visual_annotations.py
diff --git a/mineru/model/pptx/__init__.py b/mineru/model/flash/pptx/__init__.py
similarity index 100%
rename from mineru/model/pptx/__init__.py
rename to mineru/model/flash/pptx/__init__.py
diff --git a/mineru/model/pptx/main.py b/mineru/model/flash/pptx/main.py
similarity index 86%
rename from mineru/model/pptx/main.py
rename to mineru/model/flash/pptx/main.py
index d9effd36..05474b59 100644
--- a/mineru/model/pptx/main.py
+++ b/mineru/model/flash/pptx/main.py
@@ -1,7 +1,7 @@
# Copyright (c) Opendatalab. All rights reserved.
from typing import BinaryIO
-from mineru.model.pptx.pptx_converter import PptxConverter
+from mineru.model.flash.pptx.pptx_converter import PptxConverter
def convert_path(file_path: str):
diff --git a/mineru/model/pptx/package_normalizer.py b/mineru/model/flash/pptx/package_normalizer.py
similarity index 100%
rename from mineru/model/pptx/package_normalizer.py
rename to mineru/model/flash/pptx/package_normalizer.py
diff --git a/mineru/model/pptx/pptx_converter.py b/mineru/model/flash/pptx/pptx_converter.py
similarity index 99%
rename from mineru/model/pptx/pptx_converter.py
rename to mineru/model/flash/pptx/pptx_converter.py
index 6a64a290..236d542b 100644
--- a/mineru/model/pptx/pptx_converter.py
+++ b/mineru/model/flash/pptx/pptx_converter.py
@@ -14,10 +14,10 @@ from pptx.oxml.text import CT_TextLineBreak
from mineru.backend.utils.office_chart import extract_chart_html_from_ooxml
from mineru.backend.utils.office_image import PIL_IMAGE_LOAD_ERRORS, is_vector_image, serialize_vector_image_with_placeholder
-from mineru.model.docx.tools.math.omml import oMath2Latex
+from mineru.model.flash.docx.tools.math.omml import oMath2Latex
from mineru.model.office_stream import read_stream_bytes_from_start, rewind_stream
-from mineru.model.pptx.package_normalizer import normalize_pptx_package
-from mineru.model.pptx.xycut_pp_sorter import sort_entries
+from mineru.model.flash.pptx.package_normalizer import normalize_pptx_package
+from mineru.model.flash.pptx.xycut_pp_sorter import sort_entries
from mineru.types import BlockType
from mineru.utils.office_rich_text import OfficeRichTextSegment, build_rich_text_from_segments
from mineru.utils.pdf_reader import image_to_b64str
diff --git a/mineru/model/pptx/xycut_pp_sorter.py b/mineru/model/flash/pptx/xycut_pp_sorter.py
similarity index 100%
rename from mineru/model/pptx/xycut_pp_sorter.py
rename to mineru/model/flash/pptx/xycut_pp_sorter.py
diff --git a/mineru/model/xlsx/__init__.py b/mineru/model/flash/xlsx/__init__.py
similarity index 100%
rename from mineru/model/xlsx/__init__.py
rename to mineru/model/flash/xlsx/__init__.py
diff --git a/mineru/model/xlsx/main.py b/mineru/model/flash/xlsx/main.py
similarity index 86%
rename from mineru/model/xlsx/main.py
rename to mineru/model/flash/xlsx/main.py
index b0190f51..e9b4bded 100644
--- a/mineru/model/xlsx/main.py
+++ b/mineru/model/flash/xlsx/main.py
@@ -1,7 +1,7 @@
# Copyright (c) Opendatalab. All rights reserved.
from typing import BinaryIO
-from mineru.model.xlsx.xlsx_converter import XlsxConverter
+from mineru.model.flash.xlsx.xlsx_converter import XlsxConverter
def convert_path(file_path: str):
diff --git a/mineru/model/xlsx/package_normalizer.py b/mineru/model/flash/xlsx/package_normalizer.py
similarity index 100%
rename from mineru/model/xlsx/package_normalizer.py
rename to mineru/model/flash/xlsx/package_normalizer.py
diff --git a/mineru/model/xlsx/xlsx_converter.py b/mineru/model/flash/xlsx/xlsx_converter.py
similarity index 99%
rename from mineru/model/xlsx/xlsx_converter.py
rename to mineru/model/flash/xlsx/xlsx_converter.py
index b1c02830..49b1025c 100644
--- a/mineru/model/xlsx/xlsx_converter.py
+++ b/mineru/model/flash/xlsx/xlsx_converter.py
@@ -20,9 +20,9 @@ from pydantic import BaseModel, Field, NonNegativeInt, PositiveInt
from pydantic.dataclasses import dataclass
from mineru.backend.utils.office_image import is_vector_image, serialize_vector_image_with_placeholder
-from mineru.model.docx.tools.math.omml import oMath2Latex
+from mineru.model.flash.docx.tools.math.omml import oMath2Latex
from mineru.model.office_stream import read_stream_bytes_from_start, rewind_stream
-from mineru.model.xlsx.package_normalizer import normalize_xlsx_package
+from mineru.model.flash.xlsx.package_normalizer import normalize_xlsx_package
from mineru.types import BlockType
from mineru.utils.pdf_reader import image_to_b64str
diff --git a/tests/unittest/_flash_pdf_test_utils.py b/tests/unittest/_flash_pdf_test_utils.py
index 6208f820..a1201bee 100644
--- a/tests/unittest/_flash_pdf_test_utils.py
+++ b/tests/unittest/_flash_pdf_test_utils.py
@@ -2,7 +2,7 @@ from __future__ import annotations
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
models,
)
diff --git a/tests/unittest/test_flash_model.py b/tests/unittest/test_flash_model.py
new file mode 100644
index 00000000..2c8dfc75
--- /dev/null
+++ b/tests/unittest/test_flash_model.py
@@ -0,0 +1,36 @@
+from __future__ import annotations
+
+import importlib
+from unittest.mock import MagicMock
+
+import pytest
+
+from mineru.model.flash import FlashModel
+from mineru.model.flash.native_pdf import pipeline
+from mineru.utils.pdf_document import PDFDocument
+
+
+def test_flash_model_predict_returns_native_model_list_without_owning_document(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """验证模型传递同一 PDFDocument,且不负责分类或关闭调用方文档。"""
+
+ pdf_doc = MagicMock(spec=PDFDocument)
+ expected_model_list = [[{"type": "text", "content": "native"}]]
+ native_analyze = MagicMock(return_value=expected_model_list)
+ monkeypatch.setattr(pipeline, "_analyze_native_document", native_analyze)
+
+ result = FlashModel().predict(pdf_doc)
+
+ assert result is expected_model_list
+ native_analyze.assert_called_once_with(pdf_doc)
+ pdf_doc.classify.assert_not_called()
+ pdf_doc.close.assert_not_called()
+
+
+def test_flash_model_is_public_and_old_native_pdf_import_is_removed() -> None:
+ """验证新模型入口公开可用,旧 backend native_pdf 路径不再兼容。"""
+
+ assert importlib.import_module("mineru.model.flash").FlashModel is FlashModel
+ with pytest.raises(ModuleNotFoundError):
+ importlib.import_module("mineru.backend.flash.native_pdf")
diff --git a/tests/unittest/test_flash_office_models.py b/tests/unittest/test_flash_office_models.py
new file mode 100644
index 00000000..b3e8da59
--- /dev/null
+++ b/tests/unittest/test_flash_office_models.py
@@ -0,0 +1,59 @@
+import importlib.util
+from collections.abc import Callable
+from pathlib import Path
+from typing import Any, BinaryIO
+
+import pytest
+
+from mineru.backend.office.docx_analyze import office_docx_analyze
+from mineru.backend.office.pptx_analyze import office_pptx_analyze
+from mineru.backend.office.xlsx_analyze import office_xlsx_analyze
+from mineru.model.flash.docx.main import convert_binary as convert_docx
+from mineru.model.flash.pptx.main import convert_binary as convert_pptx
+from mineru.model.flash.xlsx.main import convert_binary as convert_xlsx
+from mineru.parser.office import DocxParser, PptxParser, XlsxParser
+
+
+_OFFICE_SAMPLE_DIR = Path(__file__).resolve().parents[2] / "demo" / "office_docs"
+
+
+ ("suffix", "converter", "expected_pages", "expected_module"),
+ [
+ ("docx", convert_docx, 3, "mineru.model.flash.docx.main"),
+ ("pptx", convert_pptx, 6, "mineru.model.flash.pptx.main"),
+ ("xlsx", convert_xlsx, 3, "mineru.model.flash.xlsx.main"),
+ ],
+)
+def test_flash_office_model_conversion(
+ suffix: str,
+ converter: Callable[[BinaryIO], list[dict[str, Any]]],
+ expected_pages: int,
+ expected_module: str,
+) -> None:
+ """验证迁移后的 Office 模型入口与真实样例转换结果保持不变。"""
+
+ sample_path = _OFFICE_SAMPLE_DIR / f"{suffix}_01.{suffix}"
+ with sample_path.open("rb") as stream:
+ pages = converter(stream)
+
+ assert converter.__module__ == expected_module
+ assert len(pages) == expected_pages
+
+
+def test_office_parsers_bind_existing_analyzers() -> None:
+ """验证三个 Office Parser 仍绑定原有的后端分析入口。"""
+
+ assert DocxParser()._analyze_fn is office_docx_analyze
+ assert PptxParser()._analyze_fn is office_pptx_analyze
+ assert XlsxParser()._analyze_fn is office_xlsx_analyze
+
+
+ "module_name",
+ ["mineru.model.docx", "mineru.model.pptx", "mineru.model.xlsx"],
+)
+def test_legacy_office_model_paths_are_removed(module_name: str) -> None:
+ """验证迁移后不再暴露旧的 Office 模型包路径。"""
+
+ assert importlib.util.find_spec(module_name) is None
diff --git a/tests/unittest/test_flash_pdf_auxiliary_text.py b/tests/unittest/test_flash_pdf_auxiliary_text.py
index cdab8977..29bdd6b3 100644
--- a/tests/unittest/test_flash_pdf_auxiliary_text.py
+++ b/tests/unittest/test_flash_pdf_auxiliary_text.py
@@ -4,7 +4,7 @@ import inspect
import pytest
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
auxiliary_text,
models,
pipeline,
diff --git a/tests/unittest/test_flash_pdf_code_blocks.py b/tests/unittest/test_flash_pdf_code_blocks.py
index dad38e96..fc1bf0d1 100644
--- a/tests/unittest/test_flash_pdf_code_blocks.py
+++ b/tests/unittest/test_flash_pdf_code_blocks.py
@@ -4,7 +4,7 @@ from typing import Any
import pytest
-from mineru.backend.flash.native_pdf import code_blocks, models, pipeline
+from mineru.model.flash.native_pdf import code_blocks, models, pipeline
from mineru.backend.hybrid.table_text import project_pdf_spatial_text
from mineru.utils.pdf_document import PDFPathInfo
diff --git a/tests/unittest/test_flash_pdf_document_profile.py b/tests/unittest/test_flash_pdf_document_profile.py
index e29264a4..0b9e86c4 100644
--- a/tests/unittest/test_flash_pdf_document_profile.py
+++ b/tests/unittest/test_flash_pdf_document_profile.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from mineru.backend.flash.native_pdf import titles
+from mineru.model.flash.native_pdf import titles
from _flash_pdf_test_utils import _prepared_text_page, _text_line
diff --git a/tests/unittest/test_flash_pdf_extractor.py b/tests/unittest/test_flash_pdf_extractor.py
index 005f0575..934e3896 100644
--- a/tests/unittest/test_flash_pdf_extractor.py
+++ b/tests/unittest/test_flash_pdf_extractor.py
@@ -8,7 +8,8 @@ from unittest.mock import MagicMock
import pytest
from mineru.backend.flash import pdf_extractor
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash import FlashModel
+from mineru.model.flash.native_pdf import (
pipeline,
)
@@ -107,8 +108,8 @@ def test_txt_mode_keeps_native_flash_path(
monkeypatch,
classified_mode="txt",
)
- native_analyze = MagicMock(return_value=expected_model_list)
- monkeypatch.setattr(pipeline, "_analyze_native_document", native_analyze)
+ native_predict = MagicMock(return_value=expected_model_list)
+ monkeypatch.setattr(FlashModel, "predict", native_predict)
hybrid_doc_analyze = _install_hybrid_analyze(
monkeypatch,
model_list=[[{"type": "text", "content": "unexpected"}]],
@@ -121,8 +122,10 @@ def test_txt_mode_keeps_native_flash_path(
assert result is expected_model_list
assert pdf_doc.classify.call_count == expected_classify_calls
- native_analyze.assert_called_once_with(pdf_doc)
+ native_predict.assert_called_once_with(pdf_doc)
hybrid_doc_analyze.assert_not_called()
+
+
def test_invalid_parse_mode_is_rejected_before_opening_pdf(monkeypatch: pytest.MonkeyPatch) -> None:
"""验证非法解析模式在打开 PDF 前保持原有报错行为。"""
diff --git a/tests/unittest/test_flash_pdf_formulas.py b/tests/unittest/test_flash_pdf_formulas.py
index e823d360..f6765e16 100644
--- a/tests/unittest/test_flash_pdf_formulas.py
+++ b/tests/unittest/test_flash_pdf_formulas.py
@@ -5,7 +5,7 @@ from dataclasses import replace
import pytest
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
formulas,
geometry,
line_merging,
diff --git a/tests/unittest/test_flash_pdf_graphics.py b/tests/unittest/test_flash_pdf_graphics.py
index 24ccad9b..947057aa 100644
--- a/tests/unittest/test_flash_pdf_graphics.py
+++ b/tests/unittest/test_flash_pdf_graphics.py
@@ -5,7 +5,7 @@ import inspect
import pytest
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
graphics,
models,
pipeline,
diff --git a/tests/unittest/test_flash_pdf_index_blocks.py b/tests/unittest/test_flash_pdf_index_blocks.py
index 1cb2961b..9bed081d 100644
--- a/tests/unittest/test_flash_pdf_index_blocks.py
+++ b/tests/unittest/test_flash_pdf_index_blocks.py
@@ -2,7 +2,7 @@ from __future__ import annotations
import pytest
-from mineru.backend.flash.native_pdf import index_blocks
+from mineru.model.flash.native_pdf import index_blocks
from _flash_pdf_test_utils import _text_line
diff --git a/tests/unittest/test_flash_pdf_native_text.py b/tests/unittest/test_flash_pdf_native_text.py
index f2d66ac5..235b5194 100644
--- a/tests/unittest/test_flash_pdf_native_text.py
+++ b/tests/unittest/test_flash_pdf_native_text.py
@@ -5,7 +5,7 @@ from typing import Any
import pytest
-from mineru.backend.flash.native_pdf import native_text
+from mineru.model.flash.native_pdf import native_text
def _span(
diff --git a/tests/unittest/test_flash_pdf_pipeline.py b/tests/unittest/test_flash_pdf_pipeline.py
index 8f0a3bca..ac7b8130 100644
--- a/tests/unittest/test_flash_pdf_pipeline.py
+++ b/tests/unittest/test_flash_pdf_pipeline.py
@@ -6,7 +6,8 @@ import inspect
import pytest
from mineru.backend.flash import pdf_extractor
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash import FlashModel
+from mineru.model.flash.native_pdf import (
auxiliary_text,
formulas,
geometry,
@@ -187,6 +188,7 @@ def test_flash_extractor_has_no_local_ocr_runtime_logic() -> None:
inspect.getsource(module)
for module in (
pdf_extractor,
+ FlashModel,
auxiliary_text,
formulas,
geometry,
diff --git a/tests/unittest/test_flash_pdf_samples.py b/tests/unittest/test_flash_pdf_samples.py
index 873aff7c..a309cab6 100644
--- a/tests/unittest/test_flash_pdf_samples.py
+++ b/tests/unittest/test_flash_pdf_samples.py
@@ -7,7 +7,7 @@ import unicodedata
from mineru.backend.flash import pdf_extractor
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
formulas,
geometry,
graphics,
diff --git a/tests/unittest/test_flash_pdf_tables.py b/tests/unittest/test_flash_pdf_tables.py
index dbb914c1..8a964113 100644
--- a/tests/unittest/test_flash_pdf_tables.py
+++ b/tests/unittest/test_flash_pdf_tables.py
@@ -4,7 +4,7 @@ from unittest.mock import MagicMock
import pytest
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
geometry,
models,
tables,
diff --git a/tests/unittest/test_flash_pdf_text_blocks.py b/tests/unittest/test_flash_pdf_text_blocks.py
index 8f3d69e3..b25cd8c0 100644
--- a/tests/unittest/test_flash_pdf_text_blocks.py
+++ b/tests/unittest/test_flash_pdf_text_blocks.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import pytest
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
line_layout,
line_merging,
models,
diff --git a/tests/unittest/test_flash_pdf_titles.py b/tests/unittest/test_flash_pdf_titles.py
index e43a2713..e9ee329d 100644
--- a/tests/unittest/test_flash_pdf_titles.py
+++ b/tests/unittest/test_flash_pdf_titles.py
@@ -4,7 +4,7 @@ import inspect
import pytest
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
line_layout,
line_merging,
text_blocks,
diff --git a/tests/unittest/test_flash_pdf_visual_annotations.py b/tests/unittest/test_flash_pdf_visual_annotations.py
index 66df5301..cf287eba 100644
--- a/tests/unittest/test_flash_pdf_visual_annotations.py
+++ b/tests/unittest/test_flash_pdf_visual_annotations.py
@@ -2,7 +2,7 @@ from __future__ import annotations
import pytest
-from mineru.backend.flash.native_pdf import (
+from mineru.model.flash.native_pdf import (
geometry,
pipeline,
text_blocks,