Class: Durable::Llm::Providers::OpenRouter::OpenRouterResponse

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

Overview

Response wrapper for OpenRouter API completion responses.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ OpenRouterResponse

Returns a new instance of OpenRouterResponse.



152
153
154
# File 'lib/durable/llm/providers/openrouter.rb', line 152

def initialize(response)
  @raw_response = response
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



150
151
152
# File 'lib/durable/llm/providers/openrouter.rb', line 150

def raw_response
  @raw_response
end

Instance Method Details

#choicesObject



156
157
158
# File 'lib/durable/llm/providers/openrouter.rb', line 156

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

#dataObject



160
161
162
# File 'lib/durable/llm/providers/openrouter.rb', line 160

def data
  @raw_response['data']
end

#to_sObject



164
165
166
# File 'lib/durable/llm/providers/openrouter.rb', line 164

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