pub struct ContextOptimizer { /* private fields */ }Expand description
The main context optimizer.
Implementations§
Source§impl ContextOptimizer
impl ContextOptimizer
Sourcepub fn new(budget: TokenBudget) -> Self
pub fn new(budget: TokenBudget) -> Self
Create a new optimizer with a token budget.
Sourcepub fn strategy(self, s: OptimizeStrategy) -> Self
pub fn strategy(self, s: OptimizeStrategy) -> Self
Set the optimization strategy.
Sourcepub fn weights(self, w: ScoringWeights) -> Self
pub fn weights(self, w: ScoringWeights) -> Self
Set scoring weights.
Sourcepub fn counter(self, c: TokenCounter) -> Self
pub fn counter(self, c: TokenCounter) -> Self
Set a custom token counter.
Sourcepub fn optimize(&self, chunks: &[(String, f32)]) -> OptimizedContext
pub fn optimize(&self, chunks: &[(String, f32)]) -> OptimizedContext
Optimize a list of chunks with retrieval scores to fit token budget.
Each input entry is (chunk_text, retrieval_score).
Auto Trait Implementations§
impl Freeze for ContextOptimizer
impl RefUnwindSafe for ContextOptimizer
impl Send for ContextOptimizer
impl Sync for ContextOptimizer
impl Unpin for ContextOptimizer
impl UnsafeUnpin for ContextOptimizer
impl UnwindSafe for ContextOptimizer
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