Class: Durable::Llm::Providers::Perplexity::PerplexityResponse
- Inherits:
-
Object
- Object
- Durable::Llm::Providers::Perplexity::PerplexityResponse
- 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
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
- #choices ⇒ Object
- #data ⇒ Object
-
#initialize(response) ⇒ PerplexityResponse
constructor
A new instance of PerplexityResponse.
- #to_s ⇒ Object
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_response ⇒ Object (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
#choices ⇒ Object
161 162 163 |
# File 'lib/durable/llm/providers/perplexity.rb', line 161 def choices @raw_response['choices'].map { |choice| PerplexityChoice.new(choice) } end |
#data ⇒ Object
165 166 167 |
# File 'lib/durable/llm/providers/perplexity.rb', line 165 def data @raw_response['data'] end |
#to_s ⇒ Object
169 170 171 |
# File 'lib/durable/llm/providers/perplexity.rb', line 169 def to_s choices.map(&:to_s).join(' ') end |