mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-15 00:16:46 +00:00
Implement anydoc with docling
This commit is contained in:
1 parent
e0aff39a1b
commit
e101c0a7f1
18 files changed
+1443
-153
No files matched your search
@@ -153,9 +153,17 @@ def test_threshold_sends_sparse_text_to_fallback(tmp_path, parser_cls):
|
||||
|
||||
|
||||
# --- extractor wiring: the guard that source ingestion keeps docling ---------
|
||||
# (under the docling engine; the anydoc engine ignores the fast path, see below)
|
||||
|
||||
|
||||
def test_extractor_defaults_to_docling_for_pdf():
|
||||
@pytest.fixture
|
||||
def docling_engine(monkeypatch):
|
||||
from application.core.settings import settings
|
||||
|
||||
monkeypatch.setattr(settings, "DOC_PARSER_ENGINE", "docling")
|
||||
|
||||
|
||||
def test_extractor_defaults_to_docling_for_pdf(docling_engine):
|
||||
"""Sources must be unaffected: no fast path unless explicitly requested."""
|
||||
from application.parser.file.bulk import get_default_file_extractor
|
||||
|
||||
@@ -164,7 +172,7 @@ def test_extractor_defaults_to_docling_for_pdf():
|
||||
assert type(pdf_parser).__name__ == "DoclingPDFParser"
|
||||
|
||||
|
||||
def test_extractor_uses_fast_path_when_requested():
|
||||
def test_extractor_uses_fast_path_when_requested(docling_engine):
|
||||
from application.parser.file.bulk import get_default_file_extractor
|
||||
from application.parser.file.pdfium_parser import PdfiumTextParser
|
||||
|
||||
@@ -174,7 +182,20 @@ def test_extractor_uses_fast_path_when_requested():
|
||||
assert type(pdf_parser.fallback_parser).__name__ == "DoclingPDFParser"
|
||||
|
||||
|
||||
def test_fast_path_does_not_change_non_pdf_parsers():
|
||||
def test_anydoc_engine_ignores_fast_path(monkeypatch):
|
||||
"""anydoc already reads the text layer in milliseconds and keeps structure."""
|
||||
pytest.importorskip("anydoc")
|
||||
from application.core.settings import settings
|
||||
from application.parser.file.bulk import get_default_file_extractor
|
||||
|
||||
monkeypatch.setattr(settings, "DOC_PARSER_ENGINE", "anydoc")
|
||||
|
||||
pdf_parser = get_default_file_extractor(pdf_text_fast_path=True)[".pdf"]
|
||||
|
||||
assert type(pdf_parser).__name__ == "AnydocParser"
|
||||
|
||||
|
||||
def test_fast_path_does_not_change_non_pdf_parsers(docling_engine):
|
||||
from application.parser.file.bulk import get_default_file_extractor
|
||||
|
||||
plain = get_default_file_extractor()
|
||||
|
||||
Reference in new issue
Block a user