Skip to content

docling-project/docling-agent

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.
  • Model-agnostic: Plug in different backends via Mellea model_ids (e.g., OpenAI GPT OSS, IBM Granite).
  • 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 mellea.backends import model_ids
from docling_agent.agents import DoclingWritingAgent

agent = DoclingWritingAgent(model_id=model_ids.OPENAI_GPT_OSS_20B)
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 mellea.backends import model_ids
from docling_agent.agents import DoclingWritingAgent

agent = DoclingWritingAgent(model_id=model_ids.OPENAI_GPT_OSS_20B)
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 mellea.backends import model_ids
from docling_core.types.doc.document import DoclingDocument
from docling_agent.agents import DoclingEditingAgent

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

agent = DoclingEditingAgent(model_id=model_ids.OPENAI_GPT_OSS_20B)
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 mellea.backends import model_ids
from docling_agent.agents import DoclingExtractingAgent

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"}])

agent = DoclingExtractingAgent(model_id=model_ids.OPENAI_GPT_OSS_20B)
report = agent.run(task=str(schema), sources=sources)
report.save_as_html("./scratch/invoices_extraction_report.html")

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.

About

Agent that read, write and edit documents.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages