pub struct TurnUsage {
pub checkpoint: Option<UsageCheckpoint>,
pub models: Vec<ModelUsage>,
}Expand description
Usage of every model one turn or isolated prompt used.
Entries are ordered by their latest request, so the last entry with a context fill describes what the most recent request saw.
Fields§
§checkpoint: Option<UsageCheckpoint>Cumulative totals an agent reported for the conversation it left,
which the host stores and passes back through
crate::TurnContinuation::with_usage_checkpoint so the next turn
continuing that conversation can derive its own share; None for
agents and runs that report per-turn usage.
models: Vec<ModelUsage>One entry per model.
Implementations§
Source§impl TurnUsage
impl TurnUsage
Sourcepub fn single(usage: ModelUsage) -> Self
pub fn single(usage: ModelUsage) -> Self
Returns the usage of one model.
Sourcepub fn record(&mut self, next: &ModelUsage)
pub fn record(&mut self, next: &ModelUsage)
Folds the later usage next of one model into its entry, which
moves last, or appends it for a model not seen yet.
Sourcepub fn merge(&mut self, next: &Self)
pub fn merge(&mut self, next: &Self)
Folds every entry of the later usage next into this one; a later
checkpoint replaces this one.
Sourcepub fn total(&self) -> Option<ModelUsage>
pub fn total(&self) -> Option<ModelUsage>
Returns the usage of every model summed into one entry named after
the first, as ModelUsage::add sums them, or None without any
model.
Sourcepub fn context(&self) -> Option<ContextFill>
pub fn context(&self) -> Option<ContextFill>
Returns the context fill of the most recent request that reported its input.
Sourcepub fn input_tokens(&self) -> u64
pub fn input_tokens(&self) -> u64
Returns the input tokens of every model, cache included.
Sourcepub fn output_tokens(&self) -> u64
pub fn output_tokens(&self) -> u64
Returns the output tokens of every model, reasoning included.
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
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
key and return true if they are equal.