mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 02:34:59 +00:00
refactor: Simplify and optimize weight calculation in RepoMap
This commit is contained in:
parent
04e76ad6ff
commit
5e8fc3e4c8
1 changed files with 12 additions and 6 deletions
|
@ -105,6 +105,7 @@ class RepoMap:
|
|||
mentioned_idents=None,
|
||||
force_refresh=False,
|
||||
):
|
||||
|
||||
if self.max_map_tokens <= 0:
|
||||
return
|
||||
if not other_files:
|
||||
|
@ -445,12 +446,13 @@ class RepoMap:
|
|||
progress()
|
||||
|
||||
definers = defines[ident]
|
||||
|
||||
mul = 1.0
|
||||
# if ident is snake_case or camelCase, mul * 10 ai!
|
||||
if ident in mentioned_idents:
|
||||
mul = 10
|
||||
elif ident.startswith("_"):
|
||||
mul = 0.1
|
||||
else:
|
||||
mul = 1
|
||||
mul *= 10
|
||||
if ident.startswith("_"):
|
||||
mul *= 0.1
|
||||
|
||||
for referencer, num_refs in Counter(references[ident]).items():
|
||||
for definer in definers:
|
||||
|
@ -458,10 +460,14 @@ class RepoMap:
|
|||
# if referencer == definer:
|
||||
# continue
|
||||
|
||||
use_mul = mul
|
||||
if referencer in chat_rel_fnames:
|
||||
use_mul *= 50
|
||||
|
||||
# scale down so high freq (low value) mentions don't dominate
|
||||
num_refs = math.sqrt(num_refs)
|
||||
|
||||
G.add_edge(referencer, definer, weight=mul * num_refs, ident=ident)
|
||||
G.add_edge(referencer, definer, weight=use_mul * num_refs, ident=ident)
|
||||
|
||||
if not references:
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue