Class: Durable::Llm::Providers::Together::TogetherResponse

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

Overview

Response class for Together API completions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ TogetherResponse

Initializes the response with raw API data.

Parameters:

  • response (Hash)

    The raw response from the API



197
198
199
# File 'lib/durable/llm/providers/together.rb', line 197

def initialize(response)
  @raw_response = response
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



192
193
194
# File 'lib/durable/llm/providers/together.rb', line 192

def raw_response
  @raw_response
end

Instance Method Details

#choicesArray<TogetherChoice>

Returns the choices from the response.

Returns:



204
205
206
# File 'lib/durable/llm/providers/together.rb', line 204

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

#dataArray, Hash

Returns the data from the response.

Returns:

  • (Array, Hash)

    The data portion of the response



211
212
213
# File 'lib/durable/llm/providers/together.rb', line 211

def data
  @raw_response['data']
end

#to_sString

Converts the response to a string.

Returns:

  • (String)

    The concatenated content of all choices



218
219
220
# File 'lib/durable/llm/providers/together.rb', line 218

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