pub trait GetTokenUsage {
// Required method
fn token_usage(&self) -> Option<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) -> Option<Usage>
fn token_usage(&self) -> Option<Usage>
Returns token usage when the response type carries it.
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) -> Option<Usage>
Source§impl<T> GetTokenUsage for Option<T>where
T: GetTokenUsage,
impl<T> GetTokenUsage for Option<T>where
T: GetTokenUsage,
fn token_usage(&self) -> Option<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.