diff --git a/src/services/api/resources/GPT.js b/src/services/api/resources/GPT.js index b5bf3aca..8e63a477 100644 --- a/src/services/api/resources/GPT.js +++ b/src/services/api/resources/GPT.js @@ -9,6 +9,12 @@ const http = axios.create({ export default { async getInsights(prompt) { + if (!env('VITE_GPT_URL')) { + throw new Error( + `The VITE_GPT_URL environment variable is empty: ${env('VITE_GPT_URL')}`, + ); + } + const response = await http.post(env('VITE_GPT_URL'), { input: { prompt: `[INST] ${prompt} [/INST]`, diff --git a/src/utils/env.js b/src/utils/env.js index 9c012dcf..c10ce855 100644 --- a/src/utils/env.js +++ b/src/utils/env.js @@ -1,7 +1,9 @@ export default function env(name) { - return import.meta.env[name] || - window?.configs?.[name] || - process.env[name] || - window?.configs?.[`VITE_${name}`] || - process.env[`VITE_${name}`]; + return ( + import.meta.env?.[name] || + window?.configs?.[name] || + process.env[name] || + window?.configs?.[`VITE_${name}`] || + process.env[`VITE_${name}`] + ); }