Class: LLM::Ollama::StreamParser
- Inherits:
-
Object
- Object
- LLM::Ollama::StreamParser
- Defined in:
- lib/llm/providers/ollama/stream_parser.rb
Instance Attribute Summary collapse
-
#body ⇒ Hash
readonly
Returns the fully constructed response body.
Instance Method Summary collapse
-
#free ⇒ void
Frees internal parser state used during streaming.
- #initialize(stream) ⇒ LLM::OpenAI::Chunk constructor
- #parse!(chunk) ⇒ LLM::OpenAI::Chunk
Constructor Details
#initialize(stream) ⇒ LLM::OpenAI::Chunk
14 15 16 17 18 |
# File 'lib/llm/providers/ollama/stream_parser.rb', line 14 def initialize(stream) @body = {} @stream = stream @can_push_content = stream.respond_to?(:<<) end |
Instance Attribute Details
#body ⇒ Hash (readonly)
Returns the fully constructed response body
10 11 12 |
# File 'lib/llm/providers/ollama/stream_parser.rb', line 10 def body @body end |
Instance Method Details
#free ⇒ void
This method returns an undefined value.
Frees internal parser state used during streaming.
30 31 |
# File 'lib/llm/providers/ollama/stream_parser.rb', line 30 def free end |
#parse!(chunk) ⇒ LLM::OpenAI::Chunk
23 24 25 |
# File 'lib/llm/providers/ollama/stream_parser.rb', line 23 def parse!(chunk) tap { merge!(chunk) } end |