Class: OmniAI::Chat::Stream
- Inherits:
-
Object
- Object
- OmniAI::Chat::Stream
- Defined in:
- lib/omniai/chat/stream.rb
Overview
Used when streaming to process chunks of data.
Instance Method Summary collapse
-
#initialize(body:, logger: nil, context: nil) ⇒ Stream
constructor
A new instance of Stream.
- #stream! {|payload| ... } ⇒ Object
Constructor Details
#initialize(body:, logger: nil, context: nil) ⇒ Stream
Returns a new instance of Stream.
10 11 12 13 14 |
# File 'lib/omniai/chat/stream.rb', line 10 def initialize(body:, logger: nil, context: nil) @body = body @logger = logger @context = context end |
Instance Method Details
#stream! {|payload| ... } ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/omniai/chat/stream.rb', line 18 def stream!(&) @body.each do |chunk| parser.feed(chunk) do |type, data, id| process!(type, data, id, &) end end end |