diff --git a/HISTORY.md b/HISTORY.md index 6595d69d3..3d43f6cff 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,7 @@ - Allow Claude 3.5 Sonnet to stream back >4k tokens! - It is the first model capable of writing such large coherent, useful code edits. - Do large refactors or generate multiple files of new code in one go. +- Aider now uses `claude-3-5-sonnet-20240620` by default if `ANTHROPIC_API_KEY` is set in the environment. - Enabled [image support](https://aider.chat/docs/images-urls.html) for 3.5 Sonnet and for GPT-4o & 3.5 Sonnet via OpenRouter (by @yamitzky). - Added `--attribute-commit-message` to prefix aider's commit messages with "aider:". - Fixed regression in quality of one-line commit messages. diff --git a/README.md b/README.md index 0f40212dd..2d036b08f 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ and works best with GPT-4o, Claude 3.5 Sonnet, Claude 3 Opus and DeepSeek Coder # Because this page is rendered by GitHub as the repo README cog.out(open("website/_includes/get-started.md").read()) ]]]--> + You can get started quickly like this: ``` @@ -43,14 +44,9 @@ $ cd /to/your/git/repo $ export OPENAI_API_KEY=your-key-goes-here $ aider -# Or, work with Anthropic's models +# Work with Claude 3.5 Sonnet on your repo $ export ANTHROPIC_API_KEY=your-key-goes-here - -# Claude 3 Opus -$ aider --opus - -# Claude 3.5 Sonnet -$ aider --sonnet +$ aider ``` diff --git a/aider/args.py b/aider/args.py index 474fb2257..7d4e6a160 100644 --- a/aider/args.py +++ b/aider/args.py @@ -6,7 +6,7 @@ import sys import configargparse -from aider import __version__, models +from aider import __version__ from aider.args_formatter import ( DotEnvFormatter, MarkdownHelpFormatter, @@ -44,12 +44,11 @@ def get_parser(default_config_files, git_root): env_var="ANTHROPIC_API_KEY", help="Specify the Anthropic API key", ) - default_model = models.DEFAULT_MODEL_NAME group.add_argument( "--model", metavar="MODEL", - default=default_model, - help=f"Specify the model to use for the main chat (default: {default_model})", + default=None, + help="Specify the model to use for the main chat", ) opus_model = "claude-3-opus-20240229" group.add_argument( diff --git a/aider/main.py b/aider/main.py index 75a9cde24..a7a6ce67a 100644 --- a/aider/main.py +++ b/aider/main.py @@ -403,6 +403,11 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F register_models(git_root, args.model_settings_file, io) register_litellm_models(git_root, args.model_metadata_file, io) + if not args.model: + args.model = "gpt-4o" + if os.environ.get("ANTHROPIC_API_KEY"): + args.model = "claude-3-5-sonnet-20240620" + main_model = models.Model(args.model, weak_model=args.weak_model) lint_cmds = parse_lint_cmds(args.lint_cmd, io) diff --git a/website/HISTORY.md b/website/HISTORY.md index 55d3bbe24..7e35864e6 100644 --- a/website/HISTORY.md +++ b/website/HISTORY.md @@ -17,6 +17,7 @@ cog.out(text) - Allow Claude 3.5 Sonnet to stream back >4k tokens! - It is the first model capable of writing such large coherent, useful code edits. - Do large refactors or generate multiple files of new code in one go. +- Aider now uses `claude-3-5-sonnet-20240620` by default if `ANTHROPIC_API_KEY` is set in the environment. - Enabled [image support](https://aider.chat/docs/images-urls.html) for 3.5 Sonnet and for GPT-4o & 3.5 Sonnet via OpenRouter (by @yamitzky). - Added `--attribute-commit-message` to prefix aider's commit messages with "aider:". - Fixed regression in quality of one-line commit messages. diff --git a/website/_includes/get-started.md b/website/_includes/get-started.md index e31d2ca3a..5e756f846 100644 --- a/website/_includes/get-started.md +++ b/website/_includes/get-started.md @@ -1,3 +1,4 @@ + You can get started quickly like this: ``` @@ -10,12 +11,7 @@ $ cd /to/your/git/repo $ export OPENAI_API_KEY=your-key-goes-here $ aider -# Or, work with Anthropic's models +# Work with Claude 3.5 Sonnet on your repo $ export ANTHROPIC_API_KEY=your-key-goes-here - -# Claude 3 Opus -$ aider --opus - -# Claude 3.5 Sonnet -$ aider --sonnet +$ aider ``` diff --git a/website/_posts/2024-07-01-sonnet-not-lazy.md b/website/_posts/2024-07-01-sonnet-not-lazy.md new file mode 100644 index 000000000..fc7284111 --- /dev/null +++ b/website/_posts/2024-07-01-sonnet-not-lazy.md @@ -0,0 +1,93 @@ +--- +title: Sonnet is the opposite of lazy +excerpt: Claude 3.5 Sonnet represents a step change in AI coding. +#highlight_image: /assets/linting.jpg +draft: true +nav_exclude: true +--- +{% if page.date %} +

{{ page.date | date: "%B %d, %Y" }}

+{% endif %} + + +# Sonnet is the opposite of lazy + +Claude 3.5 Sonnet represents a step change +in AI coding. +It is so industrious, diligent and hard working that +it has caused multiple problems for aider. +It's been worth the effort to adapt aider to work well +with Sonnet, +because the result is surprisingly powerful. + +Sonnet's amazing work ethic caused a few problems: + +1. Sonnet is capable of outputting a very large amount of correct, +complete code in one response. +So much that it can easily blow through the 4k output token limit +on API responses, which truncates its coding in mid-stream. +2. Similarly, Sonnet can specify large sequences of edits in one go, +like changing a majority of lines while refactoring a large file. +Again, this regularly triggered the 4k output limit +and resulted in a failed edits. +3. Sonnet is not shy about quoting large chunks of an +existing file to perform a SEARCH & REPLACE edit across +a long span of lines. +This can be wasteful and also trigger the 4k output limit. + + +## Good problems + +Problems (1) and (2) are "good problems" +in the sense that Sonnet is +able to write more high quality code than any other model! + +Aider now allows Sonnet to return code in multiple 4k token +responses. +This gets all the upsides of Sonnet's prolific coding skills, +without being constrained by the 4k output token limit. + + +## Wasting tokens + +Problem (3) does cause some real downsides. + +Faced with a few small changes spread far apart in +a source file, +Sonnet would often prefer to do one giant SEARCH/REPLACE +operation of the ~entire file. +This wastes a tremendous amount of tokens, +time and money -- and risks hitting the 4k output limit. +It would be far faster and less expensive to instead +do a few surgical edits. + +Aider now prompts Sonnet to discourage these long-winded +SEARCH/REPLACE operations +and promotes much more concise edits. + + +## Aider with Sonnet + +[The latest release of aider](https://aider.chat/HISTORY.html#aider-v0410) +has specialized support for Claude 3.5 Sonnet: + +- Aider allows Sonnet to produce as much code as it wants, +by automatically and seamlessly spreading the response +out over a sequence of 4k token API responses. +- Aider carefully prompts Sonnet to be concise and +return only changing sections of code. +This reduces Sonnet's tendency to waste time, tokens and money +returning large chunks of unchanging code. +- Aider now uses `claude-3-5-sonnet-20240620` by default if `ANTHROPIC_API_KEY` is set in the environment. + +You can use aider with Sonnet like this: + +``` +pip install aider-chat + +export ANTHROPIC_API_KEY= # Mac/Linux +setx ANTHROPIC_API_KEY # Windows + +aider +``` + diff --git a/website/assets/sample.aider.conf.yml b/website/assets/sample.aider.conf.yml index 66a24dc33..f6b3233ac 100644 --- a/website/assets/sample.aider.conf.yml +++ b/website/assets/sample.aider.conf.yml @@ -19,8 +19,8 @@ ## Specify the Anthropic API key #anthropic-api-key: -## Specify the model to use for the main chat (default: gpt-4o) -#model: gpt-4o +## Specify the model to use for the main chat +#model: ## Use claude-3-opus-20240229 model for the main chat #opus: false diff --git a/website/assets/sample.env b/website/assets/sample.env index 154a722c9..72cc98a3a 100644 --- a/website/assets/sample.env +++ b/website/assets/sample.env @@ -27,8 +27,8 @@ ## Specify the Anthropic API key #ANTHROPIC_API_KEY= -## Specify the model to use for the main chat (default: gpt-4o) -#AIDER_MODEL=gpt-4o +## Specify the model to use for the main chat +#AIDER_MODEL= ## Use claude-3-opus-20240229 model for the main chat #AIDER_OPUS= diff --git a/website/docs/config/aider_conf.md b/website/docs/config/aider_conf.md index 58c452fb8..428ff55d2 100644 --- a/website/docs/config/aider_conf.md +++ b/website/docs/config/aider_conf.md @@ -47,8 +47,8 @@ cog.outl("```") ## Specify the Anthropic API key #anthropic-api-key: -## Specify the model to use for the main chat (default: gpt-4o) -#model: gpt-4o +## Specify the model to use for the main chat +#model: ## Use claude-3-opus-20240229 model for the main chat #opus: false diff --git a/website/docs/config/dotenv.md b/website/docs/config/dotenv.md index 9aae6011b..dfede0e8e 100644 --- a/website/docs/config/dotenv.md +++ b/website/docs/config/dotenv.md @@ -60,8 +60,8 @@ cog.outl("```") ## Specify the Anthropic API key #ANTHROPIC_API_KEY= -## Specify the model to use for the main chat (default: gpt-4o) -#AIDER_MODEL=gpt-4o +## Specify the model to use for the main chat +#AIDER_MODEL= ## Use claude-3-opus-20240229 model for the main chat #AIDER_OPUS= diff --git a/website/docs/config/options.md b/website/docs/config/options.md index 557d0cf53..310999899 100644 --- a/website/docs/config/options.md +++ b/website/docs/config/options.md @@ -72,8 +72,7 @@ Specify the Anthropic API key Environment variable: `ANTHROPIC_API_KEY` ### `--model MODEL` -Specify the model to use for the main chat (default: gpt-4o) -Default: gpt-4o +Specify the model to use for the main chat Environment variable: `AIDER_MODEL` ### `--opus` diff --git a/website/docs/llms/anthropic.md b/website/docs/llms/anthropic.md index 027feef44..22a45fa30 100644 --- a/website/docs/llms/anthropic.md +++ b/website/docs/llms/anthropic.md @@ -19,12 +19,12 @@ pip install aider-chat export ANTHROPIC_API_KEY= # Mac/Linux setx ANTHROPIC_API_KEY # Windows +# Aider uses Claude 3.5 Sonnet by default (or use --sonnet) +aider + # Claude 3 Opus aider --opus -# Claude 3.5 Sonnet -aider --sonnet - # List models available from Anthropic aider --models anthropic/ ``` diff --git a/website/docs/llms/openai.md b/website/docs/llms/openai.md index 40fee02e4..c4cd2d917 100644 --- a/website/docs/llms/openai.md +++ b/website/docs/llms/openai.md @@ -19,7 +19,7 @@ pip install aider-chat export OPENAI_API_KEY= # Mac/Linux setx OPENAI_API_KEY # Windows -# GPT-4o is the best model, used by default +# Aider uses gpt-4o by default (or use --4o) aider # GPT-4 Turbo (1106) diff --git a/website/index.md b/website/index.md index e70259f77..a8abc461a 100644 --- a/website/index.md +++ b/website/index.md @@ -45,6 +45,7 @@ and works best with GPT-4o, Claude 3.5 Sonnet, Claude 3 Opus and DeepSeek Coder # Because this page is rendered by GitHub as the repo README cog.out(open("website/_includes/get-started.md").read()) --> + You can get started quickly like this: ``` @@ -57,14 +58,9 @@ $ cd /to/your/git/repo $ export OPENAI_API_KEY=your-key-goes-here $ aider -# Or, work with Anthropic's models +# Work with Claude 3.5 Sonnet on your repo $ export ANTHROPIC_API_KEY=your-key-goes-here - -# Claude 3 Opus -$ aider --opus - -# Claude 3.5 Sonnet -$ aider --sonnet +$ aider ```