Skip to main content
Version: Next

ConfigureAI

ConfigureAI

Represents the configuration options for the AI model.

Signature
interface ConfigureAI {
disableBuiltInTools?: boolean;
messageFilter?: MessageFilter;
selectAiModel: SelectAiModel;
prepareSystemPrompt?: (ctx: AiContext, message: Message) => Promise<string>;
preparePrompt?: (
ctx: AiContext,
message: Message,
) => Promise<string | AiMessage>;
onProcessingStart?: (ctx: AiContext, message: Message) => Promise<void>;
onProcessingFinish?: (ctx: AiContext, message: Message) => Promise<void>;
onResult?: (
ctx: AiContext,
message: Message,
result: AIGenerateResult,
) => Promise<void>;
onError?: (ctx: AiContext, message: Message, error: Error) => Promise<void>;
}

disableBuiltInTools

property
boolean

Whether to disable the built-in tools. Default is false.

messageFilter

A filter function that determines whether a message should be processed by the AI. CommandKit invokes this function before processing the message.

selectAiModel

A function that selects the AI model to use based on the message. This function should return a promise that resolves to an object containing the model and options.

prepareSystemPrompt

property
(ctx: AiContext, message: Message) => Promise<string>

A function that generates a system prompt based on the message. This function should return a promise that resolves to a string containing the system prompt. If not provided, a default system prompt will be used.

preparePrompt

property
( ctx: AiContext, message: Message, ) => Promise<string | AiMessage>

A function that prepares the prompt for the AI model.

onProcessingStart

property
(ctx: AiContext, message: Message) => Promise<void>

A function that gets called when the AI starts processing a message.

onProcessingFinish

property
(ctx: AiContext, message: Message) => Promise<void>

A function that gets called when the AI finishes processing a message.

onResult

property
( ctx: AiContext, message: Message, result: AIGenerateResult, ) => Promise<void>

A function that gets called upon receiving the result from the AI model.

onError

property
(ctx: AiContext, message: Message, error: Error) => Promise<void>

A function that gets called when error occurs.