Class: Durable::Llm::Providers::Groq::GroqResponse
- Inherits:
-
Object
- Object
- Durable::Llm::Providers::Groq::GroqResponse
- Defined in:
- lib/durable/llm/providers/groq.rb
Overview
Response object for Groq chat API responses.
Wraps the raw response and provides a consistent interface for accessing message content, embeddings, and metadata.
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) ⇒ GroqResponse
constructor
A new instance of GroqResponse.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ GroqResponse
158 159 160 |
# File 'lib/durable/llm/providers/groq.rb', line 158 def initialize(response) @raw_response = response end |
Instance Attribute Details
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
156 157 158 |
# File 'lib/durable/llm/providers/groq.rb', line 156 def raw_response @raw_response end |
Instance Method Details
#choices ⇒ Object
162 163 164 |
# File 'lib/durable/llm/providers/groq.rb', line 162 def choices @raw_response['choices'].map { |choice| GroqChoice.new(choice) } end |
#data ⇒ Object
166 167 168 |
# File 'lib/durable/llm/providers/groq.rb', line 166 def data @raw_response['data'] end |
#embedding ⇒ Object
170 171 172 |
# File 'lib/durable/llm/providers/groq.rb', line 170 def @raw_response.dig('data', 0, 'embedding') end |
#to_h ⇒ Object
178 179 180 |
# File 'lib/durable/llm/providers/groq.rb', line 178 def to_h @raw_response.dup end |
#to_s ⇒ Object
174 175 176 |
# File 'lib/durable/llm/providers/groq.rb', line 174 def to_s choices.map(&:to_s).join(' ') end |