Class: Rubino::Tools::CustomToolBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/tools/custom_tool_loader.rb

Overview

DSL builder for custom tools

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCustomToolBuilder

Returns a new instance of CustomToolBuilder.



70
71
72
73
# File 'lib/rubino/tools/custom_tool_loader.rb', line 70

def initialize
  @_risk_level = :low
  @_input_schema = { type: "object", properties: {} }
end

Instance Attribute Details

#_descriptionObject (readonly)

Returns the value of attribute _description.



68
69
70
# File 'lib/rubino/tools/custom_tool_loader.rb', line 68

def _description
  @_description
end

#_execute_blockObject (readonly)

Returns the value of attribute _execute_block.



68
69
70
# File 'lib/rubino/tools/custom_tool_loader.rb', line 68

def _execute_block
  @_execute_block
end

#_input_schemaObject (readonly)

Returns the value of attribute _input_schema.



68
69
70
# File 'lib/rubino/tools/custom_tool_loader.rb', line 68

def _input_schema
  @_input_schema
end

#_nameObject (readonly)

Returns the value of attribute _name.



68
69
70
# File 'lib/rubino/tools/custom_tool_loader.rb', line 68

def _name
  @_name
end

#_risk_levelObject (readonly)

Returns the value of attribute _risk_level.



68
69
70
# File 'lib/rubino/tools/custom_tool_loader.rb', line 68

def _risk_level
  @_risk_level
end

Instance Method Details

#buildObject

Builds a Tool instance from the DSL



96
97
98
99
100
101
102
103
104
105
# File 'lib/rubino/tools/custom_tool_loader.rb', line 96

def build
  builder = self
  Class.new(Base) do
    define_method(:name) { builder._name }
    define_method(:description) { builder._description }
    define_method(:input_schema) { builder._input_schema }
    define_method(:risk_level) { builder._risk_level }
    define_method(:call) { |args| builder._execute_block.call(args) }
  end.new
end

#description(val) ⇒ Object



79
80
81
# File 'lib/rubino/tools/custom_tool_loader.rb', line 79

def description(val)
  @_description = val
end

#execute(&block) ⇒ Object



91
92
93
# File 'lib/rubino/tools/custom_tool_loader.rb', line 91

def execute(&block)
  @_execute_block = block
end

#input_schema(val) ⇒ Object



83
84
85
# File 'lib/rubino/tools/custom_tool_loader.rb', line 83

def input_schema(val)
  @_input_schema = val
end

#name(val) ⇒ Object



75
76
77
# File 'lib/rubino/tools/custom_tool_loader.rb', line 75

def name(val)
  @_name = val
end

#risk_level(val) ⇒ Object



87
88
89
# File 'lib/rubino/tools/custom_tool_loader.rb', line 87

def risk_level(val)
  @_risk_level = val
end