Class: Durable::Llm::Providers::OpenAI::OpenAIResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ OpenAIResponse

Returns a new instance of OpenAIResponse.



147
148
149
# File 'lib/durable/llm/providers/openai.rb', line 147

def initialize(response)
  @raw_response = response
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



145
146
147
# File 'lib/durable/llm/providers/openai.rb', line 145

def raw_response
  @raw_response
end

Instance Method Details

#choicesObject



151
152
153
# File 'lib/durable/llm/providers/openai.rb', line 151

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

#dataObject



155
156
157
# File 'lib/durable/llm/providers/openai.rb', line 155

def data
  @raw_response['data']
end

#embeddingObject



159
160
161
# File 'lib/durable/llm/providers/openai.rb', line 159

def embedding
  @raw_response['embedding']
end

#to_sObject



163
164
165
# File 'lib/durable/llm/providers/openai.rb', line 163

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