Class: Durable::Llm::Providers::OpenAI::OpenAIResponse
- Inherits:
-
Object
- Object
- Durable::Llm::Providers::OpenAI::OpenAIResponse
- Defined in:
- lib/durable/llm/providers/openai.rb
Instance Attribute Summary collapse
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
- #choices ⇒ Object
- #data ⇒ Object
- #embedding ⇒ Object
-
#initialize(response) ⇒ OpenAIResponse
constructor
A new instance of OpenAIResponse.
- #to_s ⇒ Object
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_response ⇒ Object (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
#choices ⇒ Object
151 152 153 |
# File 'lib/durable/llm/providers/openai.rb', line 151 def choices @raw_response['choices'].map { |choice| OpenAIChoice.new(choice) } end |
#data ⇒ Object
155 156 157 |
# File 'lib/durable/llm/providers/openai.rb', line 155 def data @raw_response['data'] end |
#embedding ⇒ Object
159 160 161 |
# File 'lib/durable/llm/providers/openai.rb', line 159 def @raw_response['embedding'] end |
#to_s ⇒ Object
163 164 165 |
# File 'lib/durable/llm/providers/openai.rb', line 163 def to_s choices.map(&:to_s).join(' ') end |