@@ -938,11 +938,17 @@ export class AIProviderService implements Disposable {
938938 'You do not have the required entitlement or are over the limits to use this AI feature' ,
939939 ) ;
940940 return undefined ;
941- case AIErrorReason . RequestTooLarge :
942- void window . showErrorMessage (
943- 'Your request is too large. Please reduce the size of your request or switch to a different model and try again.' ,
941+ case AIErrorReason . RequestTooLarge : {
942+ const switchModel : MessageItem = { title : 'Switch Model' } ;
943+ const result = await window . showErrorMessage (
944+ 'Your request is too large. Please reduce the size of your request or switch to a different model, and then try again.' ,
945+ switchModel ,
944946 ) ;
947+ if ( result === switchModel ) {
948+ void this . switchModel ( source ) ;
949+ }
945950 return undefined ;
951+ }
946952 case AIErrorReason . UserQuotaExceeded : {
947953 const increaseLimit : MessageItem = { title : 'Increase Limit' } ;
948954 const result = await window . showErrorMessage (
@@ -956,18 +962,69 @@ export class AIProviderService implements Disposable {
956962
957963 return undefined ;
958964 }
959- case AIErrorReason . RateLimitExceeded :
960- void window . showErrorMessage (
961- 'Rate limit exceeded. Please wait a few moments and try again later.' ,
965+ case AIErrorReason . RateLimitExceeded : {
966+ const switchModel : MessageItem = { title : 'Switch Model' } ;
967+ const result = await window . showErrorMessage (
968+ 'Rate limit exceeded. Please wait a few moments or switch to a different model, and then try again.' ,
969+ switchModel ,
962970 ) ;
971+ if ( result === switchModel ) {
972+ void this . switchModel ( source ) ;
973+ }
974+
963975 return undefined ;
976+ }
977+ case AIErrorReason . RateLimitOrFundsExceeded : {
978+ const switchModel : MessageItem = { title : 'Switch Model' } ;
979+ const result = await window . showErrorMessage (
980+ 'Rate limit exceeded, or your account is out of funds. Please wait a few moments, check your account balance, or switch to a different model, and then try again.' ,
981+ switchModel ,
982+ ) ;
983+ if ( result === switchModel ) {
984+ void this . switchModel ( source ) ;
985+ }
986+ return undefined ;
987+ }
964988 case AIErrorReason . ServiceCapacityExceeded : {
965989 void window . showErrorMessage (
966990 'GitKraken AI is temporarily unable to process your request due to high volume. Please wait a few moments and try again. If this issue persists, please contact support.' ,
967991 'OK' ,
968992 ) ;
969993 return undefined ;
970994 }
995+ case AIErrorReason . ModelNotSupported : {
996+ const switchModel : MessageItem = { title : 'Switch Model' } ;
997+ const result = await window . showErrorMessage (
998+ 'The selected model is not supported for this request. Please select a different model and try again.' ,
999+ switchModel ,
1000+ ) ;
1001+ if ( result === switchModel ) {
1002+ void this . switchModel ( source ) ;
1003+ }
1004+ return undefined ;
1005+ }
1006+ case AIErrorReason . ModelUserUnauthorized : {
1007+ const switchModel : MessageItem = { title : 'Switch Model' } ;
1008+ const result = await window . showErrorMessage (
1009+ 'You do not have access to the selected model. Please select a different model and try again.' ,
1010+ switchModel ,
1011+ ) ;
1012+ if ( result === switchModel ) {
1013+ void this . switchModel ( source ) ;
1014+ }
1015+ return undefined ;
1016+ }
1017+ case AIErrorReason . ModelUserDeniedAccess : {
1018+ const switchModel : MessageItem = { title : 'Switch Model' } ;
1019+ const result = await window . showErrorMessage (
1020+ 'You have denied access to the selected model. Please provide access or select a different model, and then try again.' ,
1021+ switchModel ,
1022+ ) ;
1023+ if ( result === switchModel ) {
1024+ void this . switchModel ( source ) ;
1025+ }
1026+ return undefined ;
1027+ }
9711028 }
9721029
9731030 return undefined ;
0 commit comments