Class: Async::Ollama::StreamingMessageParser
- Inherits:
-
StreamingParser
- Object
- Protocol::HTTP::Body::Wrapper
- StreamingParser
- Async::Ollama::StreamingMessageParser
- Defined in:
- lib/async/ollama/wrapper.rb
Overview
Parses streaming message responses for the Ollama API, collecting message content.
Instance Method Summary collapse
-
#each ⇒ Object
Iterates over each message line, yielding the message content.
-
#initialize ⇒ StreamingMessageParser
constructor
Initializes the parser with an empty message content.
Methods inherited from StreamingParser
Constructor Details
#initialize ⇒ StreamingMessageParser
Initializes the parser with an empty message content.
91 92 93 94 95 96 97 |
# File 'lib/async/ollama/wrapper.rb', line 91 def initialize(...) super @content = String.new @message = {content: @content, role: "assistant"} @value[:message] = @message end |
Instance Method Details
#each ⇒ Object
Iterates over each message line, yielding the message content.
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/async/ollama/wrapper.rb', line 101 def each super do |line| = line.delete(:message) content = .delete(:content) @content << content @message.merge!() @value.merge!(line) yield content end end |