Skip to main content

ContextStrategy

Trait ContextStrategy 

Source
pub trait ContextStrategy: Send + Sync {
    // Required method
    fn compact(
        &self,
        messages: Vec<Message>,
        max_tokens: usize,
    ) -> Result<Vec<Message>, AppError>;
}
Expand description

Strategy for compacting the message history when context is too large.

Required Methods§

Source

fn compact( &self, messages: Vec<Message>, max_tokens: usize, ) -> Result<Vec<Message>, AppError>

Compact the message list toward max_tokens.

Strategies decide how aggressively to reduce history. Implementations that cannot satisfy their own policy should return an error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§