diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 2c811ae84..5c467435b 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -526,6 +526,13 @@ class Coder: messages = [ dict(role="system", content=main_sys), ] + for msg in self.gpt_prompts.example_messages: + messages.append( + dict( + role=msg["role"], + content=self.fmt_system_prompt(msg["content"]), + ) + ) self.summarize_end() messages += self.done_messages diff --git a/aider/coders/editblock_prompts.py b/aider/coders/editblock_prompts.py index eb5054cc3..05e358a6c 100644 --- a/aider/coders/editblock_prompts.py +++ b/aider/coders/editblock_prompts.py @@ -16,49 +16,17 @@ Once you understand the request you MUST: 2. Think step-by-step and explain the needed changes with a numbered list of short sentences. 3. 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*! +All changes to files must use the *SEARCH/REPLACE block* format. +""" -# Example conversation: - -## USER: These are the *read-write* files: - -{fence[0]} -mathweb/flask/app.py -from flask import Flask - -app = Flask(__name__) - -@app.route('/div//') -def divide(n, d): - if d == 0: - return 'Error: Division by zero' - else: - result = n / d - return str(result) - -def factorial(n): - "compute factorial" - - if n == 0: - return 1 - else: - return n * factorial(n-1) - -@app.route('/factorial/') -def get_factorial(n): - return str(factorial(n)) - -if __name__ == '__main__': - print("Starting...") - app.run() -{fence[1]} - -## ASSISTANT: Ok. - -## USER: Change get_factorial() to use math.factorial - -## ASSISTANT: - -Do make this change we need to modify `mathweb/flask/app.py` to: + example_messages = [ + dict( + role="user", + content="Change get_factorial() to use math.factorial", + ), + 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. @@ -99,30 +67,15 @@ mathweb/flask/app.py return str(math.factorial(n)) >>>>>>> REPLACE {fence[1]} - - -# Example conversation: - -## USER: These are the *read-write* files: - -{fence[0]} -main.py -def hello(): - "print a greeting" - - print("hello") - -if __name__ == '__main__': - hello() -{fence[1]} - -## ASSISTANT: Ok. - -## USER: Refactor hello() into its own file. - -## ASSISTANT: - -Do make this change we need to modify `main.py` and make a new file `hello.py`: +""", + ), + dict( + role="user", + content="Refactor hello() into its own file.", + ), + 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. @@ -151,9 +104,9 @@ def hello(): from hello import hello >>>>>>> REPLACE {fence[1]} - -# Rules -""" +""", + ), + ] system_reminder = """Every *SEARCH/REPLACE block* must use this format: 1. The opening fence and code language, eg: {fence[0]} diff --git a/aider/coders/udiff_prompts.py b/aider/coders/udiff_prompts.py index 14d1a73ac..abff70413 100644 --- a/aider/coders/udiff_prompts.py +++ b/aider/coders/udiff_prompts.py @@ -14,13 +14,17 @@ Respect and use existing conventions, libraries, etc that are already present in Take requests for changes to the supplied code. If the request is ambiguous, ask questions. -For each file that needs to be changed, write out the changes similar to a unified diff like `diff -U0` would produce. For example: +For each file that needs to be changed, write out the changes similar to a unified diff like `diff -U0` would produce. +""" -# Example conversation 1 - -## USER: Replace is_prime with a call to sympy. - -## ASSISTANT: Ok, I will: + example_messages = [ + dict( + role="user", + content="Replace is_prime with a call to sympy.", + ), + dict( + role="assistant", + content="""Ok, I will: 1. Add an imports of sympy. 2. Remove the is_prime() function. @@ -64,7 +68,9 @@ Here are the diffs for those changes: + count += 1 + return str(num) ``` -""" +""", + ), + ] system_reminder = """# File editing rules: