pub struct StreamChunk {
pub delta: String,
pub done: bool,
pub finish_reason: Option<FinishReason>,
pub usage: Option<Usage>,
pub tool_calls: Option<Vec<ToolCall>>,
}Expand description
A single chunk from a streaming response.
Fields§
§delta: StringThe text delta for this chunk (may be empty for the final chunk).
done: boolSet to true when the stream is complete.
finish_reason: Option<FinishReason>The provider-reported reason the stream stopped, when available. Populated on the terminal content chunk.
usage: Option<Usage>Token usage for the request. Only populated on the terminal usage chunk, and only for providers that report usage while streaming.
tool_calls: Option<Vec<ToolCall>>Tool calls reconstructed from the stream, surfaced on the terminal
chunk for providers that support streaming tool calls. None for
chunks that carry no tool calls (and for providers, such as Ollama,
that do not reconstruct tool calls while streaming).
Trait Implementations§
Source§impl Clone for StreamChunk
impl Clone for StreamChunk
Source§fn clone(&self) -> StreamChunk
fn clone(&self) -> StreamChunk
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 moreSource§impl Debug for StreamChunk
impl Debug for StreamChunk
Source§impl Default for StreamChunk
impl Default for StreamChunk
Source§fn default() -> StreamChunk
fn default() -> StreamChunk
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for StreamChunk
impl<'de> Deserialize<'de> for StreamChunk
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 StreamChunk
impl RefUnwindSafe for StreamChunk
impl Send for StreamChunk
impl Sync for StreamChunk
impl Unpin for StreamChunk
impl UnsafeUnpin for StreamChunk
impl UnwindSafe for StreamChunk
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