Crig::StreamingCompletionResponse(R)
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
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)
SourceBuild a streaming response from pre-parsed provider streaming choices.
Build a streaming response from plain text chunks.
Build a streaming response from a channel-backed source.
Class methods
raw_choices_from_choice(choice : Crig::OneOrMany(Crig::Completion::AssistantContent)) : Array(RawStreamingChoice(R))
SourceInstance methods
cancel
Sourcechoice
Sourcechunks
Sourceconsume
Sourceeach_item
Sourcefinal_response_yielded
Sourcefinal_response_yielded?
Sourceload_stream_channel(source_channel : Channel(Crig::Concurrency::Result(RawStreamingChoice(R)))) : self
Sourcemessage_id
Sourcenext_item
Sourcepause
Sourcepause_control
Sourceresponse
Sourceresume
Sourceto_completion_response
Source