From bc7dc431715b0394c7d2a1d43840792e69190471 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 30 Mar 2023 18:45:33 +0530 Subject: [PATCH] chore: ai assistant limit error (#619) --- apps/app/components/core/gpt-assistant-modal.tsx | 15 +++++++++++++++ apps/app/services/ai.service.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/app/components/core/gpt-assistant-modal.tsx b/apps/app/components/core/gpt-assistant-modal.tsx index f5c372798..75af0a50b 100644 --- a/apps/app/components/core/gpt-assistant-modal.tsx +++ b/apps/app/components/core/gpt-assistant-modal.tsx @@ -91,6 +91,21 @@ export const GptAssistantModal: React.FC = ({ if (res.response === "") setInvalidResponse(true); else setInvalidResponse(false); + }) + .catch((err) => { + if (err.status === 429) + setToastAlert({ + type: "error", + title: "Error!", + message: + "You have reached the maximum number of requests of 50 requests per month per user.", + }); + else + setToastAlert({ + type: "error", + title: "Error!", + message: "Some error occurred. Please try again.", + }); }); }; diff --git a/apps/app/services/ai.service.ts b/apps/app/services/ai.service.ts index 069f33fc7..26168115e 100644 --- a/apps/app/services/ai.service.ts +++ b/apps/app/services/ai.service.ts @@ -18,7 +18,7 @@ class AiServices extends APIService { return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/ai-assistant/`, data) .then((response) => response?.data) .catch((error) => { - throw error?.response?.data; + throw error?.response; }); } }