mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
gpt-4
This commit is contained in:
parent
65d118e64b
commit
d50b4c4de2
2 changed files with 26 additions and 28 deletions
17
coder.py
17
coder.py
|
@ -163,10 +163,10 @@ class Coder:
|
|||
edited_message = '<redacted>ORIGINAL/UPDATED formatted changes: '
|
||||
edited_message += ', '.join(edited)
|
||||
edited_message += '</redacted>'
|
||||
cur_messages.pop()
|
||||
cur_messages += [
|
||||
dict(role = 'user', content = edited_message),
|
||||
]
|
||||
#cur_messages.pop()
|
||||
#cur_messages += [
|
||||
# dict(role = 'user', content = edited_message),
|
||||
#]
|
||||
done_messages += cur_messages
|
||||
cur_messages = []
|
||||
|
||||
|
@ -184,12 +184,12 @@ class Coder:
|
|||
for line in content:
|
||||
print(role, line)
|
||||
|
||||
def send(self, messages, show_progress = 0):
|
||||
def send(self, messages, show_progress = 0, model="gpt-4"):
|
||||
#self.show_messages(messages, "all")
|
||||
|
||||
completion = openai.ChatCompletion.create(
|
||||
#model="gpt-3.5-turbo",
|
||||
model="gpt-4",
|
||||
model=model,
|
||||
messages=messages,
|
||||
temperature=0,
|
||||
stream = True,
|
||||
|
@ -334,7 +334,8 @@ class Coder:
|
|||
return True
|
||||
|
||||
def do_gpt_powered_replace(self, fname, edit, request):
|
||||
print(f'Asking GPT to apply ambiguous edit to {fname}...')
|
||||
model = 'gpt-3.5-turbo'
|
||||
print(f'Asking {model} to apply ambiguous edit to {fname}...')
|
||||
|
||||
fname = Path(fname)
|
||||
content = fname.read_text()
|
||||
|
@ -349,7 +350,7 @@ class Coder:
|
|||
dict(role = 'system', content = prompts.editor_system),
|
||||
dict(role = 'user', content = prompt),
|
||||
]
|
||||
res = self.send(messages, show_progress = len(content) + len(edit)/2)
|
||||
res = self.send(messages, show_progress = len(content) + len(edit)/2, model=model)
|
||||
res = self.strip_quoted_wrapping(res, fname)
|
||||
fname.write_text(res)
|
||||
|
||||
|
|
35
prompts.py
35
prompts.py
|
@ -7,32 +7,29 @@ I want you to act as an expert software engineer and pair programmer.
|
|||
You are to take requests from the user for new features, improvements, bug fixes and other changes to the code.
|
||||
If the user's request is ambiguous, ask questions to fully understand.
|
||||
|
||||
# For each change to the code, describe it using the ORIGINAL/UPDATED format shown in the examples below.
|
||||
Once you understand each change, your responses must be:
|
||||
|
||||
First line is the full filename, including path
|
||||
Next line is exactly: <<<<<<< ORIGINAL
|
||||
Followed by a chunk of lines from the original file which need to change
|
||||
Next line is exactly: =======
|
||||
Followed by the new lines to replace the original chunk
|
||||
Last line is exactly: >>>>>>> UPDATED
|
||||
1. Once you understand the question, briefly explain the needed changes.
|
||||
2. For each change to the code, describe it using the ORIGINAL/UPDATED format shown in the examples below.
|
||||
|
||||
# Here are examples:
|
||||
|
||||
path/to/filename.ext
|
||||
<<<<<<< ORIGINAL
|
||||
original lines
|
||||
to search for
|
||||
=======
|
||||
new lines to replace
|
||||
the original chunk
|
||||
>>>>>>> UPDATED
|
||||
|
||||
example.py
|
||||
some/dir/names/example.py
|
||||
<<<<<<< ORIGINAL
|
||||
# Main functions
|
||||
#
|
||||
# Function to multiply two numbers
|
||||
def mul(a,b)
|
||||
"""
|
||||
=======
|
||||
# Main functions
|
||||
#
|
||||
# Function to multiply two numbers using the standard algorithm
|
||||
def mul(a,b)
|
||||
"""
|
||||
>>>>>>> UPDATED
|
||||
|
||||
Be sure to include the correct path and filename for each edit, exactly as specified by the user.
|
||||
LEADING WHITESPACE IS IMPORTANT IN ALL CODE!
|
||||
NEVER RETURN THE ENTIRE SOURCE FILE. ONLY RETURN CODE IN ORIGINAL/UPDATED FORMAT CHANGES!
|
||||
'''
|
||||
|
||||
returned_code = '''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue