CodeGPT

command module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 5 Imported by: 0

README

CodeGPT

Lint and Testing codecov Go Report Card

cover

A CLI written in Go language that writes git commit messages for you using ChatGPT AI (gpt-3.5-turbo model) and automatically installs a git prepare-commit-msg hook.

Installation

The pre-compiled binaries can be downloaded from release page.

On linux AMD64

wget -c https://github.com/appleboy/CodeGPT/releases/download/v0.0.4/CodeGPT-0.0.4-linux-amd64 -O codegpt

On macOS (Intel amd64)

wget -c https://github.com/appleboy/CodeGPT/releases/download/v0.0.4/CodeGPT-0.0.4-darwin-amd64 -O codegpt

On macOS (Apple arm64)

wget -c https://github.com/appleboy/CodeGPT/releases/download/v0.0.4/CodeGPT-0.0.4-darwin-arm64 -O codegpt

On Windows (AMD64)

wget -c https://github.com/appleboy/CodeGPT/releases/download/v0.0.4/CodeGPT-0.0.4-windows-amd64.exe -O codegpt.exe

Change the binary permissions to 755 and copy the binary to the system bin directory. Use the codegpt command as shown below.

$ codegpt version
version: v0.0.4 commit: 359a48a

Setup

Please first create your OpenAI API Key. The OpenAI Platform allows you to generate a new API Key.

register

codegpt config set openai.api_key sk-xxxxxxx

This will create a .codegpt.yaml file in your home directory ($HOME/.config/codegpt/.codegpt.yaml). The following options are available.

  • openai.org_id: Identifier for this organization sometimes used in API requests. see organization settings.
  • openai.model: default model is gpt-3.5-turbo, you can change to text-davinci-003 or other available model list.
  • openai.lang: default language is en and available languages zh-tw, zh-tw, ja.
  • openai.proxy: set http client proxy.

Usage

There are two methods for generating a commit message using the codegpt command. The first is CLI mode, and the second is Git Hook.

CLI mode

You can call codegpt directly to generate a commit message for your staged changes:

git add <files...>
codegpt commit

The commit message is shown below.

Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
We are trying to summarize a title for pull request
================Commit Summary====================

Add OpenAI integration and CLI usage instructions

- Add download links for pre-compiled binaries for various platforms
- Add instructions for setting up OpenAI API key
- Add CLI usage instructions for generating commit messages with `codegpt`
- Add references to OpenAI Chat completions documentation and introducing ChatGPT and Whisper APIs

==================================================
Write the commit message to .git/COMMIT_EDITMSG file

or translate all git commit messages into a different language (Traditional Chinese, Simplified Chinese or Japanese)

codegpt commit --lang zh-tw

Consider the following outcome:

Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
We are trying to summarize a title for pull request
We are trying to translate a git commit message to Traditional Chineselanguage
================Commit Summary====================
增加發布頁面改進和CLI模式說明。

- 在發布頁面上增加了不同系統的預編譯二進制文件。
- 提供設置OpenAI API密鑰的說明。
- 提供使用CLI模式生成暫存更改的提交消息的說明。

==================================================
Write the commit message to .git/COMMIT_EDITMSG file
Git hook

You can also use the prepare-commit-msg hook to integrate codegpt with Git. This allows you to use Git normally and edit the commit message before committing.

Install

You want to install the hook in the Git repository:

codegpt hook install
Uninstall

You want to remove the hook from the Git repository:

codegpt hook uninstall

Stage your files and commit after installation:

git add <files...>
git commit

codegpt will generate the commit message for you and pass it back to Git. Git will open it with the configured editor for you to review/edit it. Then, to commit, save and close the editor!

$ git commit
Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
We are trying to summarize a title for pull request
================Commit Summary====================

Improve user experience and documentation for OpenAI tools

- Add download links for pre-compiled binaries
- Include instructions for setting up OpenAI API key
- Add a CLI mode for generating commit messages
- Provide references for OpenAI Chat completions and ChatGPT/Whisper APIs

==================================================
Write the commit message to .git/COMMIT_EDITMSG file
[main 6a9e879] Improve user experience and documentation for OpenAI tools
 1 file changed, 56 insertions(+)

Reference

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL