Class: Durable::Llm::Providers::Perplexity::PerplexityResponse

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

Overview

Response class for Perplexity API completion responses.

Wraps the raw API response and provides access to choices and data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ PerplexityResponse

Returns a new instance of PerplexityResponse.



157
158
159
# File 'lib/durable/llm/providers/perplexity.rb', line 157

def initialize(response)
  @raw_response = response
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



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

def raw_response
  @raw_response
end

Instance Method Details

#choicesObject



161
162
163
# File 'lib/durable/llm/providers/perplexity.rb', line 161

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

#dataObject



165
166
167
# File 'lib/durable/llm/providers/perplexity.rb', line 165

def data
  @raw_response['data']
end

#to_sObject



169
170
171
# File 'lib/durable/llm/providers/perplexity.rb', line 169

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