From b0d2fafdd5f596f72c9e29a91c3ddcc063dc221c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 8 May 2023 10:41:54 -0700 Subject: [PATCH] commit wip --- coder.py | 21 +++++++++++++++++++-- prompts.py | 7 +++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/coder.py b/coder.py index 57fd840ae..7f4473a0a 100755 --- a/coder.py +++ b/coder.py @@ -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,12 +445,17 @@ 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: - coder.run() + return + + coder.run() if __name__ == "__main__": diff --git a/prompts.py b/prompts.py index 943f39d79..6568bc0d6 100644 --- a/prompts.py +++ b/prompts.py @@ -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. +"""