mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
prompt and token adjustments when no files in chat with repo
This commit is contained in:
parent
edc70bdf84
commit
292250db4f
3 changed files with 18 additions and 3 deletions
|
@ -446,6 +446,9 @@ class Coder:
|
|||
files_content = self.gpt_prompts.files_content_prefix
|
||||
files_content += self.get_files_content()
|
||||
files_reply = "Ok, any changes I propose will be to those files."
|
||||
elif repo_content:
|
||||
files_content = self.gpt_prompts.files_no_full_files_with_repo_map
|
||||
files_reply = "Ok, based on your requests I will suggest which files need to be edited."
|
||||
else:
|
||||
files_content = self.gpt_prompts.files_no_full_files
|
||||
files_reply = "Ok."
|
||||
|
|
|
@ -20,6 +20,11 @@ You always COMPLETELY IMPLEMENT the needed code!
|
|||
|
||||
files_no_full_files = "I am not sharing any files that you can edit yet."
|
||||
|
||||
files_no_full_files_with_repo_map = """Tell me which files in my repo are the most likely to **need changes** to solve the requests I make.
|
||||
Only include the 1-2 files that are most likely to actually need to be edited.
|
||||
Don't include files that might contain relevant context, just files that will need to be changed.
|
||||
""" # noqa: E501
|
||||
|
||||
repo_content_prefix = """Here are summaries of some files present in my git repository.
|
||||
Do not propose changes to these files, treat them as *read-only*.
|
||||
If you need to edit any of these files, ask me to *add them to the chat* first.
|
||||
|
|
|
@ -61,8 +61,13 @@ class RepoMap:
|
|||
if not other_files:
|
||||
return
|
||||
|
||||
max_map_tokens = self.max_map_tokens
|
||||
if not chat_files:
|
||||
# with no code in the chat, give a bigger view of the entire repo
|
||||
max_map_tokens *= 4
|
||||
|
||||
try:
|
||||
files_listing = self.get_ranked_tags_map(chat_files, other_files)
|
||||
files_listing = self.get_ranked_tags_map(chat_files, other_files, max_map_tokens)
|
||||
except RecursionError:
|
||||
self.io.tool_error("Disabling repo map, git repo too large?")
|
||||
self.max_map_tokens = 0
|
||||
|
@ -327,9 +332,11 @@ class RepoMap:
|
|||
|
||||
return ranked_tags
|
||||
|
||||
def get_ranked_tags_map(self, chat_fnames, other_fnames=None):
|
||||
def get_ranked_tags_map(self, chat_fnames, other_fnames=None, max_map_tokens=None):
|
||||
if not other_fnames:
|
||||
other_fnames = list()
|
||||
if not max_map_tokens:
|
||||
max_map_tokens = self.max_map_tokens
|
||||
|
||||
ranked_tags = self.get_ranked_tags(chat_fnames, other_fnames)
|
||||
num_tags = len(ranked_tags)
|
||||
|
@ -345,7 +352,7 @@ class RepoMap:
|
|||
tree = self.to_tree(ranked_tags[:middle], chat_rel_fnames)
|
||||
num_tokens = self.token_count(tree)
|
||||
|
||||
if num_tokens < self.max_map_tokens:
|
||||
if num_tokens < max_map_tokens:
|
||||
best_tree = tree
|
||||
lower_bound = middle + 1
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue