PromptFunctions interface

A collection of functions that can be called from a prompt template string.

Methods

getFunction(string)

Looks up the given function.

hasFunction(string)

Returns true if the given function is defined.

invokeFunction(string, TurnContext, Memory, Tokenizer, string[])

Calls the given function.

Method Details

getFunction(string)

Looks up the given function.

function getFunction(name: string): PromptFunction

Parameters

name

string

Name of the function to lookup.

Returns

Remarks

Throws an error if the function is not defined.

hasFunction(string)

Returns true if the given function is defined.

function hasFunction(name: string): boolean

Parameters

name

string

Name of the function to lookup.

Returns

boolean

invokeFunction(string, TurnContext, Memory, Tokenizer, string[])

Calls the given function.

function invokeFunction(name: string, context: TurnContext, memory: Memory, tokenizer: Tokenizer, args: string[]): Promise<any>

Parameters

name

string

Name of the function to invoke.

context

TurnContext

Context for the current turn of conversation.

memory
Memory

Interface used to access state variables.

tokenizer
Tokenizer

Tokenizer used to encode/decode strings.

args

string[]

Arguments to pass to the function as an array of strings.

Returns

Promise<any>

Remarks

Throws an error if the function is not defined.