pub struct StreamChunk {
pub meta: CompletionMeta,
pub choices: Vec<Choice>,
pub usage: Option<Usage>,
}Expand description
A streaming chat completion chunk
Fields§
§meta: CompletionMetaCompletion metadata
choices: Vec<Choice>The list of completion choices (with delta content)
usage: Option<Usage>Token usage statistics (only in final chunk)
Implementations§
Source§impl StreamChunk
impl StreamChunk
Sourcepub fn separator() -> Self
pub fn separator() -> Self
Create a separator chunk (newline) emitted between tool-call rounds.
Sourcepub fn reasoning_content(&self) -> Option<&str>
pub fn reasoning_content(&self) -> Option<&str>
Get the reasoning content of the first choice
Sourcepub fn tool_calls(&self) -> Option<&[ToolCall]>
pub fn tool_calls(&self) -> Option<&[ToolCall]>
Get the tool calls of the first choice
Sourcepub fn reason(&self) -> Option<&FinishReason>
pub fn reason(&self) -> Option<&FinishReason>
Get the reason the model stopped generating
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 · 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