pub struct SlidingWindowTrimmer { /* private fields */ }Expand description
Simple sliding window trimmer.
Keeps the most recent N messages, always preserving system messages and optionally the first user message.
§Example
ⓘ
use bob_core::context_trimmer::{ContextTrimmer, SlidingWindowTrimmer};
// Keep 50 most recent messages, target ~8K tokens
let trimmer = SlidingWindowTrimmer::new(50, 8192);Implementations§
Source§impl SlidingWindowTrimmer
impl SlidingWindowTrimmer
Sourcepub fn new(max_messages: usize, target_tokens: usize) -> Self
pub fn new(max_messages: usize, target_tokens: usize) -> Self
Create a new sliding window trimmer.
Sourcepub fn with_config(config: TrimConfig) -> Self
pub fn with_config(config: TrimConfig) -> Self
Create with full configuration.
Trait Implementations§
Source§impl Clone for SlidingWindowTrimmer
impl Clone for SlidingWindowTrimmer
Source§fn clone(&self) -> SlidingWindowTrimmer
fn clone(&self) -> SlidingWindowTrimmer
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 ContextTrimmer for SlidingWindowTrimmer
impl ContextTrimmer for SlidingWindowTrimmer
Source§fn trim<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
_usage: &'life2 TokenUsage,
) -> Pin<Box<dyn Future<Output = Result<TrimResult, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn trim<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
_usage: &'life2 TokenUsage,
) -> Pin<Box<dyn Future<Output = Result<TrimResult, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Trim the message history according to the strategy. Read more
Source§fn strategy_name(&self) -> &'static str
fn strategy_name(&self) -> &'static str
Human-readable name of this trimming strategy.
Auto Trait Implementations§
impl Freeze for SlidingWindowTrimmer
impl RefUnwindSafe for SlidingWindowTrimmer
impl Send for SlidingWindowTrimmer
impl Sync for SlidingWindowTrimmer
impl Unpin for SlidingWindowTrimmer
impl UnsafeUnpin for SlidingWindowTrimmer
impl UnwindSafe for SlidingWindowTrimmer
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