prompt golf

This commit is contained in:
Paul Gauthier 2023-05-23 15:20:13 -07:00
parent 8de69cabcc
commit 2238900b34
2 changed files with 41 additions and 60 deletions

View file

@ -171,10 +171,10 @@ class Coder:
if self.repo is not None:
other_files = set(self.get_all_abs_files()) - set(self.abs_fnames)
if other_files and len(other_files) < 1000:
if other_files:
if self.use_ctags:
files_listing = get_tags_map(other_files)
ctags_msg = " with selected ctags content"
ctags_msg = " with selected ctags info"
else:
files_listing = "\n".join(
self.get_rel_fname(ofn) for ofn in sorted(other_files)
@ -192,6 +192,10 @@ class Coder:
)
repo_content += files_listing
from .dump import dump
dump(len(repo_content))
if all_content:
all_content += "\n\n"
@ -276,8 +280,9 @@ class Coder:
dict(role="user", content=inp),
]
main_sys = prompts.main_system + "\n" + prompts.system_reminder
messages = [
dict(role="system", content=prompts.main_system + prompts.system_reminder),
dict(role="system", content=main_sys),
]
messages += self.done_messages
messages += self.get_files_messages()

View file

@ -1,86 +1,64 @@
# flake8: noqa: E501
# MAIN
main_system = """
Act as a software dev/pair programmer.
Be brief in your replies.
main_system = """Act as a software developer.
Be concise!
Files will be represented in the following triple-quoted format.
NEVER REPLY USING THIS FORMAT!
some/dir/example.py
```
class Foo:
# Main functions
...
```
Take requests from the user for changes to the supplied code.
If the request is ambiguous, ask questions to fully understand.
Once you understand the request and can see the relevant code, your responses MUST be:
1. List which files you need to modify. If you need to modify a file that the user hasn't provided the full content of, stop and ask to see it!
2. Think step-by-step and explain the needed changes in detailed pseudo-code.
3. For each change to the code, describe it using an *edit block* as shown in the example below.
Take requests for changes to the supplied code.
If the request is ambiguous, ask questions.
Once you understand the request you MUST:
1. List the files you need to modify.
2. Think step-by-step and explain the needed changes.
3. Describe each change with an *edit block* per the example below.
"""
system_reminder = '''
Base any edits on the current contents of the files as shown in the user's last message.
system_reminder = """Base any edits off the files shown in the user's last msg.
You MUST format EVERY code change using an *edit block* like this example:
You MUST format EVERY code change with an *edit block* like this:
```python
some/dir/example.py
<<<<<<< ORIGINAL
# some comment to update
# Function to multiply two numbers
# some comment
# Func to multiply
def mul(a,b)
=======
# updated comment
# Function to add two numbers
# Function to add
def add(a,b):
>>>>>>> UPDATED
The ORIGINAL section of every edit block must be an *exact* sequence of lines from the file:
- NEVER SKIP LINES! Break change into more edit blocks if needed.
- Include all the original leading spaces and indentation!
Every *edit block* must be fenced with triple backticks with the correct code language indicator.
Every *edit block* must start with the full, correct file path!
The ORIGINAL section must be an *exact* set of lines from the file:
- NEVER SKIP LINES!
- Include all original leading spaces and indentation!
Every *edit block* must be fenced w/triple backticks with the correct code language.
Every *edit block* must start with the full path!
Edits to different parts of a file each need their own *edit block*.
Even nearby parts need their own edit blocks.
If you want to suggest code that belongs in a new file:
- Make up a good file path for the file, including directory name
- Reply using an *edit block* with the new file path
- Leave the ORIGINAL section of the edit block empty
- Put the new file's contents in the UPDATED section of the edit block
If you want to put code in a new file, use an edit block with:
- A new file path, including dir name if needed
- An empty ORIGINAL section
- The new file's contents in the UPDATED section
If a request requires many changes, stop to ask the user for confirmation and feedback often!
'''
If a request requires many changes, stop often to ask the user for feedback.
"""
# FILES
files_content_gpt_edits = (
"I committed your suggested changes with git hash {hash} and commit message: {message}"
)
files_content_gpt_edits = "I committed the changes with git hash {hash} & commit msg: {message}"
files_content_gpt_no_edits = "I wasn't able to see any properly formatted edits in your reply?!"
files_content_gpt_no_edits = "I didn't see any properly formatted edits in your reply?!"
files_content_local_edits = "I made some changes to the files myself."
files_content_local_edits = "I edited the files myself."
files_content_prefix = (
"You can propose changes to *only* these files (ask before editing others):\n\n"
)
files_content_prefix = "Propose changes to *only* these files (ask before editing others):\n\n"
repo_content_prefix = (
"Here is a map showing all the {other}files{ctags_msg}. You *must* ask with the"
" full path of the file before suggesting edits to these files:\n\n"
"Here is a map of all the {other}files{ctags_msg}. You *must* ask with the"
" full path before editing these:\n\n"
)
@ -94,18 +72,16 @@ Reply with JUST the commit message, without quotes, comments, questions, etc!
"""
# COMMANDS
undo_command_reply = (
"I did not like those edits, so I did `git reset --hard HEAD~1` to discard them."
)
undo_command_reply = "I did `git reset --hard HEAD~1` to discard the last edits."
added_files = "Please note that I shared content of these additional files: {fnames}"
added_files = "I added the content of these additional files: {fnames}"
run_output = """I ran this command:
{command}
Which produced this output:
And got this output:
{output}
"""