pub struct CostTracker { /* private fields */ }Expand description
成本追踪器
Implementations§
Source§impl CostTracker
impl CostTracker
pub fn new() -> Self
Sourcepub fn set_budget_limit(&self, limit: f64)
pub fn set_budget_limit(&self, limit: f64)
设置预算上限
Sourcepub fn record_usage(
&self,
model: &str,
input_tokens: u64,
output_tokens: u64,
) -> Result<()>
pub fn record_usage( &self, model: &str, input_tokens: u64, output_tokens: u64, ) -> Result<()>
记录使用
Sourcepub fn get_current_usage(&self) -> UsageSnapshot
pub fn get_current_usage(&self) -> UsageSnapshot
获取当前使用情况
Sourcepub fn estimate_next_step(
&self,
model: &str,
estimated_input: u64,
estimated_output: u64,
) -> CostEstimate
pub fn estimate_next_step( &self, model: &str, estimated_input: u64, estimated_output: u64, ) -> CostEstimate
预估下一步成本
Sourcepub fn generate_report(&self) -> CostReport
pub fn generate_report(&self) -> CostReport
生成报告
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CostTracker
impl !RefUnwindSafe for CostTracker
impl Send for CostTracker
impl Sync for CostTracker
impl Unpin for CostTracker
impl UnsafeUnpin for CostTracker
impl UnwindSafe for CostTracker
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