Class: Durable::Llm::Providers::Groq::GroqResponse

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_responseObject (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

#choicesObject



162
163
164
# File 'lib/durable/llm/providers/groq.rb', line 162

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

#dataObject



166
167
168
# File 'lib/durable/llm/providers/groq.rb', line 166

def data
  @raw_response['data']
end

#embeddingObject



170
171
172
# File 'lib/durable/llm/providers/groq.rb', line 170

def embedding
  @raw_response.dig('data', 0, 'embedding')
end

#to_hObject



178
179
180
# File 'lib/durable/llm/providers/groq.rb', line 178

def to_h
  @raw_response.dup
end

#to_sObject



174
175
176
# File 'lib/durable/llm/providers/groq.rb', line 174

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