Skip to main content

Ai-Commit-Gen

Ai-Commit-Gen is a Python binary that leverages various language models to generate meaningful commit messages. There's approximately a thousand such binaries out there, but none that fit into all of my workflows, so here's the 1001st.

ai-commit-gen can be called from scripts to automatically create commits, or integrated into editor workflows to create commit drafts.

Installation

pip install ai-commit-gen

Usage

ai-commit-gen assumes that the current working directory is, or is a subdirectory of, the git root.

  • -p or --prompt: Override the default prompt for the language model. Available presets are "default", "refactoring", "documentation", and "mimic".

  • -c or --commit: Not only generate a commit message but also commit the changes in git.

  • -m or --model: Specify the model to be used. The default is "gpt-4o-mini". Supports a wide range of models from various providers through litellm.

  • -d or --debug: Enable debug logging.

  • --apibase: Specify a custom API base URL for the model provider.

Supported Models

Ai-Commit-Gen uses litellm, which supports a wide range of language models from various providers. Some of the supported models include:

  • OpenAI models (e.g., gpt-3.5-turbo, gpt-4)
  • Anthropic models (e.g., claude-2)
  • Local models via Ollama (e.g., ollama/llama3.1)

For a full list of supported models, please refer to the litellm documentation.

API Keys

For cloud-based models (like OpenAI or Anthropic), you'll need to provide an API key. The key can be set as an environment variable or stored in the system keyring:

  • For OpenAI: Use OPENAI_API_KEY environment variable or store in keyring as "openai_key"
  • For Anthropic: Use ANTHROPIC_API_KEY environment variable or store in keyring as "anthropic_key"

If the key is not found when the script is run, you will be prompted to enter it and given the option to store it in the keyring.

Example

Here is an example of how you might use Ai-Commit-Gen:

# Stage your changes
git add .

# Just create the commit message
ai-commit-gen

# Generate a commit message and commit the changes
ai-commit-gen --commit

# Use a specific model
ai-commit-gen --model gpt-4

# Use a local model via Ollama
ai-commit-gen --model ollama/llama3.1

# Use a custom API base URL
ai-commit-gen --apibase "https://custom-api-endpoint.com/v1"

Metadata

Release files for ai-commit-gen 0.61

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-commit-gen 0.61
File Size Uploaded
ai_commit_gen-0.61.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-commit-gen 0.61
File Interpreter ABI Platform
ai_commit_gen-0.61-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / ai_commit_gen-0.61.tar.gz

Download URL ai_commit_gen-0.61.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9b1b75fe1a28f27e24880b0e18e718f5c4c92fdc32061f82d3aca955925470e2
BLAKE2b-256 checksum
How to use checksums
521a5c423afd12645de4631ed988bd60257667c859028ffe69a5ba67b7228f53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / ai_commit_gen-0.61-py3-none-any.whl

Download URL ai_commit_gen-0.61-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca9238ec4a4d9ce53e3d9650a83d27100e8f5b437dbb86018f296d88b7084baf
BLAKE2b-256 checksum
How to use checksums
10fa1b9f460a43c19f71eaed2ff1dcfc88b8f9533ba59bec6bec3d6849c0f01d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

0.61 This release

2 release files

0.6

2 release files

0.5

2 release files

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page