toolFunction
llms: toolFunction
A toolFunction object for tool-calling capable models.
toolFunction is a scalar class object, which contains the full
description of a tool function along with the handle to its corresponding
Octave function, which should be executed after a tool call request from
the model.
Source Code: toolFunction
toolFunction: tool = toolFunction (name, description, handle)
tool = toolFunction (name, description,
handle) creates a toolFunction object, which comprises an
identifier specified by name, a functionality description that can
be understood by the LLM model specified in description and a
function handle, specified in handle, which corresponds to an
actual Octave function that will be evaluated along with any input
parameters specified by the LLM’s tool calling response.
By default, toolFunction does not add any input parameters to the
created object. Use the addParameters method to append any input
input parameters that your function handle may require for its successful
evaluation. Use the evalFunction to evaluate the underlying
function handle according to the input arguments specified by the LLM.
toolFunction: tool = addParameters (tool, propName, propType, propDescription)
toolFunction: tool = addParameters (tool, propName, propType, propDescription, enum)
addParameters appends the parameters of a single input argument
into the toolFunction object so that the LLM can understand the
context of the corresponding input argument of the underlying function
handle when asking for its evaluation.
addParameters requires at least four input arguments (and may
accept an optional fifth argument), which are as described below:
toolFunction object that the
parameters will be appended to.
toolFunction: tool_output = evalFunction (tool, tool_call)
tool_output = evalFunction (tool, tool_call)
evaluates the function handle of the toolFunction object
specified by tool according to the input arguments described by the
LLM’s tool calling response specified in tool_call, which can be a
character vector containing the appropriate JSON string message or its
equivalent to a scalar structure. The returned tool_output is a
cell array of character vectors, in which the first element
contains the output of the evaluated toolFunction object and the
second element contains its corresponding function name.