Module: RubyLLM::RedCandle::Streaming
- Included in:
- Provider
- Defined in:
- lib/ruby_llm/red_candle/streaming.rb
Overview
Streaming methods of the RedCandle integration
Instance Method Summary collapse
Instance Method Details
#stream(payload, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ruby_llm/red_candle/streaming.rb', line 7 def stream(payload, &block) if payload[:stream] perform_streaming_completion!(payload, &block) else # Non-streaming fallback result = perform_completion!(payload) # Yield the complete result as a single chunk chunk = { content: result[:content], role: result[:role], finish_reason: result[:finish_reason] } block.call(chunk) end end |