Store OpenAI API Key in config.json
#17
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The main purpose of this PR is to modify the behavior of the CLI so that it generates a
config.json
file containing the API Key instead of fetching it from an environment variable (OPENAI_API_KEY
). There are a couple of issues with using the environment variable approach:Incompatibility with Other Programs: If other programs also rely on the
OPENAI_API_KEY
, they won’t be able to use different API keys independently.Security Risk: Since
OPENAI_API_KEY
is a well-known key used by the OpenAI library, leaving it exposed in environment variables could lead to potential security risks. Malware or unauthorized access might exploit this key, resulting in unexpected charges.Changes
LOZ
prefix toOPENAI_API_KEY
but keepOPENAI_API_KEY
for a legacy.readlinePromises
instead ofreadline
insrc/config/index.ts
andsrc/index.ts
.checkEnv
method fromsrc/index.ts
as it is no longer needed.apiKey
to theOpenAiAPI
constructor insrc/llm/index.ts
.checkEnv
test case fromtest/a.loz.test.ts
as it is no longer needed.Could you please review my pull request?
And thank you for making this project! Your hard work and dedication are greatly appreciated.
감사합니다. 새해 복 많이 받으세요.