refactor: consolidate API key and environment variable handling

This commit is contained in:
Paul Gauthier 2024-12-07 10:55:18 -08:00
parent bdb08d7c78
commit 3efcd154f3
8 changed files with 239 additions and 208 deletions

View file

@ -447,6 +447,22 @@ cog.outl("```")
## Specify which editor to use for the /editor command
#editor: xxx
## Set an environment variable (can be used multiple times)
#set-env: xxx
## Specify multiple values like this:
#set-env:
# - xxx
# - yyy
# - zzz
## Set an API key for a provider (eg: --api-key anthropic=sk-123)
#api-key: xxx
## Specify multiple values like this:
#api-key:
# - xxx
# - yyy
# - zzz
#################
# Voice Settings:

View file

@ -64,10 +64,10 @@ cog.outl("```")
# Main:
## Specify the OpenAI API key
#OPENAI_API_KEY=
#AIDER_OPENAI_API_KEY=
## Specify the Anthropic API key
#ANTHROPIC_API_KEY=
#AIDER_ANTHROPIC_API_KEY=
## Specify the model to use for the main chat
#AIDER_MODEL=
@ -112,19 +112,19 @@ cog.outl("```")
#AIDER_LIST_MODELS=
## Specify the api base url
#OPENAI_API_BASE=
#AIDER_OPENAI_API_BASE=
## Specify the api_type
#OPENAI_API_TYPE=
#AIDER_OPENAI_API_TYPE=
## Specify the api_version
#OPENAI_API_VERSION=
#AIDER_OPENAI_API_VERSION=
## Specify the deployment_id
#OPENAI_API_DEPLOYMENT_ID=
#AIDER_OPENAI_API_DEPLOYMENT_ID=
## Specify the OpenAI organization ID
#OPENAI_ORGANIZATION_ID=
#AIDER_OPENAI_ORGANIZATION_ID=
## Specify a file with aider model settings for unknown models
#AIDER_MODEL_SETTINGS_FILE=.aider.model.settings.yml
@ -411,6 +411,12 @@ cog.outl("```")
## Specify which editor to use for the /editor command
#AIDER_EDITOR=
## Set an environment variable (can be used multiple times)
#AIDER_SET_ENV=
## Set an API key for a provider (eg: --api-key anthropic=sk-123)
#AIDER_API_KEY=
#################
# Voice Settings:

View file

@ -77,8 +77,8 @@ usage: aider [-h] [--openai-api-key] [--anthropic-api-key] [--model]
[--suggest-shell-commands | --no-suggest-shell-commands]
[--fancy-input | --no-fancy-input]
[--detect-urls | --no-detect-urls] [--editor]
[--voice-format] [--voice-language]
[--voice-input-device]
[--set-env] [--api-key] [--voice-format]
[--voice-language] [--voice-input-device]
```
@ -92,13 +92,13 @@ Aliases:
## Main:
### `--openai-api-key OPENAI_API_KEY`
### `--openai-api-key VALUE`
Specify the OpenAI API key
Environment variable: `OPENAI_API_KEY`
Environment variable: `AIDER_OPENAI_API_KEY`
### `--anthropic-api-key ANTHROPIC_API_KEY`
### `--anthropic-api-key VALUE`
Specify the Anthropic API key
Environment variable: `ANTHROPIC_API_KEY`
Environment variable: `AIDER_ANTHROPIC_API_KEY`
### `--model MODEL`
Specify the model to use for the main chat
@ -165,25 +165,25 @@ Aliases:
- `--list-models MODEL`
- `--models MODEL`
### `--openai-api-base OPENAI_API_BASE`
### `--openai-api-base VALUE`
Specify the api base url
Environment variable: `OPENAI_API_BASE`
Environment variable: `AIDER_OPENAI_API_BASE`
### `--openai-api-type OPENAI_API_TYPE`
### `--openai-api-type VALUE`
Specify the api_type
Environment variable: `OPENAI_API_TYPE`
Environment variable: `AIDER_OPENAI_API_TYPE`
### `--openai-api-version OPENAI_API_VERSION`
### `--openai-api-version VALUE`
Specify the api_version
Environment variable: `OPENAI_API_VERSION`
Environment variable: `AIDER_OPENAI_API_VERSION`
### `--openai-api-deployment-id OPENAI_API_DEPLOYMENT_ID`
### `--openai-api-deployment-id VALUE`
Specify the deployment_id
Environment variable: `OPENAI_API_DEPLOYMENT_ID`
Environment variable: `AIDER_OPENAI_API_DEPLOYMENT_ID`
### `--openai-organization-id OPENAI_ORGANIZATION_ID`
### `--openai-organization-id VALUE`
Specify the OpenAI organization ID
Environment variable: `OPENAI_ORGANIZATION_ID`
Environment variable: `AIDER_OPENAI_ORGANIZATION_ID`
### `--model-settings-file MODEL_SETTINGS_FILE`
Specify a file with aider model settings for unknown models
@ -713,6 +713,16 @@ Aliases:
Specify which editor to use for the /editor command
Environment variable: `AIDER_EDITOR`
### `--set-env ENV_VAR_NAME=value`
Set an environment variable (can be used multiple times)
Default: []
Environment variable: `AIDER_SET_ENV`
### `--api-key PROVIDER=KEY`
Set an API key for a provider (eg: --api-key anthropic=sk-123)
Default: []
Environment variable: `AIDER_API_KEY`
## Voice Settings:
### `--voice-format VOICE_FORMAT`