karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.14k stars 119 forks source link

authinfo, gpg, password store #51

Closed jgarte closed 1 year ago

jgarte commented 1 year ago

After following the usage section I added this config:

           (setq auth-sources '("~/.authinfo"))
           (setq auth-source-pass-filename "~/.password-store")

But gptel still prompts me for an api key.

What do you think I am missing?

karthink commented 1 year ago

Could you try executing (auth-source-pass-enable) before running gptel?

aplaice commented 1 year ago

In case somebody is lazy, like me, and also whose password-store file naming convention doesn't fit with that conventions assumed by auth-source, you can directly retrieve the key with:

(alist-get 'secret (auth-source-pass-parse-entry "KEY_FILE_WITHIN_PASSWORD_STORE_WITHOUT_EXTENSION")))

i.e. you would need to customize gptel-api-key to:

(lambda () (alist-get 'secret (auth-source-pass-parse-entry "KEY_FILE_WITHIN_PASSWORD_STORE_WITHOUT_EXTENSION")))

(You might also need (require 'auth-source-pass) somewhere in your init.)

(This works for me.)


(But if your key is in .password-store/openai.com, and you run:

(auth-source-pass-enable)

then everything should also work.)


BTW @karthink thanks for the very convenient package! :)

karthink commented 1 year ago

BTW @karthink thanks for the very convenient package! :)

Glad it's useful.

karthink commented 1 year ago

I'm assuming this issue is resolved now. Please re-open if not.