mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
Ask GPT to retry if original block is not found
This commit is contained in:
parent
691c013272
commit
4bc35a7376
3 changed files with 14 additions and 3 deletions
|
@ -532,6 +532,7 @@ class Coder:
|
|||
|
||||
edited, edit_error = self.apply_updates()
|
||||
if edit_error:
|
||||
self.update_cur_messages(content, set())
|
||||
return edit_error
|
||||
|
||||
# TODO: this shouldn't use content, should use self.partial_....
|
||||
|
@ -1006,7 +1007,7 @@ class Coder:
|
|||
apply_update_errors = 0
|
||||
|
||||
def apply_updates(self):
|
||||
max_apply_update_errors = 2
|
||||
max_apply_update_errors = 3
|
||||
|
||||
try:
|
||||
edited = self.update_files()
|
||||
|
|
|
@ -32,7 +32,17 @@ class EditBlockCoder(Coder):
|
|||
self.io.write_text(full_path, content)
|
||||
edited.add(path)
|
||||
continue
|
||||
self.io.tool_error(f"Failed to apply edit to {path}")
|
||||
raise ValueError(f"""InvalidEditBlock: edit failed!
|
||||
|
||||
{path} does not contain the *exact sequence* of ORIGINAL lines you specified.
|
||||
Try again.
|
||||
DO NOT skip blank lines, comments, docstrings, etc!
|
||||
The ORIGINAL block needs to be EXACTLY the same as the lines in {path} with nothing missing!
|
||||
|
||||
{path} does not contain these {len(original.splitlines())} exact lines in a row:
|
||||
```
|
||||
{original}```
|
||||
""")
|
||||
|
||||
return edited
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ some/dir/example.py
|
|||
|
||||
Every *edit block* must be fenced with {fence[0]}...{fence[1]} with the correct code language.
|
||||
Every *edit block* must start with the full path! *NEVER* propose edit blocks for *read-only* files.
|
||||
The ORIGINAL section must be an *exact* set of lines from the file:
|
||||
The ORIGINAL section must be an *exact set of sequential lines* from the file:
|
||||
- NEVER SKIP LINES!
|
||||
- Include all original leading spaces and indentation!
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue