A tool to generate commit messages using AI
Project description
lazym
lazym is an AI-powered tool that automatically generates meaningful commit messages for your Git repositories.
lazym is inspired by jen-Ya/commitgpt
Features
- Generates commit messages based on staged changes
- Without the risk of leaking code snippets to external LLM services
- Integrates seamlessly with your Git workflow
- Uses advanced language models for intelligent message generation
Requirements
- Ollama with Llama 3.1:8b model
- Git (version 2.0 or higher)
- Python 3.7 or above
Command to pull Llama 3.1:8b model for Ollama:
$ ollama run llama3.1:8b
Installation
To install lazym, follow these steps:
-
Ensure you have Python 3.7+ and pip installed on your system.
-
Install lazym using pip:
pip install lazym -
After installation, navigate to any Git repository and run the following command to set up the Git hook:
lazym installThis will install the necessary Git hook to enable automatic commit message generation.
Usage
Once installed and set up, lazym works in two ways:
-
Automatically when you make a commit: Simply stage your changes as usual and run
git commit. lazym will generate a commit message based on your staged changes. -
Manually by running
lazym ci "<hints for LLM>": This command allows you to generate a commit message with additional context provided to the LLM.
After generating the commit message, you'll be presented with four options:
- Accept and commit: Use the generated message as-is and commit.
- Edit message: Modify the generated message before committing.
- Regenerate message: Generate a new message using the same diff.
- Cancel commit: Abort the commit process.
This allows you to benefit from the AI-generated suggestions while maintaining full control over your commit messages. If you're not satisfied with the generated message, you can either edit it or request a new one.
Commands
lazym install: Install the prepare-commit-msg hook in the current Git repository.lazym uninstall: Uninstall the prepare-commit-msg hook from the current Git repository.lazym ci "<optional hints>": Generate a commit message with optional additional context.
Configuration
lazym can be configured using a config.ini file located at ~/.config/lazym/config.ini. The following options are available:
[DEFAULT]
model: The AI model to use for generating commit messages.- Default:
"llama3.1:8b" - Options:
- Ollama models: Use the model name directly (e.g.,
"llama3.1:8b","codellama:7b") - Groq models: Prefix with
"groq:"(e.g.,"groq:mixtral-8x7b-32768","groq:llama2-70b-4096")
- Ollama models: Use the model name directly (e.g.,
- Default:
[!NOTE] To use Groq models, you need to:
- Sign up at groq.com to get an API key
- Set the
GROQ_API_KEYenvironment variable with your API key
-
temperature: Controls the randomness of the AI's responses.- Default:
0.8 - Range:
0.0to1.0 - Lower values make responses more focused and deterministic
- Higher values make responses more creative and varied
- Default:
-
message_format: The format to apply to the generated commit message.- Default:
"lowercase" - Options:
"lowercase": Converts the first character of the message to lowercase."sentence case": Capitalizes the first character of each sentence.- Any other value will keep the original format as generated by the AI.
- Default:
-
prompt: The prompt template used to generate commit messages.- Must include the
{diff}placeholder where the code changes should be inserted - Default: empty (uses built-in prompt)
- You can customize this to match your team's commit message style
- Must include the
-
rstrip_period: Controls whether to remove trailing periods from commit messages.- Default:
"true" - Options:
"true": Remove trailing periods from commit messages"false": Keep trailing periods if present in the generated message
- Default:
Customizing Prompts
You can customize how lazym generates commit messages by providing your own prompt template. There are two ways to do this:
-
Using
config.ini: Suitable for simple, one-line prompts. Specify thepromptoption in yourconfig.inifile. This method is ideal for straightforward prompts that don't require complex formatting or multiple lines.Example:
[DEFAULT] prompt = "Generate a concise commit message for the following changes: {diff}"
-
Using
prompt.txt: Suitable for more complex, multi-line prompts. Create aprompt.txtfile in the~/.config/lazym/directory. If this file exists, its contents will override thepromptsetting inconfig.ini. This method is ideal for detailed prompts that require specific formatting or guidelines.Example
prompt.txt:Generate a conventional commit message for these changes. Format: <type>(<scope>): <description> Types: feat, fix, docs, style, refactor, test, chore Keep the message under 72 chars. Changes: {diff}
If no prompt is specified in either config.ini or prompt.txt, lazym will use its built-in prompt template that follows general Git best practices.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lazym-0.16.0.tar.gz.
File metadata
- Download URL: lazym-0.16.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fcaf2a4bf07eeff2b2c3216da730e584fe09eead92a4dc1c0e36836d74ca00c
|
|
| MD5 |
783ad4d3a1479c10884b652138cacfeb
|
|
| BLAKE2b-256 |
d1bacc2dd6f4b7dd661da9ae9d3a9dffad48bbbcf9c91849cb85ffc56299da2d
|
File details
Details for the file lazym-0.16.0-py3-none-any.whl.
File metadata
- Download URL: lazym-0.16.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
845f256b82826967464393a478669e4bd7985afde7d97f4a41461a40d1c60db8
|
|
| MD5 |
5956f81f1ea3cb706d1bef3c9bfa00ec
|
|
| BLAKE2b-256 |
0a0541fb291e18a2b7b12ff87300c4fbdeee4fa7c9a2824c22838a5aa69864fe
|