mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
Added user_suffix
This commit is contained in:
parent
c577f78f1c
commit
5628c2bf7c
2 changed files with 30 additions and 27 deletions
26
coder.py
26
coder.py
|
@ -67,7 +67,6 @@ class Coder:
|
||||||
prompt = ''
|
prompt = ''
|
||||||
for fname in self.fnames:
|
for fname in self.fnames:
|
||||||
prompt += self.quoted_file(fname)
|
prompt += self.quoted_file(fname)
|
||||||
prompt += prompts.files_content_suffix
|
|
||||||
return prompt
|
return prompt
|
||||||
|
|
||||||
def get_input(self):
|
def get_input(self):
|
||||||
|
@ -98,23 +97,26 @@ class Coder:
|
||||||
return
|
return
|
||||||
|
|
||||||
if did_edits:
|
if did_edits:
|
||||||
files_prefix = prompts.files_content_prefix_edited
|
files_content = prompts.files_content_prefix_edited
|
||||||
else:
|
else:
|
||||||
files_prefix = prompts.files_content_prefix_plain
|
files_content = prompts.files_content_prefix_plain
|
||||||
|
|
||||||
files_prefix += '\n\n'
|
files_content += self.get_files_content()
|
||||||
|
files_content += prompts.files_content_suffix
|
||||||
|
|
||||||
messages += [
|
messages += [
|
||||||
dict(role = 'user', content = files_prefix + self.get_files_content()),
|
dict(role = 'user', content = files_content),
|
||||||
dict(role = 'assistant', content = "Ok."),
|
dict(role = 'assistant', content = "Ok."),
|
||||||
dict(role = 'user', content = inp),
|
dict(role = 'user', content = inp + prompts.user_suffix),
|
||||||
]
|
]
|
||||||
|
|
||||||
content = self.send(messages)
|
content = self.send(messages)
|
||||||
user_msg = messages.pop()
|
messages.pop() # user msg
|
||||||
messages.pop()
|
messages.pop() # assistant Ok.
|
||||||
messages.pop()
|
messages.pop() # user files content
|
||||||
messages.append(user_msg)
|
|
||||||
|
# put back the user message without prompts.user_suffix
|
||||||
|
messages.append(dict(role = 'user', content = inp))
|
||||||
messages.append(dict(role = 'assistant', content = content))
|
messages.append(dict(role = 'assistant', content = content))
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
@ -129,8 +131,8 @@ class Coder:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
def send(self, messages, show_progress = 0):
|
def send(self, messages, show_progress = 0):
|
||||||
#for msg in messages:
|
for msg in messages:
|
||||||
# dump(msg)
|
dump(msg)
|
||||||
|
|
||||||
completion = openai.ChatCompletion.create(
|
completion = openai.ChatCompletion.create(
|
||||||
model="gpt-3.5-turbo",
|
model="gpt-3.5-turbo",
|
||||||
|
|
31
prompts.py
31
prompts.py
|
@ -1,12 +1,10 @@
|
||||||
|
|
||||||
|
### MAIN
|
||||||
|
|
||||||
main_system = '''
|
main_system = '''
|
||||||
I want you to act as an expert software engineer and pair programmer.
|
I want you to act as an expert software engineer and pair programmer.
|
||||||
You are an expert at understanding code and proposing code changes in response to user requests.
|
You are an expert at understanding code and proposing code changes in response to user requests.
|
||||||
|
|
||||||
Your job is to:
|
|
||||||
- Understand what the user wants. Ask questions if the user's request is not clear.
|
|
||||||
- Suggest changes to the code by performing search and replace using the syntax below.
|
|
||||||
|
|
||||||
FOR EACH CHANGE TO THE CODE, DESCRIBE IT USING THIS FORMAT:
|
FOR EACH CHANGE TO THE CODE, DESCRIBE IT USING THIS FORMAT:
|
||||||
|
|
||||||
path/to/filename.ext
|
path/to/filename.ext
|
||||||
|
@ -18,9 +16,8 @@ new lines to replace
|
||||||
the original chunk
|
the original chunk
|
||||||
>>>>>>> UPDATED
|
>>>>>>> UPDATED
|
||||||
|
|
||||||
ONLY USE THIS ORIGINAL/UPDATED FORMAT TO DESCRIBE CODE CHANGES!
|
Here is an example for how to just ADD lines to a file, without altering existing lines.
|
||||||
|
This anchors the location of the new code in the file by including 2-3 lines from the.
|
||||||
Example for how to just ADD lines to a file, without altering existing lines:
|
|
||||||
|
|
||||||
foo.py
|
foo.py
|
||||||
<<<<<<< ORIGINAL
|
<<<<<<< ORIGINAL
|
||||||
|
@ -32,23 +29,27 @@ def foo(a):
|
||||||
def bar(b):
|
def bar(b):
|
||||||
return b*b*b
|
return b*b*b
|
||||||
>>>>>>> UPDATED
|
>>>>>>> UPDATED
|
||||||
|
|
||||||
This anchors the location of the new code in the file by including 2-3 lines from the ORIGINAL file.
|
|
||||||
NEVER PUT AN ENTIRE FILE IN THE ORIGINAL BLOCK! MAKE YOUR EDITS SMALL AND SURGICAL!
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
files_content_suffix = ''''
|
### FILES
|
||||||
|
|
||||||
|
files_content_prefix_edited = 'I made your suggested changes, here are the updated files:\n\n'
|
||||||
|
|
||||||
|
files_content_prefix_plain = 'Here are the files:\n\n'
|
||||||
|
|
||||||
|
files_content_suffix = '''
|
||||||
|
|
||||||
YOU CAN ONLY EDIT THESE FILES.
|
YOU CAN ONLY EDIT THESE FILES.
|
||||||
NEVER REPLY WITH WHOLE FILES LIKE THIS!
|
NEVER REPLY WITH WHOLE FILES LIKE THIS!
|
||||||
ONLY TELL ME CODE CHANGES USING ORIGINAL/UPDATED EDIT COMMANDS!
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
files_content_prefix_edited = 'I made your suggested changes, here are the updated files:'
|
user_suffix = '''
|
||||||
|
|
||||||
files_content_prefix_plain = 'Here are the files:'
|
|
||||||
|
|
||||||
|
NEVER INCLUDE AN ENTIRE FILE IN YOUR REPLY!
|
||||||
|
ONLY TELL ME CODE CHANGES BY USING ORIGINAL/UPDATED EDIT COMMANDS!
|
||||||
|
'''
|
||||||
|
|
||||||
|
### EDITOR
|
||||||
|
|
||||||
editor_system = '''
|
editor_system = '''
|
||||||
You are an expert code editor.
|
You are an expert code editor.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue