Skip to content

Commit

Permalink
feat: Added error if VITE_GPT_URL not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldemylla committed Apr 2, 2024
1 parent 4994ea4 commit 81165c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/services/api/resources/GPT.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<s>[INST] ${prompt} [/INST]`,
Expand Down
12 changes: 7 additions & 5 deletions src/utils/env.js
Original file line number Diff line number Diff line change
@@ -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}`]
);
}

0 comments on commit 81165c4

Please sign in to comment.