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

Add support for a shell command in place of environment variable name #24

Merged
merged 3 commits into from
Mar 17, 2024

Conversation

abayomi185
Copy link
Contributor

Having the API key in environment variables is not always safe, as any application or program can read it.

I also had a situation where a program didn't load the project specific .env file but used the main key from the user profile - although, this case can be rectified with the recent pattern using a different variable name.

This PR allows for this:

chat = require("codecompanion.adapters").use("openai", {
  env = {
    api_key = "cmd:gpg --decrypt ~/.openai-api-key.gpg 2>/dev/null",
  },
}),

I'm happy to make further changes; this change breaks assumptions about what the config should be.

@olimorris
Copy link
Owner

Thank you and great suggestion.

More than happy to add this to the plugin. Could you update the readme to reflect this too? I think this would be a popular addition.

@abayomi185
Copy link
Contributor Author

Yes. README has been updated.

@olimorris
Copy link
Owner

Fantastic and thanks again. I will make sure I use this for my own API keys

@olimorris olimorris merged commit f831051 into olimorris:main Mar 17, 2024
2 checks passed
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.

None yet

2 participants