mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
Provide structured errors to GPT if it generates malformed ORIG/UPD blocks
This commit is contained in:
parent
ae41782cb4
commit
684b0e4964
3 changed files with 100 additions and 14 deletions
|
@ -248,6 +248,12 @@ class Coder:
|
|||
|
||||
try:
|
||||
edited = self.update_files(content, inp)
|
||||
except ValueError as err:
|
||||
err = err.args[0]
|
||||
self.console.print("[red]Malformed ORIGINAL/UPDATE blocks, retrying...")
|
||||
self.console.print("[red]", Text(err))
|
||||
return err
|
||||
|
||||
except Exception as err:
|
||||
print(err)
|
||||
print()
|
||||
|
@ -373,8 +379,11 @@ class Coder:
|
|||
live.stop()
|
||||
|
||||
def update_files(self, content, inp):
|
||||
# might raise ValueError for malformed ORIG/UPD blocks
|
||||
edits = list(utils.find_original_update_blocks(content))
|
||||
|
||||
edited = set()
|
||||
for path, original, updated in utils.find_original_update_blocks(content):
|
||||
for path, original, updated in edits:
|
||||
full_path = os.path.abspath(os.path.join(self.root, path))
|
||||
|
||||
if full_path not in self.abs_fnames:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue