pub struct Budget {
pub max_tokens: Option<usize>,
pub max_rounds: Option<usize>,
}Expand description
Window budget: token and round limits (both optional; when both are set, the smaller window wins).
max_tokens: total token budget for the context (WindowMemory::newrequires it);max_rounds: maximum number of complete rounds to keep. A round is one User message plus everything after it until the next User message (a tool message belongs to the same round as its Assistant).
The two dimensions can be used independently or together: when both are set, the kept result is the smaller window satisfying both (trim by tokens first, then constrained by rounds).
§Example
use molo::memory::Budget;
// Token-only budget: window of at most 4096 tokens, no round limit.
let by_tokens = Budget::tokens(4096);
// Rounds-only budget: keep at most 8 rounds.
let by_rounds = Budget::rounds(8);
// Both set: the smaller window wins.
let both = Budget::both(4096, 8);
assert_eq!(by_tokens.max_tokens, Some(4096));
assert_eq!(by_tokens.max_rounds, None);
assert_eq!(by_rounds.max_rounds, Some(8));
assert!(both.max_tokens.is_some() && both.max_rounds.is_some());Fields§
§max_tokens: Option<usize>Token budget limit; None = unlimited.
max_rounds: Option<usize>Round limit; None = unlimited.
Implementations§
Trait Implementations§
impl Copy for Budget
impl Eq for Budget
impl StructuralPartialEq for Budget
Auto Trait Implementations§
impl Freeze for Budget
impl RefUnwindSafe for Budget
impl Send for Budget
impl Sync for Budget
impl Unpin for Budget
impl UnsafeUnpin for Budget
impl UnwindSafe for Budget
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.