feat: add force_refresh arg to get_repo_map and pass to get_ranked_tags_map

This commit is contained in:
Paul Gauthier (aider) 2024-08-17 06:30:48 -07:00
parent bcd6257c90
commit 551804c289

View file

@ -83,7 +83,7 @@ class RepoMap:
est_tokens = sample_tokens / len(sample_text) * len_text est_tokens = sample_tokens / len(sample_text) * len_text
return est_tokens return est_tokens
def get_repo_map(self, chat_files, other_files, mentioned_fnames=None, mentioned_idents=None): def get_repo_map(self, chat_files, other_files, mentioned_fnames=None, mentioned_idents=None, force_refresh=False):
if self.max_map_tokens <= 0: if self.max_map_tokens <= 0:
return return
if not other_files: if not other_files:
@ -109,7 +109,7 @@ class RepoMap:
try: try:
files_listing = self.get_ranked_tags_map( files_listing = self.get_ranked_tags_map(
chat_files, other_files, max_map_tokens, mentioned_fnames, mentioned_idents chat_files, other_files, max_map_tokens, mentioned_fnames, mentioned_idents, force_refresh
) )
except RecursionError: except RecursionError:
self.io.tool_error("Disabling repo map, git repo too large?") self.io.tool_error("Disabling repo map, git repo too large?")
@ -412,6 +412,7 @@ class RepoMap:
max_map_tokens=None, max_map_tokens=None,
mentioned_fnames=None, mentioned_fnames=None,
mentioned_idents=None, mentioned_idents=None,
force_refresh=False,
): ):
# Create a cache key # Create a cache key
cache_key = ( cache_key = (
@ -420,6 +421,7 @@ class RepoMap:
max_map_tokens, max_map_tokens,
) )
if not force_refresh:
if self.refresh == "manual" and self.last_map: if self.refresh == "manual" and self.last_map:
return self.last_map return self.last_map
@ -434,7 +436,7 @@ class RepoMap:
if use_cache and cache_key in self.map_cache: if use_cache and cache_key in self.map_cache:
return self.map_cache[cache_key] return self.map_cache[cache_key]
# If not in cache, generate the map # If not in cache or force_refresh is True, generate the map
start_time = time.time() start_time = time.time()
result = self.get_ranked_tags_map_uncached( result = self.get_ranked_tags_map_uncached(
chat_fnames, other_fnames, max_map_tokens, mentioned_fnames, mentioned_idents chat_fnames, other_fnames, max_map_tokens, mentioned_fnames, mentioned_idents