Class: Durable::Llm::Providers::OpenAI::OpenAIStreamChoice

Inherits:
Object
  • Object
show all
Defined in:
lib/durable/llm/providers/openai.rb

Overview

Represents a single choice in a streaming OpenAI response chunk.

Contains the delta (incremental content) and finish reason for the choice.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(choice) ⇒ OpenAIStreamChoice

Returns a new instance of OpenAIStreamChoice.



362
363
364
365
366
# File 'lib/durable/llm/providers/openai.rb', line 362

def initialize(choice)
  @choice = [choice].flatten.first
  @delta = OpenAIStreamDelta.new(@choice['delta'])
  @finish_reason = @choice['finish_reason']
end

Instance Attribute Details

#deltaObject (readonly)

Returns the value of attribute delta.



360
361
362
# File 'lib/durable/llm/providers/openai.rb', line 360

def delta
  @delta
end

#finish_reasonObject (readonly)

Returns the value of attribute finish_reason.



360
361
362
# File 'lib/durable/llm/providers/openai.rb', line 360

def finish_reason
  @finish_reason
end

Instance Method Details

#to_sObject



368
369
370
# File 'lib/durable/llm/providers/openai.rb', line 368

def to_s
  @delta.to_s
end