Tools
Tool
A tool that can be called by the AI model.
Tool : { type : Str, function : { name : Str, description : Str, parameters : { type : Str, properties : Dict Str FunctionParameter, }, required : List Str, }, }
ToolCall
A call from the model to a tool.
ToolCall : { id : Str, type : Str, function : { name : Str, arguments : Str, }, }
handle_tool_calls! :
Client,
Dict Str (Str => Result Str ),
{ max_model_calls ? U32 }
=> Result Client
Using the given toolHandlerMap, check the last message for tool calls, call all the tools in the tool call list, send the results back to the model, and handle any additional tool calls that may have been generated. If or when no more tool calls are present, return the updated list of messages.
The Dict maps function tool names strings to roc functions that take their arguments as a JSON string, parse the json, and return the tool's response.
dispatch_tool_calls! : List ToolCall, Dict Str (Str => Result Str ) => Result (List Message)
Dispatch the tool calls to the appropriate tool handler functions and return the list of tool messages.
The Dict maps function tool names strings to roc functions that take their arguments as a JSON string, parse the json, and return the tool's response.
call_tool! : ToolCall, (Str => Result Str err) => Result Message err
Call the given tool function with the given arguments and return the tool message.
build_tool :
Str,
Str, List
{
name : Str,
type : Str,
description : Str,
required : Bool
}
-> Tool
Build a tool object with the given name, description, and parameters.
buildTool = \name, description, parameters -> ...
Parameters:
name : Str
: The name of the tool.description : Str
: The description of the tool.parameters : List { ... }
: The parameters for the tool.name : Str
: The name of the parameter.type : Str
: The type of the parameter.description : Str
: The description of the parameter.required : Bool
: Whether the parameter is required.
Returns:
Tool
: The tool object.