pub struct TurnUsage {
pub prompt_tokens: Option<u64>,
pub completion_tokens: Option<u64>,
pub total_tokens: Option<u64>,
pub cached_tokens: Option<u64>,
pub prompt_ms: Option<u64>,
pub completion_ms: Option<u64>,
pub latency_ms: u64,
pub ttft_ms: Option<u64>,
}Expand description
What one provider call cost.
Fields§
§prompt_tokens: Option<u64>§completion_tokens: Option<u64>§total_tokens: Option<u64>§cached_tokens: Option<u64>Prompt tokens served from the server’s KV/prefix cache (llama.cpp cache_n).
prompt_ms: Option<u64>Prefill time, when the server distinguishes it.
completion_ms: Option<u64>Decode time.
latency_ms: u64Wall time of the whole call as this process measured it — always present.
ttft_ms: Option<u64>Time to the first streamed character, when the provider streamed at all.
Implementations§
Source§impl TurnUsage
impl TurnUsage
Sourcepub fn from_body(body: &Value, latency_ms: u64) -> Self
pub fn from_body(body: &Value, latency_ms: u64) -> Self
Read a response body (or a stream’s final chunk) plus the wall time we measured.
Sourcepub fn tokens_per_sec(&self) -> Option<f64>
pub fn tokens_per_sec(&self) -> Option<f64>
Decode speed. Prefers the server’s own decode timing (it excludes prefill), else the whole wall time, which is a floor on the real speed rather than a fake precision.
Sourcepub fn prefill_per_sec(&self) -> Option<f64>
pub fn prefill_per_sec(&self) -> Option<f64>
Prefill speed, when the server timed it.
pub fn is_empty(&self) -> bool
Trait Implementations§
impl Eq for TurnUsage
impl StructuralPartialEq for TurnUsage
Auto Trait Implementations§
impl Forget for TurnUsage
impl Freeze for TurnUsage
impl Move for TurnUsage
impl RefUnwindSafe for TurnUsage
impl Send for TurnUsage
impl Sync for TurnUsage
impl Unpin for TurnUsage
impl UnsafeUnpin for TurnUsage
impl UnwindSafe for TurnUsage
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.