vim-ai
vim-ai copied to clipboard
Allow OpenAI API key to be loaded via shell command
- Updated README.md with instructions for using GPG-encrypted token files.
- Added
g:vim_gpg_ai_token_file_pathto Vim configuration in autoload/vim_ai_config.vim. - Modified
load_api_keyin py/utils.py to handle GPG-encrypted token files.
I suspect this hard GPG dependency is a bit of a bummer. Instead, allow for a command instead of a file, so that, say pass can be called, reading the GPG encrypted file. That's how, for example, isync and msmtp solve it.
I suspect this hard GPG dependency is a bit of a bummer. Instead, allow for a command instead of a file, so that, say pass can be called, reading the GPG encrypted file. That's how, for example, isync and msmtp solve it.
You're right. I'll modify the method of passing the secret key to vim-ai from a hard dependency to a more flexible one, allowing users to pass a command instead. Thanks for your input.
Good points! I can imagine a new config to allow passing a function that loads the key, e.g.:
let g:vim_ai_load_api_token = ...
Even more flexible as this function could just return systemlist('cmd')[0].
I would prefer to do it in a vim-way
Looking at the PR and the last comment, I wonder if there's a misunderstanding? If we agree that passing the token by a Vim function
function fn()
...
return token
endfunction
is doing it a vim-way, then this function could in particular, there are many (vim-)ways, set token = systemlist(cmd)[0] where cmd could be, say, pass my_ai_token
You can now load token with a vim function, e.g.:
function! g:GetAIToken()
return system("pass path/to/your/openai.key | head -1")
endfunction
let g:vim_ai_token_load_fn = "g:GetAIToken()"