mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 01:04:59 +00:00
clean diff edit format
This commit is contained in:
parent
5b584db90c
commit
cc15909629
2 changed files with 14 additions and 67 deletions
|
@ -4,47 +4,11 @@ from .base_prompts import CoderPrompts
|
|||
|
||||
|
||||
class EditBlockPrompts(CoderPrompts):
|
||||
main_system = """Act as an expert software developer.
|
||||
Always use best practices when coding.
|
||||
Respect and use existing conventions, libraries, etc that are already present in the code base.
|
||||
main_system = """Act as an expert software developer who edits source code.
|
||||
{lazy_prompt}
|
||||
Take requests for changes to the supplied code.
|
||||
If the request is ambiguous, ask questions.
|
||||
|
||||
Always reply to the user in the same language they are using.
|
||||
|
||||
Once you understand the request you MUST:
|
||||
|
||||
1. Decide if you need to propose *SEARCH/REPLACE* edits to any files that haven't been added to the chat. You can create new files without asking!
|
||||
|
||||
But if you need to propose edits to existing files not already added to the chat, you *MUST* tell the user their full path names and ask them to *add the files to the chat*.
|
||||
End your reply and wait for their approval.
|
||||
You can keep asking if you then decide you need to edit more files.
|
||||
|
||||
2. Think step-by-step and explain the needed changes in a few short sentences.
|
||||
|
||||
3. Describe each change with a *SEARCH/REPLACE block* per the examples below.
|
||||
|
||||
Describe each change with a *SEARCH/REPLACE block* per the examples below.
|
||||
All changes to files must use this *SEARCH/REPLACE block* format.
|
||||
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
|
||||
4. *Concisely* suggest any shell commands the user might want to run in ```bash blocks.
|
||||
|
||||
Just suggest shell commands this way, not example code.
|
||||
Only suggest complete shell commands that area ready to execute, without placeholders.
|
||||
Only suggest at most a few shell commands at a time, not more than 1-3.
|
||||
|
||||
Use the appropriate shell based on the user's system info:
|
||||
{platform}
|
||||
|
||||
Examples of when to suggest shell commands:
|
||||
|
||||
- If you changed a self-contained html file, suggest an OS-appropriate command to open a browser to view it to see the updated content.
|
||||
- If you changed a CLI program, suggest the command to run it to see the new behavior.
|
||||
- If you added a test, suggest how to run it with the testing tool used by the project.
|
||||
- Suggest OS-appropriate commands to delete or rename files/directories, or other file system operations.
|
||||
- If your code changes add new dependencies, suggest the command to install them.
|
||||
- Etc.
|
||||
"""
|
||||
|
||||
example_messages = [
|
||||
|
@ -54,14 +18,7 @@ Examples of when to suggest shell commands:
|
|||
),
|
||||
dict(
|
||||
role="assistant",
|
||||
content="""To make this change we need to modify `mathweb/flask/app.py` to:
|
||||
|
||||
1. Import the math package.
|
||||
2. Remove the existing factorial() function.
|
||||
3. Update get_factorial() to call math.factorial instead.
|
||||
|
||||
Here are the *SEARCH/REPLACE* blocks:
|
||||
|
||||
content="""
|
||||
mathweb/flask/app.py
|
||||
{fence[0]}python
|
||||
<<<<<<< SEARCH
|
||||
|
@ -103,13 +60,7 @@ mathweb/flask/app.py
|
|||
),
|
||||
dict(
|
||||
role="assistant",
|
||||
content="""To make this change we need to modify `main.py` and make a new file `hello.py`:
|
||||
|
||||
1. Make a new hello.py file with hello() in it.
|
||||
2. Remove hello() from main.py and replace it with an import.
|
||||
|
||||
Here are the *SEARCH/REPLACE* blocks:
|
||||
|
||||
content="""
|
||||
hello.py
|
||||
{fence[0]}python
|
||||
<<<<<<< SEARCH
|
||||
|
@ -176,13 +127,4 @@ To rename files which have been added to the chat, use shell commands at the end
|
|||
|
||||
{lazy_prompt}
|
||||
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
|
||||
Examples of when to suggest shell commands:
|
||||
|
||||
- If you changed a self-contained html file, suggest an OS-appropriate command to open a browser to view it to see the updated content.
|
||||
- If you changed a CLI program, suggest the command to run it to see the new behavior.
|
||||
- If you added a test, suggest how to run it with the testing tool used by the project.
|
||||
- Suggest OS-appropriate commands to delete or rename files/directories, or other file system operations.
|
||||
- If your code changes add new dependencies, suggest the command to install them.
|
||||
- Etc.
|
||||
"""
|
||||
|
|
|
@ -549,10 +549,15 @@ def run_test_real(
|
|||
chat_history_file=history_fname,
|
||||
)
|
||||
|
||||
ask_model = models.Model("openrouter/anthropic/claude-3.5-sonnet")
|
||||
whole_model = models.Model("openrouter/anthropic/claude-3.5-sonnet")
|
||||
# ask_model = models.Model("openrouter/deepseek/deepseek-chat")
|
||||
# whole_model = models.Model("openrouter/deepseek/deepseek-chat")
|
||||
ask_model = models.Model("gpt-4o")
|
||||
# ask_model = models.Model("openrouter/anthropic/claude-3.5-sonnet")
|
||||
# ask_model = models.Model("openrouter/deepseek/deepseek-coder")
|
||||
|
||||
# whole_model = models.Model("gpt-4o")
|
||||
# whole_model = models.Model("openrouter/anthropic/claude-3.5-sonnet")
|
||||
# whole_model = models.Model("openrouter/deepseek/deepseek-coder")
|
||||
# whole_model = models.Model("openrouter/anthropic/claude-3-haiku-20240307")
|
||||
whole_model = models.Model("gpt-4o-mini")
|
||||
|
||||
main_model = ask_model
|
||||
edit_format = "ask-whole"
|
||||
|
@ -613,7 +618,7 @@ def run_test_real(
|
|||
whole_coder = Coder.create(
|
||||
from_coder=coder,
|
||||
main_model=whole_model,
|
||||
edit_format="whole",
|
||||
edit_format="diff",
|
||||
**coder_kwargs,
|
||||
)
|
||||
response = whole_coder.run(with_message="make those changes", preproc=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue