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 bb61b00 commit 9937099
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@ const router = express.Router();
const { v4: uuidv4 } = require('uuid');

// openai
/*
const OpenAI = require('openai').default;
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY // This is also the default, can be omitted
});
*/

const OpenAI = require('openai').default;

// Check if the OPENAI_API_KEY environment variable is set
const apiKey = process.env.OPENAI_API_KEY;

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({
apiKey: apiKey
});
}

// integrate google gemini
const { GoogleGenerativeAI } = require('@google/generative-ai');
Expand Down

0 comments on commit 9937099

Please sign in to comment.