Skip to content

Commit 4e49958

Browse files
committed
✨ Tweak: update openai initialization.
1 parent a44e321 commit 4e49958

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

source/utils/openai.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import execa from 'execa';
22
import OpenAI from 'openai';
3-
import dotenv from 'dotenv';
43
import config from './config.json';
4+
import { getOpenAIKey } from './api.js';
5+
import dotenv from 'dotenv';
56

67
dotenv.config();
78

8-
const openai = new OpenAI(process.env.OPENAI_API_KEY);
9-
109
// remove any staged changes in git
1110
async function initGit() {
1211
try {
@@ -51,6 +50,8 @@ async function gitDiff() {
5150
}
5251

5352
async function generatePrompt() {
53+
const apiKey = await getOpenAIKey();
54+
const openai = new OpenAI({apiKey: apiKey});
5455
// get the staged changes
5556
await initGit();
5657
await gitStatus();

0 commit comments

Comments
 (0)