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.

34 lines (24 loc) • 1.08 kB
--- title: AI_DecisionRefusalError description: Identify decision questions that a model declined to answer. --- # AI_DecisionRefusalError This experimental error identifies questions that a decision model declined to answer, such as a question the provider's safety policy refuses. It is exported from `ai` and `@ai-sdk/provider` as `Experimental_DecisionRefusalError`. Decision models report a refusal as an answer with `type: 'refusal'`. `experimental_decide` throws this error when any answer is a refusal, after the provider call and without retrying it. ## Properties - `questionIds`: The IDs of the refused questions. - `provider`: The provider of the decision model. - `modelId`: The decision model ID. - `message`: A description of the refused questions and model. ## Checking for this Error Use the marker-based `isInstance` check, which works across package copies: ```typescript import { Experimental_DecisionRefusalError as DecisionRefusalError } from 'ai'; if (DecisionRefusalError.isInstance(error)) { console.log(error.questionIds, error.modelId); } ```