Module: RubyLLM::Providers::Bedrock::Streaming::MessageProcessing
- Defined in:
- lib/ruby_llm/providers/bedrock/streaming/message_processing.rb
Overview
Module for processing streaming messages from AWS Bedrock.
Instance Method Summary collapse
- #process_chunk(chunk) ⇒ Object
- #process_message(chunk, offset) ⇒ Object
- #process_valid_message(chunk, offset, message_info) ⇒ Object
Instance Method Details
#process_chunk(chunk) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/ruby_llm/providers/bedrock/streaming/message_processing.rb', line 9 def process_chunk(chunk, &) offset = 0 offset = (chunk, offset, &) while offset < chunk.bytesize rescue StandardError => e RubyLLM.logger.debug "Error processing chunk: #{e.message}" RubyLLM.logger.debug "Chunk size: #{chunk.bytesize}" end |
#process_message(chunk, offset) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/ruby_llm/providers/bedrock/streaming/message_processing.rb', line 17 def (chunk, offset, &) return chunk.bytesize unless can_read_prelude?(chunk, offset) = (chunk, offset) return (chunk, offset) unless (chunk, offset, , &) end |
#process_valid_message(chunk, offset, message_info) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/ruby_llm/providers/bedrock/streaming/message_processing.rb', line 26 def (chunk, offset, , &) payload = extract_payload(chunk, [:headers_end], [:payload_end]) return (chunk, offset) unless valid_payload?(payload) process_payload(payload, &) offset + [:total_length] end |