Class: OmniAI::Google::Chat::Stream

Inherits:
Chat::Stream
  • Object
show all
Defined in:
lib/omniai/google/chat/stream.rb

Overview

A stream given when streaming.

Instance Method Summary collapse

Instance Method Details

#stream! {|OmniAI::Chat::Chunk| ... } ⇒ Object

Yields:

  • (OmniAI::Chat::Chunk)


9
10
11
12
13
14
15
# File 'lib/omniai/google/chat/stream.rb', line 9

def stream!(&)
  @response.body.each do |chunk|
    @parser.feed(chunk) do |_, data|
      yield(Chunk.new(data: JSON.parse(data)))
    end
  end
end