Class: Durable::Llm::Providers::OpenAI::OpenAIStreamChoice
- Inherits:
-
Object
- Object
- Durable::Llm::Providers::OpenAI::OpenAIStreamChoice
- 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
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
-
#finish_reason ⇒ Object
readonly
Returns the value of attribute finish_reason.
Instance Method Summary collapse
-
#initialize(choice) ⇒ OpenAIStreamChoice
constructor
A new instance of OpenAIStreamChoice.
- #to_s ⇒ Object
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
#delta ⇒ Object (readonly)
Returns the value of attribute delta.
360 361 362 |
# File 'lib/durable/llm/providers/openai.rb', line 360 def delta @delta end |
#finish_reason ⇒ Object (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_s ⇒ Object
368 369 370 |
# File 'lib/durable/llm/providers/openai.rb', line 368 def to_s @delta.to_s end |