pub struct ModelUsageTracker { /* private fields */ }Expand description
Thread-safe tracker for actual model usage.
Useful for comparing predicted vs. actual costs and computing cost-efficiency ratios.
Implementations§
Source§impl ModelUsageTracker
impl ModelUsageTracker
Sourcepub fn register_profile(&self, profile: ModelProfile)
pub fn register_profile(&self, profile: ModelProfile)
Register a model profile so that efficiency ratios can be computed.
Sourcepub fn record(&self, model_id: &str, tokens: u64, cost: f64, latency_ms: u64)
pub fn record(&self, model_id: &str, tokens: u64, cost: f64, latency_ms: u64)
Record a completed API call for model_id.
Sourcepub fn cost_efficiency(&self, model_id: &str) -> Option<f64>
pub fn cost_efficiency(&self, model_id: &str) -> Option<f64>
Return the cost-efficiency ratio for model_id.
Efficiency = quality_score / actual_cost_per_1k_tokens.
Returns None if the model has no recorded usage or no registered profile.
Sourcepub fn usage(&self, model_id: &str) -> Option<ModelUsage>
pub fn usage(&self, model_id: &str) -> Option<ModelUsage>
Return the recorded usage for model_id, if any.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ModelUsageTracker
impl Freeze for ModelUsageTracker
impl Send for ModelUsageTracker
impl Sync for ModelUsageTracker
impl Unpin for ModelUsageTracker
impl UnsafeUnpin for ModelUsageTracker
impl UnwindSafe for ModelUsageTracker
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request