# document.Document


A document containing text content to be chunked and indexed.


Usage

``` python
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](document.ChunkedDocument.md#raghilda.document.ChunkedDocument) before being embedded and written to a store. [Document](document.Document.md#raghilda.document.Document) is the base type; [MarkdownDocument](document.MarkdownDocument.md#raghilda.document.MarkdownDocument) is the common concrete variant produced by [read_as_markdown()](read.read_as_markdown.md#raghilda.read.read_as_markdown).


## Parameters


`content: str`  
The full text content of the document.

`origin: str | None = 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: dict[str, Any] | None = 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()](#from_any) | Convert any document-like or IntoDocument object to a raghilda Document. |
| [to_chunked()](#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

``` python
from_any(doc)
```


This conversion only accepts unchunked inputs. If the source object already carries chunks, use [ChunkedDocument.from_any()](document.ChunkedDocument.md#raghilda.document.ChunkedDocument.from_any) instead.


#### Parameters


`doc: DocumentLike | IntoDocument`  
An object that implements the DocumentLike protocol or has a [to_document()](types.IntoDocument.md#raghilda.types.IntoDocument.to_document) method.


#### Returns


`Document`  
A raghilda Document instance.


------------------------------------------------------------------------


### to_chunked()


Return a ChunkedDocument with the same fields and supplied chunks.


Usage

``` python
to_chunked(chunks)
```
