-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(OpenAI Node, Basic LLM Chain Node, Tool Agent Node): Better OpenA…
…I API rate limit errors (#10797)
- Loading branch information
1 parent
0126c42
commit 59e17b5
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/helpers/error-handling.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { OpenAIError } from 'openai/error'; | ||
|
||
const errorMap: Record<string, string> = { | ||
insufficient_quota: 'OpenAI: Insufficient quota', | ||
rate_limit_exceeded: 'OpenAI: Rate limit reached', | ||
}; | ||
|
||
export function getCustomErrorMessage(errorCode: string): string | undefined { | ||
return errorMap[errorCode]; | ||
} | ||
|
||
export function isOpenAiError(error: any): error is OpenAIError { | ||
return error instanceof OpenAIError; | ||
} |