Skip to main content

CompactionStrategy

Trait CompactionStrategy 

Source
pub trait CompactionStrategy: Send + Sync {
    // Required method
    fn compact(
        &self,
        messages: &[Message],
        tokenizer: &dyn Tokenizer,
    ) -> Vec<Message>;
}
Expand description

A strategy that reduces a message list to fit some constraint.

Compaction never errors on content — it always returns some retained subset of messages, in original order. Rust equivalent of upstream CompactionStrategy.

Required Methods§

Source

fn compact( &self, messages: &[Message], tokenizer: &dyn Tokenizer, ) -> Vec<Message>

Return the retained messages (in original order) after compaction.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§