chunk.Chunk
A segment of text extracted from a document.
Usage
chunk.Chunk()Chunks are the fundamental unit for retrieval in RAG applications. Each chunk contains the text content along with positional information that allows mapping back to the original document.
Parameter Attributes
text: strstart_index: intend_index: intchar_count: intcontext: Optional[str] = Noneorigin: Optional[str] = Noneattributes: Optional[dict[str, Any]] = None
Attributes
text: str-
The actual text content of the chunk.
start_index: int-
Character position where this chunk begins in the source document.
end_index: int-
Character position where this chunk ends in the source document.
char_count: int-
Number of characters in this chunk.
context: Optional[str]-
Optional heading context showing the document hierarchy at this chunk’s position (e.g., the Markdown headings that apply).
origin: Optional[str]-
Origin of the parent document this chunk belongs to.
attributes: Optional[dict[str, Any]]- Optional user-defined attributes associated with the chunk. These attributes can be used for retrieval filtering/scoping and downstream prompt/context construction.
Methods
| Name | Description |
|---|---|
| from_any() | Convert any chunk-like or IntoChunk object to a raghilda Chunk. |
from_any()
Convert any chunk-like or IntoChunk object to a raghilda Chunk.
Usage
from_any(chunk)Parameters
chunk: Union[ChunkLike, IntoChunk]-
An object that implements the ChunkLike protocol or has a
to_chunk()method.
Returns
Chunk- A raghilda Chunk instance.