diff --git a/.changeset/ai-preferences.md b/.changeset/ai-preferences.md new file mode 100644 index 0000000..a43348a --- /dev/null +++ b/.changeset/ai-preferences.md @@ -0,0 +1,5 @@ +--- +"@plotday/twister": minor +--- + +Added: AIOptions, AICapabilities types and available() method to AI tool for controlling AI feature availability in twists diff --git a/twister/src/tools/ai.ts b/twister/src/tools/ai.ts index f787ad7..d9253a2 100644 --- a/twister/src/tools/ai.ts +++ b/twister/src/tools/ai.ts @@ -65,6 +65,13 @@ import { ITool } from ".."; * ``` */ export abstract class AI extends ITool { + /** + * Returns which AI capabilities are currently available. + * Check this before calling prompt() or embed() to gracefully + * handle cases where AI is disabled by the user. + */ + abstract available(): AICapabilities; + /** * Sends a request to an AI model and returns the response using the Vercel AI SDK. * @@ -146,6 +153,20 @@ export abstract class AI extends ITool { ): Promise>; } +/** Options for configuring AI tool usage in a twist. */ +export type AIOptions = { + /** Whether AI is required for this twist to function. Default: true */ + required?: boolean; +}; + +/** Describes which AI capabilities are currently available to this twist. */ +export type AICapabilities = { + /** Whether AI prompting (text generation) is available. */ + prompt: boolean; + /** Whether AI embedding generation is available. */ + embed: boolean; +}; + /** * Model preferences for selecting an AI model based on performance and cost requirements. * This allows Plot to match those preferences with user preferences (such as preferred or