mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 00:05:01 +00:00
better
This commit is contained in:
parent
04382f0b2b
commit
96209d67e1
1 changed files with 9 additions and 1 deletions
10
coder.py
10
coder.py
|
@ -306,7 +306,7 @@ The ``` delimiters are very important!
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def do_gpt_powered_replace(self, fname, edit):
|
def do_gpt_powered_replace(self, fname, edit):
|
||||||
print(f'Could not find CURRENT block in {fname}, asking GPT to make the edit...')
|
print(f'Could not find ORIGINAL block in {fname}, asking GPT to make the edit...')
|
||||||
fname = Path(fname)
|
fname = Path(fname)
|
||||||
content = fname.read_text()
|
content = fname.read_text()
|
||||||
prompt = f'''
|
prompt = f'''
|
||||||
|
@ -335,7 +335,15 @@ Just the content of the file!
|
||||||
dict(role = 'user', content = prompt),
|
dict(role = 'user', content = prompt),
|
||||||
]
|
]
|
||||||
res = self.send(messages)
|
res = self.send(messages)
|
||||||
|
res = res.splitlines()
|
||||||
|
if res[0].strip == str(fname):
|
||||||
|
res = res[1:]
|
||||||
|
if res[0].strip() == '```' and res[-1].strip() == '```':
|
||||||
|
res = res[1:-1]
|
||||||
|
|
||||||
|
res = '\n'.join(res)
|
||||||
|
if res[-1] != '\n':
|
||||||
|
res += '\n'
|
||||||
fname.write_text(res)
|
fname.write_text(res)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue