This script uses the OpenAI API to generate text based on the outputs of git diff
and git log
commands. It can be particularly useful for creating pull request descriptions, commit messages, or any other narrative that requires summarizing changes between different branches or commits in a Git repository.
Clone the repository and navigate to the directory:
git clone https://github.com/PxaMMaxP/ait
cd your-repository
Install the necessary Python packages:
pip install openai
To generate a message based on the current branch’s diff and log against the main branch, simply run:
python ait.py
This will use the default configuration file (ait.config.json
) located in the current directory.
You can specify a different configuration file using the --config
option:
python ait.py --config custom_config.json
Alternatively, if you only provide a keyword, the script will look for a file named ait.<KEYWORD>.config.json
in the current directory:
python ait.py --config custom
This command will look for a configuration file named ait.custom.config
.
As a fallback, if no configuration file is found, the script will search for it in the user’s home directory under ~\.ait\*
.
You can also provide a user wide configuration file by placing it in the ~\.ait\
directory.
--config
: Path to a JSON config file or a keyword to identify a specific config (ait.<KEYWORD>.config
). Default is ait.config.json
.--api_key
: Your OpenAI API key. If not provided, the script looks for it in the config file.--diff_expression
: The Git diff expression to use. Default is main...
.--log_expression
: The Git log expression used to retrieve the commit history. Default is main...
.--system_prompt
: The system prompt to set the behavior of the assistant.--prompt
: The user prompt to guide the description creation.--model
: The model to use, such as "gpt-4"
. You can change this depending on the available models in your API.--max_tokens
: The maximum number of tokens (words or parts of words) in the API response. Default is 150
.--temperature
: Controls the randomness or creativity of the model’s output. Lower values make the output more deterministic, while higher values make it more random. Default is 0.7
.See the ait.commit.sample.config.json and ait.pull_request.sample.config.json files for examples of configuration files.
The script will raise an error if the API key is not provided either via the command-line argument or the configuration file.
This project is licensed under the MIT License. See the LICENSE file for more details.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.