Class: Durable::Llm::Providers::OpenAI::OpenAIChoice

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

Overview

Represents a single choice in an OpenAI chat completion response.

Each choice contains a message with role and content, along with metadata like finish reason.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(choice) ⇒ OpenAIChoice

Returns a new instance of OpenAIChoice.



299
300
301
302
# File 'lib/durable/llm/providers/openai.rb', line 299

def initialize(choice)
  @message = OpenAIMessage.new(choice['message'])
  @finish_reason = choice['finish_reason']
end

Instance Attribute Details

#finish_reasonObject (readonly)

Returns the value of attribute finish_reason.



297
298
299
# File 'lib/durable/llm/providers/openai.rb', line 297

def finish_reason
  @finish_reason
end

#messageObject (readonly)

Returns the value of attribute message.



297
298
299
# File 'lib/durable/llm/providers/openai.rb', line 297

def message
  @message
end

Instance Method Details

#to_sObject



304
305
306
# File 'lib/durable/llm/providers/openai.rb', line 304

def to_s
  @message.to_s
end