pub struct BudgetedModel<M> {
pub model: M,
pub budget: Budget,
/* private fields */
}Expand description
A model with budget tracking.
Fields§
§model: MThe underlying model.
budget: BudgetBudget limit.
Implementations§
Source§impl<M> BudgetedModel<M>
impl<M> BudgetedModel<M>
Sourcepub fn record_usage(&self, usage: &Usage)
pub fn record_usage(&self, usage: &Usage)
Records usage from a response.
Sourcepub fn mark_exhausted(&self)
pub fn mark_exhausted(&self)
Marks this model as exhausted (e.g., from API quota error).
Sourcepub fn is_exhausted(&self) -> bool
pub fn is_exhausted(&self) -> bool
Checks if the budget is exhausted.
Sourcepub fn tokens_used(&self) -> u64
pub fn tokens_used(&self) -> u64
Returns the current token usage.
Sourcepub fn reset_usage(&self)
pub fn reset_usage(&self)
Resets the usage counters (but not the exhausted flag).
Trait Implementations§
Auto Trait Implementations§
impl<M> !Freeze for BudgetedModel<M>
impl<M> Forget for BudgetedModel<M>
impl<M> Move for BudgetedModel<M>
impl<M> RefUnwindSafe for BudgetedModel<M>where
M: RefUnwindSafe,
impl<M> Send for BudgetedModel<M>where
M: Send,
impl<M> Sync for BudgetedModel<M>where
M: Sync,
impl<M> Unpin for BudgetedModel<M>where
M: Unpin,
impl<M> UnsafeUnpin for BudgetedModel<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for BudgetedModel<M>where
M: UnwindSafe,
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