Class: Foam::Otel::LLM::HttpAnthropicShim::BufferedBodyStream
- Inherits:
-
Object
- Object
- Foam::Otel::LLM::HttpAnthropicShim::BufferedBodyStream
- Defined in:
- lib/foam/otel/llm/http_anthropic_shim.rb
Overview
Matches HTTP::Connection's readpartial contract (nil at EOF, never EOFError) so a restored Body streams exactly like a live one.
Constant Summary collapse
- CHUNK =
16_384
Instance Method Summary collapse
-
#initialize(contents) ⇒ BufferedBodyStream
constructor
A new instance of BufferedBodyStream.
- #readpartial(size = CHUNK, outbuf = nil) ⇒ Object
Constructor Details
#initialize(contents) ⇒ BufferedBodyStream
Returns a new instance of BufferedBodyStream.
221 222 223 |
# File 'lib/foam/otel/llm/http_anthropic_shim.rb', line 221 def initialize(contents) @io = StringIO.new(contents) end |
Instance Method Details
#readpartial(size = CHUNK, outbuf = nil) ⇒ Object
225 226 227 228 229 |
# File 'lib/foam/otel/llm/http_anthropic_shim.rb', line 225 def readpartial(size = CHUNK, outbuf = nil) return nil if @io.eof? outbuf ? @io.readpartial(size, outbuf) : @io.readpartial(size) end |