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.3.tar.gz
.
File metadata
- Download URL: ai-commit-gen-0.3.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b994c0ee2fae68c0cd1ab2542f7615a007ae6aacfce02865b60c393dce210e87 |
|
MD5 | 0fc3842e07e0c99623ad521086f4c516 |
|
BLAKE2b-256 | 0c06f94ba1f5b942f4e0ba1cf24415985de1552f3805c8c681f8e091d1c96d7c |