From fb2b50c0df384e350406858fdcb43e718bfb4c59 Mon Sep 17 00:00:00 2001 From: Anurag Dhote Date: Sun, 29 Oct 2023 09:54:11 +0530 Subject: [PATCH] refactor - taking API keys through enviornment variables --- src/controllers/code/index.ts | 2 +- src/controllers/do/index.ts | 2 +- src/controllers/fs/index.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/code/index.ts b/src/controllers/code/index.ts index 6f7ccd9..dcce05d 100644 --- a/src/controllers/code/index.ts +++ b/src/controllers/code/index.ts @@ -3,7 +3,7 @@ import { exec } from 'child_process'; export const main = async (args: { prompt: string }) => { try { - const openai = new OpenAI({ apiKey: "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" }); + const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); // console.log(process.env.OPENAI_API_KEY); diff --git a/src/controllers/do/index.ts b/src/controllers/do/index.ts index 451a3cf..9418d25 100644 --- a/src/controllers/do/index.ts +++ b/src/controllers/do/index.ts @@ -31,7 +31,7 @@ export const main = async (args: { prompt: string }) => { messages[messages.length - 1].content += args.prompt; // console.log(messages); - const openai = new OpenAI({ apiKey: "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" }); + const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); const completion = await openai.chat.completions.create({ messages: messages, model: "gpt-3.5-turbo", diff --git a/src/controllers/fs/index.ts b/src/controllers/fs/index.ts index ca202ca..b5e6acb 100644 --- a/src/controllers/fs/index.ts +++ b/src/controllers/fs/index.ts @@ -4,7 +4,7 @@ import { createFile, createFolder, deleteFile, deleteFolder, readFile, writeFile export const main = async (args: { prompt: string }) => { try { - const openai = new OpenAI({ apiKey: "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" }); + const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); // console.log(process.env.OPENAI_API_KEY);