class Tool
Represents a tool that can be registered and called by the Toolbox.
Definitions
def initialize(name, schema, &block)
Initializes a new tool with the given name, schema, and block.
Signature
-
parameter
name
String
The name of the tool.
-
parameter
schema
Hash
The schema describing the tool's function.
-
parameter
block
Proc
The implementation of the tool.
Implementation
def initialize(name, schema, &block)
@name = name
@schema = schema
@block = block
end
attr :name
Signature
-
attribute
String
The name of the tool.
attr :schema
Signature
-
attribute
Hash
The schema for the tool.
def call(message)
Calls the tool with the given message.
Signature
-
parameter
message
Hash
The message to process.
-
returns
Object
The result of the tool's block.
Implementation
def call(message)
@block.call(message)
end
def explain
Signature
-
returns
Hash
The explanation of the tool's function for API usage.
Implementation
def explain
{
type: "function",
function: @schema,
}
end