From 9f327d015a6beb618d0a6284a97e2bf00282b859 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Wed, 22 May 2024 09:58:10 -0500 Subject: [PATCH] update error handling for OpenAI providers --- server/utils/AiProviders/genericOpenAi/index.js | 2 +- server/utils/AiProviders/groq/index.js | 2 +- server/utils/AiProviders/koboldCPP/index.js | 2 +- server/utils/AiProviders/liteLLM/index.js | 2 +- server/utils/AiProviders/openAi/index.js | 2 +- server/utils/AiProviders/openRouter/index.js | 2 +- server/utils/AiProviders/perplexity/index.js | 2 +- server/utils/AiProviders/textGenWebUI/index.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/utils/AiProviders/genericOpenAi/index.js b/server/utils/AiProviders/genericOpenAi/index.js index 46b8aefb..8d0c0f34 100644 --- a/server/utils/AiProviders/genericOpenAi/index.js +++ b/server/utils/AiProviders/genericOpenAi/index.js @@ -97,7 +97,7 @@ class GenericOpenAiLLM { max_tokens: this.maxTokens, }) .catch((e) => { - throw new Error(e.response.data.error.message); + throw new Error(e.message); }); if (!result.hasOwnProperty("choices") || result.choices.length === 0) diff --git a/server/utils/AiProviders/groq/index.js b/server/utils/AiProviders/groq/index.js index 24a430e6..ba081219 100644 --- a/server/utils/AiProviders/groq/index.js +++ b/server/utils/AiProviders/groq/index.js @@ -103,7 +103,7 @@ class GroqLLM { temperature, }) .catch((e) => { - throw new Error(e.response.data.error.message); + throw new Error(e.message); }); if (!result.hasOwnProperty("choices") || result.choices.length === 0) diff --git a/server/utils/AiProviders/koboldCPP/index.js b/server/utils/AiProviders/koboldCPP/index.js index 90186aab..15163648 100644 --- a/server/utils/AiProviders/koboldCPP/index.js +++ b/server/utils/AiProviders/koboldCPP/index.js @@ -92,7 +92,7 @@ class KoboldCPPLLM { temperature, }) .catch((e) => { - throw new Error(e.response.data.error.message); + throw new Error(e.message); }); if (!result.hasOwnProperty("choices") || result.choices.length === 0) diff --git a/server/utils/AiProviders/liteLLM/index.js b/server/utils/AiProviders/liteLLM/index.js index 6152ea29..2c7fa823 100644 --- a/server/utils/AiProviders/liteLLM/index.js +++ b/server/utils/AiProviders/liteLLM/index.js @@ -93,7 +93,7 @@ class LiteLLM { max_tokens: parseInt(this.maxTokens), // LiteLLM requires int }) .catch((e) => { - throw new Error(e.response.data.error.message); + throw new Error(e.message); }); if (!result.hasOwnProperty("choices") || result.choices.length === 0) diff --git a/server/utils/AiProviders/openAi/index.js b/server/utils/AiProviders/openAi/index.js index 8037d23d..9e55074c 100644 --- a/server/utils/AiProviders/openAi/index.js +++ b/server/utils/AiProviders/openAi/index.js @@ -130,7 +130,7 @@ class OpenAiLLM { temperature, }) .catch((e) => { - throw new Error(e.response.data.error.message); + throw new Error(e.message); }); if (!result.hasOwnProperty("choices") || result.choices.length === 0) diff --git a/server/utils/AiProviders/openRouter/index.js b/server/utils/AiProviders/openRouter/index.js index bb8cf447..301ed704 100644 --- a/server/utils/AiProviders/openRouter/index.js +++ b/server/utils/AiProviders/openRouter/index.js @@ -142,7 +142,7 @@ class OpenRouterLLM { temperature, }) .catch((e) => { - throw new Error(e.response.data.error.message); + throw new Error(e.message); }); if (!result.hasOwnProperty("choices") || result.choices.length === 0) diff --git a/server/utils/AiProviders/perplexity/index.js b/server/utils/AiProviders/perplexity/index.js index d3f50de7..d821b2e3 100644 --- a/server/utils/AiProviders/perplexity/index.js +++ b/server/utils/AiProviders/perplexity/index.js @@ -93,7 +93,7 @@ class PerplexityLLM { temperature, }) .catch((e) => { - throw new Error(e.response.data.error.message); + throw new Error(e.message); }); if (!result.hasOwnProperty("choices") || result.choices.length === 0) diff --git a/server/utils/AiProviders/textGenWebUI/index.js b/server/utils/AiProviders/textGenWebUI/index.js index 72f116f8..71d50577 100644 --- a/server/utils/AiProviders/textGenWebUI/index.js +++ b/server/utils/AiProviders/textGenWebUI/index.js @@ -89,7 +89,7 @@ class TextGenWebUILLM { temperature, }) .catch((e) => { - throw new Error(e.response.data.error.message); + throw new Error(e.message); }); if (!result.hasOwnProperty("choices") || result.choices.length === 0)