@@ -277,6 +277,12 @@ def add_snippets(self, snippets_to_add: list[Snippet]):
277
277
for snippet in snippets_to_add :
278
278
self .current_top_snippets .append (snippet )
279
279
280
+ # does the same thing as add_snippets but adds it to the beginning of the list
281
+ def boost_snippets_to_top (self , snippets_to_boost : list [Snippet ]):
282
+ self .dir_obj .add_file_paths ([snippet .file_path for snippet in snippets_to_boost ])
283
+ for snippet in snippets_to_boost :
284
+ self .current_top_snippets .insert (0 , snippet )
285
+
280
286
def add_import_trees (self , import_trees : str ):
281
287
self .import_trees += "\n " + import_trees
282
288
@@ -411,7 +417,7 @@ def add_relevant_files_to_top_snippets(rcm: RepoContextManager) -> RepoContextMa
411
417
code_snippets = [
412
418
snippet for snippet in rcm .snippets if snippet .file_path == file
413
419
]
414
- rcm .add_snippets (code_snippets )
420
+ rcm .boost_snippets_to_top (code_snippets )
415
421
except Exception as e :
416
422
logger .error (
417
423
f"Tried to add code file found in query but recieved error: { e } , skipping and continuing to next one."
@@ -484,11 +490,11 @@ def get_relevant_context(
484
490
client = get_client ()
485
491
try :
486
492
# attempt to get import tree for relevant snippets that show up in the query
487
- repo_context_manager , import_graph = parse_query_for_files (
493
+ repo_context_manager , _ = parse_query_for_files (
488
494
query , repo_context_manager
489
495
)
490
- # for any code file mentioned in the query, build its import tree
491
- repo_context_manager = build_import_trees (repo_context_manager , import_graph , override_import_graph = override_import_graph )
496
+ # for any code file mentioned in the query, build its import tree - This is currently not used
497
+ # repo_context_manager = build_import_trees(repo_context_manager, import_graph, override_import_graph=override_import_graph)
492
498
# for any code file mentioned in the query add it to the top relevant snippets
493
499
repo_context_manager = add_relevant_files_to_top_snippets (repo_context_manager )
494
500
# add relevant files to dir_obj inside repo_context_manager, this is in case dir_obj is too large when as a string
0 commit comments