mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 19:24:59 +00:00
Allow GPT to omit the filename from edit blocks, if an earlier block provided it
This commit is contained in:
parent
ef22abd8be
commit
ca74eee2f9
2 changed files with 17 additions and 5 deletions
|
@ -215,6 +215,9 @@ def find_original_update_blocks(content):
|
|||
pieces.reverse()
|
||||
processed = []
|
||||
|
||||
# Keep using the same filename in cases where GPT produces an edit block
|
||||
# without a filename.
|
||||
current_filename = None
|
||||
try:
|
||||
while pieces:
|
||||
cur = pieces.pop()
|
||||
|
@ -233,12 +236,20 @@ def find_original_update_blocks(content):
|
|||
try:
|
||||
if not len(filename) or "`" in filename:
|
||||
filename = processed[-2].splitlines()[-2].strip()
|
||||
if not len(filename) or "`" in filename:
|
||||
if not len(filename) or "`" in filename:
|
||||
if current_filename:
|
||||
filename = current_filename
|
||||
else:
|
||||
raise ValueError(
|
||||
f"Bad/missing filename. It should go right above {ORIGINAL}"
|
||||
)
|
||||
except IndexError:
|
||||
raise ValueError(f"Bad/missing filename. It should go right above {ORIGINAL}")
|
||||
if current_filename:
|
||||
filename = current_filename
|
||||
else:
|
||||
raise ValueError(f"Bad/missing filename. It should go right above {ORIGINAL}")
|
||||
|
||||
current_filename = filename
|
||||
|
||||
original_text = pieces.pop()
|
||||
processed.append(original_text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue