This commit is contained in:
Paul Gauthier 2023-04-11 12:30:58 -07:00
parent 1dfe6b31f1
commit aebdb332a0
2 changed files with 12 additions and 30 deletions

View file

@ -159,8 +159,9 @@ class Coder:
files_messages = self.get_files_messages(True) files_messages = self.get_files_messages(True)
edited_message = 'You need to edit these files: ' edited_message = '<redacted>ORIGINAL/UPDATED formatted changes: '
edited_message += ', '.join(edited) edited_message += ', '.join(edited)
edited_message += '</redacted>'
cur_messages.pop() cur_messages.pop()
cur_messages += [ cur_messages += [
dict(role = 'assistant', content = edited_message), dict(role = 'assistant', content = edited_message),
@ -224,6 +225,8 @@ class Coder:
partial_line = '' partial_line = ''
for chunk in completion: for chunk in completion:
if chunk.choices[0].finish_reason:
dump(chunk.choices[0].finish_reason)
try: try:
text = chunk.choices[0].delta.content text = chunk.choices[0].delta.content
resp += text resp += text
@ -291,7 +294,7 @@ class Coder:
return ''.join(resp) return ''.join(resp)
pattern = re.compile(r'^(\S+)\n<<<<<<< ORIGINAL\n(.*?)\n=======\n(.*?)\n>>>>>>> UPDATED$', re.MULTILINE | re.DOTALL) pattern = re.compile(r'^(\S+)\s+<<<<<<< ORIGINAL\n(.*?)\n=======\n(.*?)\n>>>>>>> UPDATED$', re.MULTILINE | re.DOTALL)
def update_files(self, content, inp): def update_files(self, content, inp):

View file

@ -3,7 +3,9 @@
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 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. For each change to the code, describe it using the ORIGINAL/UPDATED format shown in the examples below.
@ -34,34 +36,11 @@ example.py
''' '''
returned_code = ''' returned_code = '''
It looks like you tried to return code. Don't do that! It looks like you tried to return a code block. Don't do that!
Only return code using the specific ORIGINAL/UPDATED format shown in the examples below. Only return code using the specific ORIGINAL/UPDATED format.
Be selective!
First line is the full filename, including path Only return the parts of the code which need changes!
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
Here are examples:
path/to/filename.ext
<<<<<<< ORIGINAL
original lines
to search for
=======
new lines to replace
the original chunk
>>>>>>> UPDATED
example.py
<<<<<<< ORIGINAL
# Function to multiply two numbers
=======
# Function to multiply two numbers using the standard algorithm
>>>>>>> UPDATED
''' '''
system_reminder = 'REMEMBER, ONLY RETURN CODE USING THE ORIGINAL/UPDATED FORMAT!' system_reminder = 'REMEMBER, ONLY RETURN CODE USING THE ORIGINAL/UPDATED FORMAT!'