-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openai): Wrap some common OpenAI errors (#7003)
- Loading branch information
1 parent
9a29419
commit 3ac6e4e
Showing
4 changed files
with
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable no-param-reassign */ | ||
|
||
// Duplicate of core | ||
// TODO: Remove once we stop supporting 0.2.x core versions | ||
export type LangChainErrorCodes = | ||
| "INVALID_PROMPT_INPUT" | ||
| "INVALID_TOOL_RESULTS" | ||
| "MESSAGE_COERCION_FAILURE" | ||
| "MODEL_AUTHENTICATION" | ||
| "MODEL_NOT_FOUND" | ||
| "MODEL_RATE_LIMIT" | ||
| "OUTPUT_PARSING_FAILURE"; | ||
|
||
export function addLangChainErrorFields( | ||
error: any, | ||
lc_error_code: LangChainErrorCodes | ||
) { | ||
(error as any).lc_error_code = lc_error_code; | ||
error.message = `${error.message}\n\nTroubleshooting URL: https://js.langchain.com/docs/troubleshooting/errors/${lc_error_code}/\n`; | ||
return error; | ||
} |
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