#[non_exhaustive]pub enum AutoFunctionStreamChunk {
Delta(Content),
ExecutingFunctions {
response: InteractionResponse,
pending_calls: Vec<PendingFunctionCall>,
},
FunctionResults(Vec<FunctionExecutionResult>),
Complete(InteractionResponse),
MaxLoopsReached(InteractionResponse),
Unknown {
chunk_type: String,
data: Value,
},
}Expand description
A chunk from streaming with automatic function calling.
This enum represents the different events that can occur during a streaming interaction with automatic function execution. The stream yields deltas as content arrives, signals when functions are being executed, and completes when the model returns a response without function calls.
§Forward Compatibility
This enum uses #[non_exhaustive] to allow adding new event types in future
versions without breaking existing code. Always include a wildcard arm in
match statements. Unknown variants are preserved with their data for debugging.
§Serialization
This enum implements Serialize and Deserialize for logging, persistence,
and replay of streaming events.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Delta(Content)
Incremental content from the model (text, thoughts, etc.)
ExecutingFunctions
Function calls detected, about to execute.
This event is yielded when the model requests function calls and
before the functions are executed. The pending_calls field contains
the function calls that are about to be executed.
Note: In streaming mode, function calls arrive incrementally via
Delta chunks. The pending_calls list is built from accumulated deltas
and will always be populated, even though response.function_calls()
may be empty.
Fields
response: InteractionResponseThe response from the API (may have empty function_calls() in streaming mode)
pending_calls: Vec<PendingFunctionCall>The function calls that are about to be executed (always populated)
FunctionResults(Vec<FunctionExecutionResult>)
Function execution completed with results.
This event is yielded after all functions in a batch have been executed, before sending results back to the model for the next iteration.
Complete(InteractionResponse)
Final complete response (no more function calls).
This is the last event in the stream, yielded when the model returns a response that doesn’t request any function calls.
MaxLoopsReached(InteractionResponse)
Maximum function call loops reached.
This event is yielded when the auto-function loop has reached the maximum
number of iterations (set via with_max_function_call_loops()) without
the model returning a response without function calls.
The response contains the last response from the model, which likely still
contains pending function calls. Use AutoFunctionResultAccumulator to
collect all function execution results from prior FunctionResults chunks.
This allows debugging why the model is stuck in a loop while preserving all partial results.
Unknown
Unknown event type (for forward compatibility).
This variant is used when deserializing JSON that contains an unrecognized
chunk_type. This allows the library to gracefully handle new event types
added by the API in future versions without failing deserialization.
The chunk_type field contains the unrecognized type string, and data
contains the full JSON data for inspection or debugging.
Implementations§
Source§impl AutoFunctionStreamChunk
impl AutoFunctionStreamChunk
Sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Check if this is an unknown chunk type.
Sourcepub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Check if this chunk is a Complete variant.
Sourcepub fn unknown_chunk_type(&self) -> Option<&str>
pub fn unknown_chunk_type(&self) -> Option<&str>
Returns the chunk type name if this is an unknown chunk type.
Returns None for known chunk types.
Sourcepub fn unknown_data(&self) -> Option<&Value>
pub fn unknown_data(&self) -> Option<&Value>
Returns the raw JSON data if this is an unknown chunk type.
Returns None for known chunk types.
Trait Implementations§
Source§impl Clone for AutoFunctionStreamChunk
impl Clone for AutoFunctionStreamChunk
Source§fn clone(&self) -> AutoFunctionStreamChunk
fn clone(&self) -> AutoFunctionStreamChunk
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AutoFunctionStreamChunk
impl Debug for AutoFunctionStreamChunk
Source§impl<'de> Deserialize<'de> for AutoFunctionStreamChunk
impl<'de> Deserialize<'de> for AutoFunctionStreamChunk
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>,
Auto Trait Implementations§
impl Freeze for AutoFunctionStreamChunk
impl RefUnwindSafe for AutoFunctionStreamChunk
impl Send for AutoFunctionStreamChunk
impl Sync for AutoFunctionStreamChunk
impl Unpin for AutoFunctionStreamChunk
impl UnwindSafe for AutoFunctionStreamChunk
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);