Class: Providers::Anthropic::ApiResponse

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

Overview

Response wrapper containing both the parsed body and API metrics. Behaves like a Hash for backward compatibility (delegates to body).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_metricsObject (readonly)

Returns the value of attribute api_metrics

Returns:

  • (Object)

    the current value of api_metrics



37
38
39
40
41
42
43
44
45
46
# File 'lib/providers/anthropic.rb', line 37

ApiResponse = Data.define(:body, :api_metrics) do
  # Delegate Hash methods to body for backward compatibility.
  # Callers using response["content"] continue to work unchanged.
  def [](key) = body[key]
  def dig(...) = body.dig(...)
  def fetch(...) = body.fetch(...)
  def key?(key) = body.key?(key)
  def to_h = body
  def to_json(...) = body.to_json(...)
end

#bodyObject (readonly)

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



37
38
39
40
41
42
43
44
45
46
# File 'lib/providers/anthropic.rb', line 37

ApiResponse = Data.define(:body, :api_metrics) do
  # Delegate Hash methods to body for backward compatibility.
  # Callers using response["content"] continue to work unchanged.
  def [](key) = body[key]
  def dig(...) = body.dig(...)
  def fetch(...) = body.fetch(...)
  def key?(key) = body.key?(key)
  def to_h = body
  def to_json(...) = body.to_json(...)
end

Instance Method Details

#[](key) ⇒ Object

Delegate Hash methods to body for backward compatibility. Callers using response continue to work unchanged.



40
# File 'lib/providers/anthropic.rb', line 40

def [](key) = body[key]

#digObject



41
# File 'lib/providers/anthropic.rb', line 41

def dig(...) = body.dig(...)

#fetchObject



42
# File 'lib/providers/anthropic.rb', line 42

def fetch(...) = body.fetch(...)

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


43
# File 'lib/providers/anthropic.rb', line 43

def key?(key) = body.key?(key)

#to_hObject



44
# File 'lib/providers/anthropic.rb', line 44

def to_h = body

#to_jsonObject



45
# File 'lib/providers/anthropic.rb', line 45

def to_json(...) = body.to_json(...)