document.Document
A document containing text content to be chunked and indexed.
Usage
document.Document(
content,
origin=None,
attributes=None,
)Documents are the primary input for RAG stores. Each document holds the full text to be indexed plus an optional origin identifying where it came from. A document is chunked into a ChunkedDocument before being embedded and written to a store. Document is the base type; MarkdownDocument is the common concrete variant produced by read_as_markdown().
Parameters
content: str-
The full text content of the document.
origin: Optional[str] = None-
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]] = None- 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
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
to_chunked(chunks)