pub struct CompactionStrategy {
pub strategy_type: CompactionStrategyType,
pub target_tokens: usize,
pub min_preserve_percent: u8,
pub segments_to_compact: Option<Vec<ContextSegmentType>>,
pub protected_segments: Option<Vec<ContextSegmentType>>,
pub summary_max_tokens: Option<usize>,
pub window_size: Option<usize>,
pub min_importance_score: Option<f64>,
}Expand description
Configuration for context compaction
Matches compactionStrategySchema in @enact/schemas
Fields§
§strategy_type: CompactionStrategyTypeStrategy type
target_tokens: usizeTarget token count after compaction
min_preserve_percent: u8Minimum content to preserve (percentage, 0-100)
segments_to_compact: Option<Vec<ContextSegmentType>>Segments to compact (in priority order)
protected_segments: Option<Vec<ContextSegmentType>>Segments to never compact
summary_max_tokens: Option<usize>For summarize strategy: max summary tokens
window_size: Option<usize>For sliding_window strategy: window size
min_importance_score: Option<f64>For importance_weighted: minimum importance score to keep
Implementations§
Source§impl CompactionStrategy
impl CompactionStrategy
Sourcepub fn sliding_window(target_tokens: usize, window_size: usize) -> Self
pub fn sliding_window(target_tokens: usize, window_size: usize) -> Self
Create a sliding window strategy
Sourcepub fn summarize(target_tokens: usize, summary_max_tokens: usize) -> Self
pub fn summarize(target_tokens: usize, summary_max_tokens: usize) -> Self
Create a summarization strategy
Sourcepub fn is_protected(&self, segment_type: ContextSegmentType) -> bool
pub fn is_protected(&self, segment_type: ContextSegmentType) -> bool
Check if a segment type is protected
Sourcepub fn should_compact(&self, segment_type: ContextSegmentType) -> bool
pub fn should_compact(&self, segment_type: ContextSegmentType) -> bool
Check if a segment type should be compacted
Trait Implementations§
Source§impl Clone for CompactionStrategy
impl Clone for CompactionStrategy
Source§fn clone(&self) -> CompactionStrategy
fn clone(&self) -> CompactionStrategy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompactionStrategy
impl Debug for CompactionStrategy
Source§impl<'de> Deserialize<'de> for CompactionStrategy
impl<'de> Deserialize<'de> for CompactionStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CompactionStrategy
impl RefUnwindSafe for CompactionStrategy
impl Send for CompactionStrategy
impl Sync for CompactionStrategy
impl Unpin for CompactionStrategy
impl UnsafeUnpin for CompactionStrategy
impl UnwindSafe for CompactionStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more