Files
deepset-ai--haystack/docs-website/reference_versioned_docs/version-2.25/integrations-api/docling.md
T
wehub-resource-sync c56bef871b
Sync docs with Docusaurus / sync (push) Waiting to run
Tests / Check if changed (push) Waiting to run
Tests / format (push) Blocked by required conditions
Tests / check-imports (push) Blocked by required conditions
Tests / Unit / macos-latest (push) Blocked by required conditions
Tests / Unit / ubuntu-latest (push) Blocked by required conditions
Tests / Unit / windows-latest (push) Blocked by required conditions
Tests / mypy (push) Blocked by required conditions
Tests / Integration / ubuntu-latest (push) Blocked by required conditions
Tests / Integration / macos-latest (push) Blocked by required conditions
Tests / Integration / windows-latest (push) Blocked by required conditions
Tests / notify-slack-on-failure (push) Blocked by required conditions
Tests / Mark tests as completed (push) Blocked by required conditions
Docker image release / Build base image (push) Waiting to run
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:22:28 +08:00

4.9 KiB
Raw Blame History

title, id, description, slug
title id description slug
Docling integrations-docling Docling integration for Haystack /integrations-docling

haystack_integrations.components.converters.docling.converter

Docling Haystack converter module.

ExportType

Bases: str, Enum

Enumeration of available export types.

BaseMetaExtractor

Bases: ABC

BaseMetaExtractor.

extract_chunk_meta

extract_chunk_meta(chunk: BaseChunk) -> dict[str, Any]

Extract chunk meta.

extract_dl_doc_meta

extract_dl_doc_meta(dl_doc: DoclingDocument) -> dict[str, Any]

Extract Docling document meta.

to_dict

to_dict() -> dict[str, Any]

Serialize to a dictionary.

from_dict

from_dict(data: dict[str, Any]) -> BaseMetaExtractor

Deserialize from a dictionary.

MetaExtractor

Bases: BaseMetaExtractor

MetaExtractor.

extract_chunk_meta

extract_chunk_meta(chunk: BaseChunk) -> dict[str, Any]

Extract chunk meta.

extract_dl_doc_meta

extract_dl_doc_meta(dl_doc: DoclingDocument) -> dict[str, Any]

Extract Docling document meta.

DoclingConverter

Docling Haystack converter.

init

__init__(
    converter: DocumentConverter | None = None,
    convert_kwargs: dict[str, Any] | None = None,
    export_type: ExportType = ExportType.MARKDOWN,
    md_export_kwargs: dict[str, Any] | None = None,
    chunker: BaseChunker | None = None,
    meta_extractor: BaseMetaExtractor | None = None,
) -> None

Create a Docling Haystack converter.

Parameters:

  • converter (DocumentConverter | None) The Docling DocumentConverter to use; if not set, a system default is used.
  • convert_kwargs (dict[str, Any] | None) Any parameters to pass to Docling conversion; if not set, a system default is used.
  • export_type (ExportType) The export mode to use:
  • ExportType.MARKDOWN (default) captures each input document as a single markdown Document.
  • ExportType.DOC_CHUNKS first chunks each input document and then returns one Document per chunk.
  • ExportType.JSON serializes the full Docling document to a JSON string.
  • md_export_kwargs (dict[str, Any] | None) Any parameters to pass to Markdown export (applicable in case of ExportType.MARKDOWN).
  • chunker (BaseChunker | None) The Docling chunker instance to use; if not set, a system default is used.
  • meta_extractor (BaseMetaExtractor | None) The extractor instance to use for populating the output document metadata; if not set, a system default is used.

warm_up

warm_up() -> None

Build the default HybridChunker for ExportType.DOC_CHUNKS if no chunker was passed at init time.

Deferred to warm-up time because constructing the default chunker downloads a Hugging Face tokenizer.

to_dict

to_dict() -> dict[str, Any]

Serialize this component to a dictionary.

from_dict

from_dict(data: dict[str, Any]) -> DoclingConverter

Deserialize this component from a dictionary.

The converter and chunker parameters are not serializable and are always ignored during deserialization; the restored instance will use the default DocumentConverter and HybridChunker respectively.

Parameters:

  • data (dict[str, Any]) Dictionary with keys type and init_parameters, as produced by to_dict.

Returns:

  • DoclingConverter A new DoclingConverter instance.

run

run(
    paths: list[str | Path] | None = None,
    sources: list[str | Path | ByteStream] | None = None,
    meta: dict[str, Any] | list[dict[str, Any]] | None = None,
) -> dict[str, list[Document]]

Run the DoclingConverter.

Parameters:

  • paths (list[str | Path] | None) Deprecated. Use sources instead.
  • sources (list[str | Path | ByteStream] | None) List of file paths, URLs, or ByteStream objects to convert.
  • meta (dict[str, Any] | list[dict[str, Any]] | None) Optional metadata to attach to the Documents. This value can be either a list of dictionaries or a single dictionary. If it's a single dictionary, its content is added to the metadata of all produced Documents. If it's a list, the length of the list must match the number of sources, because the two lists will be zipped. If a source is a ByteStream, its own metadata is also merged into the output.

Returns:

  • dict[str, list[Document]] A dictionary with key "documents" containing the output Haystack Documents.

Raises:

  • ValueError If meta is a list whose length does not match the number of sources.
  • RuntimeError If an unexpected export_type is encountered.