From b122696cabff6063bc829450dc3ed1b077cc54a8 Mon Sep 17 00:00:00 2001 From: KaySar12 Date: Wed, 21 May 2025 14:26:46 +0700 Subject: [PATCH] feat: enhance commit generation with temperature setting and confirmation prompt --- scripts/interpreter/gen_commit.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/interpreter/gen_commit.py b/scripts/interpreter/gen_commit.py index 650957f..49f14a2 100755 --- a/scripts/interpreter/gen_commit.py +++ b/scripts/interpreter/gen_commit.py @@ -33,6 +33,7 @@ def gen_commit(project_path): agent.llm.model = "gpt-4o" agent.auto_run = True agent.verbose = False + agent.llm.temperature = 0.3 convention_path = os.path.join( os.path.dirname(__file__), "resources/commit_convention.md" ) @@ -191,8 +192,7 @@ async def commit_and_push_submodules(): def format_tree_output(project_path, base_name, base_diff, submodule_diffs, commit): """Format the output in a tree structure.""" - - output = [f"📦 {base_name}"] + output = [f"📁 {base_name}"] output.append(f" └── 📝 {commit[project_path]}:") output.append(f" └── 📦 {base_diff}") @@ -235,7 +235,6 @@ async def push_code(): remote_url = f"https://{git_user}:{git_pass}@{git_repo}" await commit_and_push_submodules() - commit_msg = gen_commit(project_path) commit[project_path] = commit_msg print(f"Generated commit message:\n{commit_msg}\n") @@ -260,11 +259,26 @@ async def push_code(): print(stderr.decode()) # Format and print the tree output - tree_output = format_tree_output(project_path, base_name, base_diff, submodule_diffs, commit) + tree_output = format_tree_output( + project_path, base_name, base_diff, submodule_diffs, commit + ) print("\nProject Status:") print(tree_output) print() +def confirm_commit(project_path, base_name, base_diff): + tree_output = format_tree_output( + project_path, base_name, base_diff, submodule_diffs, commit + ) + print("\nProject Status:") + print(tree_output) + print() + confirmation = input( + "Do you want to commit and push these changes? (y/n): " + ).lower() + return confirmation in ["y", "yes"] + + if __name__ == "__main__": asyncio.run(push_code())