pub struct UsageAnchor {
pub provider_tokens: u64,
pub fixed_tokens: u64,
pub messages: Vec<SharedMessage>,
}Expand description
The provider-reported input of one request (input + cache_read + cache_write), kept to measure the requests that follow it.
The estimator cannot know what the provider bills: a thinking block’s signature carries reasoning the visible (summarized) text does not show, and how much of earlier turns’ reasoning bills varies by request. The provider’s count is exact, so the next request is measured as that count plus an estimate of only what was appended since. Requests that rewrite the history (rollover, compaction, a changed image view) do not extend the anchored one and fall back to the estimate.
Fields§
§provider_tokens: u64§fixed_tokens: u64Estimate of the anchored request’s fixed part
(ContextAssessment::fixed_tokens).
messages: Vec<SharedMessage>The anchored request’s messages as they were assessed.
Implementations§
Source§impl UsageAnchor
impl UsageAnchor
Sourcepub fn footprint(
&self,
fixed_tokens: u64,
messages: &[SharedMessage],
) -> Option<u64>
pub fn footprint( &self, fixed_tokens: u64, messages: &[SharedMessage], ) -> Option<u64>
Footprint of a request with fixed part fixed_tokens (estimated) and
messages: the provider’s count plus the estimate of every message
past the ones the two requests share, or None when they diverge
before the anchored request’s last message.
The last anchored message may differ (a per-turn injection rides the request tail and is not kept in history): what it billed stays counted beside the estimate of its replacement. Growth of the fixed part is added; neither it nor a shrink is ever subtracted (the estimate of what left may exceed what it billed). Every deviation therefore errs high, never below the provider’s count.
Trait Implementations§
Source§impl Clone for UsageAnchor
impl Clone for UsageAnchor
Auto Trait Implementations§
impl Freeze for UsageAnchor
impl RefUnwindSafe for UsageAnchor
impl Send for UsageAnchor
impl Sync for UsageAnchor
impl Unpin for UsageAnchor
impl UnsafeUnpin for UsageAnchor
impl UnwindSafe for UsageAnchor
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.