Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ai-preferences.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: AIOptions, AICapabilities types and available() method to AI tool for controlling AI feature availability in twists
21 changes: 21 additions & 0 deletions twister/src/tools/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -146,6 +153,20 @@ export abstract class AI extends ITool {
): Promise<AIResponse<TOOLS, SCHEMA>>;
}

/** 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
Expand Down