#[non_exhaustive]pub enum StreamEvent {
TextDelta {
text: String,
},
ToolCallStart {
id: CallId,
name: String,
},
ToolCallDelta {
id: CallId,
arguments_fragment: String,
},
ToolCallEnd {
id: CallId,
},
Usage {
usage: TokenUsage,
},
ResponseId {
id: String,
},
Warning {
warning: ResponseWarning,
},
Finish {
reason: FinishReason,
},
}Expand description
One increment of a streamed answer.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TextDelta
More prose.
ToolCallStart
A tool call begins. Must precede any fragment for the same id.
ToolCallDelta
More argument bytes for a call already started.
Fields
ToolCallEnd
A tool call’s arguments are complete.
Usage
Reported token usage. Providers send it once, at the end; a later report replaces an earlier one.
Fields
usage: TokenUsageThe counts.
ResponseId
The provider’s own response identifier, as soon as the wire reveals it.
Most vendors put it on the first frame — an OpenAI chunk’s id, an
Anthropic message_start, a Gemini responseId — so the caller no
longer has to seed it out of band to have it on the rebuilt response.
A later identifier replaces an earlier one.
Warning
Something the adapter wants the caller to know without failing the call.
The streamed path reports exactly what the whole path reports. Without
this event an adapter that had to drop a stop sequence or a cache hint
could say so in ModelResponse::warnings
when called whole, and had nowhere to say it when called streamed —
which made the same call honest one way and silent the other.
Fields
warning: ResponseWarningWhat was given up.
Finish
Generation stopped. Exactly one per stream, and it must arrive.
Fields
reason: FinishReasonWhy.
Implementations§
Source§impl StreamEvent
impl StreamEvent
Sourcepub fn tool_call_start(id: impl Into<CallId>, name: impl Into<String>) -> Self
pub fn tool_call_start(id: impl Into<CallId>, name: impl Into<String>) -> Self
A tool-call announcement.
Sourcepub fn tool_call_delta(
id: impl Into<CallId>,
fragment: impl Into<String>,
) -> Self
pub fn tool_call_delta( id: impl Into<CallId>, fragment: impl Into<String>, ) -> Self
An argument fragment.
Sourcepub fn tool_call_end(id: impl Into<CallId>) -> Self
pub fn tool_call_end(id: impl Into<CallId>) -> Self
A tool-call terminator.
Sourcepub fn response_id(id: impl Into<String>) -> Self
pub fn response_id(id: impl Into<String>) -> Self
The provider’s response identifier.
Sourcepub const fn warning(warning: ResponseWarning) -> Self
pub const fn warning(warning: ResponseWarning) -> Self
A warning the adapter wants carried into the rebuilt response.
Sourcepub const fn is_user_visible(&self) -> bool
pub const fn is_user_visible(&self) -> bool
Returns true for the events a UI may render directly (spec §18.5:
only model-authored prose is streamed to the user).
Trait Implementations§
Source§impl Clone for StreamEvent
impl Clone for StreamEvent
Source§impl Debug for StreamEvent
impl Debug for StreamEvent
Source§impl<'de> Deserialize<'de> for StreamEvent
impl<'de> Deserialize<'de> for StreamEvent
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>,
impl Eq for StreamEvent
Source§impl PartialEq for StreamEvent
impl PartialEq for StreamEvent
Source§impl Serialize for StreamEvent
impl Serialize for StreamEvent
impl StructuralPartialEq for StreamEvent
Auto 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.