-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor API call and error handling in BioGenerator
- Loading branch information
1 parent
cc9a493
commit f85813b
Showing
2 changed files
with
46 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import { Configuration, OpenAIApi } from 'openai' | ||
// import { Configuration, OpenAIApi } from 'openai' | ||
|
||
// if (!process.env.OPENAI_API_KEY) { | ||
// process.env.OPENAI_API_KEY = "" | ||
import { Configuration, OpenAIApi } from "openai"; | ||
|
||
// if (!process.env.NEXT_OPENAI_API_KEY) { | ||
// console.log(process.env.NEXT_OPENAI_API_KEY) | ||
// } | ||
|
||
const configuration = new Configuration({ | ||
apiKey: process.env.NEXT_PUBLIC_OPENAI_API_KEY, | ||
}); | ||
// const configuration = new Configuration({ | ||
// apiKey: process.env.NEXT_PUBLIC_OPENAI_API_KEY, | ||
// }); | ||
|
||
// const openai = new OpenAIApi(configuration); | ||
|
||
const openai = new OpenAIApi(configuration); | ||
// export default openai | ||
|
||
export default openai | ||
export function getOpenAIApiInstance(apiKey: string) { | ||
const configuration = new Configuration({ | ||
apiKey, | ||
}); | ||
return new OpenAIApi(configuration); | ||
} |