Class: Durable::Llm::Providers::Mistral::MistralResponse
- Inherits:
-
Object
- Object
- Durable::Llm::Providers::Mistral::MistralResponse
- 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
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
-
#choices ⇒ Array<MistralChoice>
Returns the completion choices from the response.
-
#data ⇒ Array
Returns the raw data array from the response.
-
#initialize(response) ⇒ MistralResponse
constructor
Initializes a new response object.
-
#to_s ⇒ String
Returns the concatenated text of all choices.
Constructor Details
#initialize(response) ⇒ MistralResponse
Initializes a new response object
250 251 252 |
# File 'lib/durable/llm/providers/mistral.rb', line 250 def initialize(response) @raw_response = response end |
Instance Attribute Details
#raw_response ⇒ Object (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
#choices ⇒ Array<MistralChoice>
Returns the completion choices from the response
257 258 259 |
# File 'lib/durable/llm/providers/mistral.rb', line 257 def choices @raw_response['choices'].map { |choice| MistralChoice.new(choice) } end |
#data ⇒ Array
Returns the raw data array from the response
264 265 266 |
# File 'lib/durable/llm/providers/mistral.rb', line 264 def data @raw_response['data'] end |
#to_s ⇒ String
Returns the concatenated text of all choices
271 272 273 |
# File 'lib/durable/llm/providers/mistral.rb', line 271 def to_s choices.map(&:to_s).join(' ') end |