UNPKG

ai

Version:

AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.

36 lines (29 loc) 946 B
import { AISDKError } from '@ai-sdk/provider'; const name = 'AI_NoSuchToolError'; const marker = `vercel.ai.error.${name}`; const symbol = Symbol.for(marker); export class NoSuchToolError extends AISDKError { private readonly [symbol] = true; // used in isInstance readonly toolName: string; readonly availableTools: string[] | undefined; constructor({ toolName, availableTools = undefined, message = `Model tried to call unavailable tool '${toolName}'. ${ availableTools === undefined ? 'No tools are available.' : `Available tools: ${availableTools.join(', ')}.` }`, }: { toolName: string; availableTools?: string[] | undefined; message?: string; }) { super({ name, message }); this.toolName = toolName; this.availableTools = availableTools; } static isInstance(error: unknown): error is NoSuchToolError { return AISDKError.hasMarker(error, marker); } }