Module: RubyLLM::Protocol::BinaryStreaming
- Included in:
- RubyLLM::Protocol
- Defined in:
- lib/ruby_llm/protocol/binary_streaming.rb
Overview
:nodoc: all
Instance Method Summary collapse
Instance Method Details
#stream_binary(url, payload) {|state.buffer.dup| ... } ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ruby_llm/protocol/binary_streaming.rb', line 6 def stream_binary(url, payload, &) progress = {} fallback = Streaming::StreamState.new on_data = binary_on_data(fallback, progress, &) response = @connection.post(url, payload, usage: @usage_tracker) do |request| (request..context ||= {})[Transport::Connection::STREAM_PROGRESS_KEY] = progress if faraday_1? request.[:on_data] = on_data else request..on_data = on_data end end state = response.env[:streaming_state] || fallback validate_binary_response(response, state.buffer) yield state.buffer.dup unless progress[:started] || state.buffer.empty? response.env.body = state.buffer.b response end |