Skip to main content

A binary to generate commit messages or commits using generative models.

Project description

Ai-Commit-Gen

Ai-Commit-Gen is a Python binary that leverages OpenAI's 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 OpenAI model.

  • -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-3.5-turbo". The models "gpt-4" and "gpt-4-32k" are also supported.

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

OpenAI API Key

The OpenAI API key can either be set as an environment variable OPENAI_KEY, or it can be stored in the system keyring, which is how I use it.

If the key is not found in either of these locations when the script is run, you will be prompted to enter the key 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

In the above example, Ai-Commit-Gen will consider the staged changes, generate a commit message using the OpenAI model, and directly commit the changes with the generated message.

Note

Please make sure that you have the required permissions and credits to use the OpenAI API.

Contribute

Feel free to open an issue or submit a pull request if you have any issues or feature requests.

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.4.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file ai-commit-gen-0.4.tar.gz.

File metadata

  • Download URL: ai-commit-gen-0.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for ai-commit-gen-0.4.tar.gz
Algorithm Hash digest
SHA256 0573e9325441f55c6e5d3fed1594eb9224cec33d654982e6d4d50d473cfd894e
MD5 b17bfd97038d90ba3113c34b0624c93a
BLAKE2b-256 a12ac505b08c0dc3d4d78347e23984fac733c76ce970422fa891aabad804af1c

See more details on using hashes here.

Supported by

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