@@ -14,7 +14,6 @@ import type { VisibilityType } from './visibility-selector';
14
14
import { useArtifactSelector } from '@/hooks/use-artifact' ;
15
15
import { unstable_serialize } from 'swr/infinite' ;
16
16
import { getChatHistoryPaginationKey } from './sidebar-history' ;
17
- import { toast } from './toast' ;
18
17
import type { Session } from 'next-auth' ;
19
18
import { useSearchParams } from 'next/navigation' ;
20
19
import { useChatVisibility } from '@/hooks/use-chat-visibility' ;
@@ -63,7 +62,8 @@ export function Chat({
63
62
64
63
const [ input , setInput ] = useState < string > ( '' ) ;
65
64
const [ usage , setUsage ] = useState < AppUsage | undefined > ( initialLastContext ) ;
66
- const [ showCreditCardAlert , setShowCreditCardAlert ] = useState ( false ) ;
65
+ const [ showErrorAlert , setShowErrorAlert ] = useState ( false ) ;
66
+ const [ errorMessage , setErrorMessage ] = useState ( '' ) ;
67
67
const [ currentModelId , setCurrentModelId ] = useState ( initialChatModel ) ;
68
68
const currentModelIdRef = useRef ( currentModelId ) ;
69
69
@@ -108,17 +108,8 @@ export function Chat({
108
108
} ,
109
109
onError : ( error ) => {
110
110
if ( error instanceof ChatSDKError ) {
111
- // Check if it's a credit card error
112
- if (
113
- error . message ?. includes ( 'AI Gateway requires a valid credit card' )
114
- ) {
115
- setShowCreditCardAlert ( true ) ;
116
- } else {
117
- toast ( {
118
- type : 'error' ,
119
- description : error . message ,
120
- } ) ;
121
- }
111
+ setErrorMessage ( error . message ) ;
112
+ setShowErrorAlert ( true ) ;
122
113
}
123
114
} ,
124
115
} ) ;
@@ -218,8 +209,8 @@ export function Chat({
218
209
/>
219
210
220
211
< AlertDialog
221
- open = { showCreditCardAlert }
222
- onOpenChange = { setShowCreditCardAlert }
212
+ open = { showErrorAlert }
213
+ onOpenChange = { setShowErrorAlert }
223
214
>
224
215
< AlertDialogContent >
225
216
< AlertDialogHeader >
0 commit comments