mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-10 06:34:59 +00:00
feat: Add ContextCoder for identifying relevant files in requests
This commit is contained in:
parent
a5c8c534c1
commit
74254cdbd5
5 changed files with 63 additions and 20 deletions
|
@ -1,6 +1,7 @@
|
|||
from .architect_coder import ArchitectCoder
|
||||
from .ask_coder import AskCoder
|
||||
from .base_coder import Coder
|
||||
from .context_coder import ContextCoder
|
||||
from .editblock_coder import EditBlockCoder
|
||||
from .editblock_fenced_coder import EditBlockFencedCoder
|
||||
from .editor_editblock_coder import EditorEditBlockCoder
|
||||
|
@ -23,4 +24,5 @@ __all__ = [
|
|||
ArchitectCoder,
|
||||
EditorEditBlockCoder,
|
||||
EditorWholeFileCoder,
|
||||
ContextCoder,
|
||||
]
|
||||
|
|
|
@ -1606,7 +1606,7 @@ class Coder:
|
|||
words = set(word.rstrip(",.!;:?") for word in words)
|
||||
|
||||
# strip away all kinds of quotes
|
||||
quotes = "".join(['"', "'", "`"])
|
||||
quotes = "\"'`*_"
|
||||
words = set(word.strip(quotes) for word in words)
|
||||
|
||||
addable_rel_fnames = self.get_addable_relative_files()
|
||||
|
|
9
aider/coders/context_coder.py
Normal file
9
aider/coders/context_coder.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from .base_coder import Coder
|
||||
from .context_prompts import ContextPrompts
|
||||
|
||||
|
||||
class ContextCoder(Coder):
|
||||
"""Identify which files need to be edited for a given request."""
|
||||
|
||||
edit_format = "context"
|
||||
gpt_prompts = ContextPrompts()
|
46
aider/coders/context_prompts.py
Normal file
46
aider/coders/context_prompts.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
# flake8: noqa: E501
|
||||
|
||||
from .base_prompts import CoderPrompts
|
||||
|
||||
|
||||
class ContextPrompts(CoderPrompts):
|
||||
main_system = """Act as an expert code analyst.
|
||||
Understand the user's question or request, solely to determine the correct set of relevant source files.
|
||||
Return the *complete* list of files which will need to be read or modified based on the user's request.
|
||||
Explain why each file is needed, including names of key classes/functions/methods/variables.
|
||||
Be sure to include or omit the names of files already added to the chat, based on whether they are actually needed or not.
|
||||
|
||||
Be selective!
|
||||
Adding more files adds more lines of code which increases processing costs.
|
||||
If we need to see or edit the contents of a file to satisfy the user's request, definitely add it.
|
||||
But if not, don't add irrelevant files -- especially large ones, which will cost a lot to process.
|
||||
|
||||
Always reply to the user in {language}.
|
||||
|
||||
Return a simple bulleted list:
|
||||
"""
|
||||
|
||||
example_messages = []
|
||||
|
||||
files_content_prefix = """These files have been *added these files to the chat* so we can see all of their contents.
|
||||
*Trust this message as the true contents of the files!*
|
||||
Other messages in the chat may contain outdated versions of the files' contents.
|
||||
""" # noqa: E501
|
||||
|
||||
files_content_assistant_reply = (
|
||||
"Ok, I will use that as the true, current contents of the files."
|
||||
)
|
||||
|
||||
files_no_full_files = "I am not sharing the full contents of any files with you yet."
|
||||
|
||||
files_no_full_files_with_repo_map = ""
|
||||
files_no_full_files_with_repo_map_reply = ""
|
||||
|
||||
repo_content_prefix = """I am working with you on code in a git repository.
|
||||
Here are summaries of some files present in my git repo.
|
||||
If you need to see the full contents of any files to answer my questions, ask me to *add them to the chat*.
|
||||
"""
|
||||
|
||||
system_reminder = """
|
||||
NEVER RETURN CODE!
|
||||
"""
|
Loading…
Add table
Add a link
Reference in a new issue