pub struct ConversationStats {
pub total_messages: u64,
pub total_cost_usd: f64,
pub total_duration_ms: u64,
pub total_tokens: TokenUsage,
}
Expand description
Statistics for an entire conversation
Provides aggregate metrics for a complete conversation session, including
message counts, costs, duration, and token usage. This is typically included
in the final Result
message of a stream.
§Examples
let stats = ConversationStats {
total_messages: 10,
total_cost_usd: 0.045,
total_duration_ms: 3500,
total_tokens: TokenUsage {
input: 1500,
output: 2500,
total: 4000,
},
};
println!("Conversation summary:");
println!(" Messages: {}", stats.total_messages);
println!(" Cost: ${:.4}", stats.total_cost_usd);
println!(" Duration: {:.1}s", stats.total_duration_ms as f64 / 1000.0);
println!(" Tokens: {} ({}in/{}out)",
stats.total_tokens.total,
stats.total_tokens.input,
stats.total_tokens.output
);
Fields§
§total_messages: u64
Total number of messages exchanged in the conversation
total_cost_usd: f64
Total cost of the conversation in USD
total_duration_ms: u64
Total processing time in milliseconds
total_tokens: TokenUsage
Aggregate token usage for the entire conversation
Trait Implementations§
Source§impl Clone for ConversationStats
impl Clone for ConversationStats
Source§fn clone(&self) -> ConversationStats
fn clone(&self) -> ConversationStats
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ConversationStats
impl Debug for ConversationStats
Source§impl<'de> Deserialize<'de> for ConversationStats
impl<'de> Deserialize<'de> for ConversationStats
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ConversationStats
impl RefUnwindSafe for ConversationStats
impl Send for ConversationStats
impl Sync for ConversationStats
impl Unpin for ConversationStats
impl UnwindSafe for ConversationStats
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more