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.
Auto Trait Implementations§
impl<D> Freeze for ChunkingDistiller<D>where
D: Freeze,
impl<D> RefUnwindSafe for ChunkingDistiller<D>where
D: RefUnwindSafe,
impl<D> Send for ChunkingDistiller<D>
impl<D> Sync for ChunkingDistiller<D>
impl<D> Unpin for ChunkingDistiller<D>where
D: Unpin,
impl<D> UnsafeUnpin for ChunkingDistiller<D>where
D: UnsafeUnpin,
impl<D> UnwindSafe for ChunkingDistiller<D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more