Skip to main content

Summarizer

Trait Summarizer 

Source
pub trait Summarizer: Send + Sync {
    // Required method
    fn summarize<'life0, 'life1, 'async_trait>(
        &'life0 self,
        messages: &'life1 [ChatMessage],
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn max_batch_size(&self) -> usize { ... }
    fn merge_summaries<'life0, 'life1, 'async_trait>(
        &'life0 self,
        summaries: &'life1 [String],
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Summarizes conversation messages for memory compression.

Built-in implementations: LLMSummarizer (uses an LLM to generate summaries) and NoopSummarizer (concatenates messages, for testing). Most users use LLMSummarizer, auto-configured from the YAML summarizer_llm field.

Required Methods§

Source

fn summarize<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [ChatMessage], ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Produce a summary from a batch of messages.

Provided Methods§

Source

fn max_batch_size(&self) -> usize

Maximum messages per summarization call. Returns 20 by default.

Source

fn merge_summaries<'life0, 'life1, 'async_trait>( &'life0 self, summaries: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Combine multiple summaries into one. Joins with \n\n by default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§