document.Document

A document containing text content to be chunked and indexed.

Usage

Source

document.Document()

Documents are the primary input for RAG stores. Each document has text content and an optional origin identifier.

Parameter Attributes

content: str
origin: Optional[str] = None
attributes: Optional[dict[str, Any]] = None

Attributes

content: str

The full text content of the document.

origin: Optional[str]

Unique origin identifier for the document. This can be None or an empty string while preparing a document object, but stores require a populated origin for upsert operations.

attributes: Optional[dict[str, Any]]
Optional user-defined attributes applied at document insertion time. Document-level attributes can be inherited by chunks and returned during retrieval for filtering and downstream prompt/context use.

Methods

Name Description
from_any() Convert any document-like or IntoDocument object to a raghilda Document.
to_chunked() Return a ChunkedDocument with the same fields and supplied chunks.

from_any()

Convert any document-like or IntoDocument object to a raghilda Document.

Usage

Source

from_any(doc)

This conversion only accepts unchunked inputs. If the source object already carries chunks, use ChunkedDocument.from_any() instead.

Parameters
doc: Union[DocumentLike, IntoDocument]
An object that implements the DocumentLike protocol or has a to_document() method.
Returns
Document
A raghilda Document instance.

to_chunked()

Return a ChunkedDocument with the same fields and supplied chunks.

Usage

Source

to_chunked(chunks)