Skip to main content

Class: Tool<NAME, PARAMETERS, RESULT>

A tool is a function with a name, description and defined inputs that can be used by agents and chatbots.

Type parameters

NameType
NAMEextends string
PARAMETERSPARAMETERS
RESULTRESULT

Hierarchy

Implements

Constructors

constructor

new Tool<NAME, PARAMETERS, RESULT>(«destructured»): Tool<NAME, PARAMETERS, RESULT>

Type parameters

NameType
NAMEextends string
PARAMETERSPARAMETERS
RESULTRESULT

Parameters

NameType
«destructured»Object
› description?string
› nameNAME
› parametersSchema<PARAMETERS> & JsonSchemaProducer
› returnType?Schema<RESULT>
› execute(args: PARAMETERS, options?: FunctionOptions) => PromiseLike<RESULT>

Returns

Tool<NAME, PARAMETERS, RESULT>

Defined in

packages/modelfusion/src/tool/Tool.ts:43

Properties

description

Optional Readonly description: string

A optional description of what the tool does. Will be used by the language model to decide whether to use the tool.

Implementation of

ToolDefinition.description

Defined in

packages/modelfusion/src/tool/Tool.ts:22


execute

Readonly execute: (args: PARAMETERS, options: FunctionCallOptions) => PromiseLike<RESULT>

The actual execution function of the tool.

Type declaration

▸ (args, options): PromiseLike<RESULT>

The actual execution function of the tool.

Parameters
NameType
argsPARAMETERS
optionsFunctionCallOptions
Returns

PromiseLike<RESULT>

Defined in

packages/modelfusion/src/tool/Tool.ts:38


name

Readonly name: NAME

The name of the tool. Should be understandable for language models and unique among the tools that they know.

Implementation of

ToolDefinition.name

Defined in

packages/modelfusion/src/tool/Tool.ts:17


parameters

Readonly parameters: Schema<PARAMETERS> & JsonSchemaProducer

The schema of the input that the tool expects. The language model will use this to generate the input. Use descriptions to make the input understandable for the language model.

Implementation of

ToolDefinition.parameters

Defined in

packages/modelfusion/src/tool/Tool.ts:28


returnType

Optional Readonly returnType: Schema<RESULT>

An optional schema of the output that the tool produces. This will be used to validate the output.

Defined in

packages/modelfusion/src/tool/Tool.ts:33