Version: 0.0.5 (stable)
agrag.loaders.docling.loader.DoclingLoader
Bases: ProseLoader
Reads Markdown, HTML, AsciiDoc, DOCX, PPTX and XLSX files with docling.
The loader gives a document its sections from the structure that docling finds. It needs no model and no extra. The content hash comes from the raw source bytes, because the parsed output can change between docling versions and runs.
Attributes:
- extensions – The formats this loader reads.
Functions:
- is_available – Return whether the package that the loader's extra installs is present.
- load – Yield one prose Document parsed by docling.
extensions
extensions = frozenset(_formats)
extra
extra: str | None = None
extra_module
extra_module: str | None = None
family
family = DocumentFamily.PROSE
is_available
is_available() -> bool
Return whether the package that the loader's extra installs is present.
A loader with no extra is always available. The check looks the module up without importing it, so an installed package that fails to import still counts.
load
load(source:SourceRef, stream:BinaryIO, opts:ReadOptions, *, start_at:int = 0) -> Iterator[Document]
Yield one prose Document parsed by docling.
Parameters:
- source (
SourceRef) – The source to read. - stream (
BinaryIO) – The open binary stream for the source. - opts (
ReadOptions) – The read options. - start_at (
int) – Ignored by prose loaders.
Yields:
Document– One Document. Whenopts.store_textis on, its text is the doclingDocument– Markdown export and its sections hold the content; with the flag offDocument– both are empty. Its title is the first heading, or the file name whenDocument– the source has no heading.
Raises:
DocumentTooLargeError– The source is larger than the configured byte limit.MissingExtraError–DoclingPdfLoaderonly. A package that docling needs is not installed, and the error names thedoclingextra. It is anUnsupportedFormatError, so SKIP and QUARANTINE treat it like an unsupported format.ImportError–DoclingLoaderonly. A package that docling needs is not installed. This is an install problem, not a problem with the source, so the walker policies do not catch it.DocumentConversionError– Docling or its export failed on the source, for any other reason. Walker policies such as SKIP and QUARANTINE catch this error.ValueError–opts.max_document_bytesis not a positive integer.
mime_types
mime_types: frozenset[str] = frozenset()