From 706451d43f9c36659871871767c0423eef1b3a77 Mon Sep 17 00:00:00 2001 From: Omri Bloch Date: Tue, 14 Nov 2023 12:06:51 +0200 Subject: [PATCH] Change editblock SEARCH/REPLACE prompt Change the prompt to be an example of edit and not example of replacement --- aider/coders/editblock_prompts.py | 39 ++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/aider/coders/editblock_prompts.py b/aider/coders/editblock_prompts.py index feef051299b..385a5a18fcd 100644 --- a/aider/coders/editblock_prompts.py +++ b/aider/coders/editblock_prompts.py @@ -19,27 +19,41 @@ class EditBlockPrompts(CoderPrompts): system_reminder = """You MUST use a *SEARCH/REPLACE block* to modify the source file: +For example, when changing some/dir/example.py: +{fence[0]} + 1|def multiply(a,b) + 2| "multiply 2 numbers" + 3| pass + 4| + 5|def add(a,b): + 6| "add 2 numbers" + 7| pass +{fence[1]} + +We will have the following *SEARCH/REPLACE block*: + {fence[0]}python some/dir/example.py <<<<<<< SEARCH - 1|# Multiplication function - 2|def multiply(a,b) - 3| "multiply 2 numbers" + 1|def multiply(a,b) + 2| "multiply 2 numbers" + 3| pass 4| - 5| return a*b + 5|def add(a,b): + 6| "add 2 numbers" + 7| pass ======= - 1|# Addition function - 2|def add(a,b): - 3| "add 2 numbers" + 1|def multiply(a,b) + 2| "multiply 2 numbers" + 3| return a * b 4| - 5| return a+b + 5|def add(a,b): + 6| "add 2 numbers" + 7| return a + b >>>>>>> REPLACE {fence[1]} The *SEARCH* section must *EXACTLY MATCH* the existing source code, character for character. -The *SEARCH/REPLACE block* must be concise. -Include just enough lines to uniquely specify the change. -Don't include extra unchanging lines. Every *SEARCH/REPLACE block* must be fenced with {fence[0]} and {fence[1]}, with the correct code language. @@ -59,4 +73,7 @@ class EditBlockPrompts(CoderPrompts): repo_content_prefix = """Below here are summaries of other files! Do not propose changes to these files, they are *read-only*. To make a file *read-write*, ask me to *add it to the chat*. +""" + additional_context_prefix = """ +Here is some context for our conversation.\n """