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.
16 lines (14 loc) • 524 B
text/typescript
import { getErrorMessage } from '@ai-sdk/provider';
/**
* Returns the error text that the model receives for a failed tool call (see
* `createToolModelOutput` with `errorMode: 'text'`), or `undefined` when the
* error cannot be serialized. In that case the model did not receive an error
* text either, because creating the tool result fails the same way.
*/
export function getModelToolErrorText(error: unknown): string | undefined {
try {
return getErrorMessage(error);
} catch {
return undefined;
}
}