feat: enhance commit generation with temperature setting and confirmation prompt

This commit is contained in:
KaySar12 2025-05-21 14:26:46 +07:00
parent 1bdbf478e3
commit b122696cab

View File

@ -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())