Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow OpenAI API key to be loaded via shell command #122

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

VimfanTPdvorak
Copy link

  • Updated README.md with instructions for using GPG-encrypted token files.
  • Added g:vim_gpg_ai_token_file_path to Vim configuration in autoload/vim_ai_config.vim.
  • Modified load_api_key in py/utils.py to handle GPG-encrypted token files.

- Updated README.md with instructions for using GPG-encrypted token
  files.
- Added `g:vim_gpg_ai_token_file_path` to Vim configuration in
  autoload/vim_ai_config.vim.
- Modified `load_api_key` in py/utils.py to handle GPG-encrypted token
  files.
@Konfekt
Copy link
Contributor

Konfekt commented Oct 2, 2024

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.

@VimfanTPdvorak
Copy link
Author

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.

@madox2
Copy link
Owner

madox2 commented Oct 2, 2024

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 = ...

@Konfekt
Copy link
Contributor

Konfekt commented Oct 2, 2024

Even more flexible as this function could just return systemlist('cmd')[0].

@madox2
Copy link
Owner

madox2 commented Oct 2, 2024

I would prefer to do it in a vim-way

- Replaced GPG decryption support with a more flexible approach to load
  API tokens from any shell command.
- Users can now specify a command through `g:vim_ai_load_api_token`, and
  its output will be used as the API key.
@Konfekt
Copy link
Contributor

Konfekt commented Oct 3, 2024

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

@VimfanTPdvorak VimfanTPdvorak changed the title Add support to store the token in a GPG-encrypted file Allow OpenAI API key to be loaded via shell command Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants