Class: Durable::Llm::Providers::Mistral::MistralResponse

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

Overview

Response object for Mistral AI completion API responses

Wraps the raw API response and provides convenient access to choices and data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ MistralResponse

Initializes a new response object

Parameters:

  • response (Hash)

    The raw API response data



250
251
252
# File 'lib/durable/llm/providers/mistral.rb', line 250

def initialize(response)
  @raw_response = response
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



245
246
247
# File 'lib/durable/llm/providers/mistral.rb', line 245

def raw_response
  @raw_response
end

Instance Method Details

#choicesArray<MistralChoice>

Returns the completion choices from the response

Returns:



257
258
259
# File 'lib/durable/llm/providers/mistral.rb', line 257

def choices
  @raw_response['choices'].map { |choice| MistralChoice.new(choice) }
end

#dataArray

Returns the raw data array from the response

Returns:

  • (Array)

    The data array from the API response



264
265
266
# File 'lib/durable/llm/providers/mistral.rb', line 264

def data
  @raw_response['data']
end

#to_sString

Returns the concatenated text of all choices

Returns:

  • (String)

    The combined text content of all choices



271
272
273
# File 'lib/durable/llm/providers/mistral.rb', line 271

def to_s
  choices.map(&:to_s).join(' ')
end