From 3e7dfad096ecae8f173569a72f7d9e3cdbc9dfa8 Mon Sep 17 00:00:00 2001 From: KaustubhKumar05 Date: Wed, 3 Apr 2024 22:14:53 +0530 Subject: [PATCH 1/2] fix: throw openai error response --- .changeset/gold-hounds-relate.md | 5 +++++ packages/ai/src/providers/openai/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/gold-hounds-relate.md diff --git a/.changeset/gold-hounds-relate.md b/.changeset/gold-hounds-relate.md new file mode 100644 index 00000000..62be298b --- /dev/null +++ b/.changeset/gold-hounds-relate.md @@ -0,0 +1,5 @@ +--- +"@empiricalrun/ai": patch +--- + +fix: throw error response diff --git a/packages/ai/src/providers/openai/index.ts b/packages/ai/src/providers/openai/index.ts index 12d3ab80..0ebcac9a 100644 --- a/packages/ai/src/providers/openai/index.ts +++ b/packages/ai/src/providers/openai/index.ts @@ -36,7 +36,7 @@ const createChatCompletion: ICreateChatCompletion = async (body) => { retry(err); throw err; } - return err; + throw err; }); }, { @@ -48,7 +48,7 @@ const createChatCompletion: ICreateChatCompletion = async (body) => { } catch (err) { throw new AIError( AIErrorEnum.FAILED_CHAT_COMPLETION, - `failed chat completion for model openai ${body.model} with error code: ${(err as OpenAI.ErrorObject).code}`, + `failed chat completion for model openai "${body.model}" with the error message: ${(err as any)?.error?.message}`, ); } }; From bee2d52c50d6f02464dd2b7cae03f11cecfd957a Mon Sep 17 00:00:00 2001 From: Saikat Mitra Date: Wed, 3 Apr 2024 22:45:07 +0530 Subject: [PATCH 2/2] fix: review commets --- .changeset/gold-hounds-relate.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/gold-hounds-relate.md b/.changeset/gold-hounds-relate.md index 62be298b..32d5f2e3 100644 --- a/.changeset/gold-hounds-relate.md +++ b/.changeset/gold-hounds-relate.md @@ -2,4 +2,4 @@ "@empiricalrun/ai": patch --- -fix: throw error response +fix: openai errors not getting captured