Przejdź do głównej zawartości

Class: FunctionTool<T, R>

Simple Tool interface. Likely to change.

Type parameters

NameType
TT
Rextends JSONValue | Promise<JSONValue>

Implements

Constructors

constructor

new FunctionTool<T, R>(_fn, _metadata): FunctionTool<T, R>

Type parameters

NameType
TT
Rextends JSONValue | Promise<JSONValue>

Parameters

NameType
_fn(input: T) => R
_metadataToolMetadata<JSONSchemaType<T>>

Returns

FunctionTool<T, R>

Defined in

packages/core/src/tools/functionTool.ts:7

Properties

_fn

Private Readonly _fn: (input: T) => R

Type declaration

▸ (input): R

Parameters
NameType
inputT
Returns

R

Defined in

packages/core/src/tools/functionTool.ts:8


_metadata

Private Readonly _metadata: ToolMetadata<JSONSchemaType<T>>

Defined in

packages/core/src/tools/functionTool.ts:9

Accessors

metadata

get metadata(): T extends Known ? ToolMetadata<JSONSchemaType<T<T>>> : ToolMetadata<Record<string, unknown>>

Returns

T extends Known ? ToolMetadata<JSONSchemaType<T<T>>> : ToolMetadata<Record<string, unknown>>

Implementation of

BaseTool.metadata

Defined in

packages/core/src/tools/functionTool.ts:23

Methods

call

call(input): R

Parameters

NameType
inputT

Returns

R

Implementation of

BaseTool.call

Defined in

packages/core/src/tools/functionTool.ts:27


from

from<T>(fn, schema): FunctionTool<T, JSONValue | Promise<JSONValue>>

Type parameters

Name
T

Parameters

NameType
fn(input: T) => JSONValue | Promise<JSONValue>
schemaToolMetadata<JSONSchemaType<T>>

Returns

FunctionTool<T, JSONValue | Promise<JSONValue>>

Defined in

packages/core/src/tools/functionTool.ts:12