From 617b1bdee2c93b221131d24b0dd2765739810496 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 5 Aug 2024 14:41:56 -0300 Subject: [PATCH] Can force repo-map on with: --map-tokens 1024 --- HISTORY.md | 1 + aider/args.py | 2 +- aider/coders/base_coder.py | 11 ++++++++++- aider/website/HISTORY.md | 1 + aider/website/assets/sample.aider.conf.yml | 2 +- aider/website/assets/sample.env | 2 +- aider/website/docs/config/aider_conf.md | 2 +- aider/website/docs/config/dotenv.md | 2 +- aider/website/docs/config/options.md | 1 - 9 files changed, 17 insertions(+), 7 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index db7a3554f..6c9bedcb0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,7 @@ - Added `--subtree-only` to limit aider to current directory subtree. - Should help with large/mono repo performance. - New `/add-clipboard-image` to add images to the chat from your clipboard. +- Use `--map-tokens 1024` to use repo map with any model. - Support for Sonnet's 8k output window. - [Aider already supported infinite output from Sonnet.](https://aider.chat/2024/07/01/sonnet-not-lazy.html) - Performance improvements for large repos. diff --git a/aider/args.py b/aider/args.py index 3d5596687..ff061c4b1 100644 --- a/aider/args.py +++ b/aider/args.py @@ -181,7 +181,7 @@ def get_parser(default_config_files, git_root): group.add_argument( "--map-tokens", type=int, - default=1024, + default=None, help="Max number of tokens to use for repo map, use 0 to disable (default: 1024)", ) group.add_argument( diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index f7c201fe8..baf95dced 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -311,8 +311,17 @@ class Coder: if not self.repo: self.find_common_root() + if map_tokens is None: + use_repo_map = main_model.use_repo_map + map_tokens = 1024 + else: + use_repo_map = True + max_inp_tokens = self.main_model.info.get("max_input_tokens") or 0 - if main_model.use_repo_map and self.repo and self.gpt_prompts.repo_content_prefix: + + has_map_prompt = hasattr(self, "gpt_prompts") and self.gpt_prompts.repo_content_prefix + + if use_repo_map and self.repo and has_map_prompt: self.repo_map = RepoMap( map_tokens, self.root, diff --git a/aider/website/HISTORY.md b/aider/website/HISTORY.md index ee99d10f2..cf8cfc5ce 100644 --- a/aider/website/HISTORY.md +++ b/aider/website/HISTORY.md @@ -21,6 +21,7 @@ cog.out(text) - Added `--subtree-only` to limit aider to current directory subtree. - Should help with large/mono repo performance. - New `/add-clipboard-image` to add images to the chat from your clipboard. +- Use `--map-tokens 1024` to use repo map with any model. - Support for Sonnet's 8k output window. - [Aider already supported infinite output from Sonnet.](https://aider.chat/2024/07/01/sonnet-not-lazy.html) - Performance improvements for large repos. diff --git a/aider/website/assets/sample.aider.conf.yml b/aider/website/assets/sample.aider.conf.yml index e3a790c4e..31088fecc 100644 --- a/aider/website/assets/sample.aider.conf.yml +++ b/aider/website/assets/sample.aider.conf.yml @@ -84,7 +84,7 @@ #show-model-warnings: true ## Max number of tokens to use for repo map, use 0 to disable (default: 1024) -#map-tokens: true +#map-tokens: ## Maximum number of tokens to use for chat history. If not specified, uses the model's max_chat_history_tokens. #max-chat-history-tokens: diff --git a/aider/website/assets/sample.env b/aider/website/assets/sample.env index b5c41b54c..56708a188 100644 --- a/aider/website/assets/sample.env +++ b/aider/website/assets/sample.env @@ -88,7 +88,7 @@ #AIDER_SHOW_MODEL_WARNINGS=true ## Max number of tokens to use for repo map, use 0 to disable (default: 1024) -#AIDER_MAP_TOKENS=true +#AIDER_MAP_TOKENS= ## 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= diff --git a/aider/website/docs/config/aider_conf.md b/aider/website/docs/config/aider_conf.md index 6943130f5..3f6c1e40a 100644 --- a/aider/website/docs/config/aider_conf.md +++ b/aider/website/docs/config/aider_conf.md @@ -123,7 +123,7 @@ cog.outl("```") #show-model-warnings: true ## Max number of tokens to use for repo map, use 0 to disable (default: 1024) -#map-tokens: true +#map-tokens: ## Maximum number of tokens to use for chat history. If not specified, uses the model's max_chat_history_tokens. #max-chat-history-tokens: diff --git a/aider/website/docs/config/dotenv.md b/aider/website/docs/config/dotenv.md index 816f2fd3a..493b123db 100644 --- a/aider/website/docs/config/dotenv.md +++ b/aider/website/docs/config/dotenv.md @@ -130,7 +130,7 @@ cog.outl("```") #AIDER_SHOW_MODEL_WARNINGS=true ## Max number of tokens to use for repo map, use 0 to disable (default: 1024) -#AIDER_MAP_TOKENS=true +#AIDER_MAP_TOKENS= ## 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= diff --git a/aider/website/docs/config/options.md b/aider/website/docs/config/options.md index c8fcff34e..1c6428b24 100644 --- a/aider/website/docs/config/options.md +++ b/aider/website/docs/config/options.md @@ -175,7 +175,6 @@ Aliases: ### `--map-tokens VALUE` Max number of tokens to use for repo map, use 0 to disable (default: 1024) -Default: 1024 Environment variable: `AIDER_MAP_TOKENS` ### `--max-chat-history-tokens VALUE`