class StreamingResponseParser
Parses streaming responses for the Ollama API, collecting the response string.
Definitions
def initialize(...)
Initializes the parser with an empty response string.
Implementation
def initialize(...)
super
@response = String.new
@value[:response] = @response
end
def each
Iterates over each response line, yielding the response string.
Signature
-
returns
Enumerator
Yields each response string.
Implementation
def each
super do |line|
response = line.delete(:response)
@response << response
@value.merge!(line)
yield response
end
end