Skip to main content
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:

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. When opts.store_text is on, its text is the docling
  • Document – Markdown export and its sections hold the content; with the flag off
  • Document – both are empty. Its title is the first heading, or the file name when
  • Document – the source has no heading.

Raises:

  • DocumentTooLargeError – The source is larger than the configured byte limit.
  • MissingExtraError – DoclingPdfLoader only. A package that docling needs is not installed, and the error names the docling extra. It is an UnsupportedFormatError, so SKIP and QUARANTINE treat it like an unsupported format.
  • ImportError – DoclingLoader only. 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_bytes is not a positive integer.

mime_types​

mime_types: frozenset[str] = frozenset()