pub struct ContextBudget { /* private fields */ }Expand description
Assembles messages from multiple context slots within a token budget.
Slots are sorted by priority (lowest value = highest priority). Higher-priority slots are included first. Lower-priority slots are dropped if the budget is exceeded.
Implementations§
Source§impl ContextBudget
impl ContextBudget
pub fn new(max_tokens: usize, counter: Arc<dyn TokenCounter>) -> Self
Sourcepub fn assemble(&self, slots: Vec<ContextSlot>) -> Vec<Message>
pub fn assemble(&self, slots: Vec<ContextSlot>) -> Vec<Message>
Assemble messages from slots that fit within the token budget.
Slots are processed in priority order (CRITICAL first, LOW last).
Each slot’s messages are included if they fit. Slots with
reserved_tokens > 0 are guaranteed inclusion (if total reserved
fits within budget).
Auto Trait Implementations§
impl Freeze for ContextBudget
impl !RefUnwindSafe for ContextBudget
impl Send for ContextBudget
impl Sync for ContextBudget
impl Unpin for ContextBudget
impl UnsafeUnpin for ContextBudget
impl !UnwindSafe for ContextBudget
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