Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow generating commit message via ollama #236

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Allow generating commit message via ollama #236

wants to merge 4 commits into from

Conversation

jserv
Copy link
Contributor

@jserv jserv commented Mar 6, 2025

Use an large language model (via ollama) to generate commit message that match commit style by learning from previous commits.

Currently, qwen2.5-coder is used for commit message generation, code reasoning, and suggestions.

Reference: Using Large Language Models for Commit Message Generation: A Preliminary Study

Use an large language model (via ollama) to generate commit message
that match commit style by learning from previous commits.

Currently, qwen2.5-coder is used for commit message generation, code
reasoning, and suggestions.

Change-Id: Iaf4b1952a3e14bbdd4c832aa4a93753f7ca11473
@jserv jserv marked this pull request as draft March 6, 2025 10:26
yenslife and others added 3 commits March 8, 2025 09:06
Two-Stage Commit Message Generation:
First, generate a detailed commit description.
Then, refine the subject line for conciseness and clarity.

If the initial subject exceeds 50 characters, the script regenerates it
with explicit length constraints. Up to 10 iterations ensure compliance
with Git conventions. If still too long, a warning prompts users for
manual adjustments.

This commit also improved LLM instructions for better adherence to
commit message best practices. Clear separation of Subject Line and
Body with enforced constraints.

Set SHOW_AI_COMMIT_PROMPT to see full prompt.
Set TEMPERATURE to change model temperature.

Change-Id: I6b9c1337210b86a400e84c3984c17dcdc72fb26e
Refine aicommit with iterative subject Shortening
Transform git commit tracking from subject-only to full structured
messages. This enhancement provides richer context for commit message
practices and creates a format better suited for LLM learning and
manipulation.

Change-Id: I601aa5d46873066c13a324bb3e0a6a16bd6864d4
@yenslife
Copy link
Contributor

The current architecture's repeated regeneration of style prompts results in slower performance. Why not adopt a fixed style prompt instead? For example, with clear, predefined instructions like a Linux commit style. Alternatively, we could generate the style prompt once and only regenerate it if the model changes (or any condition that could affect model performance).

Current Strategy

graph LR
  OS_Start[Start] --"git log"--> OS_GenStylePrompt["Generate Style Prompt every commit"]
  OS_GenStylePrompt --"Style prompt"--> OS_GenCommitMsg[Generate Commit Message]
  OS_GenCommitMsg --"suggested commit message"--> OS_End[End]
Loading

Option 1: Fixed Style Prompt (only 1 inference time)

graph LR
  FS_Start[Start] --"Fixed style prompt"--> FS_GenCommitMsg[Generate Commit Message]
  FS_GenCommitMsg --"suggested commit message"--> FS_End[End]
Loading

Option 2: Generate Prompt Once

graph TD
  GP_Start[Start] --> GP_CheckPrompt{"Check Style Prompt Exists (for current model)"}
  GP_CheckPrompt -- "Style Prompt File Exists?" --> GP_LoadPrompt[Load Stored Style Prompt]
  GP_CheckPrompt -- "Style Prompt File Missing or difference model name" --> GP_GenStylePrompt[Generate Style Prompt]
  GP_GenStylePrompt -- "Generated Style Prompt" --> GP_SavePrompt[Save Style Prompt]
  GP_SavePrompt -- "Saved Style Prompt" --> GP_GenCommitMsg[Generate Commit Message]
  GP_LoadPrompt -- "Loaded Style Prompt" --> GP_GenCommitMsg
  GP_GenCommitMsg -- "suggested commit message" --> GP_End[End]
Loading

@sysprog21 sysprog21 deleted a comment from Urbaner3 Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants