pub struct StreamChunk {
pub text: String,
pub token_usage: Option<TokenUsage>,
}Expand description
A single streaming chunk emitted by BaseChatModel::stream_chat.
Replaces the bare String chunk so streaming paths can observe token
usage without a separate non-streaming invoke. Most providers only
populate StreamChunk::token_usage on the final chunk; intermediate
chunks carry text with token_usage: None. Providers that do not report
usage (Ollama, local, proxy passthrough) always yield token_usage: None.
Fields§
§text: StringThe text delta for this chunk.
token_usage: Option<TokenUsage>Token usage for the whole streaming call, typically only on the last chunk (when the provider reports it).
Implementations§
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 moreAuto 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