File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -190,15 +190,24 @@ export class AnthropicProvider extends OpenAICompatibleProviderBase<typeof provi
190190
191191 debugger ;
192192
193- if ( json ?. error ?. type === 'invalid_request_error' && json ?. error ?. message ?. includes ( 'prompt is too long' ) ) {
194- if ( retries < 2 ) {
195- return { retry : true , maxInputTokens : maxInputTokens - 200 * ( retries || 1 ) } ;
193+ if ( json ?. error ?. type === 'invalid_request_error' ) {
194+ if ( json ?. error ?. message ?. includes ( 'prompt is too long' ) ) {
195+ if ( retries < 2 ) {
196+ return { retry : true , maxInputTokens : maxInputTokens - 200 * ( retries || 1 ) } ;
197+ }
198+
199+ throw new AIError (
200+ AIErrorReason . RequestTooLarge ,
201+ new Error ( `(${ this . name } ) ${ rsp . status } : ${ json ?. error ?. message || rsp . statusText } ` ) ,
202+ ) ;
196203 }
197204
198- throw new AIError (
199- AIErrorReason . RequestTooLarge ,
200- new Error ( `(${ this . name } ) ${ rsp . status } : ${ json ?. error ?. message || rsp . statusText } ` ) ,
201- ) ;
205+ if ( json ?. error ?. message ?. includes ( 'balance is too low' ) ) {
206+ throw new AIError (
207+ AIErrorReason . RateLimitOrFundsExceeded ,
208+ new Error ( `(${ this . name } ) ${ rsp . status } : ${ json ?. error ?. message || rsp . statusText } ` ) ,
209+ ) ;
210+ }
202211 }
203212 }
204213
You can’t perform that action at this time.
0 commit comments