mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
feat: Estimate initial middle value for binary search in get_ranked_tags_map
This commit is contained in:
parent
b19795228f
commit
ba1c8d1701
1 changed files with 13 additions and 5 deletions
|
@ -395,13 +395,21 @@ class RepoMap:
|
||||||
|
|
||||||
chat_rel_fnames = [self.get_rel_fname(fname) for fname in chat_fnames]
|
chat_rel_fnames = [self.get_rel_fname(fname) for fname in chat_fnames]
|
||||||
|
|
||||||
dump(max_map_tokens)
|
|
||||||
|
|
||||||
# Guess a small starting number to help with giant repos
|
|
||||||
middle = min(max_map_tokens // 50, num_tags)
|
|
||||||
|
|
||||||
self.tree_cache = dict()
|
self.tree_cache = dict()
|
||||||
|
|
||||||
|
# Estimate initial middle value
|
||||||
|
sample_size = min(100, num_tags)
|
||||||
|
sample_tree = self.to_tree(ranked_tags[:sample_size], chat_rel_fnames)
|
||||||
|
sample_tokens = self.token_count(sample_tree)
|
||||||
|
|
||||||
|
if sample_tokens > 0:
|
||||||
|
estimated_tags = int((max_map_tokens / sample_tokens) * sample_size)
|
||||||
|
middle = min(estimated_tags, num_tags)
|
||||||
|
else:
|
||||||
|
middle = min(max_map_tokens // 50, num_tags)
|
||||||
|
|
||||||
|
dump(max_map_tokens, sample_size, sample_tokens, estimated_tags, middle)
|
||||||
|
|
||||||
while lower_bound <= upper_bound:
|
while lower_bound <= upper_bound:
|
||||||
dump(lower_bound, middle, upper_bound)
|
dump(lower_bound, middle, upper_bound)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue