Class: OmniAI::Llama::Chat::Stream
- Inherits:
-
Chat::Stream
- Object
- Chat::Stream
- OmniAI::Llama::Chat::Stream
- Defined in:
- lib/omniai/llama/chat/stream.rb
Overview
A stream is used to process a series of chunks of data. It converts the following into a combined payload.
Instance Method Summary collapse
Instance Method Details
#stream! {|delta| ... } ⇒ Hash
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/omniai/llama/chat/stream.rb', line 12 def stream!(&block) @message = { "role" => "assistant" } @metrics = [] @chunks.map do |chunk| parser.feed(chunk) do |type, data, id| process!(type, data, id, &block) end end { "completion_message" => @message, "metrics" => @metrics, } end |