Module: Anthropic::Models::ToolChoice

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

Overview

How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Internal::Type::Union

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

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:, **args) ⇒ Anthropic::Models::ToolChoiceAuto, ...

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::ToolChoice for more details.

Parameters:

  • type (Symbol, String)
  • args (Hash{Symbol=>Object})

    Attributes for the chosen variant.

    @option args [Boolean] :disable_parallel_tool_use Whether to disable parallel tool use.

    @option args [String] :name The name of the tool to use.

Returns:

Raises:

  • (ArgumentError)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/anthropic/models/tool_choice.rb', line 43

def self.new(type:, **args)
  case type.to_sym
  when :auto
    Anthropic::ToolChoiceAuto.new(**args)
  when :any
    Anthropic::ToolChoiceAny.new(**args)
  when :tool
    Anthropic::ToolChoiceTool.new(**args)
  when :none
    Anthropic::ToolChoiceNone.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end

Instance Method Details

#self?.variants::Array[Anthropic::Models::tool_choice]

Returns:

  • (::Array[Anthropic::Models::tool_choice])


12
# File 'sig/anthropic/models/tool_choice.rbs', line 12

def self?.variants: -> ::Array[Anthropic::Models::tool_choice]