pub struct ChunkingDistiller<D: Distiller> { /* private fields */ }Expand description
A Distiller decorator that bounds the size of any single prompt sent
to inner.
A long transcript is split into chunks of at most max_chunk_chars (via
split_on_budget), each chunk is distilled independently through
inner, and the partial results are combined into one
DistilledMemory (via an internal reduce step, using the configured
ReduceStrategy). A transcript that already fits in one chunk — including
an empty transcript — is passed through to inner unchanged, with no
splitting or reducing.
max_chunk_chars is caller-supplied policy: this type has no opinion on
what a safe prompt size is for any particular model or host, only on how
to split, map, and reduce once a budget is given.
Implementations§
Source§impl<D: Distiller> ChunkingDistiller<D>
impl<D: Distiller> ChunkingDistiller<D>
Sourcepub fn new(inner: D, max_chunk_chars: usize) -> Self
pub fn new(inner: D, max_chunk_chars: usize) -> Self
Wraps inner, splitting any transcript over max_chunk_chars into
multiple distillation calls. Uses ReduceStrategy::Structural to
combine the results; call Self::with_reduce_strategy to use
ReduceStrategy::Llm instead.
Sourcepub fn with_reduce_strategy(self, strategy: ReduceStrategy) -> Self
pub fn with_reduce_strategy(self, strategy: ReduceStrategy) -> Self
Sets the ReduceStrategy used to combine chunk results.
Trait Implementations§
Source§impl<D: Distiller> Distiller for ChunkingDistiller<D>
impl<D: Distiller> Distiller for ChunkingDistiller<D>
Source§fn distill(&self, transcript: &str) -> Result<DistilledMemory>
fn distill(&self, transcript: &str) -> Result<DistilledMemory>
§Errors
Returns an error if any chunk’s call to inner.distill fails, or if
ReduceStrategy::Llm is used and the consolidating call fails. On
error, no partial result is produced: chunks already distilled
successfully before the failure are discarded, not saved or returned.