Skip to main content

A python library to simplify agentic operations on documents, such as writing, editing, summarizing, extracting, and enriching.

Project description

uv Ruff Pydantic v2 pre-commit License MIT LF AI & Data

Docling-Agent

Docling-agent simplifies agentic operation on documents, such as writing, editing, summarizing, etc.

[!NOTE] This package is still immature and work-in-progress. We are happy to get comments, suggestions, code contributions, etc!

Features

  • Document writing: Generate well-structured reports from natural prompts and export to JSON/Markdown/HTML.
  • Targeted editing: Load an existing Docling JSON and apply focused edits with natural-language tasks.
  • Schema-guided extraction: Extract typed fields from PDFs/images using a simple schema and produce HTML reports. See examples on curriculum_vitae, papers, invoices, etc.
  • Document enrichment: Enrich existing documents with summaries, search keywords, key entities, and item classifications (language/function).
  • Model-agnostic: Choose mellea, ollama, lmstudio, or litellm through backend configuration.
  • Simple API surface: Use agent.run(...) with DoclingDocument in/out; save via save_as_* helpers.
  • Optional tools: Integrate external tools (e.g., MCP) when available.

Quick start (writing):

from docling_agent.agents import BackendConfig, DoclingWritingAgent, ModelConfig, create_backend

backend = create_backend(
    BackendConfig(
        type="ollama",
        base_url="http://localhost:11434",
        models=ModelConfig(reasoning="qwen3:8b", writing="qwen3:8b"),
    )
)
agent = DoclingWritingAgent(backend=backend, tools=[])
doc = agent.run("Write a one-page summary about polymers in food packaging.")
doc.save_as_html("report.html")

Installation

Coming soon

Getting started

Below are three minimal, end-to-end examples mirroring the scripts in the examples folder. Each snippet shows how to initialize an agent, run a task, and save the result.

Write a new document (see example):

from docling_agent.agents import BackendConfig, DoclingWritingAgent, ModelConfig, create_backend

backend = create_backend(
    BackendConfig(
        type="ollama",
        base_url="http://localhost:11434",
        models=ModelConfig(reasoning="qwen3:8b", writing="qwen3:8b"),
    )
)
agent = DoclingWritingAgent(backend=backend, tools=[])
doc = agent.run("Write a brief report on polymers in food packaging with a small comparison table.")
doc.save_as_html("./scratch/report.html")

Edit an existing document (see example):

Use natural-language tasks to update a Docling JSON. You can run multiple tasks to iteratively refine content, structure, or formatting.

from pathlib import Path
from docling_core.types.doc.document import DoclingDocument
from docling_agent.agents import BackendConfig, DoclingEditingAgent, ModelConfig, create_backend

ipath = Path("./examples/example_02_edit_resources/20250815_125216.json")
doc = DoclingDocument.load_from_json(ipath)

backend = create_backend(
    BackendConfig(
        type="mellea",
        models=ModelConfig(reasoning="OPENAI_GPT_OSS_20B", writing="OPENAI_GPT_OSS_20B"),
    )
)
agent = DoclingEditingAgent(backend=backend, tools=[])
updated = agent.run(task="Put polymer abbreviations in a separate column in the first table.", document=doc)
updated.save_as_html("./scratch/updated_table.html")

Extract structured data with a schema (see example):

Define a simple schema and provide a list of files (PDFs/images). The agent produces an HTML report with extracted fields.

from pathlib import Path
from docling_agent.agents import BackendConfig, DoclingExtractingAgent, ModelConfig, create_backend

schema = {"invoice-number": "string", "total": "float", "currency": "string"}
sources = sorted([p for p in Path("./examples/example_03_extract/invoices").rglob("*.*") if p.suffix.lower() in {".pdf", ".png", ".jpg", ".jpeg"}])

backend = create_backend(
    BackendConfig(
        type="mellea",
        models=ModelConfig(reasoning="OPENAI_GPT_OSS_20B", writing="OPENAI_GPT_OSS_20B"),
    )
)
agent = DoclingExtractingAgent(backend=backend, tools=[])
report = agent.run(task=str(schema), sources=sources)
report.save_as_html("./scratch/invoices_extraction_report.html")

Enrich an existing document (see example):

Run enrichment passes like summaries, keywords, entities, and classifications on a Docling JSON.

from pathlib import Path
from docling_core.types.doc.document import DoclingDocument
from docling_agent.agents import BackendConfig, DoclingEnrichingAgent, ModelConfig, create_backend

ipath = Path("./examples/example_02_edit_resources/20250815_125216.json")
doc = DoclingDocument.load_from_json(ipath)

backend = create_backend(
    BackendConfig(
        type="mellea",
        models=ModelConfig(reasoning="OPENAI_GPT_OSS_20B", writing="OPENAI_GPT_OSS_20B"),
    )
)
agent = DoclingEnrichingAgent(backend=backend, tools=[])
enriched = agent.run(task="Summarize each paragraph, table, and section header.", document=doc)
enriched.save_as_html("./scratch/enriched_summaries.html")

Backend Configuration

Task files now select the backend explicitly:

backend:
  type: ollama  # mellea | ollama | lmstudio | litellm
  base_url: http://localhost:11434
  timeout: 120
  models:
    reasoning: qwen3:8b
    writing: qwen3:8b

Typical defaults:

  • mellea: model names like OPENAI_GPT_OSS_20B
  • ollama: model names like qwen3:8b
  • lmstudio: model names like granite-3.3-8b-instruct
  • litellm: routed model names like openai/gpt-4.1-mini

Documentation

Coming soon

Examples

Go hands-on with our examples, demonstrating how to address different application use cases with Docling.

Integrations

To further accelerate your AI application development, check out Docling's native integrations with popular frameworks and tools.

Get help and support

Please feel free to connect with us using the discussion section.

Technical report

For more details on Docling's inner workings, check out the Docling Technical Report.

Contributing

Please read Contributing to Docling for details.

References

If you use Docling or Docling-agent in your projects, please consider citing the following:

@techreport{Docling,
  author = {Deep Search Team},
  month = {8},
  title = {Docling Technical Report},
  url = {https://arxiv.org/abs/2408.09869},
  eprint = {2408.09869},
  doi = {10.48550/arXiv.2408.09869},
  version = {1.0.0},
  year = {2024}
}

License

The Docling codebase is under MIT license. For individual model usage, please refer to the model licenses found in the original packages.

LF AI & Data

Docling is hosted as a project in the LF AI & Data Foundation.

IBM ❤️ Open Source AI

The project was started by the AI for knowledge team at IBM Research Zurich.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docling_agent-0.2.0.tar.gz (57.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docling_agent-0.2.0-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

Details for the file docling_agent-0.2.0.tar.gz.

File metadata

  • Download URL: docling_agent-0.2.0.tar.gz
  • Upload date:
  • Size: 57.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for docling_agent-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9d90685635300ffa8ca8c571d9f8a0407ee253c28367ced0bf2843aa2e0822b7
MD5 55a357dbae79cf679f5310e881f9e219
BLAKE2b-256 f43349d37d84a6822bead74cf8be50a813c5572b15662411bacc2cfda259a13d

See more details on using hashes here.

Provenance

The following attestation bundles were made for docling_agent-0.2.0.tar.gz:

Publisher: pypi.yml on docling-project/docling-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docling_agent-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: docling_agent-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 70.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for docling_agent-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9af822c27a39a2d10fc68188160f44f5f098b5d8b075f1131ee71c5ab3cbddb1
MD5 7b6437dfde406a51dad7f67db23b0c79
BLAKE2b-256 e6ecd3d1077ef2173529294b861ae82e4895be3f51f62da8018a8d31ecdafdd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for docling_agent-0.2.0-py3-none-any.whl:

Publisher: pypi.yml on docling-project/docling-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page