Class: LLM::Google::StreamParser
- Inherits:
-
Object
- Object
- LLM::Google::StreamParser
- Defined in:
- lib/llm/providers/google/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::Google::StreamParser constructor
- #parse!(chunk) ⇒ LLM::Google::StreamParser
Constructor Details
#initialize(stream) ⇒ LLM::Google::StreamParser
15 16 17 18 19 |
# File 'lib/llm/providers/google/stream_parser.rb', line 15 def initialize(stream) @body = {"candidates" => []} @stream = stream @emits = {tools: []} end |
Instance Attribute Details
#body ⇒ Hash (readonly)
Returns the fully constructed response body
10 11 12 |
# File 'lib/llm/providers/google/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.
31 32 33 |
# File 'lib/llm/providers/google/stream_parser.rb', line 31 def free @emits.clear end |
#parse!(chunk) ⇒ LLM::Google::StreamParser
24 25 26 |
# File 'lib/llm/providers/google/stream_parser.rb', line 24 def parse!(chunk) tap { merge_chunk!(chunk) } end |