Class: LLM::OpenAI::Responses::StreamParser
- Inherits:
-
Object
- Object
- LLM::OpenAI::Responses::StreamParser
- Defined in:
- lib/llm/providers/openai/responses/stream_parser.rb
Constant Summary collapse
- EMPTY_HASH =
{}.freeze
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::Responses::StreamParser constructor
- #parse!(chunk) ⇒ LLM::OpenAI::Responses::StreamParser
Constructor Details
#initialize(stream) ⇒ LLM::OpenAI::Responses::StreamParser
17 18 19 20 21 22 23 24 25 |
# File 'lib/llm/providers/openai/responses/stream_parser.rb', line 17 def initialize(stream) @body = {"output" => []} @stream = stream @emits = {tools: {}} @cached_output_index = nil @cached_output_item = nil @cached_content_index = nil @cached_content_part = nil end |
Instance Attribute Details
#body ⇒ Hash (readonly)
Returns the fully constructed response body
12 13 14 |
# File 'lib/llm/providers/openai/responses/stream_parser.rb', line 12 def body @body end |
Instance Method Details
#free ⇒ void
This method returns an undefined value.
Frees internal parser state used during streaming.
37 38 39 40 |
# File 'lib/llm/providers/openai/responses/stream_parser.rb', line 37 def free @emits.clear clear_cache! end |
#parse!(chunk) ⇒ LLM::OpenAI::Responses::StreamParser
30 31 32 |
# File 'lib/llm/providers/openai/responses/stream_parser.rb', line 30 def parse!(chunk) tap { handle_event(chunk) } end |