Skip to main content

Class: FunctionTool<T, R>

Simple Tool interface. Likely to change.

Type Parameters

T

R extends JSONValue | Promise<JSONValue>

Implements

Constructors

new FunctionTool()

new FunctionTool<T, R>(fn, metadata, zodType?): FunctionTool<T, R>

Parameters

fn

metadata: ToolMetadata<JSONSchemaType<T>>

zodType?: ZodType<T, ZodTypeDef, T>

Returns

FunctionTool<T, R>

Defined in

packages/core/tools/dist/index.d.ts:10

Properties

[kOriginalFn]()?

optional [kOriginalFn]: (input) => R

Parameters

input: T

Returns

R

Defined in

packages/core/tools/dist/index.d.ts:9

Accessors

metadata

Get Signature

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/tools/dist/index.d.ts:15

Methods

call()

call(input): R

This could be undefined if the implementation is not provided, which might be the case when communicating with a llm.

Parameters

input: T

Returns

R

The output of the tool.

Implementation of

BaseTool.call

Defined in

packages/core/tools/dist/index.d.ts:16


from()

from(fn, schema)

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

Type Parameters

T

Parameters

fn

schema: ToolMetadata<JSONSchemaType<T>>

Returns

FunctionTool<T, JSONValue | Promise<JSONValue>>

Defined in

packages/core/tools/dist/index.d.ts:11

from(fn, schema)

static from<T, R>(fn, schema): FunctionTool<T, JSONValue>

Type Parameters

T

R extends ZodType<T, ZodTypeDef, T>

Parameters

fn

schema: Omit<ToolMetadata, "parameters"> & object

Returns

FunctionTool<T, JSONValue>

Defined in

packages/core/tools/dist/index.d.ts:12