Giter Club home page Giter Club logo

gptcommit's Introduction

gptcommit

Github Contributors Github Stars CI

crates.io status crates.io downloads Rust dependency status

A git prepare-commit-msg hook for authoring commit messages with GPT-3. With this tool, you can easily generate clear, comprehensive and descriptive commit messages letting you focus on writing code.

See announcement blog post.

Demo

asciicast

Installation

  1. Install this tool locally with cargo (recommended).
cargo install --locked gptcommit

or on macOS, use homebrew

brew install zurawiki/brews/gptcommit
  1. In your git repository, run the following command to install gptcommit as a git prepare-commit-msg hook. You will need to provide an OpenAI API key to complete the installation.
gptcommit install

Usage

To use gptcommit, simply run git commit as you normally would. The hook will automatically generate a commit message for you using a large language model like GPT. If you're not satisfied with the generated message, you can always edit it before committing.

Note: By default, gptcommit uses the GPT-3 model. Please ensure you have sufficient credits in your OpenAI account to use it.

Features

gptcommit supports a number of configuration options that are read from $HOME/.config/gptcommit/config.toml. Configs are applied in the following order:

  • User settings as read from $HOME/.config/gptcommit/config.toml.
  • The settings as read from the repo clone at $GIT_ROOT/.git/gptcommit.toml.
  • Environment variables starting with GPTCOMMIT__*.

See all the config options available with gptcommit config keys.

Set your OpenAI API key

Persist your OpenAI key

gptcommit config set openai.api_key sk-...

or set it just for you local repo:

gptcommit config set --local openai.api_key sk-...

You can also config this setting via the GPTCOMMIT__OPENAI__API_KEY.

To maintain compatibility with other OpenAI clients, we support the OPENAI_API_KEY environment variables. This will take the highest precedence.

Set a custom OpenAI API base URL

Persist your OpenAI key

gptcommit config set openai.api_base https://...

or set it just for you local repo:

gptcommit config set --local openai.api_base https://...

You can also config this setting via the GPTCOMMIT__OPENAI__API_BASE or .

To maintain compatibility with other OpenAI clients, we support the OPENAI_API_BASE environment variables. This will take the highest precedence.

Try out a different OpenAI model

gptcommit uses text-davinci-003 by default. The model can be configured to use other models as below

gptcommit config set openai.model text-davinci-002

You can also config this setting via the GPTCOMMIT__OPENAI__MODEL.

For a list of public OpenAI models, checkout the OpenAI docs. You can also bring in your own fine-tuned model.

Set summarizing language

gptcommit uses English by default. The language can be configured to use other languages as below

gptcommit config set output.lang zh-cn

Now, supported languages are:

locale code language
en English
zh-cn 简体中文
zh-tw 繁體中文
ja 日本語

Allow re-summarizing when amending commits

gptcommit config set allow-amend true

Proxy configuration support

Configure an OpenAI proxy using

gptcommit config set openai.proxy "my_http_proxy...."

Common Issues / FAQs

How can I reduce my OpenAI usage bill?

In the current design, gptcommit issues N+2 prompts, where N is the number of modified files with diffs under the max_token_limit. The other prompts are the title and summary.

OpenAI Completions are billed by "tokens" that are both sent and generated. Pricing per token depends on the model used. The number of tokens generated are generally predictable (as a commit message is usually only so big) but gptcommit could be sending over a lot of tokens in the form of diff data.

Today, I see two low-hanging solutions for reducing cost:

  • Switch to a different model using the openai.model configuration option
  • Reduce the side of prompts and diff data sent to OpenAI

OpenAI's pricing page can be found at https://openai.com/api/pricing/#faq-completions-pricing

The githook is not running when I commit

By default, the githook is only run for new commits. If a template is set or the commit is being amended, the githook will skip by default.

Because the githook detected the user is supplying their own template, we make sure not to overwrite it with GPT. You can remove the commit template by making sure git config --local commit.template is blank.

You can allow gptcommit to summarize amended commits with the following configuration above.

Installing in GitHub codespaces

You'll need to install Rust and the cargo toolchain first. Remember to configure your API key.

curl https://sh.rustup.rs -sSf | sh
bash
cargo install --locked gptcommit

# insert your openai api key https://platform.openai.com/account/api-keys
gptcommit config set openai.api_key # sk-...

Derived Works

All of these awesome projects are built using gptcommit.

Encountered any bugs?

If you encounter any bugs or have any suggestions for improvements, please open an issue on the repository.

License

This project is licensed under the MIT License.


Detailed Help Usage

$ gptcommit -h
Usage: gptcommit [OPTIONS] <COMMAND>

Commands:
  install             Install the git hook
  uninstall           Uninstall the git hook
  config              Read and modify settings
  prepare-commit-msg  Run on the prepare-commit-msg hook
  help                Print this message or the help of the given subcommand(s)

Options:
  -v, --verbose  Enable verbose logging
  -h, --help     Print help
  -V, --version  Print version
$ gptcommit install -h
Install the git hook

Usage: gptcommit install [OPTIONS]

Options:
  -v, --verbose  Enable verbose logging
  -h, --help     Print help
  -V, --version  Print version
$ gptcommit uninstall -h
Uninstall the git hook

Usage: gptcommit uninstall [OPTIONS]

Options:
  -v, --verbose  Enable verbose logging
  -h, --help     Print help
  -V, --version  Print version
$ gptcommit config -h
Read and modify settings

Usage: gptcommit config [OPTIONS] <COMMAND>

Commands:
  keys    List all config keys
  list    List all config values
  get     Read a config value
  set     Set a config value
  delete  Clear a config value
  help    Print this message or the help of the given subcommand(s)

Options:
  -v, --verbose  Enable verbose logging
  -h, --help     Print help
  -V, --version  Print version
$ gptcommit config keys
allow_amend
file_ignore
model_provider
openai.api_base
openai.api_key
openai.model
openai.proxy
openai.retries
output.conventional_commit
output.conventional_commit_prefix_format
output.lang
output.show_per_file_summary
prompt.commit_summary
prompt.commit_title
prompt.conventional_commit_prefix
prompt.file_diff
prompt.translation

gptcommit's People

Contributors

dependabot[bot] avatar ferstar avatar grayfallstown avatar j178 avatar jermyn626 avatar ottsch avatar sinnosong avatar twistoy avatar zcf0508 avatar zurawiki 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  avatar  avatar  avatar  avatar  avatar

gptcommit's Issues

Feature request: Allow custom prompting

The first version of gptcommit uses hardcoded prompts in a hardcoded way that can't be customized.

See code snippet:

static PROMPT_TO_SUMMARIZE_DIFF: &str = r#"You are an expert programmer, and you are trying to summarize a git diff.

gptcommit should have a configuration system in place that allows users to customize the summary prompts as needed. Maybe to start, users would bring their own "few-shot" examples

Proxy support

Is there any way to let gptcommit use proxy to make requests?

Feature request: Request rate limitation

Hi zurawiki,

My OpenAI account is currently kept unpaid, which resulted in rate limitation failures on large (maybe?) patchsets:

$ git commit
🤖 Asking GPT-3 to summarize diffs...
2023-02-09T16:33:58.976Z WARN  [gptcommit::openai] skipping... token count: 4552 < 4097
2023-02-09T16:33:58.980Z WARN  [gptcommit::openai] skipping... token count: 4092 < 4097
2023-02-09T16:33:58.988Z WARN  [gptcommit::openai] skipping... token count: 4310 < 4097
2023-02-09T16:33:58.988Z WARN  [gptcommit::openai] skipping... token count: 4252 < 4097
2023-02-09T16:33:58.992Z WARN  [gptcommit::openai] skipping... token count: 17654 < 4097
Error: Unexpected JSON response:
{"error":{"code":null,"message":"Rate limit reached for default-text-davinci-003 in organization org-xxxxxx on requests per min. Limit: 60.000000 / min. Current: 70.000000 / min. Contact [email protected] if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method.","param":null,"type":"requests"}}

$ git diff --staged --shortstat
 28 files changed, 2854 insertions(+)

The error occurs mid-execution, so the requests before the error were dropped. Retries may cause additional overhead in the costing. (related to #41)

Switching to a mature OpenAI API client (#20) could probably solve this problem, but before doing so, an additional configuration to limit the request rate will also come in handy.

Feature Request: allow specifying `--no-ext-diff` when running `git diff`

I've configured diff.external=difft in ~/.gitconfig (see Difftastic), so the output format of git diff is quite different from the default behavior of Git. With gptcommit, the generated commit message is always too generic, e.g.:

Refactor outdated code for improved performance

- Refactors code to improve performance
- Implements new feature that enhances user experience
- Fixes bug that was causing errors for a group of users
- Improves documentation for better comprehension and maintenance

If I remove the diff.external setting in ~/.gitconfig, the gptcommit generated commit message is more accurate:

Refactor protobufs for improved readability and accuracy

- Remove `crlf_end_of_line` option in `formats.cpp` for cleaner code.
- Adjust line positions, modify metadata, and reorganize submessages in `algebra.proto` for better readability and consistency.
- Revise `CsvReadOptions` and adjust indices and options within `FileOrFiles` message definition, resulting in more accurate schema inference.

To solve this issue, I suggest adding option --no-ext-diff when running git diff. In this way, Git will not use the configured external diff tool when generating diff. The option can be added either by default or by a new gptcommit config.

insufficient_quota

I'm getting this error since a few days ago, even with new api key:

Error: insufficient_quota: You exceeded your current quota, please check your plan and billing details.

Where to find the changelog?

Need a breakdown of changes when the new version is released so that we can better implement the new features into the downstream tools.

Running git commit -> Invalid URL

Error: Unexpected JSON response:
{"error":{"code":null,"message":"Invalid URL (POST /v1/completions1)","param":null,"type":"invalid_request_error"}}

When running "git commit". (Ensured that OPENAI_API_KEY is properly set.)

Managing OpenAI usage and costs

Greetings,

out of curiosity I tried out gptcommit yesterday for the first time with three commits. Two of them were a bit larger with 265 additions and 214 deletions according to git. Much to my surprise there were two dozen requests and got billed for $0.55. I'd like to ask whether it's expected that the amount of requests (and thus the price) is that high or whether this might indicate a bug?

image

Setting `openai.api_key` panics

I have a fresh install of gptcommit-0.1.9

When I'm trying to set openai.api_key like so:

gptcommit config set openai.api_key sk-…

it fails with this error:

thread 'main' panicked at 'Could not find user config path', /home/…/.cargo/registry/src/github.com-1ecc6299db9ec823/gptcommit-0.1.9/src/actions/config.rs:85:51

Feature request: Allow for different models

The first version of gptcommit uses text-davinci-003 in a hardcoded way that can't be customized.

See code snippet:

gptcommit/src/openai.rs

Lines 12 to 20 in 257ff00

let json_data = json!({
"model": "text-davinci-003",
"prompt": prompt,
"temperature": 0.5,
"max_tokens": 100,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
});

gptcommit should have a configuration system in place that allows users to select different models and other parameters.

This should be done after #20 is closed, to eliminate duplication of work

Allow custom max summary length

Right now, the max summary length is hard-coded and is 3000. I think it would be nice to allow users to change that threshold if needed.

Proposal: Add a `check` option to verify the local network environment

I have completed the relevant code and it is in my forked repository.

I did the following things:

  1. Added proxy for OpenAI's LLM.
  2. Added a check option to verify the local network environment.
  3. Added a ProxySettings configuration.
  4. Every time PrepareCommitMsg is executed, it will check the local network environment.

Why I add check option

Recently, there is a type of software called OpenAI Translator. The translator that does more than just translation - powered by OpenAI.

The author is distressed by some negative reviews because some users' OpenAI account was banned due to their local network issues.

I have referred to the strategy of OpenAI Translator and added a 'check' option to check the user's local network conditions.

image

If you think this proposal is useful, I will submit a PR.

If you think checking the local network environment is the user's own responsibility, then ignore this proposal.

config file permissions should be more restrictive

Running the command gptcommit config set openai.api_key sk-... the first time produced a config.toml which had group and world read permissions enabled (0644). Since this file contains an API key, seems like a good idea to create it with user read permissions only (0600).

Running git commit --> Could not decode JSON respose

This is my test case

I made some minor changes ( for testing purpose )
I run git add .
And then I run git commit

After that, I received this

🤖 Asking GPT-3 to summarize diffs...
Error: Could not decode JSON respose ( a typo )

Is there a verbose mode, so that the user will know what the error is and act accordingly ?

Thanks

Allow to force overwrite commit message on git commit --amend

After resolving issue #2 commit message is not overwritten by git commit --amend, however, there are still use cases when one would want to overwrite the commit message.

How about to add something like --force option to allow users to force overwrite commit messages?

the input device is not a TTY

Hi,

I've got this problem, do you have any idea?
It seems like error from docker.

➤  rustup update                    
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: checking for self-updates

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.67.0 (fc594f156 2023-01-24)

info: cleaning up downloads & tmp directories
╰─➤  cat .git/hooks/prepare-commit-msg
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: .git/hooks/prepare-commit-msg
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ #!/bin/sh
   2   │ 
   3   │ ### BEGIN GPTCOMMIT HOOK ###
   4   │ gptcommit prepare-commit-msg --commit-msg-file "$1" --commit-source "$2" --commit-sha "$3"
   5   │ ### END GPTCOMMIT HOOK ###
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
╰─➤  RUST_LOG=trace git commit
the input device is not a TTY

bug: Skipping because githook is not run on commit

Hey there,

Thanks for creating this tool for the community. It looks very interesting on the demos.

I managed to install it using cargo and also installed the git hook on my existing git repo. I can see the git hook prepare-commit-msg file showing up in the hook folder. However, it won't run whenever I tried to run git commit (with or without flags) command. I had the OPENAI_API_KEY env variable setup and activated already on my machine. What do you think might be the problem?

Thanks again for your attention.

Installation Issue

Hello I'm totally not into Rust environment. Decided to share it and luckily get some valid answer instead of copy pasting dunno what.

  rra@whatisthat:~/Documents/siemens/SDI/build-image$ cargo install --locked gptcommit
      Updating crates.io index
    Installing gptcommit v0.1.4
  error: failed to compile `gptcommit v0.1.4`, intermediate artifacts can be found at `/tmp/cargo-installBD3IP0`
  
  Caused by:
    package `clap_lex v0.3.1` cannot be built because it requires rustc 1.64.0 or newer, while the currently active rustc version is 1.61.0
  rra@workmachine:~/Documents/siemens/SDI/build-image$ 

Use OpenAI API client

Today, we use a naive HTTP request to get the OpenAI completions using the reqwest library.

Some benefits of a better API client

  • Better handling around rate limits
  • Typed parameters like model name and temperature
  • We can better re-use connections (today we create HTTP client per completion)

We should use a more robust API client library. I saw a few choices on lib.rs: https://lib.rs/search?q=openai but there isn't any library that is officially supported by OpenAI

async-openai https://lib.rs/crates/async-openai looks promising but isn't v1

Make gptcommit not overwrite commit message when using git commit --amend

When using git commit --amend gptcommit always replaces the last commit message with the same generic message:

# AI Generated Commit Summary:
# EDIT BELOW AS NEEDED
- Refactor backend code to improve performance
- Update frontend design to improve user experience
- Add new features to improve application functionality
#
# File-level changes:
~                      

[Feature Request] Per-project configuration

Now, gptcommit uses a global configuration, including API keys, prompts, etc. Is it possible to have per-project configurations?

For example, with a per-project prompt, I can have only titles for some projects, or I can add some specific characters in the messages, for example, some emojis.

One solution I can think of is to have a configuration file ./.gptcommit/config.toml, which overwrites the global one.

It is also helpful for us to use different API keys and track their usage for different projects.

Temporary failure in name resolution

Hi, I just wanted to try the tool because I think it is a really great idea but encountered a problem that I can't figure out. I have staged some changes, set my API key and executed gptcommit install in the repository. But when I enter git commit I get the following output:

Error: error sending request for url (https://api.openai.com/v1/completions): error trying to connect: dns error: failed to lookup address information: Temporary failure in name resolution

Caused by:
    0: error trying to connect: dns error: failed to lookup address information: Temporary failure in name resolution
    1: dns error: failed to lookup address information: Temporary failure in name resolution
    2: failed to lookup address information: Temporary failure in name resolution

When I try to make a request to the completions API using curl, it works.

Thanks in advance!

Implement `gptcommit uninstall`

Create a new command allowing users to uninstall the githook.

Work involved:

  • Add a new subcommand action named Uninstall in main.rs
  • Add the match handler in main.rs, line 53
  • Create a new file under src/actions named uninstall.rs, implement a main function.
    • This function should call get_hooks_path
    • Delete the prepare-commit-msg if it exists (ideally we should verify that the file is equivalent to include_str!("../../prepare-commit-msg") checked into this project.
  • Add a line to src/actions/mod.rs to expose the module to the crate.

Before submitting run just fix. You may need to run the command multiple times until there are no more file changes.

[BUG] Set custom OpenAI API base URL by CLI not working.

Description

I found that setting custom base URL to openai.api_base key with CLI is not working, just works for openai.api_key.

my device info:

  • macOS 12.3.1 (Intel)
  • gptcommit 0.4.0
$ gptcommit config set openai.api_base "XXXXXXX" -v
2023-03-27T08:22:20.551Z DEBUG [gptcommit::settings] Using home dir at /Users/Bobot
2023-03-27T08:22:20.551Z DEBUG [gptcommit::settings] Found config dir at /Users/Bobot/.config/gptcommit
2023-03-27T08:22:20.551Z DEBUG [gptcommit::settings] Applying config file at /Users/Bobot/.config/gptcommit/config.toml
2023-03-27T08:22:20.558Z INFO  [gptcommit::git] Repo path from git: Output { status: ExitStatus(unix_wait_status(0)), stdout: "/Users/Bobot/Repositories/xvautomator\n.git/hooks\n", stderr: "" }
2023-03-27T08:22:20.558Z INFO  [gptcommit::git] Creating dir at .git/hooks
2023-03-27T08:22:20.558Z DEBUG [gptcommit::settings] Applying config from  GPTCOMMIT__*: Ok({"openai_api_base": Value { origin: Some("the environment"), kind: String("XXXXXXXX") }})
2023-03-27T08:22:20.559Z DEBUG [gptcommit] Settings: Settings { model_provider: Some(OpenAI), openai: Some(OpenAISettings { api_key: Some("my-personal-key"), model: Some("gpt-3.5-turbo"), retries: Some(2) }), prompt: Some(PromptSettings { conventional_commit_prefix: Some("You are an expert programmer, and you are trying to summarize a code change.\nYou went over every file that was changed in it.\nFor some of these files changes where too big and were omitted in the files diff summary.\nDetermine the best label for the commit.\n\nHere are the labels you can choose from:\n\n- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)\n- chore: Updating libraries, copyrights or other repo setting, includes updating dependencies.\n- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, GitHub Actions)\n- docs: Non-code changes, such as fixing typos or adding new documentation\n- feat: a commit of the type feat introduces a new feature to the codebase\n- fix: A commit of the type fix patches a bug in your codebase\n- perf: A code change that improves performance\n- refactor: A code change that neither fixes a bug nor adds a feature\n- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)\n- test: Adding missing tests or correcting existing tests\n\n\nTHE FILE SUMMARIES:\n###\n{{ summary_points }}\n###\n\nThe label best describing this change:\n"), commit_summary: Some("You are an expert programmer, and you are trying to summarize a pull request.\nYou went over every file that was changed in it.\nFor some of these files changes were too big and were omitted in the files diff summary.\nPlease summarize the pull request.\nWrite your response in bullet points, using the imperative tense following the pull request style guide.\nStarting each bullet point with a `-`.\nWrite a high level description. Do not repeat the commit summaries or the file summaries.\nWrite the most important bullet points. The list should not be more than a few bullet points.\n\nTHE FILE SUMMARIES:\n###\n{{ summary_points }}\n###\n\nRemember to write only the most important points and do not write more than a few bullet points.\nTHE PULL REQUEST SUMMARY:\n\n"), commit_title: Some("You are an expert programmer, and you are trying to title a pull request.\nYou went over every file that was changed in it.\nFor some of these files changes were too big and were omitted in the files diff summary.\nPlease summarize the pull request into a single specific theme.\nWrite your response using the imperative tense following the kernel git commit style guide.\nWrite a high level title.\nDo not repeat the commit summaries or the file summaries.\nDo not list individual changes in the title.\n\nEXAMPLE SUMMARY COMMENTS:\n```\nRaise the amount of returned recordings\nSwitch to internal API for completions\nLower numeric tolerance for test files\nSchedule all GitHub actions on all OSs\n```\n\nTHE FILE SUMMARIES:\n###\n{{ summary_points }}\n###\n\nRemember to write only one line, no more than 50 characters.\nTHE PULL REQUEST TITLE:\n"), file_diff: Some("You are an expert programmer, and you are trying to summarize a git diff.\nReminders about the git diff format:\nFor every file, there are a few metadata lines, like (for example):\n```\ndiff --git a/lib/index.js b/lib/index.js\nindex aadf691..bfef603 100644\n--- a/lib/index.js\n+++ b/lib/index.js\n```\nThis means that `lib/index.js` was modified in this commit. Note that this is only an example.\nThen there is a specifier of the lines that were modified.\nA line starting with `+` means it was added.\nA line that starting with `-` means that line was deleted.\nA line that starts with neither `+` nor `-` is code given for context and better understanding.\nIt is not part of the diff.\nAfter the git diff of the first file, there will be an empty line, and then the git diff of the next file.\n\nDo not include the file name as another part of the comment.\nDo not use the characters `[` or `]` in the summary.\nWrite every summary comment in a new line.\nComments should be in a bullet point list, each line starting with a `-`.\nThe summary should not include comments copied from the code.\nThe output should be easily readable. When in doubt, write less comments and not more. Do not output comments that simply repeat the contents of the file.\nReadability is top priority. Write only the most important comments about the diff.\n\nEXAMPLE SUMMARY COMMENTS:\n###\n- Raise the amount of returned recordings from `10` to `100`\n- Fix a typo in the github action name\n- Move the `octokit` initialization to a separate file\n- Add an OpenAI API for completions\n- Lower numeric tolerance for test files\n- Add 2 tests for the inclusive string split function\n###\nMost commits will have less comments than this examples list.\nThe last comment does not include the file names,\nbecause there were more than two relevant files in the hypothetical commit.\nDo not include parts of the example in your summary.\nIt is given only as an example of appropriate comments.\n\n\nTHE GIT DIFF TO BE SUMMARIZED:\n###\n{{ file_diff }}\n###\n\nTHE SUMMARY:\n\n"), translation: Some("You are a professional programmer and translator, and you are trying to translate a git commit message.\nYou want to ensure that the translation is high level and in line with the programmer's consensus, taking care to keep the formatting intact.\n\nNow, translate the following message into {{ output_language }}.\n\nGIT COMMIT MESSAGE:\n\n###\n{{ commit_message }}\n###\n\nRemember translate all given git commit message.\nTHE TRANSLATION:\n") }), output: Some(OutputSettings { conventional_commit: Some(true), lang: Some("en"), show_per_file_summary: Some(false) }), allow_amend: Some(true), file_ignore: Some(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "Cargo.lock"]) }
2023-03-27T08:22:20.559Z DEBUG [gptcommit::actions::config] Config subcommand - Settings = Settings { model_provider: Some(OpenAI), openai: Some(OpenAISettings { api_key: Some("my-personal-key"), model: Some("gpt-3.5-turbo"), retries: Some(2) }), prompt: Some(PromptSettings { conventional_commit_prefix: Some("You are an expert programmer, and you are trying to summarize a code change.\nYou went over every file that was changed in it.\nFor some of these files changes where too big and were omitted in the files diff summary.\nDetermine the best label for the commit.\n\nHere are the labels you can choose from:\n\n- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)\n- chore: Updating libraries, copyrights or other repo setting, includes updating dependencies.\n- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, GitHub Actions)\n- docs: Non-code changes, such as fixing typos or adding new documentation\n- feat: a commit of the type feat introduces a new feature to the codebase\n- fix: A commit of the type fix patches a bug in your codebase\n- perf: A code change that improves performance\n- refactor: A code change that neither fixes a bug nor adds a feature\n- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)\n- test: Adding missing tests or correcting existing tests\n\n\nTHE FILE SUMMARIES:\n###\n{{ summary_points }}\n###\n\nThe label best describing this change:\n"), commit_summary: Some("You are an expert programmer, and you are trying to summarize a pull request.\nYou went over every file that was changed in it.\nFor some of these files changes were too big and were omitted in the files diff summary.\nPlease summarize the pull request.\nWrite your response in bullet points, using the imperative tense following the pull request style guide.\nStarting each bullet point with a `-`.\nWrite a high level description. Do not repeat the commit summaries or the file summaries.\nWrite the most important bullet points. The list should not be more than a few bullet points.\n\nTHE FILE SUMMARIES:\n###\n{{ summary_points }}\n###\n\nRemember to write only the most important points and do not write more than a few bullet points.\nTHE PULL REQUEST SUMMARY:\n\n"), commit_title: Some("You are an expert programmer, and you are trying to title a pull request.\nYou went over every file that was changed in it.\nFor some of these files changes were too big and were omitted in the files diff summary.\nPlease summarize the pull request into a single specific theme.\nWrite your response using the imperative tense following the kernel git commit style guide.\nWrite a high level title.\nDo not repeat the commit summaries or the file summaries.\nDo not list individual changes in the title.\n\nEXAMPLE SUMMARY COMMENTS:\n```\nRaise the amount of returned recordings\nSwitch to internal API for completions\nLower numeric tolerance for test files\nSchedule all GitHub actions on all OSs\n```\n\nTHE FILE SUMMARIES:\n###\n{{ summary_points }}\n###\n\nRemember to write only one line, no more than 50 characters.\nTHE PULL REQUEST TITLE:\n"), file_diff: Some("You are an expert programmer, and you are trying to summarize a git diff.\nReminders about the git diff format:\nFor every file, there are a few metadata lines, like (for example):\n```\ndiff --git a/lib/index.js b/lib/index.js\nindex aadf691..bfef603 100644\n--- a/lib/index.js\n+++ b/lib/index.js\n```\nThis means that `lib/index.js` was modified in this commit. Note that this is only an example.\nThen there is a specifier of the lines that were modified.\nA line starting with `+` means it was added.\nA line that starting with `-` means that line was deleted.\nA line that starts with neither `+` nor `-` is code given for context and better understanding.\nIt is not part of the diff.\nAfter the git diff of the first file, there will be an empty line, and then the git diff of the next file.\n\nDo not include the file name as another part of the comment.\nDo not use the characters `[` or `]` in the summary.\nWrite every summary comment in a new line.\nComments should be in a bullet point list, each line starting with a `-`.\nThe summary should not include comments copied from the code.\nThe output should be easily readable. When in doubt, write less comments and not more. Do not output comments that simply repeat the contents of the file.\nReadability is top priority. Write only the most important comments about the diff.\n\nEXAMPLE SUMMARY COMMENTS:\n###\n- Raise the amount of returned recordings from `10` to `100`\n- Fix a typo in the github action name\n- Move the `octokit` initialization to a separate file\n- Add an OpenAI API for completions\n- Lower numeric tolerance for test files\n- Add 2 tests for the inclusive string split function\n###\nMost commits will have less comments than this examples list.\nThe last comment does not include the file names,\nbecause there were more than two relevant files in the hypothetical commit.\nDo not include parts of the example in your summary.\nIt is given only as an example of appropriate comments.\n\n\nTHE GIT DIFF TO BE SUMMARIZED:\n###\n{{ file_diff }}\n###\n\nTHE SUMMARY:\n\n"), translation: Some("You are a professional programmer and translator, and you are trying to translate a git commit message.\nYou want to ensure that the translation is high level and in line with the programmer's consensus, taking care to keep the formatting intact.\n\nNow, translate the following message into {{ output_language }}.\n\nGIT COMMIT MESSAGE:\n\n###\n{{ commit_message }}\n###\n\nRemember translate all given git commit message.\nTHE TRANSLATION:\n") }), output: Some(OutputSettings { conventional_commit: Some(true), lang: Some("en"), show_per_file_summary: Some(false) }), allow_amend: Some(true), file_ignore: Some(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "Cargo.lock"]) }
2023-03-27T08:22:20.559Z DEBUG [gptcommit::settings] Using home dir at /Users/Bobot
2023-03-27T08:22:20.559Z DEBUG [gptcommit::settings] Found config dir at /Users/Bobot/.config/gptcommit
2023-03-27T08:22:20.559Z DEBUG [gptcommit::settings] Applying config file at /Users/Bobot/.config/gptcommit/config.toml
2023-03-27T08:22:20.566Z INFO  [gptcommit::git] Repo path from git: Output { status: ExitStatus(unix_wait_status(0)), stdout: "/Users/Bobot/Repositories/xvautomator\n.git/hooks\n", stderr: "" }
2023-03-27T08:22:20.566Z INFO  [gptcommit::git] Creating dir at .git/hooks
2023-03-27T08:22:20.566Z DEBUG [gptcommit::settings] Applying config from  GPTCOMMIT__*: Ok({"openai_api_base": Value { origin: Some("the environment"), kind: String("XXXXXXXXX") }})
openai.api_base = XXXXXXXXX
Config saved to /Users/Bobot/.config/gptcommit/config.toml

Then, there still isn't a key named openai.api_base:

$ gptcommit config keys                                                      
allow_amend
file_ignore
model_provider
openai.api_key
openai.model
openai.retries
output.conventional_commit
output.lang
output.show_per_file_summary
prompt.commit_summary
prompt.commit_title
prompt.conventional_commit_prefix
prompt.file_diff
prompt.translation

support conventional commits

Suggestion: Add support for Semantic Versioning, using tags ( such as [dev] [chore] [fix] [perf]) appropriately
Why: Semantic is a widely known standard for commit messages which are compiled to make a description of new releases. https://github.com/semantic-release/semantic-release
How: Add [dev] [chore] etc... in the commit message ; might be wrong but we are editing the message already anyway
What: Maybe a configuration that we could setup to automaticly prefix the commit message, maybe there is a way to hack this in without modifying the code too much ?

cargo install fails on windows

error[E0433]: failed to resolve: could not find `unix` in `os`
 --> C:\Users\mk\scoop\persist\rustup-msvc\.cargo\registry\src\github.com-1ecc6299db9ec823\gptcommit-0.1.0\src\actions\install.rs:4:27
  |
4 |     process::Command, os::unix::prelude::PermissionsExt,
  |                           ^^^^ could not find `unix` in `os`

error[E0599]: no function or associated item named `from_mode` found for struct `Permissions` in the current scope
  --> C:\Users\mk\scoop\persist\rustup-msvc\.cargo\registry\src\github.com-1ecc6299db9ec823\gptcommit-0.1.0\src\actions\install.rs:45:64
   |
45 |     fs::set_permissions(&prepare_commit_msg_path, Permissions::from_mode(0o755))?;
   |                                                                ^^^^^^^^^ function or associated item not found in `Permissions`

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `gptcommit` due to 2 previous errors
error: failed to compile `gptcommit v0.1.0`, intermediate artifacts can be found at `C:\Users\mk\AppData\Local\Temp\cargo-installdYv1GZ`

Disable per-file summary

Is it possible for us to disable per-file summary?

Sometimes there might be just one file or a few files changed. The per-file summary might be redundant with the main title and summary.

It's also useful to save costs.

bug: `gptinstall` should create hooks repo, if it doesn't exist

If .git/hooks doesn't exist,gpcommit install will fail.

Repro:

mkdir tmp
cd tmp
git init
rm -rf .git/hooks
gptcommit install

The last command will error with:

Installing gptcommit hook...
Error: No such file or directory (os error 2)

Work required:

  • recursively create directories to the githook install path, the equivalent of mkdir -p .git/hooks
  • [optional] Consider creating a better error message when the install fails.

not compatible with this engine

gc
🤖 Asking GPT-3 to summarize diffs...
Error: Unexpected JSON response:
{"error":{"code":null,"message":"You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions.","param":"model","type":"invalid_request_error"}}

API key doesn't update

I'm keep getting the error

Error: invalid_request_error: Incorrect API key provided: sk-eKEmW***************************************pG63. You can find your API key at https://platform.openai.com/account/api-keys.

This is the first API key I set, which is invalid. However, I've updated the valid API key, in config.toml, but this error persist and keep showing the old API-key.

I tried restart and reinstall, but doesn't work.

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.