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§
Sourcefn should_compact(&self, messages: &[ChatMessage]) -> bool
fn should_compact(&self, messages: &[ChatMessage]) -> bool
Determine if compaction should be performed on the given messages
Sourcefn select_targets(&self, messages: &[ChatMessage]) -> Vec<usize>
fn select_targets(&self, messages: &[ChatMessage]) -> Vec<usize>
Select which message indices should be targeted for compaction
Sourcefn apply_compaction(&self, messages: &mut [ChatMessage], targets: &[usize])
fn apply_compaction(&self, messages: &mut [ChatMessage], targets: &[usize])
Apply the compaction to the selected messages