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
File details
Details for the file ai-commit-gen-0.2.tar.gz
.
File metadata
- Download URL: ai-commit-gen-0.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a13ff8719c425d6e69e4c7b76430c96cfcaca6d3aee412dbb3a48902b66ab65 |
|
MD5 | 818741e1c072156d29ee744cc1007d15 |
|
BLAKE2b-256 | 2f80f5182b1c625545ec8064dcef9c844927cd37e0b7c86aa6430770123b6acf |