class

Crig::StreamingCompletionResponse(R)

Inherits Reference < Object

Stateful wrapper around provider streaming output. Providers emit raw choices; this class assembles them into assistant content, tracks the final response, and exposes pause/resume/cancel controls.

Constructors

from_raw_choices(raw_choices : Array(RawStreamingChoice(R))) : self
Source
new(chunks : Array(String), response : R | Nil = nil, choice : Crig::OneOrMany(Crig::Completion::AssistantContent) | Nil = nil, message_id : String | Nil = nil, pause_control : PauseControl = PauseControl.new, cancelled : Bool = false)
Source
stream(raw_choices : Array(RawStreamingChoice(R))) : self

Build a streaming response from pre-parsed provider streaming choices.

Source
stream(chunks : Array(String), response : R | Nil = nil) : self

Build a streaming response from plain text chunks.

Source
stream(source_channel : Channel(Crig::Concurrency::Result(RawStreamingChoice(R)))) : self

Build a streaming response from a channel-backed source.

Source
stream_raw_choices(raw_choices : Array(RawStreamingChoice(R))) : self
Source

Class methods

raw_choices_from_choice(choice : Crig::OneOrMany(Crig::Completion::AssistantContent)) : Array(RawStreamingChoice(R))
Source

Instance methods

cancel
Source
cancelled

ameba:disable Naming/QueryBoolMethods

Source
choice
Source
chunks
Source
consume
Source
each_item
Source
final_response_yielded
Source
final_response_yielded?
Source
is_paused

ameba:disable Naming/PredicateName

Source
load_raw_choices(raw_choices : Array(RawStreamingChoice(R))) : self
Source
load_stream_channel(source_channel : Channel(Crig::Concurrency::Result(RawStreamingChoice(R)))) : self
Source
message_id
Source
next_item
Source
pause
Source
pause_control
Source
response
Source
resume
Source
to_completion_response
Source