junjizhi / aide.el

An Emacs front end for GPT APIs like OpenAI

Home Page:https://emacstil.com/til/2021/12/28/playing-with-openai/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Retrieving `openai-api-key` when needed through a function instead of a var

vidbina opened this issue · comments

While glancing over the code I noticed that the docs suggest to define openai-api-key as a variable.

Defining a getter function to retrieve this key may be a bit of a "cleaner" option (since any piece of elisp code can easily read the openai-api-key variable at all times). With a getter function, end users can then define how they want this getter to resolve the secret retrieval. In my case this could be

(auth-source-pass-get 'secret "openai.com/user@domain.tld/password-DATE")

and our configurations could help decide when we are requested to enter passphrases to our key store to increase the security posture of this setup. A little more robust than always having the secrets retrievable without any guardrails in place.

WDYT? Worth a PR? If so, I'd happily submit one but just wanted to confirm that this is something you'd remotely be interested in reviewing :).