Class: RSmolagent::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/rsmolagent/tool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/rsmolagent/tool.rb', line 5

def description
  @description
end

#input_schemaObject (readonly)

Returns the value of attribute input_schema.



5
6
7
# File 'lib/rsmolagent/tool.rb', line 5

def input_schema
  @input_schema
end

#nameObject (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

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/rsmolagent/tool.rb', line 19

def execute(args)
  raise NotImplementedError, "Subclasses must implement the 'execute' method"
end

#to_json_schemaObject



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