pub struct RunnableToSummarizerAdapter<R> { /* private fields */ }Expand description
Summarizer that delegates to any
Runnable<Vec<Message>, Message> — the same shape as a chat
model. Prepends a configurable system instruction so the model
understands the task even when the buffer itself contains only
raw user/assistant turns.
Implementations§
Source§impl<R> RunnableToSummarizerAdapter<R>
impl<R> RunnableToSummarizerAdapter<R>
Sourcepub fn new(runnable: R) -> Self
pub fn new(runnable: R) -> Self
Build a summariser using runnable and the default system
instruction.
Sourcepub fn from_arc(runnable: Arc<R>) -> Self
pub fn from_arc(runnable: Arc<R>) -> Self
Build a summariser using an Arc-wrapped runnable. Useful
when the same model serves multiple memories or is shared
with other parts of the agent.
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Override the system instruction. Use to inject domain-specific summary guidance (“preserve transaction IDs verbatim”; “always summarise in the user’s preferred language”).
Trait Implementations§
Source§impl<R> Summarizer for RunnableToSummarizerAdapter<R>
impl<R> Summarizer for RunnableToSummarizerAdapter<R>
Source§fn summarize<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
ctx: &'life1 ExecutionContext,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn summarize<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
ctx: &'life1 ExecutionContext,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Summarise
messages into a single string. Returning Err
signals a transient failure — the consolidating buffer
keeps the original messages and re-attempts next call.Auto Trait Implementations§
impl<R> Freeze for RunnableToSummarizerAdapter<R>
impl<R> RefUnwindSafe for RunnableToSummarizerAdapter<R>where
R: RefUnwindSafe,
impl<R> Send for RunnableToSummarizerAdapter<R>
impl<R> Sync for RunnableToSummarizerAdapter<R>
impl<R> Unpin for RunnableToSummarizerAdapter<R>
impl<R> UnsafeUnpin for RunnableToSummarizerAdapter<R>
impl<R> UnwindSafe for RunnableToSummarizerAdapter<R>where
R: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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