fix: add dialog for vercel ai gateway activation (#1195)
This commit is contained in:
parent
a9c812b5c4
commit
38156eafcf
3 changed files with 68 additions and 5 deletions
|
|
@ -15,7 +15,8 @@ export type Surface =
|
|||
| 'history'
|
||||
| 'vote'
|
||||
| 'document'
|
||||
| 'suggestions';
|
||||
| 'suggestions'
|
||||
| 'activate_gateway';
|
||||
|
||||
export type ErrorCode = `${ErrorType}:${Surface}`;
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ export const visibilityBySurface: Record<Surface, ErrorVisibility> = {
|
|||
vote: 'response',
|
||||
document: 'response',
|
||||
suggestions: 'response',
|
||||
activate_gateway: 'response',
|
||||
};
|
||||
|
||||
export class ChatSDKError extends Error {
|
||||
|
|
@ -82,6 +84,9 @@ export function getMessageByErrorCode(errorCode: ErrorCode): string {
|
|||
case 'bad_request:api':
|
||||
return "The request couldn't be processed. Please check your input and try again.";
|
||||
|
||||
case 'bad_request:activate_gateway':
|
||||
return 'AI Gateway requires a valid credit card on file to service requests. Please visit https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dadd-credit-card to add a card and unlock your free credits.';
|
||||
|
||||
case 'unauthorized:auth':
|
||||
return 'You need to sign in before continuing.';
|
||||
case 'forbidden:auth':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue