pub struct TokenCost { /* private fields */ }Expand description
Token cost service
Implementations§
Source§impl TokenCost
impl TokenCost
pub fn new() -> Self
Sourcepub fn load_cache(&mut self) -> Result<(), String>
pub fn load_cache(&mut self) -> Result<(), String>
Load pricing from local cache
Sourcepub async fn fetch_pricing(&mut self) -> Result<(), String>
pub async fn fetch_pricing(&mut self) -> Result<(), String>
Fetch pricing data from remote or load from cache
Sourcepub fn needs_refresh(&self) -> bool
pub fn needs_refresh(&self) -> bool
Check if pricing needs refresh
Sourcepub fn get_model_pricing(&self, model_name: &str) -> Option<&ModelPricing>
pub fn get_model_pricing(&self, model_name: &str) -> Option<&ModelPricing>
Get pricing for a model
Sourcepub fn calculate_cost(
&self,
model: &str,
usage: &Usage,
) -> Option<TokenCostCalculated>
pub fn calculate_cost( &self, model: &str, usage: &Usage, ) -> Option<TokenCostCalculated>
Calculate cost for a completion
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TokenCost
impl RefUnwindSafe for TokenCost
impl Send for TokenCost
impl Sync for TokenCost
impl Unpin for TokenCost
impl UnsafeUnpin for TokenCost
impl UnwindSafe for TokenCost
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