Class: Anthropic::Helpers::Tools::BaseTool
- Inherits:
-
Object
- Object
- Anthropic::Helpers::Tools::BaseTool
- Defined in:
- lib/anthropic/helpers/tools/base_tool.rb
Constant Summary
Constants included from InputSchema::JsonSchemaConverter
InputSchema::JsonSchemaConverter::NO_REF, InputSchema::JsonSchemaConverter::POINTERS
Class Attribute Summary collapse
Class Method Summary collapse
- .description(description) ⇒ void (also: doc)
- .input_schema(model) ⇒ void
- .inspect(depth: 0) ⇒ void private
Instance Method Summary collapse
- #call(parsed) ⇒ void
- #coerce(value, state:) ⇒ void private
- #dump(value, state:) ⇒ void private
- #inspect ⇒ void private
-
#parse(value) ⇒ Object
Override the
#parsemethod to customize the pre-processing of the tool call argument. - #to_json_schema ⇒ void private
- #to_json_schema_inner(state:) ⇒ void private
Methods included from InputSchema::JsonSchemaConverter
assoc_meta!, cache_def!, to_json_schema, to_json_schema_inner, to_nilable
Methods included from Internal::Type::Converter
coerce, dump, meta_info, new_coerce_state, type_info
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Class Attribute Details
.doc_string ⇒ String (readonly)
17 18 19 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 17 def doc_string @doc_string end |
.model ⇒ Class<Anthropic::Helpers::InputSchema::BaseModel> (readonly)
14 15 16 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 14 def model @model end |
Class Method Details
.description(description) ⇒ void Also known as: doc
22 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 22 def description(description) = (@doc_string = description) |
.input_schema(model) ⇒ void
29 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 29 def input_schema(model) = (@model = model) |
.inspect(depth: 0) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 34 def inspect(depth: 0) = "#{name}[#{model.inspect(depth:)}]" |
Instance Method Details
#call(parsed) ⇒ void
72 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 72 def call(parsed) = raise NotImplementedError.new |
#coerce(value, state:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 56 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 53 def coerce(value, state:) parsed = parse(value) Anthropic::Internal::Type::Converter.coerce(self.class.model, parsed, state:) end |
#dump(value, state:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 47 def dump(value, state:) Anthropic::Internal::Type::Converter.dump(self.class.model, value, state:) end |
#inspect ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
78 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 78 def inspect = "#<#{self.class.inspect(depth: 1)}:0x#{object_id.to_s(16)}>" |
#parse(value) ⇒ Object
Override the #parse method to customize the pre-processing of the tool call argument
67 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 67 def parse(value) = value |
#to_json_schema ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 43 def to_json_schema = self.class.model&.to_json_schema |
#to_json_schema_inner(state:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 |
# File 'lib/anthropic/helpers/tools/base_tool.rb', line 39 def to_json_schema_inner(state:) = self.class.model&.to_json_schema_inner(state:) |