pub struct LlmStreamEvent {
pub call_id: String,
pub provider: String,
pub model: String,
pub delta: String,
pub done: bool,
pub error: Option<String>,
}Expand description
A single chunk of generated text emitted as the model produces tokens.
delta is the new text since the previous event; the consumer is
responsible for accumulating if it needs the full response. done is set
exactly once per call - either with the final partial delta or on its own
with an empty delta - and signals that the stream is closed.
error is non-empty when the call failed mid-stream; done will also be
true in that case. Successful calls leave error None.
Fields§
§call_id: StringCaller-supplied id correlating this event to a specific call. Lets the frontend group deltas when multiple LLM calls overlap.
provider: StringProvider name (e.g. "local", "claude").
model: StringModel id the provider reported (may differ from the requested id when the server aliases). Empty until the first chunk arrives.
delta: StringNew text since the previous event.
done: boolTrue on the final event (either with the last delta or empty).
error: Option<String>Set when the call failed mid-stream; the consumer should surface this to the user (e.g. an inline error tag on the chip).
Implementations§
Source§impl LlmStreamEvent
impl LlmStreamEvent
Sourcepub fn final_delta(call_id: &str, resp: &CloudAiResponse) -> Self
pub fn final_delta(call_id: &str, resp: &CloudAiResponse) -> Self
Construct the single done event the default invoke_stream impl
emits when wrapping a non-streaming invoke call.
Trait Implementations§
Source§impl Clone for LlmStreamEvent
impl Clone for LlmStreamEvent
Source§fn clone(&self) -> LlmStreamEvent
fn clone(&self) -> LlmStreamEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more