Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
22.73k stars 2.11k forks source link

[Question] LiteLLM environment validation #1050

Closed nabuskey closed 3 months ago

nabuskey commented 3 months ago

Issue

I am not too sure if this should go to LiteLLM or Aider, but I am going to start here.

My setup is to use Aider with Amazon Bedrock. When sending requests with LiteLLM, you actually don't have to have your credentials in environment variables e.g. AWS_ACCESS_KEY_ID. It is documented as required in LiteLLM but the code path does not require it as far as I can tell. When LiteLLM needs credentials, it more or less goes through the AWS SDK's default way of getting credentials. So this allows you to get credentials without relying on environment variables.

When Aider calls validate_environment without having environment variables set here, it returns an error. This seemed correct to me at first. But it states Checks if the environment variables are valid for the given model. It read like it should be called only if environment variables are used.

If I bypass validate_environment, Aider works just fine.

Is authenticating without using environment variables something you want to support?

Thanks for this awesome project.

Version and model info

Aider version: main

 python3 -m aider --model 'bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0'
paul-gauthier commented 3 months ago

Thanks for trying aider and filing this issue.

Aider should just be warning you about the missing env vars. Feel free to ignore it if everything works.

nponeccop commented 3 months ago

I just want to add that AWS SDK has many obscure ways to authenticate users, and ideally all of them should be supported by the libraries Aider uses (it doesn't call the SDK directly).

For example, AWS_PROFILE may point to a profile identifier in .aws/ that uses an assumed role, and so on.

So checking the required environment for AWS services is a non-trivial task, really to the point "it shouldn't be done at all unless AWS SDK provides such functionality". But in case of aider this is directed to the underlying libraries.

nabuskey commented 3 months ago

@paul-gauthier Would you be open to taking a PR to make environment variable validation not fail? Print out warning message instead. Like @nponeccop mentioned above, AWS credentials validation can become quite obscure, and I'd love to use Aider without making local changes.

paul-gauthier commented 3 months ago

In what way does environment evaluation fail? It should print out a warning with a link to relevant docs and then let you try and chat. If the config actually works, you should be able to chat and just ignore the warning.

nabuskey commented 3 months ago

NVM user error. Sorry about that!