Skip to main content

Class: WebSearchTool<NAME>

A tool for searching the web.

The input schema takes a query string.

{
query: "How many people live in Berlin?"
}

The output schema is an array of search results with title, link and snippet.

{
results:
[
{
title: "Berlin - Wikipedia",
link: "https://en.wikipedia.org/wiki/Berlin",
snippet: "Berlin is the capital and largest city of Germany by...",
},
...
]
}

Type parameters

NameType
NAMEextends string

Hierarchy

Constructors

constructor

new WebSearchTool<NAME>(«destructured»): WebSearchTool<NAME>

Type parameters

NameType
NAMEextends string

Parameters

NameTypeDefault value
«destructured»Objectundefined
› description?stringundefined
› nameNAMEundefined
› queryDescription?string"Search query"
› execute(input: WebSearchToolInput, options?: FunctionOptions) => PromiseLike<WebSearchToolOutput>undefined

Returns

WebSearchTool<NAME>

Overrides

Tool.constructor

Defined in

packages/modelfusion/src/tool/WebSearchTool.ts:72

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.

Inherited from

Tool.description

Defined in

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


execute

Readonly execute: (args: WebSearchToolInput, options: FunctionCallOptions) => PromiseLike<WebSearchToolOutput>

The actual execution function of the tool.

Type declaration

▸ (args, options): PromiseLike<WebSearchToolOutput>

The actual execution function of the tool.

Parameters
NameType
argsWebSearchToolInput
optionsFunctionCallOptions
Returns

PromiseLike<WebSearchToolOutput>

Inherited from

Tool.execute

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.

Inherited from

Tool.name

Defined in

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


parameters

Readonly parameters: Schema<WebSearchToolInput> & 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.

Inherited from

Tool.parameters

Defined in

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


returnType

Readonly returnType: ZodSchema<{ results: { link: string ; snippet: string ; title: string }[] }>

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

Overrides

Tool.returnType

Defined in

packages/modelfusion/src/tool/WebSearchTool.ts:70