Module: mellea.stdlib.docs.richdocument

Representations of Docling Documents.

Classes

class mellea.stdlib.docs.richdocument.RichDocument(doc: DoclingDocument)

A RichDocument is a block of content with an underlying DoclingDocument. It has helper functions for working with the document and extracting parts of it.

Constructor

A RichDocument is a block of content with an underlying DoclingDocument.

Methods

mellea.stdlib.docs.richdocument.RichDocument.parts()
A RichDocument has no parts.
mellea.stdlib.docs.richdocument.RichDocument.format_for_llm()
Return Document content as Markdown. No template needed here.
mellea.stdlib.docs.richdocument.RichDocument.docling()
Get the underlying Docling Document.
mellea.stdlib.docs.richdocument.RichDocument.to_markdown()
Get the full text of the document as markdown.
mellea.stdlib.docs.richdocument.RichDocument.get_tables()
Return the Tables that are a part of this document.
mellea.stdlib.docs.richdocument.RichDocument.save(filename: str | Path)
Save the underlying DoclingDocument for reuse later.
mellea.stdlib.docs.richdocument.RichDocument.load(filename: str | Path)
Load a DoclingDocument from a file. The file must already be a DoclingDocument.
mellea.stdlib.docs.richdocument.RichDocument.from_document_file(source: str | Path | DocumentStream)
Process a document with Docling.

class mellea.stdlib.docs.richdocument.TableQuery(obj: Table, query: str)

Table-specific query.

Constructor

Initializes a new instance of the TableQuery class.

Arguments

  • obj: The table object to which the query applies.
  • query: The query string.

Methods

mellea.stdlib.docs.richdocument.TableQuery.format_for_llm()
Template arguments for Formatter.

class mellea.stdlib.docs.richdocument.TableTransform(obj: Table, transformation: str)

Table-specific transform.

Constructor

Initializes a new instance of the TableTransform class.

Arguments

  • obj: The table object to which the transform applies.
  • transformation: The transformation description string.

Methods

mellea.stdlib.docs.richdocument.TableTransform.format_for_llm()
Template arguments for Formatter.

class mellea.stdlib.docs.richdocument.Table(ti: TableItem, doc: DoclingDocument)

A Table represents a single table within a larger Docling Document.

Constructor

If you pass doc=None, the underlying docling functions to extract data from tables may fail due to lack of context and docling deprecations.

Methods

mellea.stdlib.docs.richdocument.Table.from_markdown(md: str)
Creates a fake document from the markdown and attempts to extract the first table found.
mellea.stdlib.docs.richdocument.Table.to_markdown()
Get the Table as markdown.
mellea.stdlib.docs.richdocument.Table.transpose()
Transposes the table. Will return a new transposed Table if successful.
mellea.stdlib.docs.richdocument.Table.format_for_llm()
Return Table representation for Formatter.