Avoid hardcoded secrets name when checking OpenAI API Key
Summary
I noticed that this tool assumed that OpenAI API Key is always stored in OPENAI_API_KEY secrets variable (https://github.com/anc95/ChatGPT-CodeReview/blob/dev/src/bot.ts#L21). I want to make this key can be stored with using flexible secrets variable name. This is recommended because the tool also initiated Chat object with OpenAI API Key fetched from environment variables, instead of directly to secrets variable (https://github.com/anc95/ChatGPT-CodeReview/blob/dev/src/bot.ts#L10).
This improvement should be good, because somehow the bot commented on the pull request indicating that I did not set OPENAI_API_KEY secrets variable (indeed I did not set it up, instead I set up the other variable). The PR can be seen on this link: https://github.com/stefanusgusega/sepotifai-retriever/pull/2
I'm sorry, I think I probably misunderstood the code. So, the flow is: return Chat using process.env.OPENAI_API_KEY if any --> if not set, get OPENAI_API_KEY manually. Is it right?
@stefanusgusega yes. your understanding is correct, if OPENAI_API_KEY existing in ENV, then use it. if not, then trying to retrieve it from github variables
Okay, but in my following PR (https://github.com/stefanusgusega/sepotifai-retriever/pull/2), I have set OPENAI_API_KEY on my ENV (https://github.com/stefanusgusega/sepotifai-retriever/blob/master/.github/workflows/review-bot.yml#L27), but I still get the message that I do not set the OpenAI API Key. Is it expecetd?
the github action looks working.
yes, it's expected.
if you are using github bot, it can only access the OPENAI_API_KEY in variables, so it raised the error. either you deploy the bot yourself with OPENAI_API_KEY env var or you have set OPENAI_API_KEY in variables, it should work