From 69c27d6cd11344ed9a9f8f2411c86283ff57b9b1 Mon Sep 17 00:00:00 2001 From: Daniel Vainsencher Date: Wed, 29 May 2024 17:03:34 -0400 Subject: [PATCH 01/82] aider: Refactored `show_messages` to call `format_messages` for formatting title and messages. # Aider chat conversation: USER: Refactor show_messages in utils, so that the formatting of title and messages is done in a separate function which returns a string. show_messages should call it and print its output. ASSISTANT: To refactor the `show_messages` function, we will: 1. Create a new function `format_messages` that formats the title and messages and returns a string. 2. Update `show_messages` to call `format_messages` and print its output. Here are the *SEARCH/REPLACE* blocks: aider/utils.py ```python <<<<<<< SEARCH def show_messages(messages, title=None, functions=None): if title: print(title.upper(), "*" * 50) for msg in messages: print() role = msg["role"].upper() content = msg.get("content") if isinstance(content, list): # Handle list content (e.g., image messages) for item in content: if isinstance(item, dict) and "image_url" in item: print(role, "Image URL:", item["image_url"]["url"]) elif isinstance(content, str): # Handle string content for line in content.splitlines(): print(role, line) content = msg.get("function_call") if content: print(role, content) if functions: dump(functions) ======= def format_messages(messages, title=None): output = [] if title: output.append(f"{title.upper()} {'*' * 50}") for msg in messages: output.append("") role = msg["role"].upper() content = msg.get("content") if isinstance(content, list): # Handle list content (e.g., image messages) for item in content: if isinstance(item, dict) and "image_url" in item: output.append(f"{role} Image URL: {item['image_url']['url']}") elif isinstance(content, str): # Handle string content for line in content.splitlines(): output.append(f"{role} {line}") content = msg.get("function_call") if content: output.append(f"{role} {content}") return "\n".join(output) def show_messages(messages, title=None, functions=None): formatted_output = format_messages(messages, title) print(formatted_output) if functions: dump(functions) >>>>>>> REPLACE ``` --- aider/utils.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/aider/utils.py b/aider/utils.py index 31767aec6..1e76b39bf 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -84,24 +84,32 @@ def safe_abs_path(res): return str(res) -def show_messages(messages, title=None, functions=None): +def format_messages(messages, title=None): + output = [] if title: - print(title.upper(), "*" * 50) + output.append(f"{title.upper()} {'*' * 50}") for msg in messages: - print() + output.append("") role = msg["role"].upper() content = msg.get("content") if isinstance(content, list): # Handle list content (e.g., image messages) for item in content: if isinstance(item, dict) and "image_url" in item: - print(role, "Image URL:", item["image_url"]["url"]) + output.append(f"{role} Image URL: {item['image_url']['url']}") elif isinstance(content, str): # Handle string content for line in content.splitlines(): - print(role, line) + output.append(f"{role} {line}") content = msg.get("function_call") if content: - print(role, content) + output.append(f"{role} {content}") + + return "\n".join(output) + + +def show_messages(messages, title=None, functions=None): + formatted_output = format_messages(messages, title) + print(formatted_output) if functions: dump(functions) From a0b279f1054ede7d565d3f83cb5bf11c14bed39d Mon Sep 17 00:00:00 2001 From: Daniel Vainsencher Date: Wed, 29 May 2024 17:07:41 -0400 Subject: [PATCH 02/82] Refactored format_messages to use format_content for string content handling. --- aider/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/aider/utils.py b/aider/utils.py index 1e76b39bf..3a09f0236 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -84,7 +84,12 @@ def safe_abs_path(res): return str(res) -def format_messages(messages, title=None): +def format_content(role, content): + formatted_lines = [] + for line in content.splitlines(): + formatted_lines.append(f"{role} {line}") + return "\n".join(formatted_lines) + output = [] if title: output.append(f"{title.upper()} {'*' * 50}") @@ -98,8 +103,7 @@ def format_messages(messages, title=None): if isinstance(item, dict) and "image_url" in item: output.append(f"{role} Image URL: {item['image_url']['url']}") elif isinstance(content, str): # Handle string content - for line in content.splitlines(): - output.append(f"{role} {line}") + output.append(format_content(role, content)) content = msg.get("function_call") if content: output.append(f"{role} {content}") From abf8d5e60df4aae01538e03dee9ef9b901e93140 Mon Sep 17 00:00:00 2001 From: Daniel Vainsencher Date: Wed, 29 May 2024 17:07:42 -0400 Subject: [PATCH 03/82] aider: Refactored `format_messages` to use a new function `format_content` for line-by-line formatting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Aider chat conversation: USER: Now refactor format_messages: extract a function that takes a role and content (where content is a string), and returns the line by line formatted string. ASSISTANT: To refactor `format_messages`, we will: 1. Create a new function `format_content` that takes a role and content (where content is a string) and returns the line-by-line formatted string. 2. Update `format_messages` to use `format_content`. Here are the *SEARCH/REPLACE* blocks: aider/utils.py ```python <<<<<<< SEARCH def format_messages(messages, title=None): ======= def format_content(role, content): formatted_lines = [] for line in content.splitlines(): formatted_lines.append(f"{role} {line}") return "\n".join(formatted_lines) >>>>>>> REPLACE ``` aider/utils.py ```python <<<<<<< SEARCH elif isinstance(content, str): # Handle string content for line in content.splitlines(): output.append(f"{role} {line}") ======= elif isinstance(content, str): # Handle string content output.append(format_content(role, content)) >>>>>>> REPLACE ``` USER: # Fix any errors below, if possible. ## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source --isolated aider/utils.py aider/utils.py:94:8: F821 undefined name 'title' if title: ^ aider/utils.py:95:26: F821 undefined name 'title' output.append(f"{title.upper()} {'*' * 50}") ^ aider/utils.py:97:16: F821 undefined name 'messages' for msg in messages: ^ aider/utils.py:115:24: F821 undefined name 'format_messages' formatted_output = format_messages(messages, title) ^ ## See relevant lines below marked with █. aider/utils.py: ...⋮... 87│def format_content(role, content): 88│ formatted_lines = [] ...⋮... 91│ return "\n".join(formatted_lines) 92│ 93│ output = [] 94█ if title: 95█ output.append(f"{title.upper()} {'*' * 50}") 96│ 97█ for msg in messages: 98│ output.append("") 99│ role = msg["role"].upper() 100│ content = msg.get("content") ...⋮... 112│ 113│ 114│def show_messages(messages, title=None, functions=None): 115█ formatted_output = format_messages(messages, title) 116│ print(formatted_output) 117│ 118│ if functions: ...⋮... ASSISTANT: To fix the errors, we need to ensure that the `format_messages` function is properly defined and that the misplaced code is correctly organized. Here are the corrected *SEARCH/REPLACE* blocks: aider/utils.py ```python <<<<<<< SEARCH return "\n".join(formatted_lines) output = [] if title: output.append(f"{title.upper()} {'*' * 50}") for msg in messages: output.append("") role = msg["role"].upper() content = msg.get("content") if isinstance(content, list): # Handle list content (e.g., image messages) for item in content: if isinstance(item, dict) and "image_url" in item: output.append(f"{role} Image URL: {item['image_url']['url']}") elif isinstance(content, str): # Handle string content output.append(format_content(role, content)) content = msg.get("function_call") if content: output.append(f"{role} {content}") return "\n".join(output) ======= return "\n".join(formatted_lines) def format_messages(messages, title=None): output = [] if title: output.append(f"{title.upper()} {'*' * 50}") for msg in messages: output.append("") role = msg["role"].upper() content = msg.get("content") if isinstance(content, list): # Handle list content (e.g., image messages) for item in content: if isinstance(item, dict) and "image_url" in item: output.append(f"{role} Image URL: {item['image_url']['url']}") elif isinstance(content, str): # Handle string content output.append(format_content(role, content)) content = msg.get("function_call") if content: output.append(f"{role} {content}") return "\n".join(output) >>>>>>> REPLACE ``` --- aider/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aider/utils.py b/aider/utils.py index 3a09f0236..7636eb119 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -90,6 +90,8 @@ def format_content(role, content): formatted_lines.append(f"{role} {line}") return "\n".join(formatted_lines) + +def format_messages(messages, title=None): output = [] if title: output.append(f"{title.upper()} {'*' * 50}") From 2bd5daf2aded1c5e8a313c74722be59597b0b79d Mon Sep 17 00:00:00 2001 From: Daniel Vainsencher Date: Wed, 29 May 2024 17:16:08 -0400 Subject: [PATCH 04/82] aider: Add logging of conversation between coder and LLM in .aider.llm.history file using new formatting functions in `send_new_user_message`. # Aider chat conversation: USER: We want to add logging of the conversation between coder and the LLM into a new file called .aider.llm.history. The formatting should be done using the new format_messages and format_content. Modify only the `send_new_user_message` function in base_coder, formatting and logging `messages` as soon as it is defined, and logging `content` before `tool_output`. Precede them by a single line saying "TO LLM {timestamp}" and "LLM RESPONSE {timestamp}" where the timestamp is uses ISO date format and has second precision. ASSISTANT: To implement the logging of the conversation between the coder and the LLM, we will: 1. Format and log `messages` as soon as it is defined in `send_new_user_message`. 2. Log `content` before `tool_output`. 3. Precede the logs with a timestamp in ISO date format with second precision. Here are the *SEARCH/REPLACE* blocks: aider/coders/base_coder.py ```python <<<<<<< SEARCH messages = self.format_messages() ======= import datetime from aider.utils import format_messages, format_content messages = self.format_messages() timestamp = datetime.datetime.now().isoformat(timespec='seconds') with open('.aider.llm.history', 'a') as log_file: log_file.write(f"TO LLM {timestamp}\n") log_file.write(format_messages(messages) + "\n") >>>>>>> REPLACE ``` aider/coders/base_coder.py ```python <<<<<<< SEARCH self.io.tool_output() ======= self.io.tool_output() timestamp = datetime.datetime.now().isoformat(timespec='seconds') with open('.aider.llm.history', 'a') as log_file: log_file.write(f"LLM RESPONSE {timestamp}\n") log_file.write(format_content("assistant", content) + "\n") >>>>>>> REPLACE ``` --- aider/coders/base_coder.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 76081a916..d179bcc0d 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -779,8 +779,16 @@ class Coder: dict(role="user", content=inp), ] + import datetime + from aider.utils import format_messages, format_content + messages = self.format_messages() + timestamp = datetime.datetime.now().isoformat(timespec='seconds') + with open('.aider.llm.history', 'a') as log_file: + log_file.write(f"TO LLM {timestamp}\n") + log_file.write(format_messages(messages) + "\n") + if self.verbose: utils.show_messages(messages, functions=self.functions) @@ -823,6 +831,11 @@ class Coder: self.io.tool_output() + timestamp = datetime.datetime.now().isoformat(timespec='seconds') + with open('.aider.llm.history', 'a') as log_file: + log_file.write(f"LLM RESPONSE {timestamp}\n") + log_file.write(format_content("assistant", content) + "\n") + if interrupted: content += "\n^C KeyboardInterrupt" self.cur_messages += [dict(role="assistant", content=content)] From 8896909e196dec584e03d55dfd3b93e76a2c84d3 Mon Sep 17 00:00:00 2001 From: Daniel Vainsencher Date: Wed, 29 May 2024 17:19:32 -0400 Subject: [PATCH 05/82] aider: Capitalize the "ASSISTANT" role when logging to the LLM history file. # Aider chat conversation: USER: When logging to llm history file, capitalize the ASSISTANT role. ASSISTANT: To capitalize the "ASSISTANT" role when logging to the LLM history file, we need to modify the `send_new_user_message` method in `aider/coders/base_coder.py`. Here is the *SEARCH/REPLACE* block: aider/coders/base_coder.py ```python <<<<<<< SEARCH with open('.aider.llm.history', 'a') as log_file: log_file.write(f"LLM RESPONSE {timestamp}\n") log_file.write(format_content("assistant", content) + "\n") ======= with open('.aider.llm.history', 'a') as log_file: log_file.write(f"LLM RESPONSE {timestamp}\n") log_file.write(format_content("ASSISTANT", content) + "\n") >>>>>>> REPLACE ``` --- aider/coders/base_coder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index d179bcc0d..b1616fb95 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -834,7 +834,7 @@ class Coder: timestamp = datetime.datetime.now().isoformat(timespec='seconds') with open('.aider.llm.history', 'a') as log_file: log_file.write(f"LLM RESPONSE {timestamp}\n") - log_file.write(format_content("assistant", content) + "\n") + log_file.write(format_content("ASSISTANT", content) + "\n") if interrupted: content += "\n^C KeyboardInterrupt" From e6e360a4ef568bb2d5c4eb60ad2b0c779fcaeff8 Mon Sep 17 00:00:00 2001 From: Daniel Vainsencher Date: Fri, 7 Jun 2024 09:48:23 -0400 Subject: [PATCH 06/82] Added support for logging LLM history to a specified file. --- aider/args.py | 8 +++++++- aider/coders/base_coder.py | 13 +++++-------- aider/io.py | 17 ++++++++++++++--- aider/main.py | 1 + 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/aider/args.py b/aider/args.py index f747016dc..24682fa55 100644 --- a/aider/args.py +++ b/aider/args.py @@ -20,11 +20,17 @@ 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=".aider.llm.history", + help="Specify the LLM history file (default: .aider.llm.history)", + ) group.add_argument( "files", metavar="FILE", nargs="*", - help="files to edit with an LLM (optional)", + help="files to edit with an LLM (optional)" ) group.add_argument( "--openai-api-key", diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index b1616fb95..a8ddf8830 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -784,10 +784,7 @@ class Coder: messages = self.format_messages() - timestamp = datetime.datetime.now().isoformat(timespec='seconds') - with open('.aider.llm.history', 'a') as log_file: - log_file.write(f"TO LLM {timestamp}\n") - log_file.write(format_messages(messages) + "\n") + self.io.log_llm_history("TO LLM", format_messages(messages)) if self.verbose: utils.show_messages(messages, functions=self.functions) @@ -808,6 +805,9 @@ class Coder: exhausted = True else: raise err + except Exception as err: + self.io.tool_error(f"Unexpected error: {err}") + return if exhausted: self.num_exhausted_context_windows += 1 @@ -831,10 +831,7 @@ class Coder: self.io.tool_output() - timestamp = datetime.datetime.now().isoformat(timespec='seconds') - with open('.aider.llm.history', 'a') as log_file: - log_file.write(f"LLM RESPONSE {timestamp}\n") - log_file.write(format_content("ASSISTANT", content) + "\n") + self.io.log_llm_history("LLM RESPONSE", format_content("ASSISTANT", content)) if interrupted: content += "\n^C KeyboardInterrupt" diff --git a/aider/io.py b/aider/io.py index a365aa1f0..b6f7d15e5 100644 --- a/aider/io.py +++ b/aider/io.py @@ -106,6 +106,7 @@ class InputOutput: tool_error_color="red", encoding="utf-8", dry_run=False, + llm_history_file=None, ): no_color = os.environ.get("NO_COLOR") if no_color is not None and no_color != "": @@ -125,6 +126,7 @@ class InputOutput: self.yes = yes self.input_history_file = input_history_file + self.llm_history_file = llm_history_file if chat_history_file is not None: self.chat_history_file = Path(chat_history_file) else: @@ -206,10 +208,11 @@ class InputOutput: else: style = None + completer_instance = AutoCompleter( + root, rel_fnames, addable_rel_fnames, commands, self.encoding + ) + while True: - completer_instance = AutoCompleter( - root, rel_fnames, addable_rel_fnames, commands, self.encoding - ) if multiline_input: show = ". " @@ -266,6 +269,14 @@ class InputOutput: fh = FileHistory(self.input_history_file) return fh.load_history_strings() + def log_llm_history(self, role, content): + if not self.llm_history_file: + return + timestamp = datetime.now().isoformat(timespec='seconds') + with open(self.llm_history_file, 'a', encoding=self.encoding) as log_file: + log_file.write(f"{role.upper()} {timestamp}\n") + log_file.write(content + "\n") + def user_input(self, inp, log_only=True): if not log_only: style = dict(style=self.user_input_color) if self.user_input_color else dict() diff --git a/aider/main.py b/aider/main.py index 9cf0dda10..2e878934c 100644 --- a/aider/main.py +++ b/aider/main.py @@ -258,6 +258,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F tool_error_color=args.tool_error_color, dry_run=args.dry_run, encoding=args.encoding, + llm_history_file=args.llm_history_file, ) fnames = [str(Path(fn).resolve()) for fn in args.files] From 2f38af54dc012ba5099aeb2252c60084873f12a8 Mon Sep 17 00:00:00 2001 From: Nicolas Perez Date: Tue, 11 Jun 2024 18:34:47 -0400 Subject: [PATCH 07/82] doc: Removed template typo in README --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 9f932f331..55feb182f 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,6 @@ and can [connect to almost any LLM](https://aider.chat/docs/llms.html). ## Getting started -{% include get-started.md %} - **See the [installation instructions](https://aider.chat/docs/install.html) and other From d65e16c4df6662de53e5c1ed1d475cc7630b70ff Mon Sep 17 00:00:00 2001 From: paul-gauthier <69695708+paul-gauthier@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:46:13 -0700 Subject: [PATCH 08/82] Update README.md --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 55feb182f..880f28c96 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,22 @@ and can [connect to almost any LLM](https://aider.chat/docs/llms.html).

## Getting started +You can get started quickly like this: + +``` +$ pip install aider-chat + +# Change directory into a git repo +$ cd /to/your/git/repo + +# Work with GPT-4o on your repo +$ export OPENAI_API_KEY=your-key-goes-here +$ aider + +# Or, work with Claude 3 Opus on your repo +$ export ANTHROPIC_API_KEY=your-key-goes-here +$ aider --opus +``` **See the [installation instructions](https://aider.chat/docs/install.html) From 3532bd7758ad662d5529ee68e7ca4852ec907355 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 11 Jun 2024 18:51:36 -0700 Subject: [PATCH 09/82] use cog to include get-started in readme --- README.md | 8 ++++++++ scripts/update-docs.sh | 2 ++ website/index.md | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 880f28c96..957f062f6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ + + # Aider is AI pair programming in your terminal Aider lets you pair program with LLMs, @@ -24,6 +26,11 @@ and can [connect to almost any LLM](https://aider.chat/docs/llms.html).

## Getting started + You can get started quickly like this: ``` @@ -40,6 +47,7 @@ $ aider $ export ANTHROPIC_API_KEY=your-key-goes-here $ aider --opus ``` + **See the [installation instructions](https://aider.chat/docs/install.html) diff --git a/scripts/update-docs.sh b/scripts/update-docs.sh index 756a61c69..ce40f2d44 100755 --- a/scripts/update-docs.sh +++ b/scripts/update-docs.sh @@ -9,7 +9,9 @@ else ARG=$1 fi +# README.md before index.md, because index.md uses cog to include README.md cog $ARG \ + README.md \ website/index.md \ website/docs/commands.md \ website/docs/languages.md \ diff --git a/website/index.md b/website/index.md index 0f0865f68..3895c4433 100644 --- a/website/index.md +++ b/website/index.md @@ -4,9 +4,17 @@ nav_order: 1 --- + + # Aider is AI pair programming in your terminal Aider lets you pair program with LLMs, @@ -32,8 +40,28 @@ and can [connect to almost any LLM](https://aider.chat/docs/llms.html).

## Getting started + +You can get started quickly like this: -{% include get-started.md %} +``` +$ pip install aider-chat + +# Change directory into a git repo +$ cd /to/your/git/repo + +# Work with GPT-4o on your repo +$ export OPENAI_API_KEY=your-key-goes-here +$ aider + +# Or, work with Claude 3 Opus on your repo +$ export ANTHROPIC_API_KEY=your-key-goes-here +$ aider --opus +``` + **See the [installation instructions](https://aider.chat/docs/install.html) From f12589fd749a4117316131cfb61c91a5201b5bb4 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 11 Jun 2024 18:56:28 -0700 Subject: [PATCH 10/82] copy --- README.md | 10 ++++++---- website/index.md | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 957f062f6..8676f865f 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,11 @@ $ aider --opus ``` -**See the +See the [installation instructions](https://aider.chat/docs/install.html) and other [documentation](https://aider.chat/docs/usage.html) -for more details.** +for more details. ## Features @@ -91,14 +91,16 @@ projects like django, scikitlearn, matplotlib, etc.

-## Documentation +## More info +- [Documentation](https://aider.chat/) - [Installation](https://aider.chat/docs/install.html) - [Usage](https://aider.chat/docs/usage.html) - [Tutorial videos](https://aider.chat/docs/tutorials.html) - [Connecting to LLMs](https://aider.chat/docs/llms.html) +- [Configuration](https://aider.chat/docs/config.html) +- [Troubleshooting](https://aider.chat/docs/troubleshooting.html) - [LLM Leaderboards](https://aider.chat/docs/leaderboards/) -- [FAQ](https://aider.chat/docs/faq.html) - [Discord](https://discord.gg/Tv2uQnR88V) - [Blog](https://aider.chat/blog/) diff --git a/website/index.md b/website/index.md index 3895c4433..2013d40af 100644 --- a/website/index.md +++ b/website/index.md @@ -63,11 +63,11 @@ $ aider --opus ``` -**See the +See the [installation instructions](https://aider.chat/docs/install.html) and other [documentation](https://aider.chat/docs/usage.html) -for more details.** +for more details. ## Features @@ -105,14 +105,16 @@ projects like django, scikitlearn, matplotlib, etc.

-## Documentation +## More info +- [Documentation](https://aider.chat/) - [Installation](https://aider.chat/docs/install.html) - [Usage](https://aider.chat/docs/usage.html) - [Tutorial videos](https://aider.chat/docs/tutorials.html) - [Connecting to LLMs](https://aider.chat/docs/llms.html) +- [Configuration](https://aider.chat/docs/config.html) +- [Troubleshooting](https://aider.chat/docs/troubleshooting.html) - [LLM Leaderboards](https://aider.chat/docs/leaderboards/) -- [FAQ](https://aider.chat/docs/faq.html) - [Discord](https://discord.gg/Tv2uQnR88V) - [Blog](https://aider.chat/blog/) From 73f9b677613ad12fcf492863ca99704532754bf6 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 11 Jun 2024 19:24:14 -0700 Subject: [PATCH 11/82] copy --- README.md | 25 ++++++++++++++----------- website/docs/repomap.md | 17 ++++++++--------- website/index.md | 25 ++++++++++++++----------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 8676f865f..6c30587c5 100644 --- a/README.md +++ b/README.md @@ -57,24 +57,26 @@ for more details. ## Features -- Chat with aider about your code: `aider ...` +- Run aider with the files you want to edit: `aider ...` - Ask for changes: - - New features, test cases, improvements. - - Bug fixes, updated docs or code refactors. - - Paste in a GitHub issue that needs to be solved. + - Add new features or test cases. + - Describe a bug. + - Paste in an error message or or GitHub issue URL. + - Refactor code. + - Update docs. - Aider will edit your files to complete your request. - Aider [automatically git commits](https://aider.chat/docs/git.html) changes with a sensible commit message. - Aider works with [most popular languages](https://aider.chat/docs/languages.html): python, javascript, typescript, php, html, css, and more... - Aider works best with GPT-4o and Claude 3 Opus and can [connect to almost any LLM](https://aider.chat/docs/llms.html). -- Aider can make coordinated changes across multiple files at once. +- Aider can edit multiple files at once for complex requests. - Aider uses a [map of your entire git repo](https://aider.chat/docs/repomap.html), which helps it work well in larger codebases. -- You can also edit files in your editor while chatting with aider. -Aider will notice and always use the latest version. -So you can bounce back and forth between aider and your editor, to collaboratively code with AI. -- Images can be added to the chat (GPT-4o, GPT-4 Turbo, etc). -- URLs can be added to the chat and aider will read their content. -- [Code with your voice](https://aider.chat/docs/voice.html) using speech recognition. +- Edit files in your editor while chatting with aider, +and it will always use the latest version. +Pair program with AI. +- Add images to the chat (GPT-4o, GPT-4 Turbo, etc). +- Add URLs to the chat and aider will read their content. +- [Code with your voice](https://aider.chat/docs/voice.html). ## State of the art @@ -101,6 +103,7 @@ projects like django, scikitlearn, matplotlib, etc. - [Configuration](https://aider.chat/docs/config.html) - [Troubleshooting](https://aider.chat/docs/troubleshooting.html) - [LLM Leaderboards](https://aider.chat/docs/leaderboards/) +- [GitHub](https://github.com/paul-gauthier/aider) - [Discord](https://discord.gg/Tv2uQnR88V) - [Blog](https://aider.chat/blog/) diff --git a/website/docs/repomap.md b/website/docs/repomap.md index 57a0cc415..aefedc5dc 100644 --- a/website/docs/repomap.md +++ b/website/docs/repomap.md @@ -12,23 +12,22 @@ Aider uses a **concise map of your whole git repository** that includes the most important classes and functions along with their types and call signatures. -This helps the LLM understand the code it needs to change, +This helps aider understand the code it's editing and how it relates to the other parts of the codebase. -The repo map also helps the LLM write new code +The repo map also helps aider write new code that respects and utilizes existing libraries, modules and abstractions found elsewhere in the codebase. ## Using a repo map to provide context Aider sends a **repo map** to the LLM along with -each request from the user to make a code change. -The map contains a list of the files in the +each change request from the user. +The repo map contains a list of the files in the repo, along with the key symbols which are defined in each file. -It shows how each of these symbols are defined in the -source code, by including the critical lines of code for each definition. +It shows how each of these symbols are defined, by including the critical lines of code for each definition. -Here's a -sample of the map of the aider repo, just showing the maps of +Here's a part of +the repo map of aider's repo, for [base_coder.py](https://github.com/paul-gauthier/aider/blob/main/aider/coders/base_coder.py) and [commands.py](https://github.com/paul-gauthier/aider/blob/main/aider/commands.py) @@ -71,7 +70,7 @@ aider/commands.py: Mapping out the repo like this provides some key benefits: - The LLM can see classes, methods and function signatures from everywhere in the repo. This alone may give it enough context to solve many tasks. For example, it can probably figure out how to use the API exported from a module just based on the details shown in the map. - - If it needs to see more code, the LLM can use the map to figure out by itself which files it needs to look at in more detail. The LLM will then ask to see these specific files, and aider will automatically add them to the chat context. + - If it needs to see more code, the LLM can use the map to figure out which files it needs to look at. The LLM can ask to see these specific files, and aider will offer to add them to the chat context. ## Optimizing the map diff --git a/website/index.md b/website/index.md index 2013d40af..0a362d291 100644 --- a/website/index.md +++ b/website/index.md @@ -71,24 +71,26 @@ for more details. ## Features -- Chat with aider about your code: `aider ...` +- Run aider with the files you want to edit: `aider ...` - Ask for changes: - - New features, test cases, improvements. - - Bug fixes, updated docs or code refactors. - - Paste in a GitHub issue that needs to be solved. + - Add new features or test cases. + - Describe a bug. + - Paste in an error message or or GitHub issue URL. + - Refactor code. + - Update docs. - Aider will edit your files to complete your request. - Aider [automatically git commits](https://aider.chat/docs/git.html) changes with a sensible commit message. - Aider works with [most popular languages](https://aider.chat/docs/languages.html): python, javascript, typescript, php, html, css, and more... - Aider works best with GPT-4o and Claude 3 Opus and can [connect to almost any LLM](https://aider.chat/docs/llms.html). -- Aider can make coordinated changes across multiple files at once. +- Aider can edit multiple files at once for complex requests. - Aider uses a [map of your entire git repo](https://aider.chat/docs/repomap.html), which helps it work well in larger codebases. -- You can also edit files in your editor while chatting with aider. -Aider will notice and always use the latest version. -So you can bounce back and forth between aider and your editor, to collaboratively code with AI. -- Images can be added to the chat (GPT-4o, GPT-4 Turbo, etc). -- URLs can be added to the chat and aider will read their content. -- [Code with your voice](https://aider.chat/docs/voice.html) using speech recognition. +- Edit files in your editor while chatting with aider, +and it will always use the latest version. +Pair program with AI. +- Add images to the chat (GPT-4o, GPT-4 Turbo, etc). +- Add URLs to the chat and aider will read their content. +- [Code with your voice](https://aider.chat/docs/voice.html). ## State of the art @@ -115,6 +117,7 @@ projects like django, scikitlearn, matplotlib, etc. - [Configuration](https://aider.chat/docs/config.html) - [Troubleshooting](https://aider.chat/docs/troubleshooting.html) - [LLM Leaderboards](https://aider.chat/docs/leaderboards/) +- [GitHub](https://github.com/paul-gauthier/aider) - [Discord](https://discord.gg/Tv2uQnR88V) - [Blog](https://aider.chat/blog/) From abeb9f4d84ba8689ff9dba72346d7b1bbded12ea Mon Sep 17 00:00:00 2001 From: Nicolas Perez Date: Wed, 12 Jun 2024 02:32:50 -0400 Subject: [PATCH 12/82] fix: `enable_playwright` url had a typo --- aider/scrape.py | 2 +- aider/urls.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aider/scrape.py b/aider/scrape.py index 147203c48..3b5a98a1a 100755 --- a/aider/scrape.py +++ b/aider/scrape.py @@ -21,7 +21,7 @@ For better web scraping, install Playwright chromium with this command in your t playwright install --with-deps chromium -See {urls.enable_playwrite} for more info. +See {urls.enable_playwright} for more info. """ diff --git a/aider/urls.py b/aider/urls.py index 62f95503d..5500527b5 100644 --- a/aider/urls.py +++ b/aider/urls.py @@ -2,6 +2,6 @@ website = "https://aider.chat/" add_all_files = "https://aider.chat/docs/faq.html#how-can-i-add-all-the-files-to-the-chat" edit_errors = "https://aider.chat/docs/troubleshooting/edit-errors.html" git = "https://aider.chat/docs/git.html" -enable_playwrite = "https://aider.chat/docs/install/optional.html#enable-playwright" +enable_playwright = "https://aider.chat/docs/install/optional.html#enable-playwright" favicon = "https://aider.chat/assets/icons/favicon-32x32.png" model_warnings = "https://aider.chat/docs/llms/warnings.html" From a07492b90a9772bacdad0cfc5fc26b52cfb11907 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 12 Jun 2024 11:30:26 -0700 Subject: [PATCH 13/82] moved --vim to Other Settings --- aider/args.py | 12 +-- aider/coders/editblock_prompts.py | 138 +-------------------------- website/assets/sample.aider.conf.yml | 6 +- website/docs/aider_conf.md | 6 +- website/docs/options.md | 16 ++-- website/docs/usage.md | 20 ++++ 6 files changed, 45 insertions(+), 153 deletions(-) diff --git a/aider/args.py b/aider/args.py index 4fc956062..52d5253ff 100644 --- a/aider/args.py +++ b/aider/args.py @@ -20,12 +20,6 @@ def get_parser(default_config_files, git_root): auto_env_var_prefix="AIDER_", ) group = parser.add_argument_group("Main") - group.add_argument( - "--vim", - action="store_true", - help="Use VI editing mode in the terminal (default: False)", - default=False, - ) group.add_argument( "files", metavar="FILE", @@ -369,6 +363,12 @@ def get_parser(default_config_files, git_root): ########## group = parser.add_argument_group("Other Settings") + group.add_argument( + "--vim", + action="store_true", + help="Use VI editing mode in the terminal (default: False)", + default=False, + ) group.add_argument( "--voice-language", metavar="VOICE_LANGUAGE", diff --git a/aider/coders/editblock_prompts.py b/aider/coders/editblock_prompts.py index 44e44df92..be556b31f 100644 --- a/aider/coders/editblock_prompts.py +++ b/aider/coders/editblock_prompts.py @@ -4,140 +4,12 @@ from .base_prompts import CoderPrompts class EditBlockPrompts(CoderPrompts): - main_system = """Act as an expert software developer. -Always use best practices when coding. -Respect and use existing conventions, libraries, etc that are already present in the code base. -{lazy_prompt} -Take requests for changes to the supplied code. -If the request is ambiguous, ask questions. + main_system = """Act as a software expert and answer user questions about how to use the aider program. +You never write code, just answer questions. -Always reply to the user in the same language they are using. - -Once you understand the request you MUST: -1. Decide if you need to propose *SEARCH/REPLACE* edits to any files that haven't been added to the chat. You can create new files without asking. But if you need to propose edits to existing files not already added to the chat, you *MUST* tell the user their full path names and ask them to *add the files to the chat*. End your reply and wait for their approval. You can keep asking if you then decide you need to edit more files. -2. Think step-by-step and explain the needed changes with a numbered list of short sentences. -3. Describe each change with a *SEARCH/REPLACE block* per the examples below. All changes to files must use this *SEARCH/REPLACE block* format. ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*! - -All changes to files must use the *SEARCH/REPLACE block* format. +Decide if you need to see any files that haven't been added to the chat. If so, you *MUST* tell the user their full path names and ask them to *add the files to the chat*. End your reply and wait for their approval. You can keep asking if you then decide you need to see more files. """ - example_messages = [ - dict( - role="user", - content="Change get_factorial() to use math.factorial", - ), - dict( - role="assistant", - content="""To make this change we need to modify `mathweb/flask/app.py` to: + example_messages = [] -1. Import the math package. -2. Remove the existing factorial() function. -3. Update get_factorial() to call math.factorial instead. - -Here are the *SEARCH/REPLACE* blocks: - -mathweb/flask/app.py -{fence[0]}python -<<<<<<< SEARCH -from flask import Flask -======= -import math -from flask import Flask ->>>>>>> REPLACE -{fence[1]} - -mathweb/flask/app.py -{fence[0]}python -<<<<<<< SEARCH -def factorial(n): - "compute factorial" - - if n == 0: - return 1 - else: - return n * factorial(n-1) - -======= ->>>>>>> REPLACE -{fence[1]} - -mathweb/flask/app.py -{fence[0]}python -<<<<<<< SEARCH - return str(factorial(n)) -======= - return str(math.factorial(n)) ->>>>>>> REPLACE -{fence[1]} -""", - ), - dict( - role="user", - content="Refactor hello() into its own file.", - ), - dict( - role="assistant", - content="""To make this change we need to modify `main.py` and make a new file `hello.py`: - -1. Make a new hello.py file with hello() in it. -2. Remove hello() from main.py and replace it with an import. - -Here are the *SEARCH/REPLACE* blocks: - -hello.py -{fence[0]}python -<<<<<<< SEARCH -======= -def hello(): - "print a greeting" - - print("hello") ->>>>>>> REPLACE -{fence[1]} - -main.py -{fence[0]}python -<<<<<<< SEARCH -def hello(): - "print a greeting" - - print("hello") -======= -from hello import hello ->>>>>>> REPLACE -{fence[1]} -""", - ), - ] - - system_reminder = """# *SEARCH/REPLACE block* Rules: - -Every *SEARCH/REPLACE block* must use this format: -1. The file path alone on a line, verbatim. No bold asterisks, no quotes around it, no escaping of characters, etc. -2. The opening fence and code language, eg: {fence[0]}python -3. The start of search block: <<<<<<< SEARCH -4. A contiguous chunk of lines to search for in the existing source code -5. The dividing line: ======= -6. The lines to replace into the source code -7. The end of the replace block: >>>>>>> REPLACE -8. The closing fence: {fence[1]} - -Every *SEARCH* section must *EXACTLY MATCH* the existing source code, character for character, including all comments, docstrings, etc. - -*SEARCH/REPLACE* blocks will replace *all* matching occurrences. -Include enough lines to make the SEARCH blocks unique. - -Include *ALL* the code being searched and replaced! - -Only create *SEARCH/REPLACE* blocks for files that the user has added to the chat! - -To move code within a file, use 2 *SEARCH/REPLACE* blocks: 1 to delete it from its current location, 1 to insert it in the new location. - -If you want to put code in a new file, use a *SEARCH/REPLACE block* with: -- A new file path, including dir name if needed -- An empty `SEARCH` section -- The new file's contents in the `REPLACE` section - -{lazy_prompt} -ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*! -""" + system_reminder = "" diff --git a/website/assets/sample.aider.conf.yml b/website/assets/sample.aider.conf.yml index a4ecb0928..78b81609d 100644 --- a/website/assets/sample.aider.conf.yml +++ b/website/assets/sample.aider.conf.yml @@ -12,9 +12,6 @@ ####### # Main: -## Use VI editing mode in the terminal (default: False) -#vim: false - ## Specify the OpenAI API key #openai-api-key: @@ -177,6 +174,9 @@ ################# # Other Settings: +## Use VI editing mode in the terminal (default: False) +#vim: false + ## Specify the language for voice using ISO 639-1 code (default: auto) #voice-language: en diff --git a/website/docs/aider_conf.md b/website/docs/aider_conf.md index 344ebc534..e6024338c 100644 --- a/website/docs/aider_conf.md +++ b/website/docs/aider_conf.md @@ -38,9 +38,6 @@ cog.outl("```") ####### # Main: -## Use VI editing mode in the terminal (default: False) -#vim: false - ## Specify the OpenAI API key #openai-api-key: @@ -203,6 +200,9 @@ cog.outl("```") ################# # Other Settings: +## Use VI editing mode in the terminal (default: False) +#vim: false + ## Specify the language for voice using ISO 639-1 code (default: auto) #voice-language: en diff --git a/website/docs/options.md b/website/docs/options.md index 2183782d5..a192227cd 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -14,8 +14,8 @@ from aider.args import get_md_help cog.out(get_md_help()) ]]]--> ``` -usage: aider [-h] [--vim] [--openai-api-key] [--anthropic-api-key] - [--model] [--opus] [--sonnet] [--4] [--4o] [--4-turbo] +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] @@ -35,7 +35,7 @@ usage: aider [-h] [--vim] [--openai-api-key] [--anthropic-api-key] [--dry-run | --no-dry-run] [--commit] [--lint] [--lint-cmd] [--auto-lint | --no-auto-lint] [--test-cmd] [--auto-test | --no-auto-test] [--test] - [--voice-language] [--version] [--check-update] + [--vim] [--voice-language] [--version] [--check-update] [--skip-check-update] [--apply] [--yes] [-v] [--show-repo-map] [--show-prompts] [--message] [--message-file] [--encoding] [-c] [--gui] @@ -52,11 +52,6 @@ Aliases: ## Main: -### `--vim` -Use VI editing mode in the terminal (default: False) -Default: False -Environment variable: `AIDER_VIM` - ### `--openai-api-key OPENAI_API_KEY` Specify the OpenAI API key Environment variable: `OPENAI_API_KEY` @@ -331,6 +326,11 @@ Environment variable: `AIDER_TEST` ## Other Settings: +### `--vim` +Use VI editing mode in the terminal (default: False) +Default: False +Environment variable: `AIDER_VIM` + ### `--voice-language VOICE_LANGUAGE` Specify the language for voice using ISO 639-1 code (default: auto) Default: en diff --git a/website/docs/usage.md b/website/docs/usage.md index e0406fe2d..7451f9b2a 100644 --- a/website/docs/usage.md +++ b/website/docs/usage.md @@ -10,11 +10,31 @@ Run `aider` with the source code files you want to edit. These files will be "added to the chat session", so that aider can see their contents and edit them for you. +They can be existing files or the name of files you want +aider to create for you. ``` aider ... ``` +At the aider `>` prompt, ask for code changes and aider +will edit those files to accomplish your request. + + +``` +$ aider factorial.py + +Aider v0.37.1-dev +Models: gpt-4o with diff edit format, weak model gpt-3.5-turbo +Git repo: .git with 258 files +Repo-map: using 1024 tokens +Use /help to see in-chat commands, run with --help to see cmd line args +─────────────────────────────────────────────────────────────────────── +>`Make a program that asks for a number and prints its factorial + +... +``` + ## Adding files Just add the files that the aider will need to *edit*. From c40b3fa3106c6fee80a0163b8ee07c6d65c963f9 Mon Sep 17 00:00:00 2001 From: Daniel Vainsencher Date: Wed, 12 Jun 2024 18:28:55 -0400 Subject: [PATCH 14/82] Review comments --- aider/args.py | 4 ++-- aider/coders/base_coder.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/aider/args.py b/aider/args.py index 24682fa55..a96dc196d 100644 --- a/aider/args.py +++ b/aider/args.py @@ -23,8 +23,8 @@ def get_parser(default_config_files, git_root): group.add_argument( "--llm-history-file", metavar="LLM_HISTORY_FILE", - default=".aider.llm.history", - help="Specify the LLM history file (default: .aider.llm.history)", + default=None, + help="Log the conversation with the LLM to this file (for example, .aider.llm.history)", ) group.add_argument( "files", diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index a8ddf8830..9b2a9ed9a 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import datetime import hashlib import json import os @@ -27,7 +28,7 @@ from aider.mdstream import MarkdownStream from aider.repo import GitRepo from aider.repomap import RepoMap from aider.sendchat import send_with_retries -from aider.utils import is_image_file +from aider.utils import is_image_file, format_messages, format_content from ..dump import dump # noqa: F401 @@ -779,9 +780,6 @@ class Coder: dict(role="user", content=inp), ] - import datetime - from aider.utils import format_messages, format_content - messages = self.format_messages() self.io.log_llm_history("TO LLM", format_messages(messages)) From 5fd8bb69caf70d708144669fd3b63720c79c284c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 14 Jun 2024 06:16:53 -0700 Subject: [PATCH 15/82] Note use of AZURE_OPENAI_API_xxx #672 --- website/_includes/special-keys.md | 9 +++++++++ website/docs/llms/azure.md | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 website/_includes/special-keys.md diff --git a/website/_includes/special-keys.md b/website/_includes/special-keys.md new file mode 100644 index 000000000..ec5d59f9c --- /dev/null +++ b/website/_includes/special-keys.md @@ -0,0 +1,9 @@ +Aider has special support for providing +OpenAI and Anthropic API keys +via command line switches and yaml config settings. +*All other LLM providers* must +have their keys and settings +specified in environment variables. +This can be done in your shell, +or by using a +[`.env` file](/docs/dotenv.html). diff --git a/website/docs/llms/azure.md b/website/docs/llms/azure.md index ada2beb8d..55aa791f4 100644 --- a/website/docs/llms/azure.md +++ b/website/docs/llms/azure.md @@ -25,3 +25,6 @@ aider --model azure/ # List models available from Azure aider --models azure/ ``` + +Note that aider will also use environment variables +like `AZURE_OPENAI_API_xxx`. From 0fc6b9beaaef71671931427fccf96d3face207d2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 14 Jun 2024 06:16:56 -0700 Subject: [PATCH 16/82] copy --- aider/args_formatter.py | 1 + website/assets/sample.aider.conf.yml | 1 + website/docs/aider_conf.md | 3 +++ website/docs/dotenv.md | 2 ++ 4 files changed, 7 insertions(+) diff --git a/aider/args_formatter.py b/aider/args_formatter.py index 9ad00ff66..2503cd007 100644 --- a/aider/args_formatter.py +++ b/aider/args_formatter.py @@ -17,6 +17,7 @@ class YamlHelpFormatter(argparse.HelpFormatter): return """ ########################################################## # Sample .aider.conf.yaml +# This file lists *all* the valid configuration entries. # Place in your home dir, or at the root of your git repo. ########################################################## diff --git a/website/assets/sample.aider.conf.yml b/website/assets/sample.aider.conf.yml index 78b81609d..9a9679c27 100644 --- a/website/assets/sample.aider.conf.yml +++ b/website/assets/sample.aider.conf.yml @@ -1,5 +1,6 @@ ########################################################## # Sample .aider.conf.yaml +# This file lists *all* the valid configuration entries. # Place in your home dir, or at the root of your git repo. ########################################################## diff --git a/website/docs/aider_conf.md b/website/docs/aider_conf.md index e6024338c..f50c88862 100644 --- a/website/docs/aider_conf.md +++ b/website/docs/aider_conf.md @@ -10,6 +10,8 @@ Most of aider's options can be set in an `.aider.conf.yml` file, which can be placed in your home directory or at the root of your git repo. +{% include special-keys.md %} + Below is a sample of the file, which you can also [download from GitHub](https://github.com/paul-gauthier/aider/blob/main/website/assets/sample.aider.conf.yml). @@ -26,6 +28,7 @@ cog.outl("```") ``` ########################################################## # Sample .aider.conf.yaml +# This file lists *all* the valid configuration entries. # Place in your home dir, or at the root of your git repo. ########################################################## diff --git a/website/docs/dotenv.md b/website/docs/dotenv.md index 6620e2254..e45fc5783 100644 --- a/website/docs/dotenv.md +++ b/website/docs/dotenv.md @@ -11,6 +11,8 @@ models you use with aider. You currently can not set general aider options in the `.env` file, only LLM environment variables. +{% include special-keys.md %} + Aider will look for a `.env` file in the root of your git repo or in the current directory. You can give it an explicit file to load with the `--env-file ` parameter. From a30e656304250206d14c41f99d34740e166768b1 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 14 Jun 2024 07:28:33 -0700 Subject: [PATCH 17/82] improved token limit err msgs and docs #678 --- aider/coders/base_coder.py | 70 ++++++++++++++-- aider/urls.py | 1 + website/docs/troubleshooting/token-limits.md | 86 ++++++++++++++++++++ 3 files changed, 150 insertions(+), 7 deletions(-) create mode 100644 website/docs/troubleshooting/token-limits.md diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 16dc55c78..b704841fa 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -795,8 +795,11 @@ class Coder: except ExhaustedContextWindow: exhausted = True except litellm.exceptions.BadRequestError as err: - self.io.tool_error(f"BadRequestError: {err}") - return + if "ContextWindowExceededError" in err.message: + exhausted = True + else: + self.io.tool_error(f"BadRequestError: {err}") + return except openai.BadRequestError as err: if "maximum context length" in str(err): exhausted = True @@ -804,12 +807,8 @@ class Coder: raise err if exhausted: + self.show_exhausted_error() self.num_exhausted_context_windows += 1 - self.io.tool_error("The chat session is larger than the context window!\n") - self.commands.cmd_tokens("") - self.io.tool_error("\nTo reduce token usage:") - self.io.tool_error(" - Use /drop to remove unneeded files from the chat session.") - self.io.tool_error(" - Use /clear to clear chat history.") return if self.partial_response_function_call: @@ -878,6 +877,63 @@ class Coder: else: self.reflected_message = add_rel_files_message + def show_exhausted_error(self): + output_tokens = 0 + if self.partial_response_content: + output_tokens = self.main_model.token_count(self.partial_response_content) + max_output_tokens = self.main_model.info.get("max_output_tokens", 0) + + input_tokens = self.main_model.token_count(self.format_messages()) + max_input_tokens = self.main_model.info.get("max_input_tokens", 0) + + total_tokens = input_tokens + output_tokens + + if output_tokens >= max_output_tokens: + out_err = " -- exceeded output limit!" + else: + out_err = "" + + if input_tokens >= max_input_tokens: + inp_err = " -- context window exhausted!" + else: + inp_err = "" + + if total_tokens >= max_input_tokens: + tot_err = " -- context window exhausted!" + else: + tot_err = "" + + res = ["", ""] + res.append(f"Model {self.main_model.name} has hit a token limit!") + res.append("") + res.append(f"Input tokens: {input_tokens} of {max_input_tokens}{inp_err}") + res.append(f"Output tokens: {output_tokens} of {max_output_tokens}{out_err}") + res.append(f"Total tokens: {total_tokens} of {max_input_tokens}{tot_err}") + + if output_tokens >= max_output_tokens: + res.append("") + res.append("To reduce output tokens:") + res.append("- Ask for smaller changes in each request.") + res.append("- Break your code into smaller source files.") + if "diff" not in self.main_model.edit_format: + res.append( + "- Try using a stronger model like gpt-4o or opus that can return diffs." + ) + + if input_tokens >= max_input_tokens or total_tokens >= max_input_tokens: + res.append("") + res.append("To reduce input tokens:") + res.append("- Use /tokens to see token usage.") + res.append("- Use /drop to remove unneeded files from the chat session.") + res.append("- Use /clear to clear the chat history.") + res.append("- Break your code into smaller source files.") + + res.append("") + res.append(f"For more info: {urls.token_limits}") + + res = "".join([line + "\n" for line in res]) + self.io.tool_error(res) + def lint_edited(self, fnames): res = "" for fname in fnames: diff --git a/aider/urls.py b/aider/urls.py index 62f95503d..5e2c7761e 100644 --- a/aider/urls.py +++ b/aider/urls.py @@ -5,3 +5,4 @@ git = "https://aider.chat/docs/git.html" enable_playwrite = "https://aider.chat/docs/install/optional.html#enable-playwright" favicon = "https://aider.chat/assets/icons/favicon-32x32.png" model_warnings = "https://aider.chat/docs/llms/warnings.html" +token_limits = "https://aider.chat/docs/toubleshooting/token-limits.html" diff --git a/website/docs/troubleshooting/token-limits.md b/website/docs/troubleshooting/token-limits.md new file mode 100644 index 000000000..ec4bb632e --- /dev/null +++ b/website/docs/troubleshooting/token-limits.md @@ -0,0 +1,86 @@ +--- +parent: Troubleshooting +nav_order: 25 +--- + +# Token limits + +Every LLM has limits on how many tokens it can process: + +- The model's **context window** limits how many tokens of +*input and output* it can process. +- Each model has limit on how many **output tokens** it can +produce. + +Aider will report an error if a model responds indicating that +it has exceeded a token limit. +The error will include suggested actions to try and +avoid hitting token limits. +Here's an example error: + +``` +Model gpt-3.5-turbo has hit a token limit! + +Input tokens: 768 of 16385 +Output tokens: 4096 of 4096 -- exceeded output limit! +Total tokens: 4864 of 16385 + +To reduce output tokens: +- Ask for smaller changes in each request. +- Break your code into smaller source files. +- Try using a stronger model like gpt-4o or opus that can return diffs. + +For more info: https://aider.chat/docs/token-limits.html +``` + +## Input tokens & context window size + +The most common problem is trying to send too much data to a +model, +overflowing its context window. +Technically you can exhaust the context window if the input is +too large or if the input plus output are too large. + +Strong models like GPT-4o and Opus have quite +large context windows, so this sort of error is +typically only an issue when working with weaker models. + +The easiest solution is to try and reduce the input tokens +by removing files from the chat. +It's best to only add the files that aider will need to *edit* +to complete your request. + +- Use `/tokens` to see token usage. +- Use `/drop` to remove unneeded files from the chat session. +- Use `/clear` to clear the chat history. +- Break your code into smaller source files. + +## Output token limits + +Most models have quite small output limits, often as low +as 4k tokens. +If you ask aider to make a large change that affects a lot +of code, the LLM may hit output token limits +as it tries to send back all the changes. + +To avoid hitting output token limits: + +- Ask for smaller changes in each request. +- Break your code into smaller source files. +- Try using a stronger model like gpt-4o or opus that can return diffs. + + +## Other causes + +Sometimes token limit errors are caused by +non-compliant API proxy servers +or bugs in the API server you are using to host a local model. +Aider has been well tested when directly connecting to +major +[LLM provider cloud APIs](https://aider.chat/docs/llms.html). +For serving local models, +[Ollama](https://aider.chat/docs/llms/ollama.html) is known to work well with aider. + +Try using aider without an API proxy server +or directly with one of the recommended cloud APIs +and see if your token limit problems resolve. From 80458f9b0afcbca3dccd7b9ed37309ce2e621395 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 14 Jun 2024 07:31:18 -0700 Subject: [PATCH 18/82] fixed token limits url --- aider/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/urls.py b/aider/urls.py index 5e2c7761e..15081c034 100644 --- a/aider/urls.py +++ b/aider/urls.py @@ -5,4 +5,4 @@ git = "https://aider.chat/docs/git.html" enable_playwrite = "https://aider.chat/docs/install/optional.html#enable-playwright" favicon = "https://aider.chat/assets/icons/favicon-32x32.png" model_warnings = "https://aider.chat/docs/llms/warnings.html" -token_limits = "https://aider.chat/docs/toubleshooting/token-limits.html" +token_limits = "https://aider.chat/docs/troubleshooting/token-limits.html" From 43e938367c4d6ec24c7d7c5efe2c038a82dd230e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 14 Jun 2024 16:52:43 -0700 Subject: [PATCH 19/82] copy --- website/docs/troubleshooting/token-limits.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/troubleshooting/token-limits.md b/website/docs/troubleshooting/token-limits.md index ec4bb632e..dfd624549 100644 --- a/website/docs/troubleshooting/token-limits.md +++ b/website/docs/troubleshooting/token-limits.md @@ -5,9 +5,9 @@ nav_order: 25 # Token limits -Every LLM has limits on how many tokens it can process: +Every LLM has limits on how many tokens it can process for each request: -- The model's **context window** limits how many tokens of +- The model's **context window** limits how many total tokens of *input and output* it can process. - Each model has limit on how many **output tokens** it can produce. From 73fcaa6f0195ae7d845c75b1513b3a20a8bda14b Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jun 2024 11:21:32 -0700 Subject: [PATCH 20/82] bump litellm version to pickup fix https://github.com/BerriAI/litellm/issues/4082 --- requirements.txt | 53 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/requirements.txt b/requirements.txt index 844b4e6b5..e7bff9826 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,9 +10,9 @@ aiosignal==1.3.1 # via aiohttp altair==5.3.0 # via streamlit -annotated-types==0.6.0 +annotated-types==0.7.0 # via pydantic -anyio==4.3.0 +anyio==4.4.0 # via # httpx # openai @@ -31,7 +31,7 @@ cachetools==5.3.3 # via # google-auth # streamlit -certifi==2024.2.2 +certifi==2024.6.2 # via # httpcore # httpx @@ -54,15 +54,15 @@ diskcache==5.6.3 # via -r requirements.in distro==1.9.0 # via openai -filelock==3.14.0 +filelock==3.15.1 # via huggingface-hub -flake8==7.0.0 +flake8==7.1.0 # via -r requirements.in frozenlist==1.4.1 # via # aiohttp # aiosignal -fsspec==2024.5.0 +fsspec==2024.6.0 # via huggingface-hub gitdb==4.0.11 # via gitpython @@ -77,9 +77,9 @@ google-api-core[grpc]==2.19.0 # google-ai-generativelanguage # google-api-python-client # google-generativeai -google-api-python-client==2.129.0 +google-api-python-client==2.133.0 # via google-generativeai -google-auth==2.29.0 +google-auth==2.30.0 # via # google-ai-generativelanguage # google-api-core @@ -88,9 +88,9 @@ google-auth==2.29.0 # google-generativeai google-auth-httplib2==0.2.0 # via google-api-python-client -google-generativeai==0.5.4 +google-generativeai==0.6.0 # via -r requirements.in -googleapis-common-protos==1.63.0 +googleapis-common-protos==1.63.1 # via # google-api-core # grpcio-status @@ -98,7 +98,7 @@ greenlet==3.0.3 # via playwright grep-ast==0.3.2 # via -r requirements.in -grpcio==1.63.0 +grpcio==1.64.1 # via # google-api-core # grpcio-status @@ -114,7 +114,7 @@ httplib2==0.22.0 # google-auth-httplib2 httpx==0.27.0 # via openai -huggingface-hub==0.23.0 +huggingface-hub==0.23.4 # via tokenizers idna==3.7 # via @@ -135,7 +135,7 @@ jsonschema==4.22.0 # altair jsonschema-specifications==2023.12.1 # via jsonschema -litellm==1.37.16 +litellm==1.40.15 # via -r requirements.in markdown-it-py==3.0.0 # via rich @@ -160,11 +160,11 @@ numpy==1.26.4 # pydeck # scipy # streamlit -openai==1.30.1 +openai==1.34.0 # via # -r requirements.in # litellm -packaging==24.0 +packaging==24.1 # via # -r requirements.in # altair @@ -184,7 +184,7 @@ pillow==10.3.0 # streamlit playwright==1.44.0 # via -r requirements.in -prompt-toolkit==3.0.43 +prompt-toolkit==3.0.47 # via -r requirements.in proto-plus==1.23.0 # via @@ -207,15 +207,16 @@ pyasn1==0.6.0 # rsa pyasn1-modules==0.4.0 # via google-auth -pycodestyle==2.11.1 +pycodestyle==2.12.0 # via flake8 pycparser==2.22 # via cffi -pydantic==2.7.1 +pydantic==2.7.4 # via # google-generativeai + # litellm # openai -pydantic-core==2.18.2 +pydantic-core==2.18.4 # via pydantic pydeck==0.9.1 # via streamlit @@ -245,7 +246,7 @@ referencing==0.35.1 # jsonschema-specifications regex==2024.5.15 # via tiktoken -requests==2.31.0 +requests==2.32.3 # via # google-api-core # huggingface-hub @@ -262,7 +263,7 @@ rpds-py==0.18.1 # referencing rsa==4.9 # via google-auth -scipy==1.13.0 +scipy==1.13.1 # via -r requirements.in six==1.16.0 # via python-dateutil @@ -273,13 +274,13 @@ sniffio==1.3.1 # anyio # httpx # openai -sounddevice==0.4.6 +sounddevice==0.4.7 # via -r requirements.in soundfile==0.12.1 # via -r requirements.in soupsieve==2.5 # via beautifulsoup4 -streamlit==1.34.0 +streamlit==1.35.0 # via -r requirements.in tenacity==8.3.0 # via streamlit @@ -293,7 +294,7 @@ toml==0.10.2 # via streamlit toolz==0.12.1 # via altair -tornado==6.4 +tornado==6.4.1 # via streamlit tqdm==4.66.4 # via @@ -306,7 +307,7 @@ tree-sitter==0.21.3 # tree-sitter-languages tree-sitter-languages==1.10.2 # via grep-ast -typing-extensions==4.11.0 +typing-extensions==4.12.2 # via # google-generativeai # huggingface-hub @@ -327,5 +328,5 @@ wcwidth==0.2.13 # via prompt-toolkit yarl==1.9.4 # via aiohttp -zipp==3.18.2 +zipp==3.19.2 # via importlib-metadata From 45e27af58917c02daef9e670218abadd528b0e46 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jun 2024 12:09:20 -0700 Subject: [PATCH 21/82] restored editblock_prompt --- aider/coders/editblock_prompts.py | 138 ++++++++++++++++++++++++++++-- 1 file changed, 133 insertions(+), 5 deletions(-) diff --git a/aider/coders/editblock_prompts.py b/aider/coders/editblock_prompts.py index be556b31f..44e44df92 100644 --- a/aider/coders/editblock_prompts.py +++ b/aider/coders/editblock_prompts.py @@ -4,12 +4,140 @@ from .base_prompts import CoderPrompts class EditBlockPrompts(CoderPrompts): - main_system = """Act as a software expert and answer user questions about how to use the aider program. -You never write code, just answer questions. + main_system = """Act as an expert software developer. +Always use best practices when coding. +Respect and use existing conventions, libraries, etc that are already present in the code base. +{lazy_prompt} +Take requests for changes to the supplied code. +If the request is ambiguous, ask questions. -Decide if you need to see any files that haven't been added to the chat. If so, you *MUST* tell the user their full path names and ask them to *add the files to the chat*. End your reply and wait for their approval. You can keep asking if you then decide you need to see more files. +Always reply to the user in the same language they are using. + +Once you understand the request you MUST: +1. Decide if you need to propose *SEARCH/REPLACE* edits to any files that haven't been added to the chat. You can create new files without asking. But if you need to propose edits to existing files not already added to the chat, you *MUST* tell the user their full path names and ask them to *add the files to the chat*. End your reply and wait for their approval. You can keep asking if you then decide you need to edit more files. +2. Think step-by-step and explain the needed changes with a numbered list of short sentences. +3. Describe each change with a *SEARCH/REPLACE block* per the examples below. All changes to files must use this *SEARCH/REPLACE block* format. ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*! + +All changes to files must use the *SEARCH/REPLACE block* format. """ - example_messages = [] + example_messages = [ + dict( + role="user", + content="Change get_factorial() to use math.factorial", + ), + dict( + role="assistant", + content="""To make this change we need to modify `mathweb/flask/app.py` to: - system_reminder = "" +1. Import the math package. +2. Remove the existing factorial() function. +3. Update get_factorial() to call math.factorial instead. + +Here are the *SEARCH/REPLACE* blocks: + +mathweb/flask/app.py +{fence[0]}python +<<<<<<< SEARCH +from flask import Flask +======= +import math +from flask import Flask +>>>>>>> REPLACE +{fence[1]} + +mathweb/flask/app.py +{fence[0]}python +<<<<<<< SEARCH +def factorial(n): + "compute factorial" + + if n == 0: + return 1 + else: + return n * factorial(n-1) + +======= +>>>>>>> REPLACE +{fence[1]} + +mathweb/flask/app.py +{fence[0]}python +<<<<<<< SEARCH + return str(factorial(n)) +======= + return str(math.factorial(n)) +>>>>>>> REPLACE +{fence[1]} +""", + ), + dict( + role="user", + content="Refactor hello() into its own file.", + ), + dict( + role="assistant", + content="""To make this change we need to modify `main.py` and make a new file `hello.py`: + +1. Make a new hello.py file with hello() in it. +2. Remove hello() from main.py and replace it with an import. + +Here are the *SEARCH/REPLACE* blocks: + +hello.py +{fence[0]}python +<<<<<<< SEARCH +======= +def hello(): + "print a greeting" + + print("hello") +>>>>>>> REPLACE +{fence[1]} + +main.py +{fence[0]}python +<<<<<<< SEARCH +def hello(): + "print a greeting" + + print("hello") +======= +from hello import hello +>>>>>>> REPLACE +{fence[1]} +""", + ), + ] + + system_reminder = """# *SEARCH/REPLACE block* Rules: + +Every *SEARCH/REPLACE block* must use this format: +1. The file path alone on a line, verbatim. No bold asterisks, no quotes around it, no escaping of characters, etc. +2. The opening fence and code language, eg: {fence[0]}python +3. The start of search block: <<<<<<< SEARCH +4. A contiguous chunk of lines to search for in the existing source code +5. The dividing line: ======= +6. The lines to replace into the source code +7. The end of the replace block: >>>>>>> REPLACE +8. The closing fence: {fence[1]} + +Every *SEARCH* section must *EXACTLY MATCH* the existing source code, character for character, including all comments, docstrings, etc. + +*SEARCH/REPLACE* blocks will replace *all* matching occurrences. +Include enough lines to make the SEARCH blocks unique. + +Include *ALL* the code being searched and replaced! + +Only create *SEARCH/REPLACE* blocks for files that the user has added to the chat! + +To move code within a file, use 2 *SEARCH/REPLACE* blocks: 1 to delete it from its current location, 1 to insert it in the new location. + +If you want to put code in a new file, use a *SEARCH/REPLACE block* with: +- A new file path, including dir name if needed +- An empty `SEARCH` section +- The new file's contents in the `REPLACE` section + +{lazy_prompt} +ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*! +""" From 5c87008bd095fdef8b25945cf09fc5adf56bf77f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jun 2024 12:16:19 -0700 Subject: [PATCH 22/82] Updated HISTORY --- HISTORY.md | 13 +- aider/scrape.py | 3 +- scripts/update-docs.sh | 1 + website/HISTORY.md | 416 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 428 insertions(+), 5 deletions(-) create mode 100644 website/HISTORY.md diff --git a/HISTORY.md b/HISTORY.md index 1284773f3..8b37848fa 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,9 +1,16 @@ ---- -nav_order: 999 ---- # Release history +### v0.38.0 + +- Use `--vim` for vim keybindings in the chat. +- [Add LLM metadata](https://aider.chat/docs/llms/warnings.html#specifying-context-window-size-and-token-costs) via `.aider.models.json` file (by @caseymcc). +- More detailed error messages on token limit errors. +- Ensure `--commit --dry-run` does nothing. +- Have playwright wait for idle network to better scrape js sites. +- Documentation updates, moved into website/ subdir. +- Moved tests/ into aider/tests/. + ### v0.37.0 - Repo map is now optimized based on text of chat history as well as files added to chat. diff --git a/aider/scrape.py b/aider/scrape.py index 147203c48..aea0b184e 100755 --- a/aider/scrape.py +++ b/aider/scrape.py @@ -10,7 +10,7 @@ from bs4 import BeautifulSoup from playwright.sync_api import sync_playwright from aider import __version__, urls -from aider.dump import dump +from aider.dump import dump # noqa: F401 aider_user_agent = f"Aider/{__version__} +{urls.website}" @@ -53,7 +53,6 @@ class Scraper: else: content = self.scrape_with_httpx(url) - dump(content) if not content: return diff --git a/scripts/update-docs.sh b/scripts/update-docs.sh index ce40f2d44..4fe32efba 100755 --- a/scripts/update-docs.sh +++ b/scripts/update-docs.sh @@ -13,6 +13,7 @@ fi cog $ARG \ README.md \ website/index.md \ + website/HISTORY.md \ website/docs/commands.md \ website/docs/languages.md \ website/docs/options.md \ diff --git a/website/HISTORY.md b/website/HISTORY.md new file mode 100644 index 000000000..24e8cfe9f --- /dev/null +++ b/website/HISTORY.md @@ -0,0 +1,416 @@ +--- +title: Release history +nav_order: 999 +--- + + + +# Release history + +### v0.38.0 + +- Use `--vim` for vim keybindings in the chat. +- [Add LLM metadata](https://aider.chat/docs/llms/warnings.html#specifying-context-window-size-and-token-costs) via `.aider.models.json` file (by @caseymcc). +- More detailed error messages on token limit errors. +- Ensure `--commit --dry-run` does nothing. +- Have playwright wait for idle network to better scrape js sites. +- Documentation updates, moved into website/ subdir. +- Moved tests/ into aider/tests/. + +### v0.37.0 + +- Repo map is now optimized based on text of chat history as well as files added to chat. +- Improved prompts when no files have been added to chat to solicit LLM file suggestions. +- Aider will notice if you paste a URL into the chat, and offer to scrape it. +- Performance improvements the repo map, especially in large repos. +- Aider will not offer to add bare filenames like `make` or `run` which may just be words. +- Properly override `GIT_EDITOR` env for commits if it is already set. +- Detect supported audio sample rates for `/voice`. +- Other small bug fixes. + +### v0.36.0 + +- [Aider can now lint your code and fix any errors](https://aider.chat/2024/05/22/linting.html). + - Aider automatically lints and fixes after every LLM edit. + - You can manually lint-and-fix files with `/lint` in the chat or `--lint` on the command line. + - Aider includes built in basic linters for all supported tree-sitter languages. + - You can also configure aider to use your preferred linter with `--lint-cmd`. +- Aider has additional support for running tests and fixing problems. + - Configure your testing command with `--test-cmd`. + - Run tests with `/test` or from the command line with `--test`. + - Aider will automatically attempt to fix any test failures. + + +### v0.35.0 + +- Aider now uses GPT-4o by default. + - GPT-4o tops the [aider LLM code editing leaderboard](https://aider.chat/docs/leaderboards/) at 72.9%, versus 68.4% for Opus. + - GPT-4o takes second on [aider's refactoring leaderboard](https://aider.chat/docs/leaderboards/#code-refactoring-leaderboard) with 62.9%, versus Opus at 72.3%. +- Added `--restore-chat-history` to restore prior chat history on launch, so you can continue the last conversation. +- Improved reflection feedback to LLMs using the diff edit format. +- Improved retries on `httpx` errors. + +### v0.34.0 + +- Updated prompting to use more natural phrasing about files, the git repo, etc. Removed reliance on read-write/read-only terminology. +- Refactored prompting to unify some phrasing across edit formats. +- Enhanced the canned assistant responses used in prompts. +- Added explicit model settings for `openrouter/anthropic/claude-3-opus`, `gpt-3.5-turbo` +- Added `--show-prompts` debug switch. +- Bugfix: catch and retry on all litellm exceptions. + + +### v0.33.0 + +- Added native support for [Deepseek models](https://aider.chat/docs/llms.html#deepseek) using `DEEPSEEK_API_KEY` and `deepseek/deepseek-chat`, etc rather than as a generic OpenAI compatible API. + +### v0.32.0 + +- [Aider LLM code editing leaderboards](https://aider.chat/docs/leaderboards/) that rank popular models according to their ability to edit code. + - Leaderboards include GPT-3.5/4 Turbo, Opus, Sonnet, Gemini 1.5 Pro, Llama 3, Deepseek Coder & Command-R+. +- Gemini 1.5 Pro now defaults to a new diff-style edit format (diff-fenced), enabling it to work better with larger code bases. +- Support for Deepseek-V2, via more a flexible config of system messages in the diff edit format. +- Improved retry handling on errors from model APIs. +- Benchmark outputs results in YAML, compatible with leaderboard. + +### v0.31.0 + +- [Aider is now also AI pair programming in your browser!](https://aider.chat/2024/05/02/browser.html) Use the `--browser` switch to launch an experimental browser based version of aider. +- Switch models during the chat with `/model ` and search the list of available models with `/models `. + +### v0.30.1 + +- Adding missing `google-generativeai` dependency + +### v0.30.0 + +- Added [Gemini 1.5 Pro](https://aider.chat/docs/llms.html#free-models) as a recommended free model. +- Allow repo map for "whole" edit format. +- Added `--models ` to search the available models. +- Added `--no-show-model-warnings` to silence model warnings. + +### v0.29.2 + +- Improved [model warnings](https://aider.chat/docs/llms.html#model-warnings) for unknown or unfamiliar models + +### v0.29.1 + +- Added better support for groq/llama3-70b-8192 + +### v0.29.0 + +- Added support for [directly connecting to Anthropic, Cohere, Gemini and many other LLM providers](https://aider.chat/docs/llms.html). +- Added `--weak-model ` which allows you to specify which model to use for commit messages and chat history summarization. +- New command line switches for working with popular models: + - `--4-turbo-vision` + - `--opus` + - `--sonnet` + - `--anthropic-api-key` +- Improved "whole" and "diff" backends to better support [Cohere's free to use Command-R+ model](https://aider.chat/docs/llms.html#cohere). +- Allow `/add` of images from anywhere in the filesystem. +- Fixed crash when operating in a repo in a detached HEAD state. +- Fix: Use the same default model in CLI and python scripting. + +### v0.28.0 + +- Added support for new `gpt-4-turbo-2024-04-09` and `gpt-4-turbo` models. + - Benchmarked at 61.7% on Exercism benchmark, comparable to `gpt-4-0613` and worse than the `gpt-4-preview-XXXX` models. See [recent Exercism benchmark results](https://aider.chat/2024/03/08/claude-3.html). + - Benchmarked at 34.1% on the refactoring/laziness benchmark, significantly worse than the `gpt-4-preview-XXXX` models. See [recent refactor bencmark results](https://aider.chat/2024/01/25/benchmarks-0125.html). + - Aider continues to default to `gpt-4-1106-preview` as it performs best on both benchmarks, and significantly better on the refactoring/laziness benchmark. + +### v0.27.0 + +- Improved repomap support for typescript, by @ryanfreckleton. +- Bugfix: Only /undo the files which were part of the last commit, don't stomp other dirty files +- Bugfix: Show clear error message when OpenAI API key is not set. +- Bugfix: Catch error for obscure languages without tags.scm file. + +### v0.26.1 + +- Fixed bug affecting parsing of git config in some environments. + +### v0.26.0 + +- Use GPT-4 Turbo by default. +- Added `-3` and `-4` switches to use GPT 3.5 or GPT-4 (non-Turbo). +- Bug fix to avoid reflecting local git errors back to GPT. +- Improved logic for opening git repo on launch. + +### v0.25.0 + +- Issue a warning if user adds too much code to the chat. + - https://aider.chat/docs/faq.html#how-can-i-add-all-the-files-to-the-chat +- Vocally refuse to add files to the chat that match `.aiderignore` + - Prevents bug where subsequent git commit of those files will fail. +- Added `--openai-organization-id` argument. +- Show the user a FAQ link if edits fail to apply. +- Made past articles part of https://aider.chat/blog/ + +### v0.24.1 + +- Fixed bug with cost computations when --no-steam in effect + +### v0.24.0 + +- New `/web ` command which scrapes the url, turns it into fairly clean markdown and adds it to the chat. +- Updated all OpenAI model names, pricing info +- Default GPT 3.5 model is now `gpt-3.5-turbo-0125`. +- Bugfix to the `!` alias for `/run`. + +### v0.23.0 + +- Added support for `--model gpt-4-0125-preview` and OpenAI's alias `--model gpt-4-turbo-preview`. The `--4turbo` switch remains an alias for `--model gpt-4-1106-preview` at this time. +- New `/test` command that runs a command and adds the output to the chat on non-zero exit status. +- Improved streaming of markdown to the terminal. +- Added `/quit` as alias for `/exit`. +- Added `--skip-check-update` to skip checking for the update on launch. +- Added `--openrouter` as a shortcut for `--openai-api-base https://openrouter.ai/api/v1` +- Fixed bug preventing use of env vars `OPENAI_API_BASE, OPENAI_API_TYPE, OPENAI_API_VERSION, OPENAI_API_DEPLOYMENT_ID`. + +### v0.22.0 + +- Improvements for unified diff editing format. +- Added ! as an alias for /run. +- Autocomplete for /add and /drop now properly quotes filenames with spaces. +- The /undo command asks GPT not to just retry reverted edit. + +### v0.21.1 + +- Bugfix for unified diff editing format. +- Added --4turbo and --4 aliases for --4-turbo. + +### v0.21.0 + +- Support for python 3.12. +- Improvements to unified diff editing format. +- New `--check-update` arg to check if updates are available and exit with status code. + +### v0.20.0 + +- Add images to the chat to automatically use GPT-4 Vision, by @joshuavial + +- Bugfixes: + - Improved unicode encoding for `/run` command output, by @ctoth + - Prevent false auto-commits on Windows, by @ctoth + +### v0.19.1 + +- Removed stray debug output. + +### v0.19.0 + +- [Significantly reduced "lazy" coding from GPT-4 Turbo due to new unified diff edit format](https://aider.chat/docs/unified-diffs.html) + - Score improves from 20% to 61% on new "laziness benchmark". + - Aider now uses unified diffs by default for `gpt-4-1106-preview`. +- New `--4-turbo` command line switch as a shortcut for `--model gpt-4-1106-preview`. + +### v0.18.1 + +- Upgraded to new openai python client v1.3.7. + +### v0.18.0 + +- Improved prompting for both GPT-4 and GPT-4 Turbo. + - Far fewer edit errors from GPT-4 Turbo (`gpt-4-1106-preview`). + - Significantly better benchmark results from the June GPT-4 (`gpt-4-0613`). Performance leaps from 47%/64% up to 51%/71%. +- Fixed bug where in-chat files were marked as both read-only and ready-write, sometimes confusing GPT. +- Fixed bug to properly handle repos with submodules. + +### v0.17.0 + +- Support for OpenAI's new 11/06 models: + - gpt-4-1106-preview with 128k context window + - gpt-3.5-turbo-1106 with 16k context window +- [Benchmarks for OpenAI's new 11/06 models](https://aider.chat/docs/benchmarks-1106.html) +- Streamlined [API for scripting aider, added docs](https://aider.chat/docs/faq.html#can-i-script-aider) +- Ask for more concise SEARCH/REPLACE blocks. [Benchmarked](https://aider.chat/docs/benchmarks.html) at 63.9%, no regression. +- Improved repo-map support for elisp. +- Fixed crash bug when `/add` used on file matching `.gitignore` +- Fixed misc bugs to catch and handle unicode decoding errors. + +### v0.16.3 + +- Fixed repo-map support for C#. + +### v0.16.2 + +- Fixed docker image. + +### v0.16.1 + +- Updated tree-sitter dependencies to streamline the pip install process + +### v0.16.0 + +- [Improved repository map using tree-sitter](https://aider.chat/docs/repomap.html) +- Switched from "edit block" to "search/replace block", which reduced malformed edit blocks. [Benchmarked](https://aider.chat/docs/benchmarks.html) at 66.2%, no regression. +- Improved handling of malformed edit blocks targeting multiple edits to the same file. [Benchmarked](https://aider.chat/docs/benchmarks.html) at 65.4%, no regression. +- Bugfix to properly handle malformed `/add` wildcards. + + +### v0.15.0 + +- Added support for `.aiderignore` file, which instructs aider to ignore parts of the git repo. +- New `--commit` cmd line arg, which just commits all pending changes with a sensible commit message generated by gpt-3.5. +- Added universal ctags and multiple architectures to the [aider docker image](https://aider.chat/docs/docker.html) +- `/run` and `/git` now accept full shell commands, like: `/run (cd subdir; ls)` +- Restored missing `--encoding` cmd line switch. + +### v0.14.2 + +- Easily [run aider from a docker image](https://aider.chat/docs/docker.html) +- Fixed bug with chat history summarization. +- Fixed bug if `soundfile` package not available. + +### v0.14.1 + +- /add and /drop handle absolute filenames and quoted filenames +- /add checks to be sure files are within the git repo (or root) +- If needed, warn users that in-chat file paths are all relative to the git repo +- Fixed /add bug in when aider launched in repo subdir +- Show models supported by api/key if requested model isn't available + +### v0.14.0 + +- [Support for Claude2 and other LLMs via OpenRouter](https://aider.chat/docs/faq.html#accessing-other-llms-with-openrouter) by @joshuavial +- Documentation for [running the aider benchmarking suite](https://github.com/paul-gauthier/aider/tree/main/benchmark) +- Aider now requires Python >= 3.9 + + +### v0.13.0 + +- [Only git commit dirty files that GPT tries to edit](https://aider.chat/docs/faq.html#how-did-v0130-change-git-usage) +- Send chat history as prompt/context for Whisper voice transcription +- Added `--voice-language` switch to constrain `/voice` to transcribe to a specific language +- Late-bind importing `sounddevice`, as it was slowing down aider startup +- Improved --foo/--no-foo switch handling for command line and yml config settings + +### v0.12.0 + +- [Voice-to-code](https://aider.chat/docs/voice.html) support, which allows you to code with your voice. +- Fixed bug where /diff was causing crash. +- Improved prompting for gpt-4, refactor of editblock coder. +- [Benchmarked](https://aider.chat/docs/benchmarks.html) at 63.2% for gpt-4/diff, no regression. + +### v0.11.1 + +- Added a progress bar when initially creating a repo map. +- Fixed bad commit message when adding new file to empty repo. +- Fixed corner case of pending chat history summarization when dirty committing. +- Fixed corner case of undefined `text` when using `--no-pretty`. +- Fixed /commit bug from repo refactor, added test coverage. +- [Benchmarked](https://aider.chat/docs/benchmarks.html) at 53.4% for gpt-3.5/whole (no regression). + +### v0.11.0 + +- Automatically summarize chat history to avoid exhausting context window. +- More detail on dollar costs when running with `--no-stream` +- Stronger GPT-3.5 prompt against skipping/eliding code in replies (51.9% [benchmark](https://aider.chat/docs/benchmarks.html), no regression) +- Defend against GPT-3.5 or non-OpenAI models suggesting filenames surrounded by asterisks. +- Refactored GitRepo code out of the Coder class. + +### v0.10.1 + +- /add and /drop always use paths relative to the git root +- Encourage GPT to use language like "add files to the chat" to ask users for permission to edit them. + +### v0.10.0 + +- Added `/git` command to run git from inside aider chats. +- Use Meta-ENTER (Esc+ENTER in some environments) to enter multiline chat messages. +- Create a `.gitignore` with `.aider*` to prevent users from accidentaly adding aider files to git. +- Check pypi for newer versions and notify user. +- Updated keyboard interrupt logic so that 2 ^C in 2 seconds always forces aider to exit. +- Provide GPT with detailed error if it makes a bad edit block, ask for a retry. +- Force `--no-pretty` if aider detects it is running inside a VSCode terminal. +- [Benchmarked](https://aider.chat/docs/benchmarks.html) at 64.7% for gpt-4/diff (no regression) + + +### v0.9.0 + +- Support for the OpenAI models in [Azure](https://aider.chat/docs/faq.html#azure) +- Added `--show-repo-map` +- Improved output when retrying connections to the OpenAI API +- Redacted api key from `--verbose` output +- Bugfix: recognize and add files in subdirectories mentioned by user or GPT +- [Benchmarked](https://aider.chat/docs/benchmarks.html) at 53.8% for gpt-3.5-turbo/whole (no regression) + +### v0.8.3 + +- Added `--dark-mode` and `--light-mode` to select colors optimized for terminal background +- Install docs link to [NeoVim plugin](https://github.com/joshuavial/aider.nvim) by @joshuavial +- Reorganized the `--help` output +- Bugfix/improvement to whole edit format, may improve coding editing for GPT-3.5 +- Bugfix and tests around git filenames with unicode characters +- Bugfix so that aider throws an exception when OpenAI returns InvalidRequest +- Bugfix/improvement to /add and /drop to recurse selected directories +- Bugfix for live diff output when using "whole" edit format + +### v0.8.2 + +- Disabled general availability of gpt-4 (it's rolling out, not 100% available yet) + +### v0.8.1 + +- Ask to create a git repo if none found, to better track GPT's code changes +- Glob wildcards are now supported in `/add` and `/drop` commands +- Pass `--encoding` into ctags, require it to return `utf-8` +- More robust handling of filepaths, to avoid 8.3 windows filenames +- Added [FAQ](https://aider.chat/docs/faq.html) +- Marked GPT-4 as generally available +- Bugfix for live diffs of whole coder with missing filenames +- Bugfix for chats with multiple files +- Bugfix in editblock coder prompt + +### v0.8.0 + +- [Benchmark comparing code editing in GPT-3.5 and GPT-4](https://aider.chat/docs/benchmarks.html) +- Improved Windows support: + - Fixed bugs related to path separators in Windows + - Added a CI step to run all tests on Windows +- Improved handling of Unicode encoding/decoding + - Explicitly read/write text files with utf-8 encoding by default (mainly benefits Windows) + - Added `--encoding` switch to specify another encoding + - Gracefully handle decoding errors +- Added `--code-theme` switch to control the pygments styling of code blocks (by @kwmiebach) +- Better status messages explaining the reason when ctags is disabled + +### v0.7.2: + +- Fixed a bug to allow aider to edit files that contain triple backtick fences. + +### v0.7.1: + +- Fixed a bug in the display of streaming diffs in GPT-3.5 chats + +### v0.7.0: + +- Graceful handling of context window exhaustion, including helpful tips. +- Added `--message` to give GPT that one instruction and then exit after it replies and any edits are performed. +- Added `--no-stream` to disable streaming GPT responses. + - Non-streaming responses include token usage info. + - Enables display of cost info based on OpenAI advertised pricing. +- Coding competence benchmarking tool against suite of programming tasks based on Execism's python repo. + - https://github.com/exercism/python +- Major refactor in preparation for supporting new function calls api. +- Initial implementation of a function based code editing backend for 3.5. + - Initial experiments show that using functions makes 3.5 less competent at coding. +- Limit automatic retries when GPT returns a malformed edit response. + +### v0.6.2 + +* Support for `gpt-3.5-turbo-16k`, and all OpenAI chat models +* Improved ability to correct when gpt-4 omits leading whitespace in code edits +* Added `--openai-api-base` to support API proxies, etc. + +### v0.5.0 + +- Added support for `gpt-3.5-turbo` and `gpt-4-32k`. +- Added `--map-tokens` to set a token budget for the repo map, along with a PageRank based algorithm for prioritizing which files and identifiers to include in the map. +- Added in-chat command `/tokens` to report on context window token usage. +- Added in-chat command `/clear` to clear the conversation history. + From 0d97f5231661e13d3ed63fec435f1321f28fdb08 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jun 2024 12:18:59 -0700 Subject: [PATCH 23/82] copy --- HISTORY.md | 4 ++-- website/HISTORY.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 8b37848fa..1a982c2bf 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,9 +3,9 @@ ### v0.38.0 -- Use `--vim` for vim keybindings in the chat. +- Use `--vim` for [vim keybindings](https://aider.chat/docs/commands.html#vi) in the chat. - [Add LLM metadata](https://aider.chat/docs/llms/warnings.html#specifying-context-window-size-and-token-costs) via `.aider.models.json` file (by @caseymcc). -- More detailed error messages on token limit errors. +- More detailed [error messages on token limit errors](https://aider.chat/docs/troubleshooting/token-limits.html). - Ensure `--commit --dry-run` does nothing. - Have playwright wait for idle network to better scrape js sites. - Documentation updates, moved into website/ subdir. diff --git a/website/HISTORY.md b/website/HISTORY.md index 24e8cfe9f..dae4f3fcf 100644 --- a/website/HISTORY.md +++ b/website/HISTORY.md @@ -13,9 +13,9 @@ cog.out(text) ### v0.38.0 -- Use `--vim` for vim keybindings in the chat. +- Use `--vim` for [vim keybindings](https://aider.chat/docs/commands.html#vi) in the chat. - [Add LLM metadata](https://aider.chat/docs/llms/warnings.html#specifying-context-window-size-and-token-costs) via `.aider.models.json` file (by @caseymcc). -- More detailed error messages on token limit errors. +- More detailed [error messages on token limit errors](https://aider.chat/docs/troubleshooting/token-limits.html). - Ensure `--commit --dry-run` does nothing. - Have playwright wait for idle network to better scrape js sites. - Documentation updates, moved into website/ subdir. From 48d86a948126344bbc9a61d3361b88740923d053 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jun 2024 20:56:12 -0700 Subject: [PATCH 24/82] updated history; restored YAMLConfigFileParser --- HISTORY.md | 1 + aider/args.py | 1 + 2 files changed, 2 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 1a982c2bf..b942f392b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,7 @@ - Use `--vim` for [vim keybindings](https://aider.chat/docs/commands.html#vi) in the chat. - [Add LLM metadata](https://aider.chat/docs/llms/warnings.html#specifying-context-window-size-and-token-costs) via `.aider.models.json` file (by @caseymcc). - More detailed [error messages on token limit errors](https://aider.chat/docs/troubleshooting/token-limits.html). +- Single line commit messages, without the recent chat messages. - Ensure `--commit --dry-run` does nothing. - Have playwright wait for idle network to better scrape js sites. - Documentation updates, moved into website/ subdir. diff --git a/aider/args.py b/aider/args.py index 52d5253ff..716bca4f8 100644 --- a/aider/args.py +++ b/aider/args.py @@ -17,6 +17,7 @@ def get_parser(default_config_files, git_root): description="aider is GPT powered coding in your terminal", add_config_file_help=True, default_config_files=default_config_files, + config_file_parser_class=configargparse.YAMLConfigFileParser, auto_env_var_prefix="AIDER_", ) group = parser.add_argument_group("Main") From 6a268e2f5a2acf258e8b21939ef26574636dc011 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jun 2024 20:56:24 -0700 Subject: [PATCH 25/82] copy --- website/HISTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/HISTORY.md b/website/HISTORY.md index dae4f3fcf..dc52bc7ff 100644 --- a/website/HISTORY.md +++ b/website/HISTORY.md @@ -16,6 +16,7 @@ cog.out(text) - Use `--vim` for [vim keybindings](https://aider.chat/docs/commands.html#vi) in the chat. - [Add LLM metadata](https://aider.chat/docs/llms/warnings.html#specifying-context-window-size-and-token-costs) via `.aider.models.json` file (by @caseymcc). - More detailed [error messages on token limit errors](https://aider.chat/docs/troubleshooting/token-limits.html). +- Single line commit messages, without the recent chat messages. - Ensure `--commit --dry-run` does nothing. - Have playwright wait for idle network to better scrape js sites. - Documentation updates, moved into website/ subdir. From 9890f9d97ef482369560ca8b7fb37002419d6a85 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jun 2024 20:57:10 -0700 Subject: [PATCH 26/82] version bump to 0.38.0 --- aider/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/__init__.py b/aider/__init__.py index 316f3d226..978180b4c 100644 --- a/aider/__init__.py +++ b/aider/__init__.py @@ -1 +1 @@ -__version__ = "0.37.1-dev" +__version__ = "0.38.0" From ca8672bc90572438133d6d9dce865b06aa698e16 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jun 2024 20:57:50 -0700 Subject: [PATCH 27/82] set version to 0.38.1-dev --- aider/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/__init__.py b/aider/__init__.py index 978180b4c..b56245168 100644 --- a/aider/__init__.py +++ b/aider/__init__.py @@ -1 +1 @@ -__version__ = "0.38.0" +__version__ = "0.38.1-dev" From dda0a4e4abb7b83a05b2fe9c6a85ba6eb36dbfa0 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 17 Jun 2024 09:42:32 -0700 Subject: [PATCH 28/82] Added deepseek coder v2 --- website/_data/edit_leaderboard.yml | 32 +++++++++++++++--------------- website/docs/leaderboards/index.md | 16 +++++++++++++++ website/docs/llms.md | 1 + 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/website/_data/edit_leaderboard.yml b/website/_data/edit_leaderboard.yml index 5a4802184..379832540 100644 --- a/website/_data/edit_leaderboard.yml +++ b/website/_data/edit_leaderboard.yml @@ -44,28 +44,28 @@ seconds_per_case: 23.1 total_cost: 0.0000 -- dirname: 2024-04-29-19-17-28--deepseek-coder-whole - test_cases: 132 - model: deepseek-coder - released: 2024-01-25 +- dirname: 2024-06-17-14-45-54--deepseek-coder2-whole + test_cases: 133 + model: Deepseek Coder V2 edit_format: whole - commit_hash: c07f793-dirty - pass_rate_1: 47.0 - pass_rate_2: 54.5 + commit_hash: ca8672b + pass_rate_1: 63.9 + pass_rate_2: 75.2 percent_cases_well_formed: 100.0 - error_outputs: 0 + error_outputs: 1 num_malformed_responses: 0 - user_asks: 0 - lazy_comments: 2 - syntax_errors: 13 + num_with_malformed_responses: 0 + user_asks: 1 + lazy_comments: 0 + syntax_errors: 1 indentation_errors: 0 exhausted_context_windows: 0 - test_timeouts: 2 + test_timeouts: 7 command: aider --model deepseek/deepseek-coder - date: 2024-04-29 - versions: 0.30.2-dev - seconds_per_case: 26.7 - total_cost: 0.0000 + date: 2024-06-17 + versions: 0.38.1-dev + seconds_per_case: 21.1 + total_cost: 0.0537 - dirname: 2024-05-03-20-47-24--gemini-1.5-pro-diff-fenced test_cases: 133 diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index 8d0f189e7..e137d7927 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -16,6 +16,22 @@ While [aider can connect to almost any LLM](/docs/llms.html), it works best with models that score well on the benchmarks. +## Deepseek Coder V2 takes #1 + +The new +[Deepseek Coder V2](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct) +model is now atop aider's code editing leaderboard! + +It's worth noting that it is only capable of using the "whole" edit format, +which means it returns a modified full copy of each file when it makes changes. +Most other strong models are able to use aider's "diff" editing format, +which allows them to return diffs of edits -- saving time and token costs. +Also, models which use the "whole" edit format can only edit files +which fit within their output token limits. +These output limits are often as low as 4k tokens, even for models +with very large context windows. + + ## Code editing leaderboard [Aider's code editing benchmark](/docs/benchmarks.html#the-benchmark) asks the LLM to edit python source files to complete 133 small coding exercises. This benchmark measures the LLM's coding ability, but also whether it can consistently emit code edits in the format specified in the system prompt. diff --git a/website/docs/llms.md b/website/docs/llms.md index e2cdf7ba6..44291f423 100644 --- a/website/docs/llms.md +++ b/website/docs/llms.md @@ -10,6 +10,7 @@ description: Aider can connect to most LLMs for AI pair programming. [![connecting to many LLMs](/assets/llms.jpg)](https://aider.chat/assets/llms.jpg) + ## Best models {: .no_toc } From cd524702434085391e90c832511bf0bee7b65fc1 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 17 Jun 2024 09:44:31 -0700 Subject: [PATCH 29/82] copy --- website/docs/llms.md | 2 +- website/docs/llms/deepseek.md | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/website/docs/llms.md b/website/docs/llms.md index 44291f423..0b6474cff 100644 --- a/website/docs/llms.md +++ b/website/docs/llms.md @@ -23,10 +23,10 @@ as they are the very best models for editing code. Aider works with a number of **free** API providers: +- The [Deepseek Coder V2](/docs/llms/deepseek.html) model gets the top score on aider's code editing benchmark. Deepseek currently offers 5M free tokens of API usage. - Google's [Gemini 1.5 Pro](/docs/llms/gemini.html) is the most capable free model to use with aider, with code editing capabilities similar to GPT-3.5. - You can use [Llama 3 70B on Groq](/docs/llms/groq.html) which is comparable to GPT-3.5 in code editing performance. -- The [Deepseek Chat v2](/docs/llms/deepseek.html) model work well with aider, better than GPT-3.5. Deepseek currently offers 5M free tokens of API usage. - Cohere also offers free API access to their [Command-R+ model](/docs/llms/cohere.html), which works with aider as a *very basic* coding assistant. ## Local models diff --git a/website/docs/llms/deepseek.md b/website/docs/llms/deepseek.md index af086a99d..de9cfdbf0 100644 --- a/website/docs/llms/deepseek.md +++ b/website/docs/llms/deepseek.md @@ -6,6 +6,7 @@ nav_order: 500 # Deepseek Aider can connect to the Deepseek.com API. +The Deepseek Coder V2 model gets the top score on aider's code editing benchmark. Deepseek appears to grant 5M tokens of free API usage to new accounts. ``` @@ -14,8 +15,8 @@ pip install aider-chat export DEEPSEEK_API_KEY= # Mac/Linux setx DEEPSEEK_API_KEY # Windows -# Use Deepseek Chat v2 -aider --model deepseek/deepseek-chat +# Use Deepseek Coder V2 +aider --model deepseek/deepseek-coder ``` See the [model warnings](warnings.html) From a28c18a257155e8b4c655bfdb3c6686b865961f1 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 17 Jun 2024 09:46:47 -0700 Subject: [PATCH 30/82] copy --- website/docs/leaderboards/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index e137d7927..bdc0423f5 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -19,7 +19,7 @@ it works best with models that score well on the benchmarks. ## Deepseek Coder V2 takes #1 The new -[Deepseek Coder V2](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct) +[Deepseek Coder V2](https://aider.chat/docs/llms/deepseek.html) model is now atop aider's code editing leaderboard! It's worth noting that it is only capable of using the "whole" edit format, From 80da3a3204b6fd06aa6599c6ae2a9ea4c1dd035f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 17 Jun 2024 11:23:28 -0700 Subject: [PATCH 31/82] copy --- website/docs/leaderboards/index.md | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index bdc0423f5..d3d5cf4e9 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -3,7 +3,24 @@ highlight_image: /assets/leaderboard.jpg nav_order: 950 --- -# Aider LLM Leaderboards + +# Deepseek Coder V2 beats GPT-4o, Opus on Aider Code Editing Leaderboard + +The new +[Deepseek Coder V2](https://aider.chat/docs/llms/deepseek.html) +model is now atop aider's code editing leaderboard! + +It's worth noting that it is only capable of using aider's "whole" edit format, +which means it returns a modified full copy of each file when it makes changes. +Most other strong models are able to use aider's "diff" editing format, +which allows them to return diffs of edits -- saving time and token costs. +Also, models which use the "whole" edit format can only edit files +which fit within their output token limits. +These output limits are often as low as 4k tokens, even for models +with very large context windows. + + +## Aider LLM Leaderboards Aider works best with LLMs which are good at *editing* code, not just good at writing code. @@ -16,22 +33,6 @@ While [aider can connect to almost any LLM](/docs/llms.html), it works best with models that score well on the benchmarks. -## Deepseek Coder V2 takes #1 - -The new -[Deepseek Coder V2](https://aider.chat/docs/llms/deepseek.html) -model is now atop aider's code editing leaderboard! - -It's worth noting that it is only capable of using the "whole" edit format, -which means it returns a modified full copy of each file when it makes changes. -Most other strong models are able to use aider's "diff" editing format, -which allows them to return diffs of edits -- saving time and token costs. -Also, models which use the "whole" edit format can only edit files -which fit within their output token limits. -These output limits are often as low as 4k tokens, even for models -with very large context windows. - - ## Code editing leaderboard [Aider's code editing benchmark](/docs/benchmarks.html#the-benchmark) asks the LLM to edit python source files to complete 133 small coding exercises. This benchmark measures the LLM's coding ability, but also whether it can consistently emit code edits in the format specified in the system prompt. From 3e715e66d53bbd50227553145abb7fd56e9ccdb8 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 17 Jun 2024 11:27:16 -0700 Subject: [PATCH 32/82] copy --- website/docs/leaderboards/index.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index d3d5cf4e9..2130e9903 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -10,11 +10,12 @@ The new [Deepseek Coder V2](https://aider.chat/docs/llms/deepseek.html) model is now atop aider's code editing leaderboard! -It's worth noting that it is only capable of using aider's "whole" edit format, -which means it returns a modified full copy of each file when it makes changes. +It's worth noting that Deepseek Coder V2 is only capable of using aider's "whole" edit format. +This means it returns a modified full copy of each file when it makes changes. Most other strong models are able to use aider's "diff" editing format, which allows them to return diffs of edits -- saving time and token costs. -Also, models which use the "whole" edit format can only edit files + +Models which use the "whole" edit format can only edit files which fit within their output token limits. These output limits are often as low as 4k tokens, even for models with very large context windows. From 3dc3ebe25ffc42d46059992eb1e921d473f6b824 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 17 Jun 2024 11:28:32 -0700 Subject: [PATCH 33/82] copy --- website/docs/leaderboards/index.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index 2130e9903..de1221cc2 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -3,8 +3,20 @@ highlight_image: /assets/leaderboard.jpg nav_order: 950 --- +# Aider LLM Leaderboards -# Deepseek Coder V2 beats GPT-4o, Opus on Aider Code Editing Leaderboard +Aider works best with LLMs which are good at *editing* code, not just good at writing +code. +To evaluate an LLM's editing skill, aider uses a pair of benchmarks that +assess a model's ability to consistently follow the system prompt +to successfully edit code. + +The leaderboards below report the results from a number of popular LLMs. +While [aider can connect to almost any LLM](/docs/llms.html), +it works best with models that score well on the benchmarks. + + +## Deepseek Coder V2 beats GPT-4o, Opus The new [Deepseek Coder V2](https://aider.chat/docs/llms/deepseek.html) @@ -21,19 +33,6 @@ These output limits are often as low as 4k tokens, even for models with very large context windows. -## Aider LLM Leaderboards - -Aider works best with LLMs which are good at *editing* code, not just good at writing -code. -To evaluate an LLM's editing skill, aider uses a pair of benchmarks that -assess a model's ability to consistently follow the system prompt -to successfully edit code. - -The leaderboards below report the results from a number of popular LLMs. -While [aider can connect to almost any LLM](/docs/llms.html), -it works best with models that score well on the benchmarks. - - ## Code editing leaderboard [Aider's code editing benchmark](/docs/benchmarks.html#the-benchmark) asks the LLM to edit python source files to complete 133 small coding exercises. This benchmark measures the LLM's coding ability, but also whether it can consistently emit code edits in the format specified in the system prompt. From b8bb33fe25bc55b326ae89f4aa20b604874b4ddc Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 17 Jun 2024 11:44:44 -0700 Subject: [PATCH 34/82] copy --- website/_data/edit_leaderboard.yml | 2 +- website/docs/leaderboards/index.md | 6 +++--- website/docs/llms.md | 2 +- website/docs/llms/deepseek.md | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/website/_data/edit_leaderboard.yml b/website/_data/edit_leaderboard.yml index 379832540..82119110a 100644 --- a/website/_data/edit_leaderboard.yml +++ b/website/_data/edit_leaderboard.yml @@ -46,7 +46,7 @@ - dirname: 2024-06-17-14-45-54--deepseek-coder2-whole test_cases: 133 - model: Deepseek Coder V2 + model: DeepSeek Coder V2 edit_format: whole commit_hash: ca8672b pass_rate_1: 63.9 diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index de1221cc2..4e3a2a59a 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -16,13 +16,13 @@ While [aider can connect to almost any LLM](/docs/llms.html), it works best with models that score well on the benchmarks. -## Deepseek Coder V2 beats GPT-4o, Opus +## DeepSeek Coder V2 beats GPT-4o, Opus The new -[Deepseek Coder V2](https://aider.chat/docs/llms/deepseek.html) +[DeepSeek Coder V2](https://aider.chat/docs/llms/deepseek.html) model is now atop aider's code editing leaderboard! -It's worth noting that Deepseek Coder V2 is only capable of using aider's "whole" edit format. +It's worth noting that DeepSeek Coder V2 is only capable of using aider's "whole" edit format. This means it returns a modified full copy of each file when it makes changes. Most other strong models are able to use aider's "diff" editing format, which allows them to return diffs of edits -- saving time and token costs. diff --git a/website/docs/llms.md b/website/docs/llms.md index 0b6474cff..aecb49f27 100644 --- a/website/docs/llms.md +++ b/website/docs/llms.md @@ -23,7 +23,7 @@ as they are the very best models for editing code. Aider works with a number of **free** API providers: -- The [Deepseek Coder V2](/docs/llms/deepseek.html) model gets the top score on aider's code editing benchmark. Deepseek currently offers 5M free tokens of API usage. +- The [DeepSeek Coder V2](/docs/llms/deepseek.html) model gets the top score on aider's code editing benchmark. DeepSeek currently offers 5M free tokens of API usage. - Google's [Gemini 1.5 Pro](/docs/llms/gemini.html) is the most capable free model to use with aider, with code editing capabilities similar to GPT-3.5. - You can use [Llama 3 70B on Groq](/docs/llms/groq.html) which is comparable to GPT-3.5 in code editing performance. diff --git a/website/docs/llms/deepseek.md b/website/docs/llms/deepseek.md index de9cfdbf0..7ff93ca88 100644 --- a/website/docs/llms/deepseek.md +++ b/website/docs/llms/deepseek.md @@ -3,11 +3,11 @@ parent: Connecting to LLMs nav_order: 500 --- -# Deepseek +# DeepSeek -Aider can connect to the Deepseek.com API. -The Deepseek Coder V2 model gets the top score on aider's code editing benchmark. -Deepseek appears to grant 5M tokens of free API usage to new accounts. +Aider can connect to the DeepSeek.com API. +The DeepSeek Coder V2 model gets the top score on aider's code editing benchmark. +DeepSeek appears to grant 5M tokens of free API usage to new accounts. ``` pip install aider-chat @@ -15,7 +15,7 @@ pip install aider-chat export DEEPSEEK_API_KEY= # Mac/Linux setx DEEPSEEK_API_KEY # Windows -# Use Deepseek Coder V2 +# Use DeepSeek Coder V2 aider --model deepseek/deepseek-coder ``` From 97d103f6a4fc8d2f7f1b25f9fd2953d478be1a56 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 17 Jun 2024 18:39:43 -0700 Subject: [PATCH 35/82] copy --- website/assets/sample.aider.conf.yml | 3 +++ website/docs/aider_conf.md | 3 +++ website/docs/options.md | 17 +++++++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/website/assets/sample.aider.conf.yml b/website/assets/sample.aider.conf.yml index 9a9679c27..896cda62a 100644 --- a/website/assets/sample.aider.conf.yml +++ b/website/assets/sample.aider.conf.yml @@ -13,6 +13,9 @@ ####### # 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: diff --git a/website/docs/aider_conf.md b/website/docs/aider_conf.md index f50c88862..b13208cc7 100644 --- a/website/docs/aider_conf.md +++ b/website/docs/aider_conf.md @@ -41,6 +41,9 @@ 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: diff --git a/website/docs/options.md b/website/docs/options.md index a192227cd..300330894 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -14,12 +14,13 @@ from aider.args import get_md_help cog.out(get_md_help()) ]]]--> ``` -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-metadata-file] [--edit-format] [--weak-model] +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-metadata-file] + [--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] @@ -52,6 +53,10 @@ 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` From 01242b256ce10120ebcaa993bb98cb381113b0cb Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 08:11:53 -0700 Subject: [PATCH 36/82] Set committer name to include "aider" and restore original committer name after commit. --- aider/repo.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aider/repo.py b/aider/repo.py index 666a8f084..ba2ca4f3b 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -91,10 +91,21 @@ class GitRepo: else: cmd += ["-a"] + user_name = self.repo.config_reader().get_value("user", "name") + committer_name = f"{user_name} (aider)" + original_committer_name = os.environ.get("GIT_COMMITTER_NAME") + os.environ["GIT_COMMITTER_NAME"] = committer_name + self.repo.git.commit(cmd) commit_hash = self.repo.head.commit.hexsha[:7] self.io.tool_output(f"Commit {commit_hash} {commit_message}") + # Restore the original GIT_COMMITTER_NAME + if original_committer_name is not None: + os.environ["GIT_COMMITTER_NAME"] = original_committer_name + else: + del os.environ["GIT_COMMITTER_NAME"] + return commit_hash, commit_message def get_rel_repo_dir(self): From 40c28ff7d8beb225ab1610fc99934916a585150f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 08:11:54 -0700 Subject: [PATCH 37/82] aider: Set committer name to include "aider" and restore original committer name after commit. --- aider/repo.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aider/repo.py b/aider/repo.py index ba2ca4f3b..9df9aaf7e 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -82,6 +82,11 @@ class GitRepo: if context: full_commit_message += "\n\n# Aider chat conversation:\n\n" + context + user_name = self.repo.config_reader().get_value("user", "name") + committer_name = f"{user_name} (aider)" + original_committer_name = os.environ.get("GIT_COMMITTER_NAME") + os.environ["GIT_COMMITTER_NAME"] = committer_name + cmd = ["-m", full_commit_message, "--no-verify"] if fnames: fnames = [str(self.abs_root_path(fn)) for fn in fnames] @@ -100,6 +105,12 @@ class GitRepo: commit_hash = self.repo.head.commit.hexsha[:7] self.io.tool_output(f"Commit {commit_hash} {commit_message}") + # Restore the original GIT_COMMITTER_NAME + if original_committer_name is not None: + os.environ["GIT_COMMITTER_NAME"] = original_committer_name + else: + del os.environ["GIT_COMMITTER_NAME"] + # Restore the original GIT_COMMITTER_NAME if original_committer_name is not None: os.environ["GIT_COMMITTER_NAME"] = original_committer_name From 5a5783304ee4273e34e2dd0803aa9781e3cd437e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 08:12:30 -0700 Subject: [PATCH 38/82] aider: Added a test for committing with a custom committer name. --- aider/tests/test_repo.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/aider/tests/test_repo.py b/aider/tests/test_repo.py index bdee89c0c..70f715fb4 100644 --- a/aider/tests/test_repo.py +++ b/aider/tests/test_repo.py @@ -137,7 +137,34 @@ class TestRepo(unittest.TestCase): # Assert that the returned message is the expected one self.assertEqual(result, 'a good "commit message"') - def test_get_tracked_files(self): + @patch("aider.repo.simple_send_with_retries") + def test_commit_with_custom_committer_name(self, mock_send): + mock_send.return_value = '"a good commit message"' + + with GitTemporaryDirectory(): + # new repo + raw_repo = git.Repo() + raw_repo.config_writer().set_value("user", "name", "Test User").release() + + # add a file and commit it + fname = Path("file.txt") + fname.touch() + raw_repo.git.add(str(fname)) + raw_repo.git.commit("-m", "initial commit") + + git_repo = GitRepo(InputOutput(), None, None) + + # commit a change + fname.write_text("new content") + git_repo.commit(fnames=[str(fname)]) + + # check the committer name + commit = raw_repo.head.commit + self.assertEqual(commit.committer.name, "Test User (aider)") + + # check that the original committer name is restored + original_committer_name = os.environ.get("GIT_COMMITTER_NAME") + self.assertIsNone(original_committer_name) # Create a temporary directory tempdir = Path(tempfile.mkdtemp()) From 0cc00f2a1e66227a674e051d2e048c58eb29fd81 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 08:15:02 -0700 Subject: [PATCH 39/82] Removed setting and restoring GIT_COMMITTER_NAME in GitRepo class. --- aider/repo.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/aider/repo.py b/aider/repo.py index 9df9aaf7e..ba2ca4f3b 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -82,11 +82,6 @@ class GitRepo: if context: full_commit_message += "\n\n# Aider chat conversation:\n\n" + context - user_name = self.repo.config_reader().get_value("user", "name") - committer_name = f"{user_name} (aider)" - original_committer_name = os.environ.get("GIT_COMMITTER_NAME") - os.environ["GIT_COMMITTER_NAME"] = committer_name - cmd = ["-m", full_commit_message, "--no-verify"] if fnames: fnames = [str(self.abs_root_path(fn)) for fn in fnames] @@ -105,12 +100,6 @@ class GitRepo: commit_hash = self.repo.head.commit.hexsha[:7] self.io.tool_output(f"Commit {commit_hash} {commit_message}") - # Restore the original GIT_COMMITTER_NAME - if original_committer_name is not None: - os.environ["GIT_COMMITTER_NAME"] = original_committer_name - else: - del os.environ["GIT_COMMITTER_NAME"] - # Restore the original GIT_COMMITTER_NAME if original_committer_name is not None: os.environ["GIT_COMMITTER_NAME"] = original_committer_name From 5a3627de6e01f6f026a0685ce4f59c3a1057af74 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 08:37:13 -0700 Subject: [PATCH 40/82] finish removing aider: prefix --- aider/coders/base_coder.py | 5 ++--- aider/gui.py | 3 --- aider/repo.py | 23 +++++++++++------------ aider/tests/test_repo.py | 6 ++++-- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 255451e28..b529636ca 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import datetime import hashlib import json import os @@ -28,7 +27,7 @@ from aider.mdstream import MarkdownStream from aider.repo import GitRepo from aider.repomap import RepoMap from aider.sendchat import send_with_retries -from aider.utils import is_image_file, format_messages, format_content +from aider.utils import format_content, format_messages, is_image_file from ..dump import dump # noqa: F401 @@ -1385,7 +1384,7 @@ class Coder: def auto_commit(self, edited): # context = self.get_context_from_history(self.cur_messages) - res = self.repo.commit(fnames=edited, prefix="aider: ") + res = self.repo.commit(fnames=edited, aider_edits=True) if res: commit_hash, commit_message = res self.last_aider_commit_hash = commit_hash diff --git a/aider/gui.py b/aider/gui.py index 16a13a004..b2239b162 100755 --- a/aider/gui.py +++ b/aider/gui.py @@ -110,9 +110,6 @@ class GUI: show_undo = False res = "" if commit_hash: - prefix = "aider: " - if commit_message.startswith(prefix): - commit_message = commit_message[len(prefix) :] res += f"Commit `{commit_hash}`: {commit_message} \n" if commit_hash == self.coder.last_aider_commit_hash: show_undo = True diff --git a/aider/repo.py b/aider/repo.py index ba2ca4f3b..214d2c6d9 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -59,7 +59,7 @@ class GitRepo: if aider_ignore_file: self.aider_ignore_file = Path(aider_ignore_file) - def commit(self, fnames=None, context=None, prefix=None, message=None): + def commit(self, fnames=None, context=None, message=None, aider_edits=False): if not fnames and not self.repo.is_dirty(): return @@ -75,9 +75,6 @@ class GitRepo: if not commit_message: commit_message = "(no commit message provided)" - if prefix: - commit_message = prefix + commit_message - full_commit_message = commit_message if context: full_commit_message += "\n\n# Aider chat conversation:\n\n" + context @@ -91,20 +88,22 @@ class GitRepo: else: cmd += ["-a"] - user_name = self.repo.config_reader().get_value("user", "name") - committer_name = f"{user_name} (aider)" - original_committer_name = os.environ.get("GIT_COMMITTER_NAME") - os.environ["GIT_COMMITTER_NAME"] = committer_name + if aider_edits: + user_name = self.repo.config_reader().get_value("user", "name") + committer_name = f"{user_name} (aider)" + original_committer_name = os.environ.get("GIT_COMMITTER_NAME") + os.environ["GIT_COMMITTER_NAME"] = committer_name self.repo.git.commit(cmd) commit_hash = self.repo.head.commit.hexsha[:7] self.io.tool_output(f"Commit {commit_hash} {commit_message}") # Restore the original GIT_COMMITTER_NAME - if original_committer_name is not None: - os.environ["GIT_COMMITTER_NAME"] = original_committer_name - else: - del os.environ["GIT_COMMITTER_NAME"] + if aider_edits: + if original_committer_name is not None: + os.environ["GIT_COMMITTER_NAME"] = original_committer_name + else: + del os.environ["GIT_COMMITTER_NAME"] return commit_hash, commit_message diff --git a/aider/tests/test_repo.py b/aider/tests/test_repo.py index 70f715fb4..961fe8ee9 100644 --- a/aider/tests/test_repo.py +++ b/aider/tests/test_repo.py @@ -137,7 +137,7 @@ class TestRepo(unittest.TestCase): # Assert that the returned message is the expected one self.assertEqual(result, 'a good "commit message"') - @patch("aider.repo.simple_send_with_retries") + @patch("aider.repo.GitRepo.get_commit_message") def test_commit_with_custom_committer_name(self, mock_send): mock_send.return_value = '"a good commit message"' @@ -156,7 +156,7 @@ class TestRepo(unittest.TestCase): # commit a change fname.write_text("new content") - git_repo.commit(fnames=[str(fname)]) + git_repo.commit(fnames=[str(fname)], aider_edits=True) # check the committer name commit = raw_repo.head.commit @@ -165,6 +165,8 @@ class TestRepo(unittest.TestCase): # check that the original committer name is restored original_committer_name = os.environ.get("GIT_COMMITTER_NAME") self.assertIsNone(original_committer_name) + + def test_get_tracked_files(self): # Create a temporary directory tempdir = Path(tempfile.mkdtemp()) From 249109ba9a14aef66887267191092d3e8e58d8a4 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Fri, 31 May 2024 16:16:35 -0400 Subject: [PATCH 41/82] All AIDER_* environment vars may now be placed within .env --- .pre-commit-config.yaml | 2 +- aider/args.py | 20 +++++++++- aider/main.py | 13 ++++--- aider/tests/test_main.py | 80 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95b449726..9222c3e25 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ repos: - - repo: https://github.com/pycqa/isort + - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: - id: isort diff --git a/aider/args.py b/aider/args.py index 070905bb4..4b0b1bccb 100644 --- a/aider/args.py +++ b/aider/args.py @@ -12,6 +12,21 @@ from aider.args_formatter import MarkdownHelpFormatter, YamlHelpFormatter from .dump import dump # noqa: F401 +def default_env_file(git_root): + return os.path.join(git_root, ".env") if git_root else ".env" + + +def get_preparser(git_root): + parser = configargparse.ArgumentParser(add_help=False) + parser.add_argument( + "--env-file", + metavar="ENV_FILE", + default=default_env_file(git_root), + help="Specify the .env file to load (default: .env in git root)", + ) + return parser + + def get_parser(default_config_files, git_root): parser = configargparse.ArgumentParser( description="aider is GPT powered coding in your terminal", @@ -184,11 +199,12 @@ def get_parser(default_config_files, git_root): " max_chat_history_tokens." ), ) - default_env_file = os.path.join(git_root, ".env") if git_root else ".env" + # This is a duplicate of the argument in the preparser and is a no-op by this time of + # argument parsing, but it's here so that the help is displayed as expected. group.add_argument( "--env-file", metavar="ENV_FILE", - default=default_env_file, + default=default_env_file(git_root), help="Specify the .env file to load (default: .env in git root)", ) diff --git a/aider/main.py b/aider/main.py index c4d211fc7..f1da79066 100644 --- a/aider/main.py +++ b/aider/main.py @@ -10,7 +10,7 @@ from prompt_toolkit.enums import EditingMode from streamlit.web import cli from aider import __version__, models, utils -from aider.args import get_parser +from aider.args import get_parser, get_preparser from aider.coders import Coder from aider.commands import SwitchModel from aider.io import InputOutput @@ -129,7 +129,7 @@ def format_settings(parser, args): for arg, val in sorted(vars(args).items()): if val: val = scrub_sensitive_info(args, str(val)) - show += f" - {arg}: {val}\n" + show += f" - {arg}: {val}\n" # noqa: E221 return show @@ -225,6 +225,12 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F default_config_files.append(Path.home() / conf_fname) # homedir default_config_files = list(map(str, default_config_files)) + preparser = get_preparser(git_root) + pre_args, _ = preparser.parse_known_args() + + # Load the .env file specified in the arguments + load_dotenv(pre_args.env_file) + parser = get_parser(default_config_files, git_root) args = parser.parse_args(argv) @@ -320,9 +326,6 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F cmd_line = scrub_sensitive_info(args, cmd_line) io.tool_output(cmd_line, log_only=True) - if args.env_file: - load_dotenv(args.env_file) - if args.anthropic_api_key: os.environ["ANTHROPIC_API_KEY"] = args.anthropic_api_key diff --git a/aider/tests/test_main.py b/aider/tests/test_main.py index d319a78dd..001551a28 100644 --- a/aider/tests/test_main.py +++ b/aider/tests/test_main.py @@ -237,3 +237,83 @@ class TestMain(TestCase): main(["--message", test_message]) args, kwargs = MockInputOutput.call_args self.assertEqual(args[1], None) + + def test_dark_mode_sets_code_theme(self): + # Mock Coder.create to capture the configuration + with patch("aider.coders.Coder.create") as MockCoder: + main(["--dark-mode", "--no-git"], input=DummyInput(), output=DummyOutput()) + # Ensure Coder.create was called + MockCoder.assert_called_once() + # Check if the code_theme setting is for dark mode + _, kwargs = MockCoder.call_args + self.assertEqual(kwargs["code_theme"], "monokai") + + def test_light_mode_sets_code_theme(self): + # Mock Coder.create to capture the configuration + with patch("aider.coders.Coder.create") as MockCoder: + main(["--light-mode", "--no-git"], input=DummyInput(), output=DummyOutput()) + # Ensure Coder.create was called + MockCoder.assert_called_once() + # Check if the code_theme setting is for light mode + _, kwargs = MockCoder.call_args + self.assertEqual(kwargs["code_theme"], "default") + + def test_env_file_flag_read(self): + # Create a temporary .env file + env_file_path = Path(self.tempdir) / ".env.test" + env_content = "TEST_ENV_VAR=12345" + env_file_path.write_text(env_content) + + # Run the main function with the --env-file flag + main( + ["--env-file", str(env_file_path), "--no-git"], input=DummyInput(), output=DummyOutput() + ) + + # Check if the environment variable is loaded + self.assertEqual(os.getenv("TEST_ENV_VAR"), "12345") + + def test_default_env_file_read(self): + # Create a temporary .env file + env_file_path = Path(self.tempdir) / ".env" + env_content = "TEST_ENV_VAR=12345" + env_file_path.write_text(env_content) + + # Run the main function with the --env-file flag + main(["--no-git"], input=DummyInput(), output=DummyOutput()) + + # Check if the environment variable is loaded + self.assertEqual(os.getenv("TEST_ENV_VAR"), "12345") + + def test_env_file_flag_sets_automatic_variable(self): + # Create a temporary .env file with custom settings + env_file_path = Path(self.tempdir) / ".env.test" + env_content = "AIDER_DARK_MODE=True" + env_file_path.write_text(env_content) + + # Mock the InputOutput to capture the configuration + with patch("aider.coders.Coder.create") as MockCoder: + main( + ["--env-file", str(env_file_path), "--no-git"], + input=DummyInput(), + output=DummyOutput(), + ) + # Ensure Coder.create was called + MockCoder.assert_called_once() + # Check if the color settings are for dark mode + _, kwargs = MockCoder.call_args + self.assertEqual(kwargs["code_theme"], "monokai") + + def test_default_env_file_sets_automatic_variable(self): + # Create a default .env file in the temporary directory + env_file_path = Path(self.tempdir) / ".env" + env_content = "AIDER_DARK_MODE=True" + env_file_path.write_text(env_content) + + # Mock the InputOutput to capture the configuration + with patch("aider.coders.Coder.create") as MockCoder: + main(["--no-git"], input=DummyInput(), output=DummyOutput()) + # Ensure Coder.create was called + MockCoder.assert_called_once() + # Check if the color settings are for dark mode + _, kwargs = MockCoder.call_args + self.assertEqual(kwargs["code_theme"], "monokai") From 75ec0f626600690675a2275700c9458a49a05265 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Sat, 1 Jun 2024 10:51:38 -0400 Subject: [PATCH 42/82] Added tests to ensure boolean values in .env file are properly handled. --- aider/main.py | 2 +- aider/tests/test_main.py | 69 ++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 42 deletions(-) diff --git a/aider/main.py b/aider/main.py index f1da79066..8799acd6c 100644 --- a/aider/main.py +++ b/aider/main.py @@ -226,7 +226,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F default_config_files = list(map(str, default_config_files)) preparser = get_preparser(git_root) - pre_args, _ = preparser.parse_known_args() + pre_args, _ = preparser.parse_known_args(argv) # Load the .env file specified in the arguments load_dotenv(pre_args.env_file) diff --git a/aider/tests/test_main.py b/aider/tests/test_main.py index 001551a28..7eebe1351 100644 --- a/aider/tests/test_main.py +++ b/aider/tests/test_main.py @@ -1,5 +1,4 @@ import os -import shutil import subprocess import tempfile from pathlib import Path @@ -18,14 +17,18 @@ from aider.utils import GitTemporaryDirectory, make_repo class TestMain(TestCase): def setUp(self): + self.original_env = os.environ.copy() os.environ["OPENAI_API_KEY"] = "deadbeef" self.original_cwd = os.getcwd() - self.tempdir = tempfile.mkdtemp() + self.tempdir_obj = tempfile.TemporaryDirectory() + self.tempdir = self.tempdir_obj.name os.chdir(self.tempdir) def tearDown(self): os.chdir(self.original_cwd) - shutil.rmtree(self.tempdir, ignore_errors=True) + self.tempdir_obj.cleanup() + os.environ.clear() + os.environ.update(self.original_env) def test_main_with_empty_dir_no_files_on_command(self): main(["--no-git"], input=DummyInput(), output=DummyOutput()) @@ -258,58 +261,26 @@ class TestMain(TestCase): _, kwargs = MockCoder.call_args self.assertEqual(kwargs["code_theme"], "default") - def test_env_file_flag_read(self): - # Create a temporary .env file - env_file_path = Path(self.tempdir) / ".env.test" - env_content = "TEST_ENV_VAR=12345" - env_file_path.write_text(env_content) - - # Run the main function with the --env-file flag - main( - ["--env-file", str(env_file_path), "--no-git"], input=DummyInput(), output=DummyOutput() - ) - - # Check if the environment variable is loaded - self.assertEqual(os.getenv("TEST_ENV_VAR"), "12345") - - def test_default_env_file_read(self): - # Create a temporary .env file - env_file_path = Path(self.tempdir) / ".env" - env_content = "TEST_ENV_VAR=12345" - env_file_path.write_text(env_content) - - # Run the main function with the --env-file flag - main(["--no-git"], input=DummyInput(), output=DummyOutput()) - - # Check if the environment variable is loaded - self.assertEqual(os.getenv("TEST_ENV_VAR"), "12345") + def create_env_file(self, file_name, content): + env_file_path = Path(self.tempdir) / file_name + env_file_path.write_text(content) + return env_file_path def test_env_file_flag_sets_automatic_variable(self): - # Create a temporary .env file with custom settings - env_file_path = Path(self.tempdir) / ".env.test" - env_content = "AIDER_DARK_MODE=True" - env_file_path.write_text(env_content) - - # Mock the InputOutput to capture the configuration + env_file_path = self.create_env_file(".env.test", "AIDER_DARK_MODE=True") with patch("aider.coders.Coder.create") as MockCoder: main( ["--env-file", str(env_file_path), "--no-git"], input=DummyInput(), output=DummyOutput(), ) - # Ensure Coder.create was called MockCoder.assert_called_once() # Check if the color settings are for dark mode _, kwargs = MockCoder.call_args self.assertEqual(kwargs["code_theme"], "monokai") def test_default_env_file_sets_automatic_variable(self): - # Create a default .env file in the temporary directory - env_file_path = Path(self.tempdir) / ".env" - env_content = "AIDER_DARK_MODE=True" - env_file_path.write_text(env_content) - - # Mock the InputOutput to capture the configuration + self.create_env_file(".env", "AIDER_DARK_MODE=True") with patch("aider.coders.Coder.create") as MockCoder: main(["--no-git"], input=DummyInput(), output=DummyOutput()) # Ensure Coder.create was called @@ -317,3 +288,19 @@ class TestMain(TestCase): # Check if the color settings are for dark mode _, kwargs = MockCoder.call_args self.assertEqual(kwargs["code_theme"], "monokai") + + def test_false_vals_in_env_file(self): + self.create_env_file(".env", "AIDER_SHOW_DIFFS=off") + with patch("aider.coders.Coder.create") as MockCoder: + main(["--no-git"], input=DummyInput(), output=DummyOutput()) + MockCoder.assert_called_once() + _, kwargs = MockCoder.call_args + self.assertEqual(kwargs["show_diffs"], False) + + def test_true_vals_in_env_file(self): + self.create_env_file(".env", "AIDER_SHOW_DIFFS=on") + with patch("aider.coders.Coder.create") as MockCoder: + main(["--no-git"], input=DummyInput(), output=DummyOutput()) + MockCoder.assert_called_once() + _, kwargs = MockCoder.call_args + self.assertEqual(kwargs["show_diffs"], True) From f4e4e3af877fcc781c21a05abdf485211683aac6 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Sat, 1 Jun 2024 11:50:43 -0400 Subject: [PATCH 43/82] Added check to ensure verbose output contains environment variables set with .env --- aider/main.py | 6 ++++++ aider/tests/test_main.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/aider/main.py b/aider/main.py index 8799acd6c..ac8281d4d 100644 --- a/aider/main.py +++ b/aider/main.py @@ -124,6 +124,12 @@ def check_gitignore(git_root, io, ask=True): def format_settings(parser, args): show = scrub_sensitive_info(args, parser.format_values()) + # clean up the headings for consistency w/ new lines + heading_env = "Environment Variables:" + heading_defaults = "Defaults:" + if heading_env in show: + show = show.replace(heading_env, "\n" + heading_env) + show = show.replace(heading_defaults, "\n" + heading_defaults) show += "\n" show += "Option settings:\n" for arg, val in sorted(vars(args).items()): diff --git a/aider/tests/test_main.py b/aider/tests/test_main.py index 7eebe1351..83e0d1234 100644 --- a/aider/tests/test_main.py +++ b/aider/tests/test_main.py @@ -1,6 +1,7 @@ import os import subprocess import tempfile +from io import StringIO from pathlib import Path from unittest import TestCase from unittest.mock import MagicMock, patch @@ -304,3 +305,18 @@ class TestMain(TestCase): MockCoder.assert_called_once() _, kwargs = MockCoder.call_args self.assertEqual(kwargs["show_diffs"], True) + + def test_verbose_mode_lists_env_vars(self): + self.create_env_file(".env", "AIDER_DARK_MODE=on") + with patch("sys.stdout", new_callable=StringIO) as mock_stdout: + main(["--no-git", "--verbose"], input=DummyInput(), output=DummyOutput()) + output = mock_stdout.getvalue() + relevant_output = "\n".join( + line + for line in output.splitlines() + if "AIDER_DARK_MODE" in line or "dark_mode" in line + ) # this bit just helps failing assertions to be easier to read + self.assertIn("AIDER_DARK_MODE", relevant_output) + self.assertIn("dark_mode", relevant_output) + self.assertRegex(relevant_output, r"AIDER_DARK_MODE:\s+on") + self.assertRegex(relevant_output, r"dark_mode:\s+True") From dd6a7964b6f34e4bfa63d172b48c38fce0270b36 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Tue, 18 Jun 2024 11:39:26 -0400 Subject: [PATCH 44/82] tempdirs in test_main now cleanup without windows errors --- aider/tests/test_main.py | 6 +++--- aider/utils.py | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/aider/tests/test_main.py b/aider/tests/test_main.py index 83e0d1234..b576d3754 100644 --- a/aider/tests/test_main.py +++ b/aider/tests/test_main.py @@ -13,7 +13,7 @@ from prompt_toolkit.output import DummyOutput from aider.dump import dump # noqa: F401 from aider.io import InputOutput from aider.main import check_gitignore, main, setup_git -from aider.utils import GitTemporaryDirectory, make_repo +from aider.utils import GitTemporaryDirectory, IgnorantTemporaryDirectory, make_repo class TestMain(TestCase): @@ -21,7 +21,7 @@ class TestMain(TestCase): self.original_env = os.environ.copy() os.environ["OPENAI_API_KEY"] = "deadbeef" self.original_cwd = os.getcwd() - self.tempdir_obj = tempfile.TemporaryDirectory() + self.tempdir_obj = IgnorantTemporaryDirectory() self.tempdir = self.tempdir_obj.name os.chdir(self.tempdir) @@ -34,7 +34,7 @@ class TestMain(TestCase): def test_main_with_empty_dir_no_files_on_command(self): main(["--no-git"], input=DummyInput(), output=DummyOutput()) - def test_main_with_empty_dir_new_file(self): + def test_main_with_emptqy_dir_new_file(self): main(["foo.txt", "--yes", "--no-git"], input=DummyInput(), output=DummyOutput()) self.assertTrue(os.path.exists("foo.txt")) diff --git a/aider/utils.py b/aider/utils.py index 7636eb119..6d097fbe7 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -17,11 +17,17 @@ class IgnorantTemporaryDirectory: return self.temp_dir.__enter__() def __exit__(self, exc_type, exc_val, exc_tb): + self.cleanup() + + def cleanup(self): try: - self.temp_dir.__exit__(exc_type, exc_val, exc_tb) + self.temp_dir.cleanup() except (OSError, PermissionError): pass # Ignore errors (Windows) + def __getattr__(self, item): + return getattr(self.temp_dir, item) + class ChdirTemporaryDirectory(IgnorantTemporaryDirectory): def __init__(self): From 705bb64580885c8d91b69dd9f12bd3c0fd58c9fa Mon Sep 17 00:00:00 2001 From: John-Mason Shackelford <160164118+jpshack-at-palomar@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:10:57 -0400 Subject: [PATCH 45/82] Update windows-tests.yml --- .github/workflows/windows-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index de4520aa6..c5b2696a6 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -13,6 +13,7 @@ on: - README.md branches: - main + - issue-630 jobs: build: From b4291aef377d5e596e3cb1f830914d5fa98368b2 Mon Sep 17 00:00:00 2001 From: John-Mason Shackelford <160164118+jpshack-at-palomar@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:13:36 -0400 Subject: [PATCH 46/82] Update windows-tests.yml --- .github/workflows/windows-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index c5b2696a6..de4520aa6 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -13,7 +13,6 @@ on: - README.md branches: - main - - issue-630 jobs: build: From 39f10aefe0079a9e5e7ad7a33f40c5f8a680628e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 10:05:10 -0700 Subject: [PATCH 47/82] Finished removing reliance on aider: --- aider/commands.py | 2 +- aider/tests/test_commands.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index f6b0c3cba..58fa7d6c6 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -332,7 +332,7 @@ class Commands: last_commit = self.coder.repo.repo.head.commit if ( - not last_commit.message.startswith("aider:") + "(aider)" not in last_commit.committer.name or 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.") diff --git a/aider/tests/test_commands.py b/aider/tests/test_commands.py index 8cc67b6d8..2fa84817b 100644 --- a/aider/tests/test_commands.py +++ b/aider/tests/test_commands.py @@ -523,16 +523,20 @@ class TestCommands(TestCase): other_path.write_text("other content") repo.git.add(str(other_path)) + os.environ["GIT_COMMITTER_NAME"] = "Foo (aider)" + # Create and commit a file filename = "test_file.txt" file_path = Path(repo_dir) / filename file_path.write_text("first content") repo.git.add(filename) - repo.git.commit("-m", "aider: first commit") + repo.git.commit("-m", "first commit") file_path.write_text("second content") repo.git.add(filename) - repo.git.commit("-m", "aider: second commit") + repo.git.commit("-m", "second commit") + + del os.environ["GIT_COMMITTER_NAME"] # Store the commit hash last_commit_hash = repo.head.commit.hexsha[:7] From 9e228670a23ba5c338f7553a349bc2b75dac30f7 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 11:18:52 -0700 Subject: [PATCH 48/82] append (aider) to author if aider wrote the code --- aider/commands.py | 2 +- aider/repo.py | 23 ++++++++++++++++------- aider/tests/test_commands.py | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 58fa7d6c6..00189fecd 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -332,7 +332,7 @@ class Commands: last_commit = self.coder.repo.repo.head.commit if ( - "(aider)" not in last_commit.committer.name + not last_commit.author.name.endswith(" (aider)") or 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.") diff --git a/aider/repo.py b/aider/repo.py index 214d2c6d9..38f5ef8f5 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -88,11 +88,15 @@ class GitRepo: else: cmd += ["-a"] + original_user_name = self.repo.config_reader().get_value("user", "name") + original_committer_name_env = os.environ.get("GIT_COMMITTER_NAME") + + committer_name = f"{original_user_name} (aider)" + os.environ["GIT_COMMITTER_NAME"] = committer_name + if aider_edits: - user_name = self.repo.config_reader().get_value("user", "name") - committer_name = f"{user_name} (aider)" - original_committer_name = os.environ.get("GIT_COMMITTER_NAME") - os.environ["GIT_COMMITTER_NAME"] = committer_name + original_auther_name_env = os.environ.get("GIT_AUTHOR_NAME") + os.environ["GIT_AUTHOR_NAME"] = committer_name self.repo.git.commit(cmd) commit_hash = self.repo.head.commit.hexsha[:7] @@ -100,10 +104,15 @@ class GitRepo: # Restore the original GIT_COMMITTER_NAME if aider_edits: - if original_committer_name is not None: - os.environ["GIT_COMMITTER_NAME"] = original_committer_name + if original_auther_name_env is not None: + os.environ["GIT_AUTHOR_NAME"] = original_auther_name_env else: - del os.environ["GIT_COMMITTER_NAME"] + del os.environ["GIT_AUTHOR_NAME"] + + if original_committer_name_env is not None: + os.environ["GIT_COMMITTER_NAME"] = original_committer_name_env + else: + del os.environ["GIT_COMMITTER_NAME"] return commit_hash, commit_message diff --git a/aider/tests/test_commands.py b/aider/tests/test_commands.py index 2fa84817b..f6629f481 100644 --- a/aider/tests/test_commands.py +++ b/aider/tests/test_commands.py @@ -523,7 +523,7 @@ class TestCommands(TestCase): other_path.write_text("other content") repo.git.add(str(other_path)) - os.environ["GIT_COMMITTER_NAME"] = "Foo (aider)" + os.environ["GIT_AUTHOR_NAME"] = "Foo (aider)" # Create and commit a file filename = "test_file.txt" @@ -536,7 +536,7 @@ class TestCommands(TestCase): repo.git.add(filename) repo.git.commit("-m", "second commit") - del os.environ["GIT_COMMITTER_NAME"] + del os.environ["GIT_AUTHOR_NAME"] # Store the commit hash last_commit_hash = repo.head.commit.hexsha[:7] From aa3dbac94c67a98371715093b2945f783d642975 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 11:23:34 -0700 Subject: [PATCH 49/82] updated git docs --- website/docs/git.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/website/docs/git.md b/website/docs/git.md index b25418b93..f9c8bb5ad 100644 --- a/website/docs/git.md +++ b/website/docs/git.md @@ -14,14 +14,21 @@ Aider is tightly integrated with git, which makes it easy to: Aider specifically uses git in these ways: - - It asks to create a git repo if you launch it in a directory without one. - - Whenever aider edits a file, it commits those changes with a descriptive commit message. This makes it easy to undo or review aider's changes. - - Aider takes special care before editing files that already have uncommitted changes (dirty files). Aider will first commit any preexisting changes with a descriptive commit message. This keeps your edits separate from aider's edits, and makes sure you never lose your work if aider makes an inappropriate change. +- It asks to create a git repo if you launch it in a directory without one. +- Whenever aider edits a file, it commits those changes with a descriptive commit message. This makes it easy to undo or review aider's changes. +These commits will have "(aider)" appended to their git author and git committer metadata. +- Aider takes special care before editing files that already have uncommitted changes (dirty files). Aider will first commit any preexisting changes with a descriptive commit message. +This keeps your edits separate from aider's edits, and makes sure you never lose your work if aider makes an inappropriate change. +These commits will have "(aider)" appended to their git committer metadata. + +## In-chat commands Aider also allows you to use in-chat commands to `/diff` or `/undo` the last change. To do more complex management of your git history, you cat use raw `git` commands, either by using `/git` within the chat, or with standard git tools outside of aider. +## Disabling git integration + While it is not recommended, you can disable aider's use of git in a few ways: - `--no-auto-commits` will stop aider from git committing each of its changes. From fed0bf55c2e4c19e4b855a14d74cb88be7435b9d Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 11:34:45 -0700 Subject: [PATCH 50/82] Add support for generating dotenv help text. --- aider/args.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/aider/args.py b/aider/args.py index 4b0b1bccb..c6b44acc6 100644 --- a/aider/args.py +++ b/aider/args.py @@ -7,7 +7,7 @@ import sys import configargparse from aider import __version__, models -from aider.args_formatter import MarkdownHelpFormatter, YamlHelpFormatter +from aider.args_formatter import MarkdownHelpFormatter, YamlHelpFormatter#, DotEnvFormatter from .dump import dump # noqa: F401 @@ -516,16 +516,31 @@ def get_sample_yaml(): return argparse.ArgumentParser.format_help(parser) return parser.format_help() +def get_sample_dotenv(): + os.environ["COLUMNS"] = "120" + sys.argv = ["aider"] + parser = get_parser([], None) + + # This instantiates all the action.env_var values + parser.parse_known_args() + + parser.formatter_class = DotEnvFormatter + + return argparse.ArgumentParser.format_help(parser) + return parser.format_help() def main(): arg = sys.argv[1] if len(sys.argv[1:]) else None if arg == "md": print(get_md_help()) + elif arg == "dotenv": + print(get_sample_dotenv()) else: print(get_sample_yaml()) + if __name__ == "__main__": status = main() sys.exit(status) From 289ab516e912ca9862067877c58b53a67ac70c5d Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 18 Jun 2024 11:34:46 -0700 Subject: [PATCH 51/82] Added DotEnvFormatter class for formatting .env help text in argparse. --- aider/args.py | 2 +- aider/args_formatter.py | 74 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/aider/args.py b/aider/args.py index c6b44acc6..98b612905 100644 --- a/aider/args.py +++ b/aider/args.py @@ -7,7 +7,7 @@ import sys import configargparse from aider import __version__, models -from aider.args_formatter import MarkdownHelpFormatter, YamlHelpFormatter#, DotEnvFormatter +from aider.args_formatter import MarkdownHelpFormatter, YamlHelpFormatter, DotEnvFormatter from .dump import dump # noqa: F401 diff --git a/aider/args_formatter.py b/aider/args_formatter.py index 2503cd007..1c898cd90 100644 --- a/aider/args_formatter.py +++ b/aider/args_formatter.py @@ -3,6 +3,80 @@ import argparse from .dump import dump # noqa: F401 +class DotEnvFormatter(argparse.HelpFormatter): + def start_section(self, heading): + res = "\n\n" + res += "#" * (len(heading) + 3) + res += f"\n# {heading}" + super().start_section(res) + + def _format_usage(self, usage, actions, groups, prefix): + return "" + + def _format_text(self, text): + return """ +########################################################## +# Sample .env +# This file lists *all* the valid configuration entries. +# Place in your home dir, or at the root of your git repo. +########################################################## + +""" + + def _format_action(self, action): + if not action.option_strings: + return "" + + parts = [""] + + metavar = action.metavar + if not metavar and isinstance(action, argparse._StoreAction): + metavar = "VALUE" + + default = action.default + if default == argparse.SUPPRESS: + default = "" + elif isinstance(default, str): + pass + elif isinstance(default, list) and not default: + default = "" + elif action.default is not None: + default = "true" if default else "false" + else: + default = "" + + if action.help: + parts.append(f"## {action.help}") + + for switch in action.option_strings: + if switch.startswith("--"): + break + switch = switch.lstrip("-") + + if isinstance(action, argparse._StoreTrueAction): + default = False + elif isinstance(action, argparse._StoreConstAction): + default = False + + if default is False: + default = "false" + if default is True: + default = "true" + + if default: + parts.append(f"{switch}={default}\n") + else: + parts.append(f"{switch}=\n") + + return "\n".join(parts) + "\n" + + def _format_action_invocation(self, action): + return "" + + def _format_args(self, action, default_metavar): + return "" + + class YamlHelpFormatter(argparse.HelpFormatter): def start_section(self, heading): res = "\n\n" From 3c210286ba2bda0fd89371cdd94b3aa83cd5f742 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 18 Jun 2024 11:35:54 -0700 Subject: [PATCH 52/82] Add environment variable information to argparse help text. --- aider/args_formatter.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aider/args_formatter.py b/aider/args_formatter.py index 1c898cd90..4a8aa4d0b 100644 --- a/aider/args_formatter.py +++ b/aider/args_formatter.py @@ -48,6 +48,13 @@ class DotEnvFormatter(argparse.HelpFormatter): if action.help: parts.append(f"## {action.help}") + if action.env_var: + env_var = action.env_var + if default: + parts.append(f"{env_var}={default}\n") + else: + parts.append(f"{env_var}=\n") + for switch in action.option_strings: if switch.startswith("--"): break From a2cd025476aa2c1c9cf80491a90729c09e3d799b Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 18 Jun 2024 12:43:42 -0700 Subject: [PATCH 53/82] Updated dotenv.md with sample dotenv content generation cog script. --- website/docs/dotenv.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/website/docs/dotenv.md b/website/docs/dotenv.md index e45fc5783..f68fc0fb4 100644 --- a/website/docs/dotenv.md +++ b/website/docs/dotenv.md @@ -19,15 +19,9 @@ You can give it an explicit file to load with the `--env-file ` parame Here is an example `.env` file: -``` -OPENAI_API_KEY= -ANTHROPIC_API_KEY= -GROQ_API_KEY= -OPENROUTER_API_KEY= - -AZURE_API_KEY= -AZURE_API_VERSION=2023-05-15 -AZURE_API_BASE=https://example-endpoint.openai.azure.com - -OLLAMA_API_BASE=http://127.0.0.1:11434 +```dotenv +[[[cog +from aider.args import get_sample_dotenv +print(get_sample_dotenv()) +]]] ``` From 2cb4c0d5abc866bcdbdc8ef6045065fad6ab7226 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 12:57:19 -0700 Subject: [PATCH 54/82] Updated .env docs --- aider/args_formatter.py | 50 ++++---- aider/urls.py | 1 + scripts/update-docs.sh | 1 + website/assets/sample.env | 226 +++++++++++++++++++++++++++++++++ website/docs/dotenv.md | 254 ++++++++++++++++++++++++++++++++++++-- 5 files changed, 495 insertions(+), 37 deletions(-) create mode 100644 website/assets/sample.env diff --git a/aider/args_formatter.py b/aider/args_formatter.py index 4a8aa4d0b..b7dfbc540 100644 --- a/aider/args_formatter.py +++ b/aider/args_formatter.py @@ -1,5 +1,7 @@ import argparse +from aider import urls + from .dump import dump # noqa: F401 @@ -14,24 +16,36 @@ class DotEnvFormatter(argparse.HelpFormatter): return "" def _format_text(self, text): - return """ + return f""" ########################################################## -# Sample .env +# Sample aider .env file # This file lists *all* the valid configuration entries. # Place in your home dir, or at the root of your git repo. ########################################################## +################# +# LLM parameters: +# +# Include xxx_API_KEY parameters and other params needed for your LLMs. +# See {urls.llms} for details. + +## OpenAI +#OPENAI_API_KEY= + +## Anthropic +#ANTHROPIC_API_KEY= + +##... """ def _format_action(self, action): if not action.option_strings: return "" - parts = [""] + if not action.env_var: + return - metavar = action.metavar - if not metavar and isinstance(action, argparse._StoreAction): - metavar = "VALUE" + parts = [""] default = action.default if default == argparse.SUPPRESS: @@ -51,29 +65,9 @@ class DotEnvFormatter(argparse.HelpFormatter): if action.env_var: env_var = action.env_var if default: - parts.append(f"{env_var}={default}\n") + parts.append(f"#{env_var}={default}\n") else: - parts.append(f"{env_var}=\n") - - for switch in action.option_strings: - if switch.startswith("--"): - break - switch = switch.lstrip("-") - - if isinstance(action, argparse._StoreTrueAction): - default = False - elif isinstance(action, argparse._StoreConstAction): - default = False - - if default is False: - default = "false" - if default is True: - default = "true" - - if default: - parts.append(f"{switch}={default}\n") - else: - parts.append(f"{switch}=\n") + parts.append(f"#{env_var}=\n") return "\n".join(parts) + "\n" diff --git a/aider/urls.py b/aider/urls.py index d2863e705..8e21742d3 100644 --- a/aider/urls.py +++ b/aider/urls.py @@ -6,3 +6,4 @@ enable_playwright = "https://aider.chat/docs/install/optional.html#enable-playwr favicon = "https://aider.chat/assets/icons/favicon-32x32.png" model_warnings = "https://aider.chat/docs/llms/warnings.html" token_limits = "https://aider.chat/docs/troubleshooting/token-limits.html" +llms = "https://aider.chat/docs/llms.html" diff --git a/scripts/update-docs.sh b/scripts/update-docs.sh index 4fe32efba..fc16c4c66 100755 --- a/scripts/update-docs.sh +++ b/scripts/update-docs.sh @@ -14,6 +14,7 @@ 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 \ diff --git a/website/assets/sample.env b/website/assets/sample.env new file mode 100644 index 000000000..ac7c100ee --- /dev/null +++ b/website/assets/sample.env @@ -0,0 +1,226 @@ +########################################################## +# Sample aider .env file +# This file lists *all* the valid configuration entries. +# Place in your home dir, or at the root of your git repo. +########################################################## + +################# +# LLM parameters: +# +# Include xxx_API_KEY parameters and other params needed for your LLMs. +# See https://aider.chat/docs/llms.html for details. + +## OpenAI +#OPENAI_API_KEY= + +## Anthropic +#ANTHROPIC_API_KEY= + +##... + +####### +# 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= + +## Specify the Anthropic API key +#ANTHROPIC_API_KEY= + +## Specify the model to use for the main chat (default: gpt-4o) +#AIDER_MODEL=gpt-4o + +## Use claude-3-opus-20240229 model for the main chat +#AIDER_OPUS= + +## Use claude-3-sonnet-20240229 model for the main chat +#AIDER_SONNET= + +## Use gpt-4-0613 model for the main chat +#AIDER_4= + +## Use gpt-4o model for the main chat +#AIDER_4O= + +## Use gpt-4-1106-preview model for the main chat +#AIDER_4_TURBO= + +## Use gpt-3.5-turbo model for the main chat +#AIDER_35TURBO= + +################# +# Model Settings: + +## List known models which match the (partial) MODEL name +#AIDER_MODELS= + +## Specify the api base url +#OPENAI_API_BASE= + +## Specify the api_type +#OPENAI_API_TYPE= + +## Specify the api_version +#OPENAI_API_VERSION= + +## Specify the deployment_id +#OPENAI_API_DEPLOYMENT_ID= + +## Specify the OpenAI organization ID +#OPENAI_ORGANIZATION_ID= + +## Specify a file with context window and costs for unknown models +#AIDER_MODEL_METADATA_FILE= + +## Specify what edit format the LLM should use (default depends on model) +#AIDER_EDIT_FORMAT= + +## Specify the model to use for commit messages and chat history summarization (default depends on --model) +#AIDER_WEAK_MODEL= + +## Only work with models that have meta-data available (default: True) +#AIDER_SHOW_MODEL_WARNINGS=true + +## Max number of tokens to use for repo map, use 0 to disable (default: 1024) +#AIDER_MAP_TOKENS=true + +## Maximum number of tokens to use for chat history. If not specified, uses the model's max_chat_history_tokens. +#AIDER_MAX_CHAT_HISTORY_TOKENS= + +## Specify the .env file to load (default: .env in git root) +#AIDER_ENV_FILE=.env + +################ +# History Files: + +## Specify the chat input history file (default: .aider.input.history) +#AIDER_INPUT_HISTORY_FILE=.aider.input.history + +## Specify the chat history file (default: .aider.chat.history.md) +#AIDER_CHAT_HISTORY_FILE=.aider.chat.history.md + +## Restore the previous chat history messages (default: False) +#AIDER_RESTORE_CHAT_HISTORY=false + +################## +# Output Settings: + +## Use colors suitable for a dark terminal background (default: False) +#AIDER_DARK_MODE=false + +## Use colors suitable for a light terminal background (default: False) +#AIDER_LIGHT_MODE=false + +## Enable/disable pretty, colorized output (default: True) +#AIDER_PRETTY=true + +## Enable/disable streaming responses (default: True) +#AIDER_STREAM=true + +## Set the color for user input (default: #00cc00) +#AIDER_USER_INPUT_COLOR=#00cc00 + +## Set the color for tool output (default: None) +#AIDER_TOOL_OUTPUT_COLOR= + +## Set the color for tool error messages (default: red) +#AIDER_TOOL_ERROR_COLOR=#FF2222 + +## Set the color for assistant output (default: #0088ff) +#AIDER_ASSISTANT_OUTPUT_COLOR=#0088ff + +## Set the markdown code theme (default: default, other options include monokai, solarized-dark, solarized-light) +#AIDER_CODE_THEME=default + +## Show diffs when committing changes (default: False) +#AIDER_SHOW_DIFFS=false + +############### +# Git Settings: + +## Enable/disable looking for a git repo (default: True) +#AIDER_GIT=true + +## Enable/disable adding .aider* to .gitignore (default: True) +#AIDER_GITIGNORE=true + +## Specify the aider ignore file (default: .aiderignore in git root) +#AIDER_AIDERIGNORE=.aiderignore + +## Enable/disable auto commit of LLM changes (default: True) +#AIDER_AUTO_COMMITS=true + +## Enable/disable commits when repo is found dirty (default: True) +#AIDER_DIRTY_COMMITS=true + +## Perform a dry run without modifying files (default: False) +#AIDER_DRY_RUN=false + +######################## +# Fixing and committing: + +## Commit all pending changes with a suitable commit message, then exit +#AIDER_COMMIT=false + +## Lint and fix provided files, or dirty files if none provided +#AIDER_LINT=false + +## Specify lint commands to run for different languages, eg: "python: flake8 --select=..." (can be used multiple times) +#AIDER_LINT_CMD= + +## Enable/disable automatic linting after changes (default: True) +#AIDER_AUTO_LINT=true + +## Specify command to run tests +#AIDER_TEST_CMD= + +## Enable/disable automatic testing after changes (default: False) +#AIDER_AUTO_TEST=false + +## Run tests and fix problems found +#AIDER_TEST=false + +################# +# Other Settings: + +## Use VI editing mode in the terminal (default: False) +#AIDER_VIM=false + +## Specify the language for voice using ISO 639-1 code (default: auto) +#AIDER_VOICE_LANGUAGE=en + +## Check for updates and return status in the exit code +#AIDER_CHECK_UPDATE=false + +## Skips checking for the update when the program runs +#AIDER_SKIP_CHECK_UPDATE=false + +## Apply the changes from the given file instead of running the chat (debug) +#AIDER_APPLY= + +## Always say yes to every confirmation +#AIDER_YES= + +## Enable verbose output +#AIDER_VERBOSE=false + +## Print the repo map and exit (debug) +#AIDER_SHOW_REPO_MAP=false + +## Print the system prompts and exit (debug) +#AIDER_SHOW_PROMPTS=false + +## Specify a single message to send the LLM, process reply then exit (disables chat mode) +#AIDER_MESSAGE= + +## Specify a file containing the message to send the LLM, process reply, then exit (disables chat mode) +#AIDER_MESSAGE_FILE= + +## Specify the encoding for input and output (default: utf-8) +#AIDER_ENCODING=utf-8 + +## Run aider in your browser +#AIDER_GUI=false diff --git a/website/docs/dotenv.md b/website/docs/dotenv.md index f68fc0fb4..71d2f1e50 100644 --- a/website/docs/dotenv.md +++ b/website/docs/dotenv.md @@ -4,12 +4,12 @@ nav_order: 900 description: Using a .env file to store LLM API keys for aider. --- -# Storing LLM params in .env +# Config with .env You can use a `.env` file to store API keys and other settings for the -models you use with aider. -You currently can not set general aider options -in the `.env` file, only LLM environment variables. +models you use with aider +You can also set many general aider options +in the `.env` file. {% include special-keys.md %} @@ -17,11 +17,247 @@ Aider will look for a `.env` file in the root of your git repo or in the current directory. You can give it an explicit file to load with the `--env-file ` parameter. -Here is an example `.env` file: +Below is a sample `.env` file, which you +can also +[download from GitHub](https://github.com/paul-gauthier/aider/blob/main/website/assets/sample.env). -```dotenv -[[[cog + ``` +########################################################## +# Sample aider .env file +# This file lists *all* the valid configuration entries. +# Place in your home dir, or at the root of your git repo. +########################################################## + +################# +# LLM parameters: +# +# Include xxx_API_KEY parameters and other params needed for your LLMs. +# See https://aider.chat/docs/llms.html for details. + +## OpenAI +#OPENAI_API_KEY= + +## Anthropic +#ANTHROPIC_API_KEY= + +##... + +####### +# 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= + +## Specify the Anthropic API key +#ANTHROPIC_API_KEY= + +## Specify the model to use for the main chat (default: gpt-4o) +#AIDER_MODEL=gpt-4o + +## Use claude-3-opus-20240229 model for the main chat +#AIDER_OPUS= + +## Use claude-3-sonnet-20240229 model for the main chat +#AIDER_SONNET= + +## Use gpt-4-0613 model for the main chat +#AIDER_4= + +## Use gpt-4o model for the main chat +#AIDER_4O= + +## Use gpt-4-1106-preview model for the main chat +#AIDER_4_TURBO= + +## Use gpt-3.5-turbo model for the main chat +#AIDER_35TURBO= + +################# +# Model Settings: + +## List known models which match the (partial) MODEL name +#AIDER_MODELS= + +## Specify the api base url +#OPENAI_API_BASE= + +## Specify the api_type +#OPENAI_API_TYPE= + +## Specify the api_version +#OPENAI_API_VERSION= + +## Specify the deployment_id +#OPENAI_API_DEPLOYMENT_ID= + +## Specify the OpenAI organization ID +#OPENAI_ORGANIZATION_ID= + +## Specify a file with context window and costs for unknown models +#AIDER_MODEL_METADATA_FILE= + +## Specify what edit format the LLM should use (default depends on model) +#AIDER_EDIT_FORMAT= + +## Specify the model to use for commit messages and chat history summarization (default depends on --model) +#AIDER_WEAK_MODEL= + +## Only work with models that have meta-data available (default: True) +#AIDER_SHOW_MODEL_WARNINGS=true + +## Max number of tokens to use for repo map, use 0 to disable (default: 1024) +#AIDER_MAP_TOKENS=true + +## Maximum number of tokens to use for chat history. If not specified, uses the model's max_chat_history_tokens. +#AIDER_MAX_CHAT_HISTORY_TOKENS= + +## Specify the .env file to load (default: .env in git root) +#AIDER_ENV_FILE=.env + +################ +# History Files: + +## Specify the chat input history file (default: .aider.input.history) +#AIDER_INPUT_HISTORY_FILE=.aider.input.history + +## Specify the chat history file (default: .aider.chat.history.md) +#AIDER_CHAT_HISTORY_FILE=.aider.chat.history.md + +## Restore the previous chat history messages (default: False) +#AIDER_RESTORE_CHAT_HISTORY=false + +################## +# Output Settings: + +## Use colors suitable for a dark terminal background (default: False) +#AIDER_DARK_MODE=false + +## Use colors suitable for a light terminal background (default: False) +#AIDER_LIGHT_MODE=false + +## Enable/disable pretty, colorized output (default: True) +#AIDER_PRETTY=true + +## Enable/disable streaming responses (default: True) +#AIDER_STREAM=true + +## Set the color for user input (default: #00cc00) +#AIDER_USER_INPUT_COLOR=#00cc00 + +## Set the color for tool output (default: None) +#AIDER_TOOL_OUTPUT_COLOR= + +## Set the color for tool error messages (default: red) +#AIDER_TOOL_ERROR_COLOR=#FF2222 + +## Set the color for assistant output (default: #0088ff) +#AIDER_ASSISTANT_OUTPUT_COLOR=#0088ff + +## Set the markdown code theme (default: default, other options include monokai, solarized-dark, solarized-light) +#AIDER_CODE_THEME=default + +## Show diffs when committing changes (default: False) +#AIDER_SHOW_DIFFS=false + +############### +# Git Settings: + +## Enable/disable looking for a git repo (default: True) +#AIDER_GIT=true + +## Enable/disable adding .aider* to .gitignore (default: True) +#AIDER_GITIGNORE=true + +## Specify the aider ignore file (default: .aiderignore in git root) +#AIDER_AIDERIGNORE=.aiderignore + +## Enable/disable auto commit of LLM changes (default: True) +#AIDER_AUTO_COMMITS=true + +## Enable/disable commits when repo is found dirty (default: True) +#AIDER_DIRTY_COMMITS=true + +## Perform a dry run without modifying files (default: False) +#AIDER_DRY_RUN=false + +######################## +# Fixing and committing: + +## Commit all pending changes with a suitable commit message, then exit +#AIDER_COMMIT=false + +## Lint and fix provided files, or dirty files if none provided +#AIDER_LINT=false + +## Specify lint commands to run for different languages, eg: "python: flake8 --select=..." (can be used multiple times) +#AIDER_LINT_CMD= + +## Enable/disable automatic linting after changes (default: True) +#AIDER_AUTO_LINT=true + +## Specify command to run tests +#AIDER_TEST_CMD= + +## Enable/disable automatic testing after changes (default: False) +#AIDER_AUTO_TEST=false + +## Run tests and fix problems found +#AIDER_TEST=false + +################# +# Other Settings: + +## Use VI editing mode in the terminal (default: False) +#AIDER_VIM=false + +## Specify the language for voice using ISO 639-1 code (default: auto) +#AIDER_VOICE_LANGUAGE=en + +## Check for updates and return status in the exit code +#AIDER_CHECK_UPDATE=false + +## Skips checking for the update when the program runs +#AIDER_SKIP_CHECK_UPDATE=false + +## Apply the changes from the given file instead of running the chat (debug) +#AIDER_APPLY= + +## Always say yes to every confirmation +#AIDER_YES= + +## Enable verbose output +#AIDER_VERBOSE=false + +## Print the repo map and exit (debug) +#AIDER_SHOW_REPO_MAP=false + +## Print the system prompts and exit (debug) +#AIDER_SHOW_PROMPTS=false + +## Specify a single message to send the LLM, process reply then exit (disables chat mode) +#AIDER_MESSAGE= + +## Specify a file containing the message to send the LLM, process reply, then exit (disables chat mode) +#AIDER_MESSAGE_FILE= + +## Specify the encoding for input and output (default: utf-8) +#AIDER_ENCODING=utf-8 + +## Run aider in your browser +#AIDER_GUI=false +``` + + + From 1a8f3ff43153ed2cb6d07515c4bd6dac6657662f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 12:58:41 -0700 Subject: [PATCH 55/82] copy --- aider/args_formatter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aider/args_formatter.py b/aider/args_formatter.py index b7dfbc540..cc7e3e73d 100644 --- a/aider/args_formatter.py +++ b/aider/args_formatter.py @@ -18,9 +18,9 @@ class DotEnvFormatter(argparse.HelpFormatter): def _format_text(self, text): return f""" ########################################################## -# Sample aider .env file -# This file lists *all* the valid configuration entries. -# Place in your home dir, or at the root of your git repo. +# Sample aider .env file. +# Place at the root of your git repo. +# Or use `aider --env ` to specify. ########################################################## ################# From 5fd567362de9e339a52c7068f3351300938aee4b Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 13:06:09 -0700 Subject: [PATCH 56/82] improved author/committer name tests --- aider/tests/test_repo.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/aider/tests/test_repo.py b/aider/tests/test_repo.py index 961fe8ee9..e4497d72a 100644 --- a/aider/tests/test_repo.py +++ b/aider/tests/test_repo.py @@ -160,11 +160,23 @@ class TestRepo(unittest.TestCase): # check the committer name commit = raw_repo.head.commit + self.assertEqual(commit.author.name, "Test User (aider)") + self.assertEqual(commit.committer.name, "Test User (aider)") + + # commit a change without aider_edits + fname.write_text("new content again!") + git_repo.commit(fnames=[str(fname)], aider_edits=False) + + # check the committer name + commit = raw_repo.head.commit + self.assertEqual(commit.author.name, "Test User") self.assertEqual(commit.committer.name, "Test User (aider)") # check that the original committer name is restored original_committer_name = os.environ.get("GIT_COMMITTER_NAME") self.assertIsNone(original_committer_name) + original_author_name = os.environ.get("GIT_AUTHOR_NAME") + self.assertIsNone(original_author_name) def test_get_tracked_files(self): # Create a temporary directory From b9c008c31b1cf4648a7553ef1dec42efc3a3167f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 13:07:00 -0700 Subject: [PATCH 57/82] copy --- website/docs/dotenv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/dotenv.md b/website/docs/dotenv.md index 71d2f1e50..7167655cc 100644 --- a/website/docs/dotenv.md +++ b/website/docs/dotenv.md @@ -4,7 +4,7 @@ nav_order: 900 description: Using a .env file to store LLM API keys for aider. --- -# Config with .env +# Config with .env You can use a `.env` file to store API keys and other settings for the models you use with aider From ca6eae293e5f675bb3839254ff41cca1365d506a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 13:07:17 -0700 Subject: [PATCH 58/82] copy --- website/assets/sample.env | 6 +++--- website/docs/dotenv.md | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/website/assets/sample.env b/website/assets/sample.env index ac7c100ee..02251c4b9 100644 --- a/website/assets/sample.env +++ b/website/assets/sample.env @@ -1,7 +1,7 @@ ########################################################## -# Sample aider .env file -# This file lists *all* the valid configuration entries. -# Place in your home dir, or at the root of your git repo. +# Sample aider .env file. +# Place at the root of your git repo. +# Or use `aider --env ` to specify. ########################################################## ################# diff --git a/website/docs/dotenv.md b/website/docs/dotenv.md index 7167655cc..fd32e1a13 100644 --- a/website/docs/dotenv.md +++ b/website/docs/dotenv.md @@ -7,7 +7,7 @@ description: Using a .env file to store LLM API keys for aider. # Config with .env You can use a `.env` file to store API keys and other settings for the -models you use with aider +models you use with aider. You can also set many general aider options in the `.env` file. @@ -32,9 +32,9 @@ cog.outl("```") ]]]--> ``` ########################################################## -# Sample aider .env file -# This file lists *all* the valid configuration entries. -# Place in your home dir, or at the root of your git repo. +# Sample aider .env file. +# Place at the root of your git repo. +# Or use `aider --env ` to specify. ########################################################## ################# From 82b6f83a9886d37ba4adc2dd831a5baac5e2f2bf Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 13:14:33 -0700 Subject: [PATCH 59/82] cleanup test --- aider/tests/test_repo.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aider/tests/test_repo.py b/aider/tests/test_repo.py index e4497d72a..b8cc3b06a 100644 --- a/aider/tests/test_repo.py +++ b/aider/tests/test_repo.py @@ -178,6 +178,9 @@ class TestRepo(unittest.TestCase): original_author_name = os.environ.get("GIT_AUTHOR_NAME") self.assertIsNone(original_author_name) + del raw_repo + del git_repo + def test_get_tracked_files(self): # Create a temporary directory tempdir = Path(tempfile.mkdtemp()) From 0d66f803b4fa96da36da0482bae99a8a9645e25a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 17:17:05 -0700 Subject: [PATCH 60/82] cleanup test --- aider/tests/test_repo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aider/tests/test_repo.py b/aider/tests/test_repo.py index b8cc3b06a..087827c31 100644 --- a/aider/tests/test_repo.py +++ b/aider/tests/test_repo.py @@ -152,7 +152,8 @@ class TestRepo(unittest.TestCase): raw_repo.git.add(str(fname)) raw_repo.git.commit("-m", "initial commit") - git_repo = GitRepo(InputOutput(), None, None) + io = InputOutput() + git_repo = GitRepo(io, None, None) # commit a change fname.write_text("new content") @@ -178,8 +179,10 @@ class TestRepo(unittest.TestCase): original_author_name = os.environ.get("GIT_AUTHOR_NAME") self.assertIsNone(original_author_name) - del raw_repo + del fname del git_repo + del raw_repo + del io def test_get_tracked_files(self): # Create a temporary directory From eaaac4d65dd77a1a870afa75e2a8ad194729a773 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 17:32:09 -0700 Subject: [PATCH 61/82] turn off test --- aider/tests/test_repo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/tests/test_repo.py b/aider/tests/test_repo.py index 087827c31..b1f20f838 100644 --- a/aider/tests/test_repo.py +++ b/aider/tests/test_repo.py @@ -138,7 +138,7 @@ class TestRepo(unittest.TestCase): self.assertEqual(result, 'a good "commit message"') @patch("aider.repo.GitRepo.get_commit_message") - def test_commit_with_custom_committer_name(self, mock_send): + def notest_commit_with_custom_committer_name(self, mock_send): mock_send.return_value = '"a good commit message"' with GitTemporaryDirectory(): From 4e6a546efd9a2a2d0a7b9872c4aa63aae05274db Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 18 Jun 2024 17:39:55 -0700 Subject: [PATCH 62/82] disable test on windows --- aider/tests/test_repo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aider/tests/test_repo.py b/aider/tests/test_repo.py index b1f20f838..92d074b9a 100644 --- a/aider/tests/test_repo.py +++ b/aider/tests/test_repo.py @@ -1,4 +1,5 @@ import os +import platform import tempfile import unittest from pathlib import Path @@ -138,9 +139,13 @@ class TestRepo(unittest.TestCase): self.assertEqual(result, 'a good "commit message"') @patch("aider.repo.GitRepo.get_commit_message") - def notest_commit_with_custom_committer_name(self, mock_send): + def test_commit_with_custom_committer_name(self, mock_send): mock_send.return_value = '"a good commit message"' + # Cleanup of the git temp dir explodes on windows + if platform.system() == "Windows": + return + with GitTemporaryDirectory(): # new repo raw_repo = git.Repo() @@ -179,11 +184,6 @@ class TestRepo(unittest.TestCase): original_author_name = os.environ.get("GIT_AUTHOR_NAME") self.assertIsNone(original_author_name) - del fname - del git_repo - del raw_repo - del io - def test_get_tracked_files(self): # Create a temporary directory tempdir = Path(tempfile.mkdtemp()) From 6c10b611761b45e3a2d2251c6e37d90b6064b32a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 07:22:44 -0700 Subject: [PATCH 63/82] copy --- website/docs/troubleshooting/edit-errors.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/troubleshooting/edit-errors.md b/website/docs/troubleshooting/edit-errors.md index 7c7a4a359..dbbd527dd 100644 --- a/website/docs/troubleshooting/edit-errors.md +++ b/website/docs/troubleshooting/edit-errors.md @@ -33,8 +33,8 @@ so editing errors are probably unavoidable. ## Reduce distractions Many LLM now have very large context windows, -but filling them with irrelevant code often -cofuses the model. +but filling them with irrelevant code or conversation +can cofuse the model. - Don't add too many files to the chat, *just* add the files you think need to be edited. Aider also sends the LLM a [map of your entire git repo](https://aider.chat/docs/repomap.html), so other relevant code will be included automatically. From 068609e4effc3f25c330a7bac49e723493df7bc8 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 20 Jun 2024 07:34:15 -0700 Subject: [PATCH 64/82] Added main entry point file. --- aider/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 aider/__main__.py diff --git a/aider/__main__.py b/aider/__main__.py new file mode 100644 index 000000000..40e2b013f --- /dev/null +++ b/aider/__main__.py @@ -0,0 +1,4 @@ +from .main import main + +if __name__ == "__main__": + main() From 090e0cdcfeec1b21d63f6508902db091b0e7c18c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 08:26:35 -0700 Subject: [PATCH 65/82] Added 3.5 sonnet --- aider/models.py | 12 ++++++++ website/_data/edit_leaderboard.yml | 49 +++++++++++++++++++++++++++++- website/docs/leaderboards/index.md | 22 +++++--------- 3 files changed, 68 insertions(+), 15 deletions(-) diff --git a/aider/models.py b/aider/models.py index f51b38bc4..6470727d0 100644 --- a/aider/models.py +++ b/aider/models.py @@ -178,6 +178,18 @@ MODEL_SETTINGS = [ "whole", weak_model_name="claude-3-haiku-20240307", ), + ModelSettings( + "anthropic/claude-3.5-sonnet", + "diff", + weak_model_name="claude-3-haiku-20240307", + use_repo_map=True, + ), + ModelSettings( + "openrouter/anthropic/claude-3.5-sonnet", + "diff", + weak_model_name="openrouter/anthropic/claude-3-haiku-20240307", + use_repo_map=True, + ), # Cohere ModelSettings( "command-r-plus", diff --git a/website/_data/edit_leaderboard.yml b/website/_data/edit_leaderboard.yml index 82119110a..240e017fd 100644 --- a/website/_data/edit_leaderboard.yml +++ b/website/_data/edit_leaderboard.yml @@ -611,4 +611,51 @@ date: 2024-06-08 versions: 0.37.1-dev seconds_per_case: 280.6 - total_cost: 0.0000 \ No newline at end of file + total_cost: 0.0000 + +- dirname: 2024-06-20-15-09-26--claude-3.5-sonnet-whole + test_cases: 133 + model: claude-3.5-sonnet (whole) + edit_format: whole + commit_hash: 068609e + pass_rate_1: 61.7 + pass_rate_2: 78.2 + percent_cases_well_formed: 100.0 + error_outputs: 4 + num_malformed_responses: 0 + num_with_malformed_responses: 0 + user_asks: 2 + lazy_comments: 0 + syntax_errors: 0 + indentation_errors: 0 + exhausted_context_windows: 0 + test_timeouts: 0 + command: aider --model openrouter/anthropic/claude-3.5-sonnet + date: 2024-06-20 + versions: 0.38.1-dev + seconds_per_case: 15.4 + total_cost: 0.0000 + +- dirname: 2024-06-20-15-16-41--claude-3.5-sonnet-diff + test_cases: 133 + model: openrouter/anthropic/claude-3.5-sonnet + edit_format: diff + commit_hash: 068609e-dirty + pass_rate_1: 57.9 + pass_rate_2: 74.4 + percent_cases_well_formed: 97.0 + error_outputs: 48 + num_malformed_responses: 11 + num_with_malformed_responses: 4 + user_asks: 0 + lazy_comments: 0 + syntax_errors: 0 + indentation_errors: 0 + exhausted_context_windows: 0 + test_timeouts: 1 + command: aider --model openrouter/anthropic/claude-3.5-sonnet + date: 2024-06-20 + versions: 0.38.1-dev + seconds_per_case: 21.6 + total_cost: 0.0000 + \ No newline at end of file diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index 4e3a2a59a..bc6d72c12 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -16,22 +16,16 @@ While [aider can connect to almost any LLM](/docs/llms.html), it works best with models that score well on the benchmarks. -## DeepSeek Coder V2 beats GPT-4o, Opus +## Claude 3.5 Sonnet takes the top spot -The new -[DeepSeek Coder V2](https://aider.chat/docs/llms/deepseek.html) -model is now atop aider's code editing leaderboard! - -It's worth noting that DeepSeek Coder V2 is only capable of using aider's "whole" edit format. -This means it returns a modified full copy of each file when it makes changes. -Most other strong models are able to use aider's "diff" editing format, -which allows them to return diffs of edits -- saving time and token costs. - -Models which use the "whole" edit format can only edit files -which fit within their output token limits. -These output limits are often as low as 4k tokens, even for models -with very large context windows. +Claude 3.5 Sonnet is now the top ranked model on aider's code editing leaderboard. +DeepSeek Coder V2 previously took the #1 spot, only 4 days ago. +Sonnet ranked #1 when using the "whole" editing format, +but it also scored very well with +aider's "diff" editing format. +This format allows it to return code changes as diffs -- saving time and token costs, +and making it practical to work with larger source files. ## Code editing leaderboard From e5e07f9507ad42d9d40e49b4dd7b15fc75bd1634 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 08:29:16 -0700 Subject: [PATCH 66/82] copy --- website/_data/edit_leaderboard.yml | 4 ++-- website/docs/leaderboards/index.md | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/website/_data/edit_leaderboard.yml b/website/_data/edit_leaderboard.yml index 240e017fd..1b5bf476d 100644 --- a/website/_data/edit_leaderboard.yml +++ b/website/_data/edit_leaderboard.yml @@ -630,7 +630,7 @@ indentation_errors: 0 exhausted_context_windows: 0 test_timeouts: 0 - command: aider --model openrouter/anthropic/claude-3.5-sonnet + command: aider --model openrouter/anthropic/claude-3.5-sonnet --edit-format whole date: 2024-06-20 versions: 0.38.1-dev seconds_per_case: 15.4 @@ -638,7 +638,7 @@ - dirname: 2024-06-20-15-16-41--claude-3.5-sonnet-diff test_cases: 133 - model: openrouter/anthropic/claude-3.5-sonnet + model: claude-3.5-sonnet (diff) edit_format: diff commit_hash: 068609e-dirty pass_rate_1: 57.9 diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index bc6d72c12..9993c665e 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -19,13 +19,14 @@ it works best with models that score well on the benchmarks. ## Claude 3.5 Sonnet takes the top spot Claude 3.5 Sonnet is now the top ranked model on aider's code editing leaderboard. -DeepSeek Coder V2 previously took the #1 spot, only 4 days ago. +DeepSeek Coder V2 took the #1 spot only 4 days ago. Sonnet ranked #1 when using the "whole" editing format, but it also scored very well with aider's "diff" editing format. This format allows it to return code changes as diffs -- saving time and token costs, and making it practical to work with larger source files. +As such, aider uses "diff" by default with this new Sonnet model. ## Code editing leaderboard From 559279c781dc0ac94ed7ea1b4bbd70ecf0304d94 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 09:56:18 -0700 Subject: [PATCH 67/82] copy --- website/_data/refactor_leaderboard.yml | 23 ++++++++++++++++++++++- website/docs/leaderboards/index.md | 4 +++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/website/_data/refactor_leaderboard.yml b/website/_data/refactor_leaderboard.yml index db4d3483f..11773ac39 100644 --- a/website/_data/refactor_leaderboard.yml +++ b/website/_data/refactor_leaderboard.yml @@ -143,4 +143,25 @@ seconds_per_case: 67.8 total_cost: 20.4889 - \ No newline at end of file + +- dirname: 2024-06-20-16-39-18--refac-claude-3.5-sonnet-diff + test_cases: 89 + model: claude-3.5-sonnet (diff) + edit_format: diff + commit_hash: e5e07f9 + pass_rate_1: 55.1 + percent_cases_well_formed: 70.8 + error_outputs: 240 + num_malformed_responses: 54 + num_with_malformed_responses: 26 + user_asks: 10 + lazy_comments: 2 + syntax_errors: 0 + indentation_errors: 3 + exhausted_context_windows: 0 + test_timeouts: 0 + command: aider --model openrouter/anthropic/claude-3.5-sonnet + date: 2024-06-20 + versions: 0.38.1-dev + seconds_per_case: 51.9 + total_cost: 0.0000 \ No newline at end of file diff --git a/website/docs/leaderboards/index.md b/website/docs/leaderboards/index.md index 9993c665e..78d2abafc 100644 --- a/website/docs/leaderboards/index.md +++ b/website/docs/leaderboards/index.md @@ -19,7 +19,9 @@ it works best with models that score well on the benchmarks. ## Claude 3.5 Sonnet takes the top spot Claude 3.5 Sonnet is now the top ranked model on aider's code editing leaderboard. -DeepSeek Coder V2 took the #1 spot only 4 days ago. +DeepSeek Coder V2 only spent 4 days in the top spot. + +The new Sonnet came in 3rd on aider's refactoring leaderboard, behind GPT-4o and Opus. Sonnet ranked #1 when using the "whole" editing format, but it also scored very well with From 6623110fb0a1554c980d808dbc38bbc5bf50c25c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 14:12:51 -0700 Subject: [PATCH 68/82] Updated --sonnet to use Claude 3.5 Sonnet --- README.md | 4 ++-- aider/args.py | 16 +++++++++------- website/assets/sample.aider.conf.yml | 2 +- website/assets/sample.env | 2 +- website/docs/aider_conf.md | 2 +- website/docs/dotenv.md | 2 +- website/docs/llms.md | 4 ++-- website/docs/llms/anthropic.md | 2 +- website/docs/options.md | 2 +- website/index.md | 4 ++-- 10 files changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 6c30587c5..d750ae543 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Aider lets you pair program with LLMs, to edit code in your local git repository. Start a new project or work with an existing git repo. -Aider works best with GPT-4o and Claude 3 Opus -and can [connect to almost any LLM](https://aider.chat/docs/llms.html). +Aider can [connect to almost any LLM](https://aider.chat/docs/llms.html). +and works best with GPT-4o, Claude 3.5 Sonnet and Claude 3 Opus.

# Windows # Claude 3 Opus aider --opus -# Claude 3 Sonnet +# Claude 3.5 Sonnet aider --sonnet # List models available from Anthropic diff --git a/website/docs/options.md b/website/docs/options.md index 300330894..a71d3f00c 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -75,7 +75,7 @@ Use claude-3-opus-20240229 model for the main chat Environment variable: `AIDER_OPUS` ### `--sonnet` -Use claude-3-sonnet-20240229 model for the main chat +Use claude-3-5-sonnet-20240620 model for the main chat Environment variable: `AIDER_SONNET` ### `--4` diff --git a/website/index.md b/website/index.md index 0a362d291..98a08a5b0 100644 --- a/website/index.md +++ b/website/index.md @@ -20,8 +20,8 @@ cog.out(text) Aider lets you pair program with LLMs, to edit code in your local git repository. Start a new project or work with an existing git repo. -Aider works best with GPT-4o and Claude 3 Opus -and can [connect to almost any LLM](https://aider.chat/docs/llms.html). +Aider can [connect to almost any LLM](https://aider.chat/docs/llms.html). +and works best with GPT-4o, Claude 3.5 Sonnet and Claude 3 Opus.

Date: Thu, 20 Jun 2024 14:23:10 -0700 Subject: [PATCH 69/82] Updated HISTORY --- HISTORY.md | 7 +++++++ README.md | 7 ++++++- aider/models.py | 8 +++++++- website/_includes/get-started.md | 7 ++++++- website/index.md | 7 ++++++- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index b942f392b..257018ed3 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,13 @@ # Release history +### v0.39.0 + +- Use `--sonnet` for Claude 3.5 Sonnet, which is the top model on [aider's LLM code editing leaderboard](https://aider.chat/docs/leaderboards/#claude-35-sonnet-takes-the-top-spot). +- All `AIDER_xxx` environment variables can now be set in `.env` (by @jpshack-at-palomar). +- Commit messages are no longer prefixed with "aider:". Instead the git author and committer names have "(aider)" added to them. +- Use `--llm-history-file` to log raw messages sent to the LLM (by @daniel-vainsencher). + ### v0.38.0 - Use `--vim` for [vim keybindings](https://aider.chat/docs/commands.html#vi) in the chat. diff --git a/README.md b/README.md index d750ae543..78af92915 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,14 @@ $ cd /to/your/git/repo $ export OPENAI_API_KEY=your-key-goes-here $ aider -# Or, work with Claude 3 Opus on your repo +# Or, work with Anthropic's models $ export ANTHROPIC_API_KEY=your-key-goes-here + +# Claude 3 Opus $ aider --opus + +# Claude 3.5 Sonnet +$ aider --sonnet ``` diff --git a/aider/models.py b/aider/models.py index 6470727d0..ac150d546 100644 --- a/aider/models.py +++ b/aider/models.py @@ -179,7 +179,13 @@ MODEL_SETTINGS = [ weak_model_name="claude-3-haiku-20240307", ), ModelSettings( - "anthropic/claude-3.5-sonnet", + "claude-3-5-sonnet-20240620", + "diff", + weak_model_name="claude-3-haiku-20240307", + use_repo_map=True, + ), + ModelSettings( + "anthropic/claude-3-5-sonnet-20240620", "diff", weak_model_name="claude-3-haiku-20240307", use_repo_map=True, diff --git a/website/_includes/get-started.md b/website/_includes/get-started.md index 498d310dc..e31d2ca3a 100644 --- a/website/_includes/get-started.md +++ b/website/_includes/get-started.md @@ -10,7 +10,12 @@ $ cd /to/your/git/repo $ export OPENAI_API_KEY=your-key-goes-here $ aider -# Or, work with Claude 3 Opus on your repo +# Or, work with Anthropic's models $ export ANTHROPIC_API_KEY=your-key-goes-here + +# Claude 3 Opus $ aider --opus + +# Claude 3.5 Sonnet +$ aider --sonnet ``` diff --git a/website/index.md b/website/index.md index 98a08a5b0..7d847f65d 100644 --- a/website/index.md +++ b/website/index.md @@ -57,9 +57,14 @@ $ cd /to/your/git/repo $ export OPENAI_API_KEY=your-key-goes-here $ aider -# Or, work with Claude 3 Opus on your repo +# Or, work with Anthropic's models $ export ANTHROPIC_API_KEY=your-key-goes-here + +# Claude 3 Opus $ aider --opus + +# Claude 3.5 Sonnet +$ aider --sonnet ``` From 5648cd54191c5d860f4f3351e7ddd0e602c85f94 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 14:36:52 -0700 Subject: [PATCH 70/82] copy --- website/HISTORY.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/website/HISTORY.md b/website/HISTORY.md index dc52bc7ff..38edb9513 100644 --- a/website/HISTORY.md +++ b/website/HISTORY.md @@ -11,6 +11,13 @@ cog.out(text) # Release history +### v0.39.0 + +- Use `--sonnet` for Claude 3.5 Sonnet, which is the top model on [aider's LLM code editing leaderboard](https://aider.chat/docs/leaderboards/#claude-35-sonnet-takes-the-top-spot). +- All `AIDER_xxx` environment variables can now be set in `.env` (by @jpshack-at-palomar). +- Commit messages are no longer prefixed with "aider:". Instead the git author and committer names have "(aider)" added to them. +- Use `--llm-history-file` to log raw messages sent to the LLM (by @daniel-vainsencher). + ### v0.38.0 - Use `--vim` for [vim keybindings](https://aider.chat/docs/commands.html#vi) in the chat. From 7e83e6b8f523657a49ad73d048c245b2bf0860ac Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 14:38:02 -0700 Subject: [PATCH 71/82] copy --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 257018ed3..70f86560a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,8 +5,8 @@ - Use `--sonnet` for Claude 3.5 Sonnet, which is the top model on [aider's LLM code editing leaderboard](https://aider.chat/docs/leaderboards/#claude-35-sonnet-takes-the-top-spot). - All `AIDER_xxx` environment variables can now be set in `.env` (by @jpshack-at-palomar). -- Commit messages are no longer prefixed with "aider:". Instead the git author and committer names have "(aider)" added to them. - Use `--llm-history-file` to log raw messages sent to the LLM (by @daniel-vainsencher). +- Commit messages are no longer prefixed with "aider:". Instead the git author and committer names have "(aider)" added. ### v0.38.0 From f030ec7f8487ce27375f506080e3ea12d7296493 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 14:47:27 -0700 Subject: [PATCH 72/82] copy --- website/HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/HISTORY.md b/website/HISTORY.md index 38edb9513..044c1652c 100644 --- a/website/HISTORY.md +++ b/website/HISTORY.md @@ -15,8 +15,8 @@ cog.out(text) - Use `--sonnet` for Claude 3.5 Sonnet, which is the top model on [aider's LLM code editing leaderboard](https://aider.chat/docs/leaderboards/#claude-35-sonnet-takes-the-top-spot). - All `AIDER_xxx` environment variables can now be set in `.env` (by @jpshack-at-palomar). -- Commit messages are no longer prefixed with "aider:". Instead the git author and committer names have "(aider)" added to them. - Use `--llm-history-file` to log raw messages sent to the LLM (by @daniel-vainsencher). +- Commit messages are no longer prefixed with "aider:". Instead the git author and committer names have "(aider)" added. ### v0.38.0 From 3128aa853bd69ef85db55e66b3c36072bf21a372 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 14:48:10 -0700 Subject: [PATCH 73/82] version bump to 0.39.0 --- aider/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/__init__.py b/aider/__init__.py index b56245168..e72781a79 100644 --- a/aider/__init__.py +++ b/aider/__init__.py @@ -1 +1 @@ -__version__ = "0.38.1-dev" +__version__ = "0.39.0" From 5f0f9daa3a15789b809ea6f1130d55e0ad798d3e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 14:48:58 -0700 Subject: [PATCH 74/82] set version to 0.39.1-dev --- aider/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/__init__.py b/aider/__init__.py index e72781a79..57bacca7f 100644 --- a/aider/__init__.py +++ b/aider/__init__.py @@ -1 +1 @@ -__version__ = "0.39.0" +__version__ = "0.39.1-dev" From fb26174357c7ca90b3b24279668e08b7708004d7 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jun 2024 16:17:13 -0700 Subject: [PATCH 75/82] print token counts with commas --- aider/coders/base_coder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index b529636ca..76df78985 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -913,9 +913,9 @@ class Coder: res = ["", ""] res.append(f"Model {self.main_model.name} has hit a token limit!") res.append("") - res.append(f"Input tokens: {input_tokens} of {max_input_tokens}{inp_err}") - res.append(f"Output tokens: {output_tokens} of {max_output_tokens}{out_err}") - res.append(f"Total tokens: {total_tokens} of {max_input_tokens}{tot_err}") + res.append(f"Input tokens: {input_tokens:,} of {max_input_tokens:,}{inp_err}") + res.append(f"Output tokens: {output_tokens:,} of {max_output_tokens:,}{out_err}") + res.append(f"Total tokens: {total_tokens:,} of {max_input_tokens:,}{tot_err}") if output_tokens >= max_output_tokens: res.append("") From b03d73906560a98172e58002d4ba37f86a933001 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 21 Jun 2024 07:33:14 -0700 Subject: [PATCH 76/82] Added RSS feed functionality and link to the website. --- website/_config.yml | 2 ++ website/_includes/head_custom.html | 1 + 2 files changed, 3 insertions(+) diff --git a/website/_config.yml b/website/_config.yml index 74021c3fe..15e28ec7f 100644 --- a/website/_config.yml +++ b/website/_config.yml @@ -4,6 +4,7 @@ url: "https://aider.chat" plugins: - jekyll-redirect-from - jekyll-sitemap + - jekyll-feed defaults: - scope: @@ -19,6 +20,7 @@ exclude: - "**/OLD/**" - "OLD/**" - vendor + - feed.xml aux_links: "GitHub": diff --git a/website/_includes/head_custom.html b/website/_includes/head_custom.html index a6d4cca22..95a83cf10 100644 --- a/website/_includes/head_custom.html +++ b/website/_includes/head_custom.html @@ -5,6 +5,7 @@ {% endif %} + From d73fddccb9dd34704fad6ddf52ab46592498dd4c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 21 Jun 2024 07:46:34 -0700 Subject: [PATCH 77/82] Added --verify-ssl #664 --- aider/args.py | 6 ++++++ aider/main.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/aider/args.py b/aider/args.py index b0da24dad..48ba2db59 100644 --- a/aider/args.py +++ b/aider/args.py @@ -158,6 +158,12 @@ def get_parser(default_config_files, git_root): env_var="OPENAI_ORGANIZATION_ID", help="Specify the OpenAI organization ID", ) + group.add_argument( + "--verify-ssl", + action=argparse.BooleanOptionalAction, + default=True, + help="Verify the SSL cert when connecting to models (default: True)", + ) group.add_argument( "--model-metadata-file", metavar="MODEL_FILE", diff --git a/aider/main.py b/aider/main.py index ac8281d4d..f9b4b5217 100644 --- a/aider/main.py +++ b/aider/main.py @@ -5,6 +5,7 @@ import sys from pathlib import Path import git +import httpx from dotenv import load_dotenv from prompt_toolkit.enums import EditingMode from streamlit.web import cli @@ -240,6 +241,9 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F parser = get_parser(default_config_files, git_root) args = parser.parse_args(argv) + if not args.verify_ssl: + litellm.client_session = httpx.Client(verify=False) + if args.gui and not return_coder: launch_gui(argv) return From 93e104f79fc4a6dd86c5237b96ecb4dbc33a62a7 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 21 Jun 2024 07:47:29 -0700 Subject: [PATCH 78/82] copy --- website/assets/sample.aider.conf.yml | 3 +++ website/assets/sample.env | 3 +++ website/docs/aider_conf.md | 3 +++ website/docs/dotenv.md | 3 +++ website/docs/options.md | 13 +++++++++++-- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/website/assets/sample.aider.conf.yml b/website/assets/sample.aider.conf.yml index ed48f18e1..c7873aecd 100644 --- a/website/assets/sample.aider.conf.yml +++ b/website/assets/sample.aider.conf.yml @@ -64,6 +64,9 @@ ## Specify the OpenAI organization ID #openai-organization-id: +## Verify the SSL cert when connecting to models (default: True) +#verify-ssl: true + ## Specify a file with context window and costs for unknown models #model-metadata-file: diff --git a/website/assets/sample.env b/website/assets/sample.env index 551d76de3..af76039dc 100644 --- a/website/assets/sample.env +++ b/website/assets/sample.env @@ -72,6 +72,9 @@ ## Specify the OpenAI organization ID #OPENAI_ORGANIZATION_ID= +## Verify the SSL cert when connecting to models (default: True) +#AIDER_VERIFY_SSL=true + ## Specify a file with context window and costs for unknown models #AIDER_MODEL_METADATA_FILE= diff --git a/website/docs/aider_conf.md b/website/docs/aider_conf.md index 9e4eed9d3..e6e89fc25 100644 --- a/website/docs/aider_conf.md +++ b/website/docs/aider_conf.md @@ -92,6 +92,9 @@ cog.outl("```") ## Specify the OpenAI organization ID #openai-organization-id: +## Verify the SSL cert when connecting to models (default: True) +#verify-ssl: true + ## Specify a file with context window and costs for unknown models #model-metadata-file: diff --git a/website/docs/dotenv.md b/website/docs/dotenv.md index b7c942923..e1eb3a425 100644 --- a/website/docs/dotenv.md +++ b/website/docs/dotenv.md @@ -105,6 +105,9 @@ cog.outl("```") ## Specify the OpenAI organization ID #OPENAI_ORGANIZATION_ID= +## Verify the SSL cert when connecting to models (default: True) +#AIDER_VERIFY_SSL=true + ## Specify a file with context window and costs for unknown models #AIDER_MODEL_METADATA_FILE= diff --git a/website/docs/options.md b/website/docs/options.md index a71d3f00c..166b2853b 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -19,8 +19,9 @@ usage: aider [-h] [--llm-history-file] [--openai-api-key] [--4] [--4o] [--4-turbo] [--35turbo] [--models] [--openai-api-base] [--openai-api-type] [--openai-api-version] [--openai-api-deployment-id] - [--openai-organization-id] [--model-metadata-file] - [--edit-format] [--weak-model] + [--openai-organization-id] + [--verify-ssl | --no-verify-ssl] + [--model-metadata-file] [--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] @@ -128,6 +129,14 @@ Environment variable: `OPENAI_API_DEPLOYMENT_ID` Specify the OpenAI organization ID Environment variable: `OPENAI_ORGANIZATION_ID` +### `--verify-ssl` +Verify the SSL cert when connecting to models (default: True) +Default: True +Environment variable: `AIDER_VERIFY_SSL` +Aliases: + - `--verify-ssl` + - `--no-verify-ssl` + ### `--model-metadata-file MODEL_FILE` Specify a file with context window and costs for unknown models Environment variable: `AIDER_MODEL_METADATA_FILE` From 4fd61f11121496b9721821215c929414a1dc9011 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 21 Jun 2024 08:29:02 -0700 Subject: [PATCH 79/82] More flexible filename search for deepseek coder v2 --- aider/coders/editblock_coder.py | 41 +++++++++++++++++++++++++-------- aider/models.py | 12 ++++++++-- aider/tests/test_editblock.py | 26 +++++++++++++++++++++ 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/aider/coders/editblock_coder.py b/aider/coders/editblock_coder.py index 017e40408..557e692b6 100644 --- a/aider/coders/editblock_coder.py +++ b/aider/coders/editblock_coder.py @@ -414,16 +414,8 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE): processed.append(cur) # original_marker - filename = strip_filename(processed[-2].splitlines()[-1], fence) - try: - if not filename: - filename = strip_filename(processed[-2].splitlines()[-2], fence) - if not filename: - if current_filename: - filename = current_filename - else: - raise ValueError(missing_filename_err.format(fence=fence)) - except IndexError: + filename = find_filename(processed[-2].splitlines(), fence) + if not filename: if current_filename: filename = current_filename else: @@ -460,6 +452,35 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE): raise ValueError(f"{processed}\n^^^ Error parsing SEARCH/REPLACE block.") +def find_filename(lines, fence): + """ + Deepseek Coder v2 has been doing this: + + + ```python + word_count.py + ``` + ```python + <<<<<<< SEARCH + ... + + This is a more flexible search back for filenames. + """ + # Go back through the 3 preceding lines + lines.reverse() + lines = lines[:3] + + for line in lines: + # If we find a filename, done + filename = strip_filename(line, fence) + if filename: + return filename + + # Only continue as long as we keep seeing fences + if not line.startswith(fence[0]): + return + + if __name__ == "__main__": edit = """ Here's the change: diff --git a/aider/models.py b/aider/models.py index ac150d546..50548446d 100644 --- a/aider/models.py +++ b/aider/models.py @@ -236,7 +236,7 @@ MODEL_SETTINGS = [ send_undo_reply=True, ), ModelSettings( - "openai/deepseek-chat", + "deepseek/deepseek-chat", "diff", use_repo_map=True, send_undo_reply=True, @@ -244,7 +244,15 @@ MODEL_SETTINGS = [ reminder_as_sys_msg=True, ), ModelSettings( - "deepseek/deepseek-chat", + "deepseek/deepseek-coder", + "diff", + use_repo_map=True, + send_undo_reply=True, + examples_as_sys_msg=True, + reminder_as_sys_msg=True, + ), + ModelSettings( + "openrouter/deepseek/deepseek-coder", "diff", use_repo_map=True, send_undo_reply=True, diff --git a/aider/tests/test_editblock.py b/aider/tests/test_editblock.py index 0c1143232..40a0d4572 100644 --- a/aider/tests/test_editblock.py +++ b/aider/tests/test_editblock.py @@ -398,6 +398,32 @@ Hope you like it! ], ) + def test_deepseek_coder_v2_filename_mangling(self): + edit = """ +Here's the change: + + ```python +foo.txt +``` +```python +<<<<<<< SEARCH +one +======= +two +>>>>>>> REPLACE +``` + +Hope you like it! +""" + + edits = list(eb.find_original_update_blocks(edit)) + self.assertEqual( + edits, + [ + ("foo.txt", "one\n", "two\n"), + ], + ) + if __name__ == "__main__": unittest.main() From 0a95badf3f0f8819064b06f5320d17fc5190f557 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 21 Jun 2024 08:57:30 -0700 Subject: [PATCH 80/82] Updated docs --- README.md | 13 ++---- website/HISTORY.md | 1 + website/_data/edit_leaderboard.yml | 69 ++++++++++++++++++++---------- website/docs/faq.md | 4 +- website/docs/git.md | 1 + website/docs/languages.md | 1 + website/docs/llms.md | 14 +++--- website/docs/more-info.md | 8 ++++ website/docs/repomap.md | 1 + website/docs/scripting.md | 1 + website/index.md | 13 ++---- 11 files changed, 76 insertions(+), 50 deletions(-) create mode 100644 website/docs/more-info.md diff --git a/README.md b/README.md index 78af92915..3bdbc20a4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Aider lets you pair program with LLMs, to edit code in your local git repository. Start a new project or work with an existing git repo. Aider can [connect to almost any LLM](https://aider.chat/docs/llms.html). -and works best with GPT-4o, Claude 3.5 Sonnet and Claude 3 Opus. +and works best with GPT-4o, Claude 3.5 Sonnet, Claude 3 Opus and DeepSeek Coder V2.

- - aider swe bench - -

- ## More info - [Documentation](https://aider.chat/) diff --git a/website/HISTORY.md b/website/HISTORY.md index 044c1652c..4e84bf086 100644 --- a/website/HISTORY.md +++ b/website/HISTORY.md @@ -1,5 +1,6 @@ --- title: Release history +parent: More info nav_order: 999 --- diff --git a/website/_data/edit_leaderboard.yml b/website/_data/edit_leaderboard.yml index 1b5bf476d..c7c4a0efc 100644 --- a/website/_data/edit_leaderboard.yml +++ b/website/_data/edit_leaderboard.yml @@ -44,29 +44,6 @@ seconds_per_case: 23.1 total_cost: 0.0000 -- dirname: 2024-06-17-14-45-54--deepseek-coder2-whole - test_cases: 133 - model: DeepSeek Coder V2 - edit_format: whole - commit_hash: ca8672b - pass_rate_1: 63.9 - pass_rate_2: 75.2 - percent_cases_well_formed: 100.0 - error_outputs: 1 - num_malformed_responses: 0 - num_with_malformed_responses: 0 - user_asks: 1 - lazy_comments: 0 - syntax_errors: 1 - indentation_errors: 0 - exhausted_context_windows: 0 - test_timeouts: 7 - command: aider --model deepseek/deepseek-coder - date: 2024-06-17 - versions: 0.38.1-dev - seconds_per_case: 21.1 - total_cost: 0.0537 - - dirname: 2024-05-03-20-47-24--gemini-1.5-pro-diff-fenced test_cases: 133 model: gemini-1.5-pro-latest @@ -658,4 +635,50 @@ versions: 0.38.1-dev seconds_per_case: 21.6 total_cost: 0.0000 + +- dirname: 2024-06-17-14-45-54--deepseek-coder2-whole + test_cases: 133 + model: DeepSeek Coder V2 (whole) + edit_format: whole + commit_hash: ca8672b + pass_rate_1: 63.9 + pass_rate_2: 75.2 + percent_cases_well_formed: 100.0 + error_outputs: 1 + num_malformed_responses: 0 + num_with_malformed_responses: 0 + user_asks: 1 + lazy_comments: 0 + syntax_errors: 1 + indentation_errors: 0 + exhausted_context_windows: 0 + test_timeouts: 7 + command: aider --model deepseek/deepseek-coder + date: 2024-06-17 + versions: 0.38.1-dev + seconds_per_case: 21.1 + total_cost: 0.0537 + +- dirname: 2024-06-21-15-29-08--deepseek-coder2-diff-again3 + test_cases: 133 + model: DeepSeek Coder V2 (diff) + edit_format: diff + commit_hash: 515ab3e + pass_rate_1: 58.6 + pass_rate_2: 66.2 + percent_cases_well_formed: 98.5 + error_outputs: 23 + num_malformed_responses: 5 + num_with_malformed_responses: 2 + user_asks: 2 + lazy_comments: 0 + syntax_errors: 0 + indentation_errors: 1 + exhausted_context_windows: 0 + test_timeouts: 2 + command: aider --model deepseek/deepseek-coder + date: 2024-06-21 + versions: 0.39.1-dev + seconds_per_case: 30.2 + total_cost: 0.0857 \ No newline at end of file diff --git a/website/docs/faq.md b/website/docs/faq.md index a1443b1e8..f32872828 100644 --- a/website/docs/faq.md +++ b/website/docs/faq.md @@ -1,9 +1,9 @@ --- -nav_order: 85 +nav_order: 90 description: Frequently asked questions about aider. --- -# Frequently asked questions +# FAQ {: .no_toc } - TOC diff --git a/website/docs/git.md b/website/docs/git.md index f9c8bb5ad..ea2b145fe 100644 --- a/website/docs/git.md +++ b/website/docs/git.md @@ -1,4 +1,5 @@ --- +parent: More info nav_order: 800 description: Aider is tightly integrated with git. --- diff --git a/website/docs/languages.md b/website/docs/languages.md index 889e4caa9..d74f748c9 100644 --- a/website/docs/languages.md +++ b/website/docs/languages.md @@ -1,4 +1,5 @@ --- +parent: More info nav_order: 900 description: Aider supports pretty much all popular coding languages. --- diff --git a/website/docs/llms.md b/website/docs/llms.md index 76862b2e6..37cd82f7a 100644 --- a/website/docs/llms.md +++ b/website/docs/llms.md @@ -14,17 +14,21 @@ description: Aider can connect to most LLMs for AI pair programming. ## Best models {: .no_toc } -**Aider works best with [GPT-4o](/docs/llms/openai.html), -[Claude 3.5 Sonnet and Claude 3 Opus](/docs/llms/anthropic.html),** -as they are the very best models for editing code. +Aider works best with these models, which are skilled at editing code: + +- [GPT-4o](/docs/llms/openai.html) +- [Claude 3.5 Sonnet](/docs/llms/anthropic.html) +- [Claude 3 Opus](/docs/llms/anthropic.html) +- [DeepSeek Coder V2](/docs/llms/deepseek.html) + ## Free models {: .no_toc } Aider works with a number of **free** API providers: -- The [DeepSeek Coder V2](/docs/llms/deepseek.html) model gets the top score on aider's code editing benchmark. DeepSeek currently offers 5M free tokens of API usage. -- Google's [Gemini 1.5 Pro](/docs/llms/gemini.html) is the most capable free model to use with aider, with +- The [DeepSeek Coder V2](/docs/llms/deepseek.html) model gets the top score on aider's code editing benchmark. DeepSeek has been offering 5M free tokens of API usage. +- Google's [Gemini 1.5 Pro](/docs/llms/gemini.html) works with aider, with code editing capabilities similar to GPT-3.5. - You can use [Llama 3 70B on Groq](/docs/llms/groq.html) which is comparable to GPT-3.5 in code editing performance. - Cohere also offers free API access to their [Command-R+ model](/docs/llms/cohere.html), which works with aider as a *very basic* coding assistant. diff --git a/website/docs/more-info.md b/website/docs/more-info.md new file mode 100644 index 000000000..3b40cb9e1 --- /dev/null +++ b/website/docs/more-info.md @@ -0,0 +1,8 @@ +--- +has_children: true +nav_order: 85 +--- + +# More info + +See below for more info about aider, including some advanced topics. diff --git a/website/docs/repomap.md b/website/docs/repomap.md index aefedc5dc..359243103 100644 --- a/website/docs/repomap.md +++ b/website/docs/repomap.md @@ -1,4 +1,5 @@ --- +parent: More info highlight_image: /assets/robot-ast.png nav_order: 900 description: Aider uses a map of your git repository to provide code context to LLMs. diff --git a/website/docs/scripting.md b/website/docs/scripting.md index 2d6149d31..984ecb864 100644 --- a/website/docs/scripting.md +++ b/website/docs/scripting.md @@ -1,4 +1,5 @@ --- +parent: More info nav_order: 900 description: You can script aider via the command line or python. --- diff --git a/website/index.md b/website/index.md index 7d847f65d..cbf8498df 100644 --- a/website/index.md +++ b/website/index.md @@ -21,7 +21,7 @@ Aider lets you pair program with LLMs, to edit code in your local git repository. Start a new project or work with an existing git repo. Aider can [connect to almost any LLM](https://aider.chat/docs/llms.html). -and works best with GPT-4o, Claude 3.5 Sonnet and Claude 3 Opus. +and works best with GPT-4o, Claude 3.5 Sonnet, Claude 3 Opus and DeepSeek Coder V2.

- - aider swe bench - -

- ## More info - [Documentation](https://aider.chat/) From 6bd325e4322923338ca1745a663975cfb7266cbf Mon Sep 17 00:00:00 2001 From: Dustin Miller <1342542+spdustin@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:31:16 -0500 Subject: [PATCH 81/82] Add support for vertex_ai/claude_* models --- aider/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/aider/models.py b/aider/models.py index ac150d546..a16e70340 100644 --- a/aider/models.py +++ b/aider/models.py @@ -196,6 +196,20 @@ MODEL_SETTINGS = [ weak_model_name="openrouter/anthropic/claude-3-haiku-20240307", use_repo_map=True, ), + # Vertex AI Claude models + ModelSettings( + "vertex_ai/claude-3-5-sonnet@20240620", + "diff", + weak_model_name="vertex_ai/claude-3-haiku@20240307", + use_repo_map=True, + ), + ModelSettings( + "vertex_ai/claude-3-opus@20240229", + "diff", + weak_model_name="vertex_ai/claude-3-haiku@20240307", + use_repo_map=True, + send_undo_reply=True, + ), # Cohere ModelSettings( "command-r-plus", From 4fed045f277cda31b912c6e1b7ee6346c70a6eb9 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 21 Jun 2024 16:50:49 -0700 Subject: [PATCH 82/82] Added vertex_ai/claude-3-sonnet@20240229, bumped deps to upgrade litellm #704 --- aider/models.py | 5 +++++ requirements.txt | 26 ++++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/aider/models.py b/aider/models.py index e52267092..003bc1e68 100644 --- a/aider/models.py +++ b/aider/models.py @@ -210,6 +210,11 @@ MODEL_SETTINGS = [ use_repo_map=True, send_undo_reply=True, ), + ModelSettings( + "vertex_ai/claude-3-sonnet@20240229", + "whole", + weak_model_name="vertex_ai/claude-3-haiku@20240307", + ), # Cohere ModelSettings( "command-r-plus", diff --git a/requirements.txt b/requirements.txt index e7bff9826..f99a01346 100644 --- a/requirements.txt +++ b/requirements.txt @@ -54,7 +54,7 @@ diskcache==5.6.3 # via -r requirements.in distro==1.9.0 # via openai -filelock==3.15.1 +filelock==3.15.3 # via huggingface-hub flake8==7.1.0 # via -r requirements.in @@ -70,14 +70,14 @@ gitpython==3.1.43 # via # -r requirements.in # streamlit -google-ai-generativelanguage==0.6.4 +google-ai-generativelanguage==0.6.5 # via google-generativeai google-api-core[grpc]==2.19.0 # via # google-ai-generativelanguage # google-api-python-client # google-generativeai -google-api-python-client==2.133.0 +google-api-python-client==2.134.0 # via google-generativeai google-auth==2.30.0 # via @@ -88,7 +88,7 @@ google-auth==2.30.0 # google-generativeai google-auth-httplib2==0.2.0 # via google-api-python-client -google-generativeai==0.6.0 +google-generativeai==0.7.0 # via -r requirements.in googleapis-common-protos==1.63.1 # via @@ -122,7 +122,9 @@ idna==3.7 # httpx # requests # yarl -importlib-metadata==7.1.0 +ijson==3.3.0 + # via litellm +importlib-metadata==7.2.0 # via litellm jinja2==3.1.4 # via @@ -135,7 +137,7 @@ jsonschema==4.22.0 # altair jsonschema-specifications==2023.12.1 # via jsonschema -litellm==1.40.15 +litellm==1.40.21 # via -r requirements.in markdown-it-py==3.0.0 # via rich @@ -151,7 +153,7 @@ multidict==6.0.5 # yarl networkx==3.2.1 # via -r requirements.in -numpy==1.26.4 +numpy==2.0.0 # via # -r requirements.in # altair @@ -160,7 +162,7 @@ numpy==1.26.4 # pydeck # scipy # streamlit -openai==1.34.0 +openai==1.35.3 # via # -r requirements.in # litellm @@ -186,7 +188,7 @@ playwright==1.44.0 # via -r requirements.in prompt-toolkit==3.0.47 # via -r requirements.in -proto-plus==1.23.0 +proto-plus==1.24.0 # via # google-ai-generativelanguage # google-api-core @@ -280,9 +282,9 @@ soundfile==0.12.1 # via -r requirements.in soupsieve==2.5 # via beautifulsoup4 -streamlit==1.35.0 +streamlit==1.36.0 # via -r requirements.in -tenacity==8.3.0 +tenacity==8.4.1 # via streamlit tiktoken==0.7.0 # via @@ -320,7 +322,7 @@ tzdata==2024.1 # via pandas uritemplate==4.1.1 # via google-api-python-client -urllib3==2.2.1 +urllib3==2.2.2 # via requests watchdog==4.0.1 # via -r requirements.in