Class: Durable::Llm::Providers::Xai::XaiChoice

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

Overview

Represents a single choice in an xAI response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(choice) ⇒ XaiChoice

Initializes the choice with message and finish reason.

Parameters:

  • choice (Hash)

    The choice data from the API response



239
240
241
242
# File 'lib/durable/llm/providers/xai.rb', line 239

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

Instance Attribute Details

#finish_reasonObject (readonly)

Returns the value of attribute finish_reason.



234
235
236
# File 'lib/durable/llm/providers/xai.rb', line 234

def finish_reason
  @finish_reason
end

#messageObject (readonly)

Returns the value of attribute message.



234
235
236
# File 'lib/durable/llm/providers/xai.rb', line 234

def message
  @message
end

Instance Method Details

#to_sString

Converts the choice to a string by returning the message content.

Returns:

  • (String)

    The message content



247
248
249
# File 'lib/durable/llm/providers/xai.rb', line 247

def to_s
  @message.to_s
end