Class: DeepAgentsRb::Tools::Tool
- Inherits:
-
Object
- Object
- DeepAgentsRb::Tools::Tool
- Defined in:
- lib/deepagents/deepagentsrb/tools.rb
Overview
Tool class to define tools
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#function ⇒ Object
readonly
Returns the value of attribute function.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call(*args, **kwargs) ⇒ Object
-
#initialize(name, description, &block) ⇒ Tool
constructor
A new instance of Tool.
Constructor Details
#initialize(name, description, &block) ⇒ Tool
12 13 14 15 16 |
# File 'lib/deepagents/deepagentsrb/tools.rb', line 12 def initialize(name, description, &block) @name = name @description = description @function = block end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/deepagents/deepagentsrb/tools.rb', line 10 def description @description end |
#function ⇒ Object (readonly)
Returns the value of attribute function.
10 11 12 |
# File 'lib/deepagents/deepagentsrb/tools.rb', line 10 def function @function end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/deepagents/deepagentsrb/tools.rb', line 10 def name @name end |
Instance Method Details
#call(*args, **kwargs) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/deepagents/deepagentsrb/tools.rb', line 18 def call(*args, **kwargs) begin @function.call(*args, **kwargs) rescue ArgumentError => e raise ToolError.new(@name, "Invalid arguments: #{e.message}") rescue => e raise ToolError.new(@name, e.) end end |