commit wip

This commit is contained in:
Paul Gauthier 2023-05-08 10:41:54 -07:00
parent 71103dd87f
commit b0d2fafdd5
2 changed files with 26 additions and 2 deletions

View file

@ -203,6 +203,7 @@ class Coder:
dict(role="user", content=prompts.files_content_gpt_edits),
dict(role="assistant", content="Ok."),
]
self.commit(self.cur_messages)
self.cur_messages = []
return True
@ -401,6 +402,12 @@ class Coder:
return res
def commit(self, message_history):
# _messages = [
# dict(role="system", content=prompts.commit_system),
# ]
pass
def main():
parser = argparse.ArgumentParser(description="Chat with GPT about code")
@ -425,6 +432,11 @@ def main():
metavar="FILE",
help="Apply the changes from the given file instead of running the chat",
)
parser.add_argument(
"--commit",
action="store_true",
help="Commit dirty changes to the files",
)
args = parser.parse_args()
@ -433,11 +445,16 @@ def main():
pretty = args.pretty
coder = Coder(use_gpt_4, fnames, pretty)
if args.commit:
coder.commit("")
return
if args.apply:
with open(args.apply, "r") as f:
content = f.read()
coder.update_files(content, inp="")
else:
return
coder.run()

View file

@ -102,3 +102,10 @@ To this file:
ONLY OUTPUT {fname} !!!
"""
# COMMIT
commit_system = """You are an expert software engineer.
Review the provided diffs which are about to be committed to a git repo.
Generate a 1 line, 1-2 sentence commit message.
Reply with JUST the commit message, without comments, questions, etc.
"""