For /help, turn down the repo map

This commit is contained in:
Paul Gauthier 2024-07-06 17:11:24 -03:00
parent 66f7cfb38f
commit e4c637724f
3 changed files with 12 additions and 3 deletions

View file

@ -231,6 +231,7 @@ class Coder:
attribute_committer=True, attribute_committer=True,
attribute_commit_message=False, attribute_commit_message=False,
aider_commit_hashes=None, aider_commit_hashes=None,
map_mul_no_files=8,
): ):
if not fnames: if not fnames:
fnames = [] fnames = []
@ -323,6 +324,7 @@ class Coder:
if not self.repo: if not self.repo:
self.find_common_root() self.find_common_root()
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: if main_model.use_repo_map and self.repo and self.gpt_prompts.repo_content_prefix:
self.repo_map = RepoMap( self.repo_map = RepoMap(
map_tokens, map_tokens,
@ -331,7 +333,8 @@ class Coder:
io, io,
self.gpt_prompts.repo_content_prefix, self.gpt_prompts.repo_content_prefix,
self.verbose, self.verbose,
self.main_model.info.get("max_input_tokens"), max_inp_tokens,
map_mul_no_files=map_mul_no_files,
) )
if max_chat_history_tokens is None: if max_chat_history_tokens is None:

View file

@ -662,6 +662,8 @@ class Commands:
from_coder=self.coder, from_coder=self.coder,
edit_format="help", edit_format="help",
summarize_from_coder=False, summarize_from_coder=False,
map_tokens=512,
map_mul_no_files=1,
) )
user_msg = self.help.ask(args) user_msg = self.help.ask(args)
user_msg += """ user_msg += """

View file

@ -41,6 +41,7 @@ class RepoMap:
repo_content_prefix=None, repo_content_prefix=None,
verbose=False, verbose=False,
max_context_window=None, max_context_window=None,
map_mul_no_files=8,
): ):
self.io = io self.io = io
self.verbose = verbose self.verbose = verbose
@ -52,6 +53,7 @@ class RepoMap:
self.load_tags_cache() self.load_tags_cache()
self.max_map_tokens = map_tokens self.max_map_tokens = map_tokens
self.map_mul_no_files = map_mul_no_files
self.max_context_window = max_context_window self.max_context_window = max_context_window
self.token_count = main_model.token_count self.token_count = main_model.token_count
@ -70,10 +72,12 @@ class RepoMap:
max_map_tokens = self.max_map_tokens max_map_tokens = self.max_map_tokens
# With no files in the chat, give a bigger view of the entire repo # With no files in the chat, give a bigger view of the entire repo
MUL = 8
padding = 4096 padding = 4096
if max_map_tokens and self.max_context_window: if max_map_tokens and self.max_context_window:
target = min(max_map_tokens * MUL, self.max_context_window - padding) target = min(
max_map_tokens * self.map_mul_no_files,
self.max_context_window - padding,
)
else: else:
target = 0 target = 0
if not chat_files and self.max_context_window and target > 0: if not chat_files and self.max_context_window and target > 0: