Class: RSmolagent::Tool
- Inherits:
-
Object
- Object
- RSmolagent::Tool
- Defined in:
- lib/rsmolagent/tool.rb
Direct Known Subclasses
FinalAnswerTool, RSmolagent::Tools::CustomClassExecutorTool, RSmolagent::Tools::RubyExecutorTool, RSmolagent::Tools::WebSearchTool
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#input_schema ⇒ Object
readonly
Returns the value of attribute input_schema.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call(args = {}) ⇒ Object
- #execute(args) ⇒ Object
-
#initialize(name:, description:, input_schema: {}, output_type: "string") ⇒ Tool
constructor
A new instance of Tool.
- #to_json_schema ⇒ Object
Constructor Details
#initialize(name:, description:, input_schema: {}, output_type: "string") ⇒ Tool
Returns a new instance of Tool.
7 8 9 10 11 12 |
# File 'lib/rsmolagent/tool.rb', line 7 def initialize(name:, description:, input_schema: {}, output_type: "string") @name = name @description = description @input_schema = input_schema @output_type = output_type end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/rsmolagent/tool.rb', line 5 def description @description end |
#input_schema ⇒ Object (readonly)
Returns the value of attribute input_schema.
5 6 7 |
# File 'lib/rsmolagent/tool.rb', line 5 def input_schema @input_schema end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rsmolagent/tool.rb', line 5 def name @name end |
Instance Method Details
#call(args = {}) ⇒ Object
14 15 16 17 |
# File 'lib/rsmolagent/tool.rb', line 14 def call(args = {}) args = args.transform_keys(&:to_sym) if args.is_a?(Hash) execute(args) end |
#execute(args) ⇒ Object
19 20 21 |
# File 'lib/rsmolagent/tool.rb', line 19 def execute(args) raise NotImplementedError, "Subclasses must implement the 'execute' method" end |
#to_json_schema ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rsmolagent/tool.rb', line 23 def to_json_schema { "name" => @name, "description" => @description, "parameters" => { "type" => "object", "properties" => formatted_input_schema, "required" => required_parameters } } end |