Class: Durable::Llm::Providers::Anthropic::AnthropicResponse

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

Overview

Response object for Anthropic messages API responses.

This class wraps the raw response from Anthropic’s messages endpoint and provides a consistent interface for accessing content and metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ AnthropicResponse



270
271
272
# File 'lib/durable/llm/providers/anthropic.rb', line 270

def initialize(response)
  @raw_response = response
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



268
269
270
# File 'lib/durable/llm/providers/anthropic.rb', line 268

def raw_response
  @raw_response
end

Instance Method Details

#choicesObject



274
275
276
# File 'lib/durable/llm/providers/anthropic.rb', line 274

def choices
  [AnthropicChoice.new(@raw_response)]
end

#to_sObject



282
283
284
# File 'lib/durable/llm/providers/anthropic.rb', line 282

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

#usageObject



278
279
280
# File 'lib/durable/llm/providers/anthropic.rb', line 278

def usage
  @raw_response['usage']
end