This commit is contained in:
Paul Gauthier 2023-05-02 19:31:15 -07:00
parent 65d118e64b
commit d50b4c4de2
2 changed files with 26 additions and 28 deletions

View file

@ -163,10 +163,10 @@ class Coder:
edited_message = '<redacted>ORIGINAL/UPDATED formatted changes: ' edited_message = '<redacted>ORIGINAL/UPDATED formatted changes: '
edited_message += ', '.join(edited) edited_message += ', '.join(edited)
edited_message += '</redacted>' edited_message += '</redacted>'
cur_messages.pop() #cur_messages.pop()
cur_messages += [ #cur_messages += [
dict(role = 'user', content = edited_message), # dict(role = 'user', content = edited_message),
] #]
done_messages += cur_messages done_messages += cur_messages
cur_messages = [] cur_messages = []
@ -184,12 +184,12 @@ class Coder:
for line in content: for line in content:
print(role, line) 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") #self.show_messages(messages, "all")
completion = openai.ChatCompletion.create( completion = openai.ChatCompletion.create(
#model="gpt-3.5-turbo", #model="gpt-3.5-turbo",
model="gpt-4", model=model,
messages=messages, messages=messages,
temperature=0, temperature=0,
stream = True, stream = True,
@ -334,7 +334,8 @@ class Coder:
return True return True
def do_gpt_powered_replace(self, fname, edit, request): 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) fname = Path(fname)
content = fname.read_text() content = fname.read_text()
@ -349,7 +350,7 @@ class Coder:
dict(role = 'system', content = prompts.editor_system), dict(role = 'system', content = prompts.editor_system),
dict(role = 'user', content = prompt), 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) res = self.strip_quoted_wrapping(res, fname)
fname.write_text(res) fname.write_text(res)

View file

@ -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. 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. 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 1. Once you understand the question, briefly explain the needed changes.
Next line is exactly: <<<<<<< ORIGINAL 2. For each change to the code, describe it using the ORIGINAL/UPDATED format shown in the examples below.
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
# Here are examples: some/dir/names/example.py
path/to/filename.ext
<<<<<<< ORIGINAL
original lines
to search for
=======
new lines to replace
the original chunk
>>>>>>> UPDATED
example.py
<<<<<<< ORIGINAL <<<<<<< ORIGINAL
# Main functions
#
# Function to multiply two numbers # Function to multiply two numbers
def mul(a,b)
"""
======= =======
# Main functions
#
# Function to multiply two numbers using the standard algorithm # Function to multiply two numbers using the standard algorithm
def mul(a,b)
"""
>>>>>>> UPDATED >>>>>>> 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 = ''' returned_code = '''