Ask GPT to retry if original block is not found

This commit is contained in:
Paul Gauthier 2023-07-19 17:24:53 -03:00
parent 691c013272
commit 4bc35a7376
3 changed files with 14 additions and 3 deletions

View file

@ -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