GithubHelp home page GithubHelp logo

gpt-commit's Introduction

gpt-commit

Generate commit messages using GPT-3. To use gpt-commit, simply invoke it whenever you'd use git commit. Git will prompt you to edit the generated commit message.

git add .
./gpt-commit.py

Getting Started

Install openai and clone gpt-commit.

pip3 install openai
git clone [email protected]:markuswt/gpt-commit.git

Set the environment variable OPENAI_API_KEY to your OpenAI API key, e.g. by adding the following line to your .bashrc.

export OPENAI_API_KEY=<YOUR API KEY>

Alternatively, you can set the openai.api_key variable in gpt-commit.py. You can also set openai.organization this way (optional).

Modify git commit (optional)

If you want git commit to automatically invoke gpt-commit, copy gpt-commit.py and prepare-commit-msg to the .git/hooks directory in any project where you want to modify git commit.

Privacy Disclaimer

gpt-commit uses the OpenAI API to generate commit messages. Both file names and contents from files that contain staged changes will be shared with OpenAI when using gpt-commit. OpenAI will process this data according to their terms of use and API data usage policies. On March 1st 2023 OpenAI pledged that by default, they would not use data submitted by customers via their API to train or improve their models, and that this data will be retained for a maximum of 30 days, after which it will be deleted.

gpt-commit's People

Contributors

ahonnecke avatar crisbal avatar joerndyherrn avatar markuswt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gpt-commit's Issues

HTTPError: 429

Made a relatively minor change in two files (the entire repository is ~50 text files).
Got this error:

Traceback (most recent call last):
File "gpt-commit/gpt-commit.py", line 82, in
commit_message = generate_commit_message(summarize_diff(diff))
File "gpt-commit/gpt-commit.py", line 35, in summarize_diff
return complete(DIFF_PROMPT + "\n\n" + diff + "\n\n")
File "gpt-commit/gpt-commit.py", line 28, in complete
response.raise_for_status()
File "/XXX/.conda/envs/daily1/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://api.openai.com/v1/completions

Any idea what could be causing this?

HTTPError: 400

Hi, I tried to evoke gpt-commit.py and got the following error:
Traceback (most recent call last):
File "./gpt-commit/gpt-commit.py", line 85, in
summaries = summarize_added_modified() + "\n\n" + summarize_deleted(
File "./gpt-commit/gpt-commit.py", line 59, in summarize_added_modified
[summarize_diff(get_diff(file)) for file in modified_files])
File "./gpt-commit/gpt-commit.py", line 59, in
[summarize_diff(get_diff(file)) for file in modified_files])
File "./gpt-commit/gpt-commit.py", line 35, in summarize_diff
return complete(DIFF_PROMPT + "\n\n" + diff + "\n\n")
File "./gpt-commit/gpt-commit.py", line 28, in complete
response.raise_for_status()
File "/mnt/users/adot/CondaEnvs/py_drit/lib/python3.8/site-packages/requests/models.py", line 960, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.openai.com/v1/completions

I have added OPENAI_API_KEY. Do I need any more settings about OpenAI?

OpenAI rate limit error

Hi there
I encounter this error when trying to call gpt-commit.py :

openai.error.RateLimitError: The server had an error while processing your request. Sorry about that!

I am on linux, and i configured globally the local git repo that i cloned on my machine, so that i can call from anywhere the command...
Is there any ratelimit on openAI ?
Or is there any issue with the code ?
Many thanks and congrats for your job ;)

Privacy and security. What data is sent to OpenAI?

Great project, but I am a little concerned about privacy and security. What information is being sent to OpenAI from this which in turn they are storing on their severs? Does it send actual code changes and filenames or does that happen locally? Maybe add a section to the README on this topic.

Title and the descriptive body

Not necessarily an issue, but in the prompt I used this and got a much more effective commit message on the changes that occured.
Mileage may vary.

COMMIT_MSG_PROMPT = (
    "Create a descriptive title up to 50 characters"
    "Create two newlines and generate a descriptive commit message from these summaries:"
)

When using script as git hook, shell script cannot find python script

Expected Behavior

The shell script prepare-commit-msg invokes the python script if the commit message is empty

Current Behavior

.git/hooks/prepare-commit-msg: line 5: ./gpt-commit.py: No such file or directory

Possible Solution

Edit the shell script to get the full path of the "gpt-commit.py" file and use that to run the python script

SCRIPT_DIR=$(dirname "$0")
"${SCRIPT_DIR}/gpt-commit.py" --print-message > "$1"

Steps to Reproduce

  1. Clone repo and copy gpt-commit.py and prepare-commit-msg into the .git/hooks dir of a project
  2. In the project root, run git commit

Context (Environment)

I think the path to the python script can't be resolved when the hook runs when you're in a different directory than the python script.

Using MacOS Ventura 13.2 on MacBook Pro M1 2020

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.