Module: Anthropic::Models::Beta::BetaIterationsUsageItem

Extended by:
Internal::Type::Union
Defined in:
lib/anthropic/models/beta/beta_iterations_usage.rb,
sig/anthropic/models/beta/beta_iterations_usage.rbs

Defined Under Namespace

Modules: Type

Class Method Summary collapse

Methods included from Internal::Type::Union

==, ===, coerce, derefed_variants, dump, hash, inspect, to_sorbet_type

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, inspect, #inspect, meta_info, new_coerce_state, type_info

Class Method Details

.new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, model:, output_tokens:) ⇒ Anthropic::Beta::BetaMessageIterationUsage .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, output_tokens:) ⇒ Anthropic::Beta::BetaCompactionIterationUsage .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, model:, output_tokens:) ⇒ Anthropic::Beta::BetaAdvisorMessageIterationUsage .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, model:, output_tokens:) ⇒ Anthropic::Beta::BetaFallbackMessageIterationUsage .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, output_tokens:, model:) ⇒ Anthropic::Models::Beta::beta_iterations_usage_item

Creates a new instance of the variant class whose type matches the given value, passing the remaining arguments to its constructor.

Some parameter documentations has been truncated, see Anthropic::Models::Beta::BetaIterationsUsageItem for more details.

Overloads:

  • .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, model:, output_tokens:) ⇒ Anthropic::Beta::BetaMessageIterationUsage

    Parameters:

    • type: (:message, "message")
    • cache_creation: (Anthropic::Beta::BetaCacheCreation, nil)
    • cache_creation_input_tokens: (Integer)
    • cache_read_input_tokens: (Integer)
    • input_tokens: (Integer)
    • model: (Anthropic::Models::model, nil)
    • output_tokens: (Integer)

    Returns:

    • (Anthropic::Beta::BetaMessageIterationUsage)
  • .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, output_tokens:) ⇒ Anthropic::Beta::BetaCompactionIterationUsage

    Parameters:

    • type: (:compaction, "compaction")
    • cache_creation: (Anthropic::Beta::BetaCacheCreation, nil)
    • cache_creation_input_tokens: (Integer)
    • cache_read_input_tokens: (Integer)
    • input_tokens: (Integer)
    • output_tokens: (Integer)

    Returns:

    • (Anthropic::Beta::BetaCompactionIterationUsage)
  • .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, model:, output_tokens:) ⇒ Anthropic::Beta::BetaAdvisorMessageIterationUsage

    Parameters:

    • type: (:advisor_message, "advisor_message")
    • cache_creation: (Anthropic::Beta::BetaCacheCreation, nil)
    • cache_creation_input_tokens: (Integer)
    • cache_read_input_tokens: (Integer)
    • input_tokens: (Integer)
    • model: (Anthropic::Models::model)
    • output_tokens: (Integer)

    Returns:

    • (Anthropic::Beta::BetaAdvisorMessageIterationUsage)
  • .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, model:, output_tokens:) ⇒ Anthropic::Beta::BetaFallbackMessageIterationUsage

    Parameters:

    • type: (:fallback_message, "fallback_message")
    • cache_creation: (Anthropic::Beta::BetaCacheCreation, nil)
    • cache_creation_input_tokens: (Integer)
    • cache_read_input_tokens: (Integer)
    • input_tokens: (Integer)
    • model: (Anthropic::Models::model)
    • output_tokens: (Integer)

    Returns:

    • (Anthropic::Beta::BetaFallbackMessageIterationUsage)
  • .new(type:, cache_creation:, cache_creation_input_tokens:, cache_read_input_tokens:, input_tokens:, output_tokens:, model:) ⇒ Anthropic::Models::Beta::beta_iterations_usage_item

    Parameters:

    • type: (Anthropic::Models::Beta::BetaIterationsUsageItem::type_, String)
    • cache_creation: (Anthropic::Beta::BetaCacheCreation, nil)
    • cache_creation_input_tokens: (Integer)
    • cache_read_input_tokens: (Integer)
    • input_tokens: (Integer)
    • output_tokens: (Integer)
    • model: (Anthropic::Models::model?, Anthropic::Models::model)

    Returns:

    • (Anthropic::Models::Beta::beta_iterations_usage_item)

Parameters:

  • type (Symbol, Anthropic::Models::Beta::BetaIterationsUsageItem::Type, String)
  • args (Hash{Symbol=>Object}) —

    Attributes for the chosen variant.

    @option args [Anthropic::Models::Beta::BetaCacheCreation, nil] :cache_creation Breakdown of cached tokens by TTL

    @option args [Integer] :cache_creation_input_tokens The number of input tokens used to create the cache entry.

    @option args [Integer] :cache_read_input_tokens The number of input tokens read from the cache.

    @option args [Integer] :input_tokens The number of input tokens which were used.

    @option args [Symbol, String, Anthropic::Models::Model, nil, Symbol, String, Anthropic::Models::Model] :model The model that will complete your prompt.

    @option args [Integer] :output_tokens The number of output tokens which were used.

Returns:

Raises:

  • (ArgumentError)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/anthropic/models/beta/beta_iterations_usage.rb', line 69

def self.new(type:, **args)
  case type.to_sym
  when :message
    Anthropic::Beta::BetaMessageIterationUsage.new(**args)
  when :compaction
    Anthropic::Beta::BetaCompactionIterationUsage.new(**args)
  when :advisor_message
    Anthropic::Beta::BetaAdvisorMessageIterationUsage.new(**args)
  when :fallback_message
    Anthropic::Beta::BetaFallbackMessageIterationUsage.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end

.values ⇒ Array<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/anthropic/models/beta/beta_iterations_usage.rb', line 38

.variants ⇒ Array(Anthropic::Models::Beta::BetaMessageIterationUsage, Anthropic::Models::Beta::BetaCompactionIterationUsage, Anthropic::Models::Beta::BetaAdvisorMessageIterationUsage, Anthropic::Models::Beta::BetaFallbackMessageIterationUsage)



# File 'lib/anthropic/models/beta/beta_iterations_usage.rb', line 42