Skip to main content

CompactionRule

Trait CompactionRule 

Source
pub trait CompactionRule: Send + Sync {
    // Required methods
    fn should_compact(&self, messages: &[ChatMessage]) -> bool;
    fn select_targets(&self, messages: &[ChatMessage]) -> Vec<usize>;
    fn apply_compaction(&self, messages: &mut [ChatMessage], targets: &[usize]);
}
Expand description

A trait for defining custom compaction rules

Required Methods§

Source

fn should_compact(&self, messages: &[ChatMessage]) -> bool

Determine if compaction should be performed on the given messages

Source

fn select_targets(&self, messages: &[ChatMessage]) -> Vec<usize>

Select which message indices should be targeted for compaction

Source

fn apply_compaction(&self, messages: &mut [ChatMessage], targets: &[usize])

Apply the compaction to the selected messages

Implementors§