Class: LLM::Transport::StreamDecoder Private
- Inherits:
-
Object
- Object
- LLM::Transport::StreamDecoder
- Defined in:
- lib/llm/transport/stream_decoder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
LLM::Transport::StreamDecoder incrementally decodes streamed HTTP response bodies into parser events.
Instance Attribute Summary collapse
- #parser ⇒ Object readonly private
Instance Method Summary collapse
- #initialize(parser = nil) {|chunk| ... } ⇒ LLM::Transport::StreamDecoder constructor private
- #<<(chunk) ⇒ void private
- #body ⇒ Object private
- #free ⇒ void private
Constructor Details
#initialize(parser = nil) {|chunk| ... } ⇒ LLM::Transport::StreamDecoder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 25 |
# File 'lib/llm/transport/stream_decoder.rb', line 19 def initialize(parser = nil, &on_chunk) @buffer = +"" @cursor = 0 @data = [] @parser = parser @on_chunk = on_chunk end |
Instance Attribute Details
#parser ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/llm/transport/stream_decoder.rb', line 13 def parser @parser end |
Instance Method Details
#<<(chunk) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
30 31 32 33 |
# File 'lib/llm/transport/stream_decoder.rb', line 30 def <<(chunk) @buffer << chunk each_line { handle_line(_1) } end |
#body ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'lib/llm/transport/stream_decoder.rb', line 37 def body parser.body end |
#free ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
43 44 45 46 47 48 |
# File 'lib/llm/transport/stream_decoder.rb', line 43 def free @buffer.clear @cursor = 0 @data.clear parser.free if parser.respond_to?(:free) end |