Class: Async::Ollama::StreamingResponseParser
- Inherits:
-
StreamingParser
- Object
- Protocol::HTTP::Body::Wrapper
- StreamingParser
- Async::Ollama::StreamingResponseParser
- Defined in:
- lib/async/ollama/wrapper.rb
Overview
Parses streaming responses for the Ollama API, collecting the response string.
Instance Method Summary collapse
-
#each ⇒ Object
Iterates over each response line, yielding the response string.
-
#initialize ⇒ StreamingResponseParser
constructor
Initializes the parser with an empty response string.
Methods inherited from StreamingParser
Constructor Details
#initialize ⇒ StreamingResponseParser
Initializes the parser with an empty response string.
68 69 70 71 72 73 |
# File 'lib/async/ollama/wrapper.rb', line 68 def initialize(...) super @response = String.new @value[:response] = @response end |
Instance Method Details
#each ⇒ Object
Iterates over each response line, yielding the response string.
77 78 79 80 81 82 83 84 85 |
# File 'lib/async/ollama/wrapper.rb', line 77 def each super do |line| response = line.delete(:response) @response << response @value.merge!(line) yield response end end |