Skip to main content

Summarizer

Trait Summarizer 

Source
pub trait Summarizer: Send + Sync {
    // Required methods
    fn should_summarize(&self, history: &[Message]) -> bool;
    fn summarize(&self, history: &mut Vec<Message>) -> Option<Message>;
}
Expand description

Summarizer trait:

  • should_summarize checks whether current history should be summarized
  • summarize mutates the history to replace older messages with a single short system summary message

Required Methods§

Source

fn should_summarize(&self, history: &[Message]) -> bool

Return true if history should be summarized now.

Source

fn summarize(&self, history: &mut Vec<Message>) -> Option<Message>

Perform summarization by mutating history. If a summary was created and applied, return Some(Message) representing the inserted summary message. If nothing was done, return None.

Implementors§