From f28f3fdcaf773969f4f729c3dd2621a1d15d5dc9 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 25 Jun 2024 14:22:50 -0700 Subject: [PATCH 01/26] Stop eliding - bullet lists in pypi desc --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ef0f72d72..d31d87a77 100644 --- a/setup.py +++ b/setup.py @@ -7,10 +7,10 @@ with open("requirements.txt") as f: from aider import __version__ -with open("website/index.md", "r", encoding="utf-8") as f: +with open("README.md", "r", encoding="utf-8") as f: long_description = f.read() long_description = re.sub(r"\n!\[.*\]\(.*\)", "", long_description) - long_description = re.sub(r"\n- \[.*\]\(.*\)", "", long_description) + # long_description = re.sub(r"\n- \[.*\]\(.*\)", "", long_description) setup( name="aider-chat", From bcabd50414fcbd7a3ae5c815bebc1c4eaa925b38 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 25 Jun 2024 14:26:32 -0700 Subject: [PATCH 02/26] Updated HISTORY --- HISTORY.md | 2 +- website/HISTORY.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index b20566cfb..0926c14c3 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,7 +1,7 @@ # Release history -### v0.40.2 +### v0.40.5 - Bump versions to pickup latest litellm to fix streaming issue with Gemini - https://github.com/BerriAI/litellm/issues/4408 diff --git a/website/HISTORY.md b/website/HISTORY.md index 081135738..38625628f 100644 --- a/website/HISTORY.md +++ b/website/HISTORY.md @@ -12,7 +12,7 @@ cog.out(text) # Release history -### v0.40.2 +### v0.40.5 - Bump versions to pickup latest litellm to fix streaming issue with Gemini - https://github.com/BerriAI/litellm/issues/4408 From 17f7297d86383aea643d3037a3d8c6bbf38f5d4c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 25 Jun 2024 14:56:02 -0700 Subject: [PATCH 03/26] updated model warnings and docs --- aider/models.py | 8 ++-- website/_includes/model-warnings.md | 60 +++++++++++++++-------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/aider/models.py b/aider/models.py index 3e61dd90b..09c250da5 100644 --- a/aider/models.py +++ b/aider/models.py @@ -551,7 +551,7 @@ def sanity_check_model(io, model): if not model.info: show = True io.tool_output( - f"Model {model}: Unknown model, context window size and token costs unavailable." + f"Model {model}: Unknown context window size and costs, using sane defaults." ) possible_matches = fuzzy_match_models(model.name) @@ -560,12 +560,12 @@ def sanity_check_model(io, model): for match in possible_matches: fq, m = match if fq == m: - io.tool_error(f"- {m}") + io.tool_output(f"- {m}") else: - io.tool_error(f"- {m} ({fq})") + io.tool_output(f"- {m} ({fq})") if show: - io.tool_error(urls.model_warnings) + io.tool_output(f"For more info, see: {urls.model_warnings}\n") def fuzzy_match_models(name): diff --git a/website/_includes/model-warnings.md b/website/_includes/model-warnings.md index 433e56bc9..4d5a07a41 100644 --- a/website/_includes/model-warnings.md +++ b/website/_includes/model-warnings.md @@ -1,18 +1,38 @@ +## Unknown context window size and token costs + +``` +Model foobar: Unknown context window size and costs, using sane defaults. +``` + +*You can probably ignore the unknown context window size and token costs warning.* + +If you specify a model that aider has never heard of, you will get +this warning. +This means aider doesn't know the context window size and token costs +for that model. +Aider will use an unlimited context window and assume the model is free, +so this is not usually a significant problem. + -Aider tries to sanity check that it is configured correctly -to work with the LLM you specified: +## Did you mean? -- It checks to see that all required environment variables are set for the model. These variables are required to configure things like API keys, API base URLs, etc. -These settings are required to be correct. -- It checks a metadata database to look up the context window size and token costs for the model. -It's usually OK if this extra metadata isn't available. +If aider isn't familiar with the model you've specified, +it will suggest similarly named models. +This helps +in the case where you made a typo or mistake when specifying the model name. -Sometimes one or both of these checks will fail, so aider will issue -some of the following warnings. +``` +Model gpt-5o: Unknown context window size and costs, using sane defaults. +Did you mean one of these? +- gpt-4o +``` ## Missing environment variables +You need to set the listed environment variables. +Otherwise you will get error messages when you start chatting with the model. + ``` Model azure/gpt-4-turbo: Missing these environment variables: - AZURE_API_BASE @@ -20,8 +40,6 @@ Model azure/gpt-4-turbo: Missing these environment variables: - AZURE_API_KEY ``` -You need to set the listed environment variables. -Otherwise you will get error messages when you start chatting with the model. ## Unknown which environment variables are required @@ -34,24 +52,8 @@ Aider is unable verify the environment because it doesn't know which variables are required for the model. If required variables are missing, you may get errors when you attempt to chat with the model. -You can look in the -[litellm provider documentation](https://docs.litellm.ai/docs/providers) +You can look in the [aider's LLM documentation](/docs/llms.html) +or the +[litellm documentation](https://docs.litellm.ai/docs/providers) to see if the required variables are listed there. -## Context window size and token costs unavailable. - -``` -Model foobar: Unknown model, context window size and token costs unavailable. -``` - -If you specify a model that aider has never heard of, you will get an -"unknown model" warning. -This means aider doesn't know the context window size and token costs -for that model. -Some minor functionality will be limited when using such models, but -it's not really a significant problem. - -Aider will also try to suggest similarly named models, -in case you made a typo or mistake when specifying the model name. - - From 56a9463db8b5394d60def0ba1c00fcfd7d421fdf Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 25 Jun 2024 15:09:58 -0700 Subject: [PATCH 04/26] copy --- website/docs/usage.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/website/docs/usage.md b/website/docs/usage.md index 7451f9b2a..1bfbda5ad 100644 --- a/website/docs/usage.md +++ b/website/docs/usage.md @@ -37,26 +37,31 @@ Use /help to see in-chat commands, run with --help to see cmd line args ## Adding files -Just add the files that the aider will need to *edit*. +Add the files that the aider will need to *edit*. + +Don't add a bunch of extra files. If you add too many files, the LLM can get overwhelmed and confused (and it costs more tokens). Aider will automatically pull in content from related files so that it can [understand the rest of your code base](https://aider.chat/docs/repomap.html). -You can also run aider without naming any files and use the in-chat +You add files to the chat by naming them on the aider command line. +Or, you can use the in-chat `/add` command to add files. -Or you can skip adding files completely, and aider -will try to figure out which files need to be edited based +You can use aider without adding any files, +and it will try to figure out which files need to be edited based on your requests. +But you'll get the best results if you add the files that need +to edited. ## LLMs Aider uses GPT-4o by default, but you can [connect to many different LLMs](/docs/llms.html). -Claude 3 Opus is another model which works very well with aider, -which you can use by running `aider --opus`. +Claude 3.5 Sonnet is also works very well with aider, +which you can use by running `aider --sonnet`. You can run `aider --model XXX` to launch aider with a specific model. @@ -68,8 +73,8 @@ Or, during your chat you can switch models with the in-chat Ask aider to make changes to your code. It will show you some diffs of the changes it is making to complete you request. -Aider will git commit all of its changes, +[Aider will git commit all of its changes](/docs/git.html), so they are easy to track and undo. -You can always use the `/undo` command to undo changes you don't +You can always use the `/undo` command to undo AI changes that you don't like. From fb3a85b6d20a6a45efb239706ff047f919154559 Mon Sep 17 00:00:00 2001 From: paul-gauthier <69695708+paul-gauthier@users.noreply.github.com> Date: Tue, 25 Jun 2024 20:12:46 -0700 Subject: [PATCH 05/26] Update usage.md --- website/docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/usage.md b/website/docs/usage.md index 1bfbda5ad..ad6bf5870 100644 --- a/website/docs/usage.md +++ b/website/docs/usage.md @@ -60,7 +60,7 @@ to edited. Aider uses GPT-4o by default, but you can [connect to many different LLMs](/docs/llms.html). -Claude 3.5 Sonnet is also works very well with aider, +Claude 3.5 Sonnet also works very well with aider, which you can use by running `aider --sonnet`. You can run `aider --model XXX` to launch aider with From ea97d0844947d0f6ec1472dd8f7b7f6455680476 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 25 Jun 2024 20:36:57 -0700 Subject: [PATCH 06/26] Handle null model.info max_input_tokens --- aider/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aider/models.py b/aider/models.py index 09c250da5..b9ae02590 100644 --- a/aider/models.py +++ b/aider/models.py @@ -328,7 +328,10 @@ class Model: self.missing_keys = res.get("missing_keys") self.keys_in_environment = res.get("keys_in_environment") - if self.info.get("max_input_tokens", 0) < 32 * 1024: + max_input_tokens = self.info.get("max_input_tokens") + if not max_input_tokens: + max_input_tokens = 0 + if max_input_tokens < 32 * 1024: self.max_chat_history_tokens = 1024 else: self.max_chat_history_tokens = 2 * 1024 From c1e55614f7bf5850e858cff17209d472c3c6dbe6 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 07:15:06 -0700 Subject: [PATCH 07/26] Don't rely on (aider) in git name field to police /undo #698 --- aider/commands.py | 5 +---- aider/tests/test_commands.py | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 00189fecd..5ea285111 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -331,10 +331,7 @@ class Commands: return last_commit = self.coder.repo.repo.head.commit - if ( - not last_commit.author.name.endswith(" (aider)") - or last_commit.hexsha[:7] != self.coder.last_aider_commit_hash - ): + if last_commit.hexsha[:7] != self.coder.last_aider_commit_hash: self.io.tool_error("The last commit was not made by aider in this chat session.") self.io.tool_error( "You could try `/git reset --hard HEAD^` but be aware that this is a destructive" diff --git a/aider/tests/test_commands.py b/aider/tests/test_commands.py index f6629f481..262262f39 100644 --- a/aider/tests/test_commands.py +++ b/aider/tests/test_commands.py @@ -523,8 +523,6 @@ class TestCommands(TestCase): other_path.write_text("other content") repo.git.add(str(other_path)) - os.environ["GIT_AUTHOR_NAME"] = "Foo (aider)" - # Create and commit a file filename = "test_file.txt" file_path = Path(repo_dir) / filename @@ -536,8 +534,6 @@ class TestCommands(TestCase): repo.git.add(filename) repo.git.commit("-m", "second commit") - del os.environ["GIT_AUTHOR_NAME"] - # Store the commit hash last_commit_hash = repo.head.commit.hexsha[:7] coder.last_aider_commit_hash = last_commit_hash From bafca6aaa0fdb7a6aeba14291f546b976368ceff Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 07:16:50 -0700 Subject: [PATCH 08/26] Updated HISTORY --- HISTORY.md | 4 ++++ website/HISTORY.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 0926c14c3..a1f7df050 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,10 @@ # Release history +### v0.40.6 + +- Fixed `/undo` so it works with `--no-attribute-author`. + ### v0.40.5 - Bump versions to pickup latest litellm to fix streaming issue with Gemini diff --git a/website/HISTORY.md b/website/HISTORY.md index 38625628f..f617fc5fd 100644 --- a/website/HISTORY.md +++ b/website/HISTORY.md @@ -12,6 +12,10 @@ cog.out(text) # Release history +### v0.40.6 + +- Fixed `/undo` so it works with `--no-attribute-author`. + ### v0.40.5 - Bump versions to pickup latest litellm to fix streaming issue with Gemini From 61d36d2f346217bb97a1bd89fb11e8a2e1e9a2ed Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 07:20:42 -0700 Subject: [PATCH 09/26] version bump to 0.40.6 --- aider/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/__init__.py b/aider/__init__.py index d4a95c429..6e2b9eaa6 100644 --- a/aider/__init__.py +++ b/aider/__init__.py @@ -1 +1 @@ -__version__ = "0.40.6-dev" +__version__ = "0.40.6" From 7e511dc21f4c0e90b66426ac93223c437df42548 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 07:21:31 -0700 Subject: [PATCH 10/26] set version to 0.40.7-dev --- aider/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/__init__.py b/aider/__init__.py index 6e2b9eaa6..8920a054a 100644 --- a/aider/__init__.py +++ b/aider/__init__.py @@ -1 +1 @@ -__version__ = "0.40.6" +__version__ = "0.40.7-dev" From e095fde27ec0aef34ad9df6293187a04a9088b00 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 10:10:36 -0700 Subject: [PATCH 11/26] updated docs --- website/_includes/model-warnings.md | 3 + website/docs/config.md | 2 +- website/docs/config/adv-model-settings.md | 86 +++++++++++++++++++++ website/docs/{ => config}/aider_conf.md | 0 website/docs/{ => config}/dotenv.md | 0 website/docs/{ => config}/options.md | 0 website/docs/llms/warnings.md | 67 ---------------- website/docs/troubleshooting/edit-errors.md | 4 +- 8 files changed, 92 insertions(+), 70 deletions(-) create mode 100644 website/docs/config/adv-model-settings.md rename website/docs/{ => config}/aider_conf.md (100%) rename website/docs/{ => config}/dotenv.md (100%) rename website/docs/{ => config}/options.md (100%) diff --git a/website/_includes/model-warnings.md b/website/_includes/model-warnings.md index 4d5a07a41..aaba1f0b1 100644 --- a/website/_includes/model-warnings.md +++ b/website/_includes/model-warnings.md @@ -14,6 +14,9 @@ for that model. Aider will use an unlimited context window and assume the model is free, so this is not usually a significant problem. +See the docs on +[configuring advanced model settings](/docs/config/adv-model-settings.html) +for details on how to remove this warning. ## Did you mean? diff --git a/website/docs/config.md b/website/docs/config.md index b018e5a90..dca28da0f 100644 --- a/website/docs/config.md +++ b/website/docs/config.md @@ -12,7 +12,7 @@ Most options can also be set in an `.aider.conf.yml` file which can be placed in your home directory or at the root of your git repo. Or via environment variables like `AIDER_xxx`, -as noted in the [options reference](options.html). +as noted in the [options reference](/docs/config/options.html). Here are 3 equivalent ways of setting an option. First, via a command line switch: diff --git a/website/docs/config/adv-model-settings.md b/website/docs/config/adv-model-settings.md new file mode 100644 index 000000000..41f1be9da --- /dev/null +++ b/website/docs/config/adv-model-settings.md @@ -0,0 +1,86 @@ +--- +parent: Configuration +nav_order: 950 +description: Configuring advanced settings for LLMs. +--- + +# Advanced model settings + +## Context window size and token costs + +In most cases, you can safely ignore aider's warning about unknown context +window size and model costs. + +But, you can register context window limits and costs for models that aren't known +to aider. Create a `.aider.litellm.models.json` file in one of these locations: + +- Your home directory. +- The root if your git repo. +- The current directory where you launch aider. +- Or specify a specific file with the `--model-metadata-file ` switch. + + +If the files above exist, they will be loaded in that order. +Files loaded last will take priority. + +The json file should be a dictionary with an entry for each model, as follows: + +``` +{ + "deepseek-chat": { + "max_tokens": 4096, + "max_input_tokens": 32000, + "max_output_tokens": 4096, + "input_cost_per_token": 0.00000014, + "output_cost_per_token": 0.00000028, + "litellm_provider": "deepseek", + "mode": "chat" + } +} +``` + +See +[litellm's model_prices_and_context_window.json file](https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json) for more examples. + +## Model settings + +Aider has a number of settings that control how it works with +different models. +These model settings are pre-configured for most popular models. +But it can sometimes be helpful to override them or add settings for +a model that aider doesn't know about. + +To do that, +create a `.aider.models.yml` file in one of these locations: + +- Your home directory. +- The root if your git repo. +- The current directory where you launch aider. +- Or specify a specific file with the `--model-settings-file ` switch. + +If the files above exist, they will be loaded in that order. +Files loaded last will take priority. + +The yaml file should be a a list of dictionary objects for each model, as follows: + +``` +- name: "gpt-3.5-turbo" + edit_format: "whole" + weak_model_name: "gpt-3.5-turbo" + use_repo_map: false + send_undo_reply: false + accepts_images: false + lazy: false + reminder_as_sys_msg: true + examples_as_sys_msg: false +- name: "gpt-4-turbo-2024-04-09" + edit_format: "udiff" + weak_model_name: "gpt-3.5-turbo" + use_repo_map: true + send_undo_reply: true + accepts_images: true + lazy: true + reminder_as_sys_msg: true + examples_as_sys_msg: false +``` + diff --git a/website/docs/aider_conf.md b/website/docs/config/aider_conf.md similarity index 100% rename from website/docs/aider_conf.md rename to website/docs/config/aider_conf.md diff --git a/website/docs/dotenv.md b/website/docs/config/dotenv.md similarity index 100% rename from website/docs/dotenv.md rename to website/docs/config/dotenv.md diff --git a/website/docs/options.md b/website/docs/config/options.md similarity index 100% rename from website/docs/options.md rename to website/docs/config/options.md diff --git a/website/docs/llms/warnings.md b/website/docs/llms/warnings.md index c33acffd2..1034089f9 100644 --- a/website/docs/llms/warnings.md +++ b/website/docs/llms/warnings.md @@ -8,70 +8,3 @@ nav_order: 900 {% include model-warnings.md %} -## Adding settings for missing models -You can register model settings used by aider for unknown models. -Create a `.aider.models.yml` file in one of these locations: - -- Your home directory. -- The root if your git repo. -- The current directory where you launch aider. -- Or specify a specific file with the `--model-settings-file ` switch. - -If the files above exist, they will be loaded in that order. -Files loaded last will take priority. - -The yaml file should be a a list of dictionary objects for each model, as follows: - -``` -- name: "gpt-3.5-turbo" - edit_format: "whole" - weak_model_name: "gpt-3.5-turbo" - use_repo_map: false - send_undo_reply: false - accepts_images: false - lazy: false - reminder_as_sys_msg: true - examples_as_sys_msg: false -- name: "gpt-4-turbo-2024-04-09" - edit_format: "udiff" - weak_model_name: "gpt-3.5-turbo" - use_repo_map: true - send_undo_reply: true - accepts_images: true - lazy: true - reminder_as_sys_msg: true - examples_as_sys_msg: false -``` - -## Specifying context window size and token costs - -You can register context window limits and costs for models that aren't known -to aider. Create a `.aider.litellm.models.json` file in one of these locations: - -- Your home directory. -- The root if your git repo. -- The current directory where you launch aider. -- Or specify a specific file with the `--model-metadata-file ` switch. - - -If the files above exist, they will be loaded in that order. -Files loaded last will take priority. - -The json file should be a dictionary with an entry for each model, as follows: - -``` -{ - "deepseek-chat": { - "max_tokens": 4096, - "max_input_tokens": 32000, - "max_output_tokens": 4096, - "input_cost_per_token": 0.00000014, - "output_cost_per_token": 0.00000028, - "litellm_provider": "deepseek", - "mode": "chat" - } -} -``` - -See -[litellm's model_prices_and_context_window.json file](https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json) for more examples. diff --git a/website/docs/troubleshooting/edit-errors.md b/website/docs/troubleshooting/edit-errors.md index dbbd527dd..6fe8978ad 100644 --- a/website/docs/troubleshooting/edit-errors.md +++ b/website/docs/troubleshooting/edit-errors.md @@ -21,8 +21,8 @@ In these cases, here are some things you might try. ## Use a capable model -If possible try using GPT-4o or Opus, as they are the strongest and most -capable models. +If possible try using GPT-4o, Claude 3.5 Sonnet or Claude 3 Opus, +as they are the strongest and most capable models. Weaker models are more prone to From 0704810d31d16562eec5411101fb7c0e383960ea Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 10:11:29 -0700 Subject: [PATCH 12/26] use new docs paths --- scripts/update-docs.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/update-docs.sh b/scripts/update-docs.sh index fc16c4c66..feb5d7f43 100755 --- a/scripts/update-docs.sh +++ b/scripts/update-docs.sh @@ -14,8 +14,8 @@ cog $ARG \ README.md \ website/index.md \ website/HISTORY.md \ - website/docs/dotenv.md \ website/docs/commands.md \ website/docs/languages.md \ - website/docs/options.md \ - website/docs/aider_conf.md + website/docs/config/dotenv.md \ + website/docs/config/options.md \ + website/docs/config/aider_conf.md From 34e83f9580e64d10dc1a62cbcbb8605e5336fc69 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 10:19:42 -0700 Subject: [PATCH 13/26] Implemented commit message attribution for Aider-generated edits. --- aider/repo.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aider/repo.py b/aider/repo.py index 713b463b3..0a755a1ac 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -84,6 +84,9 @@ class GitRepo: else: commit_message = self.get_commit_message(diffs, context) + if aider_edits and self.attribute_commit_message: + commit_message = "aider: " + commit_message + if not commit_message: commit_message = "(no commit message provided)" From 9c214e0faf9ccbab96a610e763f14396b46541a0 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 10:21:04 -0700 Subject: [PATCH 14/26] Implemented option to attribute commit messages in GitRepo class. --- aider/repo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aider/repo.py b/aider/repo.py index 0a755a1ac..6e3465697 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -25,12 +25,14 @@ class GitRepo: models=None, attribute_author=True, attribute_committer=True, + attribute_commit_message=False, ): self.io = io self.models = models self.attribute_author = attribute_author self.attribute_committer = attribute_committer + self.attribute_commit_message = attribute_commit_message if git_dname: check_fnames = [git_dname] From ec682fd683339ba97405bc7e404bc9eaf80ed9b4 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 27 Jun 2024 10:21:25 -0700 Subject: [PATCH 15/26] Added an option to prefix commit messages with 'aider: '. --- aider/args.py | 6 ++++++ aider/coders/base_coder.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/aider/args.py b/aider/args.py index bb3fd2cfc..473a9dc2e 100644 --- a/aider/args.py +++ b/aider/args.py @@ -345,6 +345,12 @@ def get_parser(default_config_files, git_root): default=True, help="Attribute aider commits in the git committer name (default: True)", ) + group.add_argument( + "--attribute-commit-message", + action=argparse.BooleanOptionalAction, + default=False, + help="Prefix commit messages with 'aider: ' (default: False)", + ) group.add_argument( "--dry-run", action=argparse.BooleanOptionalAction, diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 1c94beff6..c5a4bf794 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -221,6 +221,7 @@ class Coder: test_cmd=None, attribute_author=True, attribute_committer=True, + attribute_commit_message=False, ): if not fnames: fnames = [] @@ -280,6 +281,7 @@ class Coder: models=main_model.commit_message_models(), attribute_author=attribute_author, attribute_committer=attribute_committer, + attribute_commit_message=attribute_commit_message, ) self.root = self.repo.root except FileNotFoundError: From 506636195aa31fdd25f1e5808f5dd90fb298a750 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 27 Jun 2024 10:23:31 -0700 Subject: [PATCH 16/26] Implemented the ability to attribute the commit message in the main function. --- aider/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aider/main.py b/aider/main.py index ef22d2c4f..75a9cde24 100644 --- a/aider/main.py +++ b/aider/main.py @@ -441,6 +441,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F test_cmd=args.test_cmd, attribute_author=args.attribute_author, attribute_committer=args.attribute_committer, + attribute_commit_message=args.attribute_commit_message, ) except ValueError as err: From 9cc6447e57015f80a9a4f88b3917d66d8befcbfa Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 27 Jun 2024 10:26:36 -0700 Subject: [PATCH 17/26] Added support for prefixing commit messages with 'aider: ' to identify commits made by the aider tool. --- website/docs/git.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/docs/git.md b/website/docs/git.md index fc42c9bcb..36b238831 100644 --- a/website/docs/git.md +++ b/website/docs/git.md @@ -44,3 +44,6 @@ Aider marks commits that it either authored or committed. You can use `--no-attribute-author` and `--no-attribute-committer` to disable modification of the git author and committer name fields. + +Additionally, you can use `--attribute-commit-message` to prefix commit messages with 'aider: '. +This option is disabled by default, but can be useful for easily identifying commits made by aider. From 5d86117249dff39e3b650d42b5af1ac4f65eb8b5 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 10:27:28 -0700 Subject: [PATCH 18/26] copy --- website/assets/sample.aider.conf.yml | 3 +++ website/assets/sample.env | 3 +++ website/docs/config/aider_conf.md | 3 +++ website/docs/config/dotenv.md | 3 +++ website/docs/config/options.md | 9 +++++++++ 5 files changed, 21 insertions(+) diff --git a/website/assets/sample.aider.conf.yml b/website/assets/sample.aider.conf.yml index 7075eb6ff..6d401fe24 100644 --- a/website/assets/sample.aider.conf.yml +++ b/website/assets/sample.aider.conf.yml @@ -160,6 +160,9 @@ ## Attribute aider commits in the git committer name (default: True) #attribute-committer: true +## Prefix commit messages with 'aider: ' (default: False) +#attribute-commit-message: false + ## Perform a dry run without modifying files (default: False) #dry-run: false diff --git a/website/assets/sample.env b/website/assets/sample.env index 71fb2b34a..1f3420254 100644 --- a/website/assets/sample.env +++ b/website/assets/sample.env @@ -168,6 +168,9 @@ ## Attribute aider commits in the git committer name (default: True) #AIDER_ATTRIBUTE_COMMITTER=true +## Prefix commit messages with 'aider: ' (default: False) +#AIDER_ATTRIBUTE_COMMIT_MESSAGE=false + ## Perform a dry run without modifying files (default: False) #AIDER_DRY_RUN=false diff --git a/website/docs/config/aider_conf.md b/website/docs/config/aider_conf.md index 61f369834..fe80efe36 100644 --- a/website/docs/config/aider_conf.md +++ b/website/docs/config/aider_conf.md @@ -188,6 +188,9 @@ cog.outl("```") ## Attribute aider commits in the git committer name (default: True) #attribute-committer: true +## Prefix commit messages with 'aider: ' (default: False) +#attribute-commit-message: false + ## Perform a dry run without modifying files (default: False) #dry-run: false diff --git a/website/docs/config/dotenv.md b/website/docs/config/dotenv.md index 51faf6c07..2c201dc2c 100644 --- a/website/docs/config/dotenv.md +++ b/website/docs/config/dotenv.md @@ -201,6 +201,9 @@ cog.outl("```") ## Attribute aider commits in the git committer name (default: True) #AIDER_ATTRIBUTE_COMMITTER=true +## Prefix commit messages with 'aider: ' (default: False) +#AIDER_ATTRIBUTE_COMMIT_MESSAGE=false + ## Perform a dry run without modifying files (default: False) #AIDER_DRY_RUN=false diff --git a/website/docs/config/options.md b/website/docs/config/options.md index 82f58e1bd..d8bea2979 100644 --- a/website/docs/config/options.md +++ b/website/docs/config/options.md @@ -43,6 +43,7 @@ usage: aider [-h] [--llm-history-file] [--openai-api-key] [--dirty-commits | --no-dirty-commits] [--attribute-author | --no-attribute-author] [--attribute-committer | --no-attribute-committer] + [--attribute-commit-message | --no-attribute-commit-message] [--dry-run | --no-dry-run] [--commit] [--lint] [--lint-cmd] [--auto-lint | --no-auto-lint] [--test-cmd] [--auto-test | --no-auto-test] [--test] @@ -316,6 +317,14 @@ Aliases: - `--attribute-committer` - `--no-attribute-committer` +### `--attribute-commit-message` +Prefix commit messages with 'aider: ' (default: False) +Default: False +Environment variable: `AIDER_ATTRIBUTE_COMMIT_MESSAGE` +Aliases: + - `--attribute-commit-message` + - `--no-attribute-commit-message` + ### `--dry-run` Perform a dry run without modifying files (default: False) Default: False From fa7255cbf533b2ed36e0f56a38b3dfbf4f81b75b Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 10:34:48 -0700 Subject: [PATCH 19/26] moved --llm-history-file in args --- aider/args.py | 12 +++++------ website/assets/sample.aider.conf.yml | 6 +++--- website/assets/sample.env | 6 +++--- website/docs/config/aider_conf.md | 6 +++--- website/docs/config/dotenv.md | 6 +++--- website/docs/config/options.md | 31 ++++++++++++++-------------- 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/aider/args.py b/aider/args.py index 473a9dc2e..474fb2257 100644 --- a/aider/args.py +++ b/aider/args.py @@ -29,12 +29,6 @@ def get_parser(default_config_files, git_root): auto_env_var_prefix="AIDER_", ) group = parser.add_argument_group("Main") - group.add_argument( - "--llm-history-file", - metavar="LLM_HISTORY_FILE", - default=None, - help="Log the conversation with the LLM to this file (for example, .aider.llm.history)", - ) group.add_argument( "files", metavar="FILE", nargs="*", help="files to edit with an LLM (optional)" ) @@ -236,6 +230,12 @@ def get_parser(default_config_files, git_root): default=False, help="Restore the previous chat history messages (default: False)", ) + group.add_argument( + "--llm-history-file", + metavar="LLM_HISTORY_FILE", + default=None, + help="Log the conversation with the LLM to this file (for example, .aider.llm.history)", + ) ########## group = parser.add_argument_group("Output Settings") diff --git a/website/assets/sample.aider.conf.yml b/website/assets/sample.aider.conf.yml index 6d401fe24..66a24dc33 100644 --- a/website/assets/sample.aider.conf.yml +++ b/website/assets/sample.aider.conf.yml @@ -13,9 +13,6 @@ ####### # Main: -## Log the conversation with the LLM to this file (for example, .aider.llm.history) -#llm-history-file: - ## Specify the OpenAI API key #openai-api-key: @@ -103,6 +100,9 @@ ## Restore the previous chat history messages (default: False) #restore-chat-history: false +## Log the conversation with the LLM to this file (for example, .aider.llm.history) +#llm-history-file: + ################## # Output Settings: diff --git a/website/assets/sample.env b/website/assets/sample.env index 1f3420254..154a722c9 100644 --- a/website/assets/sample.env +++ b/website/assets/sample.env @@ -21,9 +21,6 @@ ####### # Main: -## Log the conversation with the LLM to this file (for example, .aider.llm.history) -#AIDER_LLM_HISTORY_FILE= - ## Specify the OpenAI API key #OPENAI_API_KEY= @@ -111,6 +108,9 @@ ## Restore the previous chat history messages (default: False) #AIDER_RESTORE_CHAT_HISTORY=false +## Log the conversation with the LLM to this file (for example, .aider.llm.history) +#AIDER_LLM_HISTORY_FILE= + ################## # Output Settings: diff --git a/website/docs/config/aider_conf.md b/website/docs/config/aider_conf.md index fe80efe36..58c452fb8 100644 --- a/website/docs/config/aider_conf.md +++ b/website/docs/config/aider_conf.md @@ -41,9 +41,6 @@ cog.outl("```") ####### # Main: -## Log the conversation with the LLM to this file (for example, .aider.llm.history) -#llm-history-file: - ## Specify the OpenAI API key #openai-api-key: @@ -131,6 +128,9 @@ cog.outl("```") ## Restore the previous chat history messages (default: False) #restore-chat-history: false +## Log the conversation with the LLM to this file (for example, .aider.llm.history) +#llm-history-file: + ################## # Output Settings: diff --git a/website/docs/config/dotenv.md b/website/docs/config/dotenv.md index 2c201dc2c..9aae6011b 100644 --- a/website/docs/config/dotenv.md +++ b/website/docs/config/dotenv.md @@ -54,9 +54,6 @@ cog.outl("```") ####### # Main: -## Log the conversation with the LLM to this file (for example, .aider.llm.history) -#AIDER_LLM_HISTORY_FILE= - ## Specify the OpenAI API key #OPENAI_API_KEY= @@ -144,6 +141,9 @@ cog.outl("```") ## Restore the previous chat history messages (default: False) #AIDER_RESTORE_CHAT_HISTORY=false +## Log the conversation with the LLM to this file (for example, .aider.llm.history) +#AIDER_LLM_HISTORY_FILE= + ################## # Output Settings: diff --git a/website/docs/config/options.md b/website/docs/config/options.md index d8bea2979..557d0cf53 100644 --- a/website/docs/config/options.md +++ b/website/docs/config/options.md @@ -20,24 +20,23 @@ from aider.args import get_md_help cog.out(get_md_help()) ]]]--> ``` -usage: aider [-h] [--llm-history-file] [--openai-api-key] - [--anthropic-api-key] [--model] [--opus] [--sonnet] - [--4] [--4o] [--4-turbo] [--35turbo] [--models] - [--openai-api-base] [--openai-api-type] - [--openai-api-version] [--openai-api-deployment-id] - [--openai-organization-id] [--model-settings-file] - [--model-metadata-file] +usage: aider [-h] [--openai-api-key] [--anthropic-api-key] [--model] + [--opus] [--sonnet] [--4] [--4o] [--4-turbo] + [--35turbo] [--models] [--openai-api-base] + [--openai-api-type] [--openai-api-version] + [--openai-api-deployment-id] [--openai-organization-id] + [--model-settings-file] [--model-metadata-file] [--verify-ssl | --no-verify-ssl] [--edit-format] [--weak-model] [--show-model-warnings | --no-show-model-warnings] [--map-tokens] [--max-chat-history-tokens] [--env-file] [--input-history-file] [--chat-history-file] [--restore-chat-history | --no-restore-chat-history] - [--dark-mode] [--light-mode] [--pretty | --no-pretty] - [--stream | --no-stream] [--user-input-color] - [--tool-output-color] [--tool-error-color] - [--assistant-output-color] [--code-theme] - [--show-diffs] [--git | --no-git] + [--llm-history-file] [--dark-mode] [--light-mode] + [--pretty | --no-pretty] [--stream | --no-stream] + [--user-input-color] [--tool-output-color] + [--tool-error-color] [--assistant-output-color] + [--code-theme] [--show-diffs] [--git | --no-git] [--gitignore | --no-gitignore] [--aiderignore] [--auto-commits | --no-auto-commits] [--dirty-commits | --no-dirty-commits] @@ -64,10 +63,6 @@ Aliases: ## Main: -### `--llm-history-file LLM_HISTORY_FILE` -Log the conversation with the LLM to this file (for example, .aider.llm.history) -Environment variable: `AIDER_LLM_HISTORY_FILE` - ### `--openai-api-key OPENAI_API_KEY` Specify the OpenAI API key Environment variable: `OPENAI_API_KEY` @@ -205,6 +200,10 @@ Aliases: - `--restore-chat-history` - `--no-restore-chat-history` +### `--llm-history-file LLM_HISTORY_FILE` +Log the conversation with the LLM to this file (for example, .aider.llm.history) +Environment variable: `AIDER_LLM_HISTORY_FILE` + ## Output Settings: ### `--dark-mode` From 7016587bc646cd2029ca5b98698fadc7988afd56 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 10:38:15 -0700 Subject: [PATCH 20/26] copy --- website/docs/config.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/website/docs/config.md b/website/docs/config.md index dca28da0f..1aeb6e975 100644 --- a/website/docs/config.md +++ b/website/docs/config.md @@ -11,24 +11,31 @@ command line switches. Most options can also be set in an `.aider.conf.yml` file which can be placed in your home directory or at the root of your git repo. -Or via environment variables like `AIDER_xxx`, -as noted in the [options reference](/docs/config/options.html). +Or by setting environment variables like `AIDER_xxx` +either in your shell or a `.env` file. -Here are 3 equivalent ways of setting an option. First, via a command line switch: +Here are 4 equivalent ways of setting an option. + +With a command line switch: ``` $ aider --dark-mode ``` -Or, via an env variable: - -``` -export AIDER_DARK_MODE=true -``` - -Or in the `.aider.conf.yml` file: +Using a `.aider.conf.yml` file: ```yaml dark-mode: true ``` +By setting an environgment variable: + +``` +export AIDER_DARK_MODE=true +``` + +Using an `.env` file: + +``` +AIDER_DARK_MODE=true +``` From 87f4d25133d65e1d5e083ef1914125c766b1dfcb Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 10:58:06 -0700 Subject: [PATCH 21/26] Added gui support for tool_error(log_only=True) #740 --- aider/gui.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aider/gui.py b/aider/gui.py index b2239b162..a2284c1b9 100755 --- a/aider/gui.py +++ b/aider/gui.py @@ -17,9 +17,10 @@ from aider.scrape import Scraper class CaptureIO(InputOutput): lines = [] - def tool_output(self, msg): - self.lines.append(msg) - super().tool_output(msg) + def tool_output(self, msg, log_only=False): + if not log_only: + self.lines.append(msg) + super().tool_output(msg, log_only=log_only) def tool_error(self, msg): self.lines.append(msg) From 044617b1b7f15297c88658efa3ca6e822f02df7a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 14:40:46 -0700 Subject: [PATCH 22/26] continue roughly working using anthropic's prefill --- aider/coders/base_coder.py | 64 +++++++++++++++++++++++++------------- aider/sendchat.py | 3 +- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index c5a4bf794..fed054920 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -13,7 +13,6 @@ from json.decoder import JSONDecodeError from pathlib import Path import git -import openai from jsonschema import Draft7Validator from rich.console import Console, Text from rich.markdown import Markdown @@ -37,7 +36,7 @@ class MissingAPIKeyError(ValueError): pass -class ExhaustedContextWindow(Exception): +class FinishReasonLength(Exception): pass @@ -812,28 +811,43 @@ class Coder: if self.verbose: utils.show_messages(messages, functions=self.functions) + multi_response_content = "" exhausted = False interrupted = False - try: - yield from self.send(messages, functions=self.functions) - except KeyboardInterrupt: - interrupted = True - except ExhaustedContextWindow: - exhausted = True - except litellm.exceptions.BadRequestError as err: - if "ContextWindowExceededError" in err.message: + while True: + try: + yield from self.send(messages, functions=self.functions) + break + except KeyboardInterrupt: + interrupted = True + break + except litellm.ContextWindowExceededError as cwe_err: + # the input is overflowing the context window exhausted = True - else: - self.io.tool_error(f"BadRequestError: {err}") + dump(cwe_err) + break + except litellm.exceptions.BadRequestError as br_err: + dump(br_err) + self.io.tool_error(f"BadRequestError: {br_err}") return - except openai.BadRequestError as err: - if "maximum context length" in str(err): - exhausted = True - else: - raise err - except Exception as err: - self.io.tool_error(f"Unexpected error: {err}") - return + except FinishReasonLength as frl_err: + # finish_reason=length means 4k output limit? + dump(frl_err) + # exhausted = True + + multi_response_content += self.partial_response_content + if messages[-1]["role"] == "assistant": + messages[-1]["content"] = multi_response_content + else: + messages.append(dict(role="assistant", content=multi_response_content)) + except Exception as err: + self.io.tool_error(f"Unexpected error: {err}") + traceback.print_exc() + return + + if multi_response_content: + multi_response_content += self.partial_response_content + self.partial_response_content = multi_response_content if exhausted: self.show_exhausted_error() @@ -1103,7 +1117,7 @@ class Coder: if show_func_err and show_content_err: self.io.tool_error(show_func_err) self.io.tool_error(show_content_err) - raise Exception("No data found in openai response!") + raise Exception("No data found in LLM response!") tokens = None if hasattr(completion, "usage") and completion.usage is not None: @@ -1131,6 +1145,12 @@ class Coder: if tokens is not None: self.io.tool_output(tokens) + if ( + hasattr(completion.choices[0], "finish_reason") + and completion.choices[0].finish_reason == "length" + ): + raise FinishReasonLength() + def show_send_output_stream(self, completion): if self.show_pretty(): mdargs = dict(style=self.assistant_output_color, code_theme=self.code_theme) @@ -1147,7 +1167,7 @@ class Coder: hasattr(chunk.choices[0], "finish_reason") and chunk.choices[0].finish_reason == "length" ): - raise ExhaustedContextWindow() + raise FinishReasonLength() try: func = chunk.choices[0].delta.function_call diff --git a/aider/sendchat.py b/aider/sendchat.py index 19e91d255..8f661f598 100644 --- a/aider/sendchat.py +++ b/aider/sendchat.py @@ -3,7 +3,6 @@ import json import backoff import httpx -import openai from aider.dump import dump # noqa: F401 from aider.litellm import litellm @@ -85,5 +84,5 @@ def simple_send_with_retries(model_name, messages): stream=False, ) return response.choices[0].message.content - except (AttributeError, openai.BadRequestError): + except (AttributeError, litellm.exceptions.BadRequestError): return From dac12e342bbffbe403d199eea0b55ee20d71add5 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 15:05:42 -0700 Subject: [PATCH 23/26] wip --- aider/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aider/models.py b/aider/models.py index b9ae02590..be2ec9149 100644 --- a/aider/models.py +++ b/aider/models.py @@ -27,6 +27,7 @@ class ModelSettings: lazy: bool = False reminder_as_sys_msg: bool = False examples_as_sys_msg: bool = False + can_prefill: bool = False # https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo @@ -178,6 +179,7 @@ MODEL_SETTINGS = [ "claude-3-sonnet-20240229", "whole", weak_model_name="claude-3-haiku-20240307", + can_prefill=True, ), ModelSettings( "claude-3-5-sonnet-20240620", From e3805350c986ecb9cd3177dc0c7f213c0d7d248c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 15:22:16 -0700 Subject: [PATCH 24/26] Added can_prefill metadata to the anthropic models --- aider/coders/base_coder.py | 16 ++++++++-------- aider/models.py | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index fed054920..bf82b9ee6 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -821,20 +821,20 @@ class Coder: except KeyboardInterrupt: interrupted = True break - except litellm.ContextWindowExceededError as cwe_err: - # the input is overflowing the context window + except litellm.ContextWindowExceededError: + # The input is overflowing the context window! exhausted = True - dump(cwe_err) break except litellm.exceptions.BadRequestError as br_err: - dump(br_err) self.io.tool_error(f"BadRequestError: {br_err}") return - except FinishReasonLength as frl_err: - # finish_reason=length means 4k output limit? - dump(frl_err) - # exhausted = True + except FinishReasonLength: + # We hit the 4k output limit! + if not self.main_model.can_prefill: + exhausted = True + break + # Use prefill to continue the response multi_response_content += self.partial_response_content if messages[-1]["role"] == "assistant": messages[-1]["content"] = multi_response_content diff --git a/aider/models.py b/aider/models.py index be2ec9149..5f211518a 100644 --- a/aider/models.py +++ b/aider/models.py @@ -167,6 +167,7 @@ MODEL_SETTINGS = [ weak_model_name="claude-3-haiku-20240307", use_repo_map=True, send_undo_reply=True, + can_prefill=True, ), ModelSettings( "openrouter/anthropic/claude-3-opus", @@ -174,6 +175,7 @@ MODEL_SETTINGS = [ weak_model_name="openrouter/anthropic/claude-3-haiku", use_repo_map=True, send_undo_reply=True, + can_prefill=True, ), ModelSettings( "claude-3-sonnet-20240229", @@ -187,6 +189,7 @@ MODEL_SETTINGS = [ weak_model_name="claude-3-haiku-20240307", use_repo_map=True, examples_as_sys_msg=True, + can_prefill=True, ), ModelSettings( "anthropic/claude-3-5-sonnet-20240620", @@ -194,6 +197,7 @@ MODEL_SETTINGS = [ weak_model_name="claude-3-haiku-20240307", use_repo_map=True, examples_as_sys_msg=True, + can_prefill=True, ), ModelSettings( "openrouter/anthropic/claude-3.5-sonnet", @@ -201,6 +205,7 @@ MODEL_SETTINGS = [ weak_model_name="openrouter/anthropic/claude-3-haiku-20240307", use_repo_map=True, examples_as_sys_msg=True, + can_prefill=True, ), # Vertex AI Claude models ModelSettings( @@ -208,6 +213,8 @@ MODEL_SETTINGS = [ "diff", weak_model_name="vertex_ai/claude-3-haiku@20240307", use_repo_map=True, + examples_as_sys_msg=True, + can_prefill=True, ), ModelSettings( "vertex_ai/claude-3-opus@20240229", @@ -215,11 +222,13 @@ MODEL_SETTINGS = [ weak_model_name="vertex_ai/claude-3-haiku@20240307", use_repo_map=True, send_undo_reply=True, + can_prefill=True, ), ModelSettings( "vertex_ai/claude-3-sonnet@20240229", "whole", weak_model_name="vertex_ai/claude-3-haiku@20240307", + can_prefill=True, ), # Cohere ModelSettings( @@ -377,6 +386,16 @@ class Model: if "gpt-3.5" in model or "gpt-4" in model: self.reminder_as_sys_msg = True + if "anthropic" in model: + self.can_prefill = True + + if "3.5-sonnet" in model or "3-5-sonnet" in model: + self.edit_format = "diff" + self.use_repo_map = True + self.examples_as_sys_msg = True + self.can_prefill = (True,) + self.can_prefill = True + # use the defaults if self.edit_format == "diff": self.use_repo_map = True From 6f31450b90f6276eaf8c6cebe1a4974db8dc71bb Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 15:26:40 -0700 Subject: [PATCH 25/26] we don't want badreq errors bubbling out of Coder.run() --- aider/tests/test_coder.py | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/aider/tests/test_coder.py b/aider/tests/test_coder.py index 2cd3bb9ba..ca3014ff9 100644 --- a/aider/tests/test_coder.py +++ b/aider/tests/test_coder.py @@ -1,16 +1,15 @@ import tempfile import unittest from pathlib import Path -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock import git -import openai from aider.coders import Coder from aider.dump import dump # noqa: F401 from aider.io import InputOutput from aider.models import Model -from aider.utils import ChdirTemporaryDirectory, GitTemporaryDirectory +from aider.utils import GitTemporaryDirectory class TestCoder(unittest.TestCase): @@ -330,25 +329,6 @@ class TestCoder(unittest.TestCase): # both files should still be here self.assertEqual(len(coder.abs_fnames), 2) - def test_run_with_invalid_request_error(self): - with ChdirTemporaryDirectory(): - # Mock the IO object - mock_io = MagicMock() - - # Initialize the Coder object with the mocked IO and mocked repo - coder = Coder.create(self.GPT35, None, mock_io) - - # Call the run method and assert that InvalidRequestError is raised - with self.assertRaises(openai.BadRequestError): - with patch("litellm.completion") as Mock: - Mock.side_effect = openai.BadRequestError( - message="Invalid request", - response=MagicMock(), - body=None, - ) - - coder.run(with_message="hi") - def test_new_file_edit_one_commit(self): """A new file shouldn't get pre-committed before the GPT edit commit""" with GitTemporaryDirectory(): From a3fe3c4dcf21b52e2d9ef320841a8152d84e59fc Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 27 Jun 2024 15:36:01 -0700 Subject: [PATCH 26/26] cleanup --- aider/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aider/models.py b/aider/models.py index 5f211518a..7013bc709 100644 --- a/aider/models.py +++ b/aider/models.py @@ -393,7 +393,6 @@ class Model: self.edit_format = "diff" self.use_repo_map = True self.examples_as_sys_msg = True - self.can_prefill = (True,) self.can_prefill = True # use the defaults