pub struct PriceBook { /* private fields */ }Expand description
Configurable USD price book for eval-run cost estimation.
Implementations§
Source§impl PriceBook
impl PriceBook
Sourcepub fn default_set() -> Self
pub fn default_set() -> Self
A price book with a few common models preloaded (approximate list prices).
Sourcepub fn set(&mut self, model: impl Into<String>, price: Price)
pub fn set(&mut self, model: impl Into<String>, price: Price)
Sets (or overrides) the price for a model. Prices are in “units per 1M”: a price of 3
means $3.00 per 1M input tokens.
Sourcepub fn estimate(&self, usage: &TokenUsage) -> Option<f64>
pub fn estimate(&self, usage: &TokenUsage) -> Option<f64>
Estimates the USD cost of a usage report; None when the model isn’t in the book.
Pure function over the book + usage, so it is trivially unit-testable.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PriceBook
impl RefUnwindSafe for PriceBook
impl Send for PriceBook
impl Sync for PriceBook
impl Unpin for PriceBook
impl UnsafeUnpin for PriceBook
impl UnwindSafe for PriceBook
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