Skip to main content

Module streaming

Module streaming 

Source
Expand description

Completion events, and Streamed, the one stream every reply arrives as.

use rig_core::streaming::{Item, StreamEvent};

fn text(item: &Item<StreamEvent>) -> Option<&str> {
    match item {
        Item::Event(StreamEvent::Text { text, .. }) => Some(text),
        _ => None,
    }
}

Structs§

Part
A part’s position in the response’s choice. Only this crate constructs one:
Streamed
One reply as it arrives: its events, and the fold that has seen each of them. It is what Model::stream returns for every operation, and what a call finishes.
Transcript
A completion stream’s items read back from their serialized form, in an order the writer could have produced: each part starts once, at the next position, grows only while open and with its own kind of fragment, and ends once. Unmodeled payloads may come anywhere.
UnknownPayload
Unmodeled JSON payload with content-redacted Debug output. Serialization preserves the payload; Self::value explicitly exposes it.

Enums§

Item
One item of a stream: an event of the operation, or a payload the provider sent that the decoder does not model. An unmodeled payload always reaches the consumer.
PartKind
What kind of part a StreamEvent::Start opened.
Relayed
One item of a completion stream relayed over the bus: an item of the reply, or the response the origin folded when the provider ended it.
SequenceError
Why a serialized event sequence is not one the writer could produce.
StreamEvent
One event of a completion stream: a part starts, grows, or ends with the content it finalized.
StreamedUserContent
Streamed user content. This content is primarily used to represent tool results from tool calls made during a multi-turn/step agent prompt.

Type Aliases§

CompletionStream
A streamed completion.
StreamEvents
A completion stream as the bus carries it.