pub struct BudgetTracker { /* private fields */ }Expand description
Runtime budget tracker
Implementations§
Source§impl BudgetTracker
impl BudgetTracker
Sourcepub fn new(config: BudgetConfig) -> Self
pub fn new(config: BudgetConfig) -> Self
Create a new budget tracker
Sourcepub fn record_usage(&mut self, tokens: u32, cost: f64)
pub fn record_usage(&mut self, tokens: u32, cost: f64)
Record token and cost usage
Sourcepub fn record_skip(&mut self)
pub fn record_skip(&mut self)
Record a skipped step
Sourcepub fn time_remaining(&self) -> Option<Duration>
pub fn time_remaining(&self) -> Option<Duration>
Get time remaining (if time limit set)
Sourcepub fn tokens_remaining(&self) -> Option<u32>
pub fn tokens_remaining(&self) -> Option<u32>
Get tokens remaining (if token limit set)
Sourcepub fn cost_remaining(&self) -> Option<f64>
pub fn cost_remaining(&self) -> Option<f64>
Get cost remaining (if cost limit set)
Sourcepub fn is_exhausted(&self) -> bool
pub fn is_exhausted(&self) -> bool
Check if budget is exhausted
Sourcepub fn usage_ratio(&self) -> f64
pub fn usage_ratio(&self) -> f64
Calculate budget usage ratio (0.0-1.0)
Sourcepub fn should_adapt(&self) -> bool
pub fn should_adapt(&self) -> bool
Check if we should start adapting (approaching limit)
Sourcepub fn adaptive_max_tokens(&self, requested: u32) -> u32
pub fn adaptive_max_tokens(&self, requested: u32) -> u32
Get adaptive max_tokens based on remaining budget
Sourcepub fn should_skip_step(&self, is_essential: bool) -> bool
pub fn should_skip_step(&self, is_essential: bool) -> bool
Check if step should be skipped (non-essential and low budget)
Sourcepub fn summary(&self) -> BudgetSummary
pub fn summary(&self) -> BudgetSummary
Get budget summary
Trait Implementations§
Source§impl Clone for BudgetTracker
impl Clone for BudgetTracker
Source§fn clone(&self) -> BudgetTracker
fn clone(&self) -> BudgetTracker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BudgetTracker
impl RefUnwindSafe for BudgetTracker
impl Send for BudgetTracker
impl Sync for BudgetTracker
impl Unpin for BudgetTracker
impl UnwindSafe for BudgetTracker
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more