pub struct TokenChunk {
pub delta: String,
pub finish: bool,
pub raw: Option<Value>,
}Expand description
One incremental piece of a streamed completion (the LangGraph messages
stream-mode analog at the model level).
on_token callbacks of ChatModel::chat_stream receive a sequence of
TokenChunks: zero or more with finish: false carrying text deltas,
terminated by exactly one with finish: true (whose delta is empty for
truly-streaming implementations).
Fields§
§delta: StringThe incremental text produced since the previous chunk. May be empty (e.g. on the terminal chunk, or on chunks that only carry tool-call deltas).
finish: booltrue on the final chunk of the stream.
raw: Option<Value>The raw provider chunk (the decoded SSE data: JSON), when the
implementation streams from a wire protocol. None for synthetic
chunks (default fallback, mocks).
Trait Implementations§
Source§impl Clone for TokenChunk
impl Clone for TokenChunk
Auto Trait Implementations§
impl Freeze for TokenChunk
impl RefUnwindSafe for TokenChunk
impl Send for TokenChunk
impl Sync for TokenChunk
impl Unpin for TokenChunk
impl UnsafeUnpin for TokenChunk
impl UnwindSafe for TokenChunk
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