Skip to content

Commit

Permalink
key fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaki-1052 committed Jun 14, 2024
1 parent 9937099 commit 3e871cb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ const OpenAI = require('openai').default;
// Check if the OPENAI_API_KEY environment variable is set
const apiKey = process.env.OPENAI_API_KEY;

let openai; // Declare openai outside the conditional block

if (!apiKey) {
console.warn("Warning: The OPENAI_API_KEY environment variable is missing. OpenAI features will be disabled.");
} else {
// Initialize OpenAI only if the API key is present
const openai = new OpenAI({
openai = new OpenAI({
apiKey: apiKey
});
}
Expand Down

0 comments on commit 3e871cb

Please sign in to comment.