From 01d713e303402f45c1177fb8526d331df46410fb Mon Sep 17 00:00:00 2001 From: dacoaster Date: Mon, 28 Aug 2023 10:43:53 -0700 Subject: [PATCH] Improve error handling and reponses --- src/components/settings/AddonsTab.vue | 2 +- src/integrations/OpenAIIntegrationHelpers.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/settings/AddonsTab.vue b/src/components/settings/AddonsTab.vue index b9de21f9..9ff81251 100755 --- a/src/components/settings/AddonsTab.vue +++ b/src/components/settings/AddonsTab.vue @@ -138,7 +138,6 @@ export default { }, async handleOpenAIKey() { let validates = this.$refs.openAIKey.validate(); - console.log(this.openAIKey); if (validates) { const date = dayjs().format("YYYY-MM-DD HH:mm:ss"); const data = { @@ -157,6 +156,7 @@ export default { ); if (validate) { this.openAIKey = this.sanitizeOpenAIKey(this.credentials); + this.customErrors = []; this.$refs.openAIKey.resetValidation(); this.$root.$emit( "set-snackbar", diff --git a/src/integrations/OpenAIIntegrationHelpers.js b/src/integrations/OpenAIIntegrationHelpers.js index b1611967..b364105f 100644 --- a/src/integrations/OpenAIIntegrationHelpers.js +++ b/src/integrations/OpenAIIntegrationHelpers.js @@ -8,6 +8,10 @@ import { export default { async enhanceText(credentials, config, field, text) { + if (!credentials?.openai?.accessToken) { + return { error: "You must provide an OpenAI key in Settings > Addons." }; + } // TODO - i18n + let returnResponse = { content: "", };