agrag.chunking.rules.Chunking
Bases: BaseModel
An ordered list of chunking rules and a fallback chunker.
The first rule that matches a document picks its chunker. A document that no
rule matches gets fallback.
Attributes:
- rules (
tuple[ChunkingRule, ...]) – The rules, most specific first. - fallback (
SerializeAsAny[Chunker]) – The chunker for documents that no rule matches.
Functions:
- fingerprint – Return a hash of every rule match and every chunker setting.
- select – Pick the chunker for a document.
fallback
fallback: SerializeAsAny[Chunker]
fingerprint
fingerprint() -> str
Return a hash of every rule match and every chunker setting.
model_config
model_config = ConfigDict(frozen=True, extra='forbid')
rules
rules: tuple[ChunkingRule, ...] = ()
select
select(document:Document) -> tuple[int | None, Chunker]
Pick the chunker for a document.
Parameters:
- document (
Document) – The document to chunk.
Returns:
int | None– The index of the first matching rule and its chunker, orNoneandChunker– the fallback when no rule matches.