pub struct BoxedStrategy(/* private fields */);Expand description
A type-erased wrapper around a ContextStrategy for use in CompositeStrategy.
Use BoxedStrategy::new(strategy) to wrap any strategy.
§Example
use neuron_context::{SlidingWindowStrategy, strategies::BoxedStrategy};
let boxed = BoxedStrategy::new(SlidingWindowStrategy::new(10, 100_000));Implementations§
Source§impl BoxedStrategy
impl BoxedStrategy
Sourcepub fn new<S: ContextStrategy + 'static>(strategy: S) -> Self
pub fn new<S: ContextStrategy + 'static>(strategy: S) -> Self
Wrap any ContextStrategy into a type-erased BoxedStrategy.
Trait Implementations§
Source§impl ContextStrategy for BoxedStrategy
impl ContextStrategy for BoxedStrategy
Source§fn should_compact(&self, messages: &[Message], token_count: usize) -> bool
fn should_compact(&self, messages: &[Message], token_count: usize) -> bool
Whether compaction should be triggered given the current messages and token count.
Source§fn compact(
&self,
messages: Vec<Message>,
) -> impl Future<Output = Result<Vec<Message>, ContextError>> + WasmCompatSend
fn compact( &self, messages: Vec<Message>, ) -> impl Future<Output = Result<Vec<Message>, ContextError>> + WasmCompatSend
Compact the message list to reduce token usage.
Source§fn token_estimate(&self, messages: &[Message]) -> usize
fn token_estimate(&self, messages: &[Message]) -> usize
Estimate the token count for a list of messages.
Auto Trait Implementations§
impl Freeze for BoxedStrategy
impl !RefUnwindSafe for BoxedStrategy
impl Send for BoxedStrategy
impl Sync for BoxedStrategy
impl Unpin for BoxedStrategy
impl UnsafeUnpin for BoxedStrategy
impl !UnwindSafe for BoxedStrategy
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