ConfigureAI
ConfigureAI
Represents the configuration options for the AI model.
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
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
(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
A function that prepares the prompt for the AI model.
onProcessingStart
(ctx: AiContext, message: Message) => Promise<void>
A function that gets called when the AI starts processing a message.
onProcessingFinish
(ctx: AiContext, message: Message) => Promise<void>
A function that gets called when the AI finishes processing a message.
onResult
( ctx: AiContext, message: Message, result: AIGenerateResult, ) => Promise<void>
A function that gets called upon receiving the result from the AI model.
onError
(ctx: AiContext, message: Message, error: Error) => Promise<void>
A function that gets called when error occurs.