Skip to main content

A binary to generate commit messages using generative models.

Project description

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"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_commit_gen-0.6.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_commit_gen-0.6-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file ai_commit_gen-0.6.tar.gz.

File metadata

  • Download URL: ai_commit_gen-0.6.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for ai_commit_gen-0.6.tar.gz
Algorithm Hash digest
SHA256 723ad79b572be4c92fd7553b6bee493c08fd3f856613a8b74639440118778fb7
MD5 d729f1512e20b668dc90e0629ea70988
BLAKE2b-256 5962de54854cf6fb20a63407dc8f0b58e3697025715e61fb020dfd2fb4b42963

See more details on using hashes here.

File details

Details for the file ai_commit_gen-0.6-py3-none-any.whl.

File metadata

  • Download URL: ai_commit_gen-0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for ai_commit_gen-0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8a90b1fccc17d41071fec1b2334cf96552356d7303b82986726b1e74ec3d884b
MD5 42322119efcb24e805c3859fde7cb1eb
BLAKE2b-256 40bf6e4af7fc73764b3cb56a7d435d31837e4c34f1c8ec81349eaea66cf4a97a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page