pub trait GetTokenUsage {
// Required method
fn token_usage(&self) -> Usage;
}Expand description
A trait for grabbing the token usage of a completion response.
Primarily designed for streamed completion responses in streamed multi-turn, as otherwise it would be impossible to do.
Required Methods§
Sourcefn token_usage(&self) -> Usage
fn token_usage(&self) -> Usage
Returns token usage for this response. Zero-valued usage is
Usage’s documented sentinel for missing provider usage metrics;
response types that carry no usage return Usage::new.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl GetTokenUsage for ()
impl GetTokenUsage for ()
fn token_usage(&self) -> Usage
Source§impl<T> GetTokenUsage for Option<T>where
T: GetTokenUsage,
impl<T> GetTokenUsage for Option<T>where
T: GetTokenUsage,
fn token_usage(&self) -> Usage
Implementors§
impl GetTokenUsage for CompletionResponse
impl GetTokenUsage for CopilotStreamingResponse
impl GetTokenUsage for Interaction
impl GetTokenUsage for InteractionUsage
impl GetTokenUsage for MockResponse
Available on crate feature
test-utils only.