pub enum StreamEvent {
TextDelta(String),
ToolCallStart {
name: String,
index: usize,
id: Option<String>,
},
ToolCallDelta {
index: usize,
arguments_delta: String,
},
Usage {
input_tokens: u64,
output_tokens: u64,
},
Done {
text: String,
tool_calls: Vec<ToolCall>,
},
}Expand description
Events emitted during a streaming inference response.
Variants§
TextDelta(String)
Partial text token from the model.
ToolCallStart
A tool call is starting (name known, arguments pending).
ToolCallDelta
Partial tool call arguments (JSON fragment).
Usage
Provider-reported cumulative token usage observed mid-stream.
Anthropic emits this twice: once in message_start with the
finalized input_tokens (plus a stub output_tokens: 1), and
again in message_delta at end of stream with the real
output_tokens. Consumers should prefer per-field monotonicity
(see StreamAccumulator) rather than overwriting blindly.
Done
Stream is complete. Contains the final aggregated result.
Trait Implementations§
Source§impl Clone for StreamEvent
impl Clone for StreamEvent
Source§fn clone(&self) -> StreamEvent
fn clone(&self) -> StreamEvent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StreamEvent
impl RefUnwindSafe for StreamEvent
impl Send for StreamEvent
impl Sync for StreamEvent
impl Unpin for StreamEvent
impl UnsafeUnpin for StreamEvent
impl UnwindSafe for StreamEvent
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