Skip to content

Commit 4d17772

Browse files
committed
docs: enhance CLI documentation and installation instructions
- Update the description of the CLI tool for clarity and conciseness. - Remove several outdated features and replace them with updated descriptions. - Add new sections for installation instructions on macOS and Windows. - Introduce a section for pre-compiled binaries with updated instructions. - Clarify the process for setting the OpenAI API key and environment variables. - Improve formatting and consistency in section headings. - Enhance the instructions for changing to various API services, including Azure, Gemini, Anthropic, Groq, and Ollama. - Update the commit message template and related instructions for better clarity. Signed-off-by: appleboy <[email protected]>
1 parent 40021a7 commit 4d17772

File tree

1 file changed

+62
-56
lines changed

1 file changed

+62
-56
lines changed

README.md

+62-56
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
English | [繁體中文](./README.zh-tw.md) | [简体中文](./README.zh-cn.md)
1010

11-
A CLI written in [Go](https://go.dev) that writes git commit messages or provides a code review summary for you using ChatGPT AI (gpt-4o, gpt-4 model) and automatically installs a [git prepare-commit-msg hook](https://git-scm.com/docs/githooks).
11+
A CLI tool written in [Go](https://go.dev) that generates git commit messages or provides code review summaries using ChatGPT AI (gpt-4o, gpt-4 model). It also automatically installs a [git prepare-commit-msg hook](https://git-scm.com/docs/githooks).
1212

1313
- [繁體中文介紹][1]
1414
- [繁體中文影片][2]
@@ -21,40 +21,48 @@ A CLI written in [Go](https://go.dev) that writes git commit messages or provide
2121
## Features
2222

2323
- Supports [Azure OpenAI Service](https://azure.microsoft.com/en-us/products/cognitive-services/openai-service), [OpenAI API](https://platform.openai.com/docs/api-reference), [Gemini][60], [Anthropic][100], [Ollama][41], [Groq][30], and [OpenRouter][50].
24-
- Supports [conventional commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
25-
- Supports Git prepare-commit-msg Hook, see the [Git Hooks documentation](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks).
26-
- Supports customizing generated diffs with n lines of context, the default is three.
27-
- Supports excluding files from the git diff command.
28-
- Supports commit message translation into another language (supports `en`, `zh-tw`, or `zh-cn`).
29-
- Supports socks proxy or custom network HTTP proxy.
30-
- Supports [model lists](https://github.com/appleboy/CodeGPT/blob/bf28f000463cfc6dfa2572df61e1b160c5c680f7/openai/openai.go#L18-L38) like `gpt-4`, `gpt-4o`, etc.
31-
- Supports generating a brief code review.
32-
- Supports customizing prompt template and variables.
24+
- Adheres to the [conventional commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
25+
- Integrates with Git prepare-commit-msg Hook, see the [Git Hooks documentation](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks).
26+
- Allows customization of generated diffs with a specified number of context lines (default is three).
27+
- Enables exclusion of files from the git diff command.
28+
- Translates commit messages into other languages (supports `en`, `zh-tw`, or `zh-cn`).
29+
- Supports SOCKS proxy or custom network HTTP proxy.
30+
- Provides a [model list](https://github.com/appleboy/CodeGPT/blob/bf28f000463cfc6dfa2572df61e1b160c5c680f7/openai/openai.go#L18-L38) including `gpt-4`, `gpt-4o`, etc.
31+
- Generates brief code reviews.
32+
- Allows customization of prompt templates and variables.
3333

3434
![code review](./images/code_review.png)
3535

3636
## Installation
3737

38-
Install from [Homebrew](http://brew.sh/) on macOS
38+
### macOS
39+
40+
Install via [Homebrew](http://brew.sh/):
3941

4042
```sh
4143
brew tap appleboy/tap
4244
brew install codegpt
4345
```
4446

45-
Install from [Chocolatey](https://chocolatey.org/install) on Windows
47+
### Windows
48+
49+
Install via [Chocolatey](https://chocolatey.org/install):
4650

4751
```sh
4852
choco install codegpt
4953
```
5054

51-
The pre-compiled binaries can be downloaded from [release page](https://github.com/appleboy/CodeGPT/releases). Change the binary permissions to `755` and copy the binary to the system bin directory. Use the `codegpt` command as shown below.
55+
### Pre-compiled Binaries
56+
57+
Download the pre-compiled binaries from the [release page](https://github.com/appleboy/CodeGPT/releases). Change the binary permissions to `755` and copy the binary to the system bin directory. Use the `codegpt` command as shown below:
5258

5359
```sh
5460
$ codegpt version
5561
version: v0.4.3 commit: xxxxxxx
5662
```
5763

64+
### From Source
65+
5866
Install from source code:
5967

6068
```sh
@@ -63,25 +71,23 @@ go install github.com/appleboy/CodeGPT/cmd/codegpt@latest
6371

6472
## Setup
6573

66-
Please first create your OpenAI API Key. The [OpenAI Platform](https://platform.openai.com/account/api-keys) allows you to generate a new API Key.
74+
First, create your OpenAI API Key. The [OpenAI Platform](https://platform.openai.com/account/api-keys) allows you to generate a new API Key.
6775

6876
![register](./images/register.png)
6977

70-
An environment variable is a variable that is set on your operating system, rather than within your application. It consists of a name and value. We recommend that you set the name of the variable to `OPENAI_API_KEY`.
71-
72-
See the [Best Practices for API Key Safety](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety).
78+
Set the environment variable `OPENAI_API_KEY`:
7379

7480
```sh
7581
export OPENAI_API_KEY=sk-xxxxxxx
7682
```
7783

78-
or store your API key in a custom config file.
84+
Alternatively, store your API key in a custom config file:
7985

8086
```sh
8187
codegpt config set openai.api_key sk-xxxxxxx
8288
```
8389

84-
This will create a `.codegpt.yaml` file in your home directory ($HOME/.config/codegpt/.codegpt.yaml). The following options are available.
90+
This will create a `.codegpt.yaml` file in your home directory ($HOME/.config/codegpt/.codegpt.yaml). The following options are available:
8591

8692
| Option | Description |
8793
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -131,15 +137,15 @@ save conventional_commit.tmpl to /Users/xxxxx/.config/codegpt/prompt/conventiona
131137
- [summarize_title.tmpl](./prompt/templates/summarize_title.tmpl)
132138
- [conventional_commit.tmpl](./prompt/templates/conventional_commit.tmpl)
133139

134-
### How to change to Azure OpenAI Service
140+
### How to Change to Azure OpenAI Service
135141

136-
Please get the `API key`, `Endpoint` and `Model deployments` list from Azure Resource Management Portal on left menu.
142+
Get the `API key`, `Endpoint`, and `Model deployments` list from the Azure Resource Management Portal on the left menu.
137143

138144
![azure01](./images/azure_01.png)
139145

140146
![azure02](./images/azure_02.png)
141147

142-
Update your config file.
148+
Update your config file:
143149

144150
```sh
145151
codegpt config set openai.provider azure
@@ -148,7 +154,7 @@ codegpt config set openai.api_key xxxxxxxxxxxxxxxx
148154
codegpt config set openai.model xxxxx-gpt-4o
149155
```
150156

151-
### Support [Gemini][60] API Service
157+
### Support for [Gemini][60] API Service
152158

153159
Build with the Gemini API, you can see the [Gemini API documentation][61]. Update the `provider` and `api_key` in your config file. Please create an API key from the [Gemini API][62] page.
154160

@@ -162,7 +168,7 @@ codegpt config set openai.model gemini-1.5-flash-latest
162168
[61]: https://ai.google.dev/gemini-api/docs
163169
[62]: https://aistudio.google.com/app/apikey
164170

165-
### Support [Anthropic][100] API Service
171+
### Support for [Anthropic][100] API Service
166172

167173
Build with the Anthropic API, you can see the [Anthropic API documentation][101]. Update the `provider` and `api_key` in your config file. Please create an API key from the [Anthropic API][102] page.
168174

@@ -179,9 +185,9 @@ See the model list from the [Anthropic API documentation][103].
179185
[102]: https://anthropic.com/
180186
[103]: https://docs.anthropic.com/en/docs/about-claude/models
181187

182-
### How to change to [Groq][30] API Service
188+
### How to Change to [Groq][30] API Service
183189

184-
Please get the `API key` from Groq API Service, please visit [here][31]. Update the `base_url` and `api_key` in your config file.
190+
Get the `API key` from the Groq API Service, please visit [here][31]. Update the `base_url` and `api_key` in your config file.
185191

186192
```sh
187193
codegpt config set openai.provider openai
@@ -199,9 +205,9 @@ GroqCloud currently supports the [following models][32]:
199205
[31]: https://console.groq.com/keys
200206
[32]: https://console.groq.com/docs/models
201207

202-
### How to change to ollama API Service
208+
### How to Change to Ollama API Service
203209

204-
We can use the Llama3 model from the [ollama][41] API Service, please visit [here][40]. Update the `base_url` in your config file.
210+
We can use the Llama3 model from the [Ollama][41] API Service, please visit [here][40]. Update the `base_url` in your config file.
205211

206212
[40]: https://github.com/ollama/ollama/blob/main/docs/openai.md#models
207213
[41]: https://github.com/ollama/ollama
@@ -212,7 +218,7 @@ ollama pull llama3
212218
ollama cp llama3 gpt-4o
213219
```
214220

215-
Try to use the `ollama` API Service.
221+
Try to use the `Ollama` API Service:
216222

217223
```sh
218224
curl http://localhost:11434/v1/chat/completions \
@@ -234,11 +240,11 @@ Update the `base_url` in your config file. You don't need to set the `api_key` i
234240
codegpt config set openai.base_url http://localhost:11434/v1
235241
```
236242

237-
### How to change to [OpenRouter][50] API Service
243+
### How to Change to [OpenRouter][50] API Service
238244

239245
You can see the [supported models list][51], model usage can be paid by users, developers, or both, and may shift in [availability][52]. You can also fetch models, prices, and limits [via API][53].
240246

241-
The following example use free model name: `meta-llama/llama-3-8b-instruct:free`
247+
The following example uses the free model name: `meta-llama/llama-3-8b-instruct:free`
242248

243249
```sh
244250
codegpt config set openai.provider openai
@@ -252,14 +258,14 @@ codegpt config set openai.model google/learnlm-1.5-pro-experimental:free
252258
[52]: https://openrouter.ai/terms#services
253259
[53]: https://openrouter.ai/api/v1/models
254260

255-
For including your app on openrouter.ai rankings and Shows in rankings on openrouter.ai, you can set the `openai.headers` in your config file.
261+
To include your app in openrouter.ai rankings and show it in rankings on openrouter.ai, you can set the `openai.headers` in your config file:
256262

257263
```sh
258264
codegpt config set openai.headers "HTTP-Referer=https://github.com/appleboy/CodeGPT X-Title=CodeGPT"
259265
```
260266

261-
- **HTTP-Refer**: Optional, for including your app on openrouter.ai rankings.
262-
- **X-Title**: Optional, for Shows in rankings on openrouter.ai.
267+
- **HTTP-Referer**: Optional, for including your app in openrouter.ai rankings.
268+
- **X-Title**: Optional, for showing in rankings on openrouter.ai.
263269

264270
## Usage
265271

@@ -274,24 +280,24 @@ git add <files...>
274280
codegpt commit --preview
275281
```
276282

277-
The commit message is shown below.
283+
The commit message is shown below:
278284

279285
```sh
280-
Summarize the commit message use gpt-4o model
286+
Summarize the commit message using the gpt-4o model
281287
We are trying to summarize a git diff
282-
We are trying to summarize a title for pull request
288+
We are trying to summarize a title for the pull request
283289
================Commit Summary====================
284290

285291
feat: Add preview flag and remove disableCommit flag in commit command and template file.
286292

287293
- Add a `preview` flag to the `commit` command
288-
- Remove the `disbaleCommit` flag from the `prepare-commit-msg` template file
294+
- Remove the `disableCommit` flag from the `prepare-commit-msg` template file
289295

290296
==================================================
291297
Write the commit message to .git/COMMIT_EDITMSG file
292298
```
293299

294-
or translate all git commit messages into a different language (`Traditional Chinese`, `Simplified Chinese` or `Japanese`)
300+
Or translate all git commit messages into a different language (`Traditional Chinese`, `Simplified Chinese`, or `Japanese`):
295301

296302
```sh
297303
codegpt commit --lang zh-tw --preview
@@ -300,9 +306,9 @@ codegpt commit --lang zh-tw --preview
300306
Consider the following outcome:
301307

302308
```sh
303-
Summarize the commit message use gpt-4o model
309+
Summarize the commit message using the gpt-4o model
304310
We are trying to summarize a git diff
305-
We are trying to summarize a title for pull request
311+
We are trying to summarize a title for the pull request
306312
We are trying to translate a git commit message to Traditional Chinese language
307313
================Commit Summary====================
308314

@@ -315,36 +321,36 @@ We are trying to translate a git commit message to Traditional Chinese language
315321
Write the commit message to .git/COMMIT_EDITMSG file
316322
```
317323

318-
You can replace the tip of the current branch by creating a new commit. just use `--amend` flag
324+
You can replace the tip of the current branch by creating a new commit. Just use the `--amend` flag:
319325

320326
```sh
321327
codegpt commit --amend
322328
```
323329

324-
## Change commit message template
330+
## Change Commit Message Template
325331

326-
Default commit message template as following:
332+
The default commit message template is as follows:
327333

328334
```tmpl
329335
{{ .summarize_prefix }}: {{ .summarize_title }}
330336
331337
{{ .summarize_message }}
332338
```
333339

334-
change format with template string using `--template_string` parameter:
340+
Change the format with a template string using the `--template_string` parameter:
335341

336342
```sh
337343
codegpt commit --preview --template_string \
338344
"[{{ .summarize_prefix }}]: {{ .summarize_title }}"
339345
```
340346

341-
change format with template file using `--template_file` parameter:
347+
Change the format with a template file using the `--template_file` parameter:
342348

343349
```sh
344350
codegpt commit --preview --template_file your_file_path
345351
```
346352

347-
Add custom variable to git commit message template:
353+
Add a custom variable to the git commit message template:
348354

349355
```sh
350356
{{ .summarize_prefix }}: {{ .summarize_title }}
@@ -354,40 +360,40 @@ Add custom variable to git commit message template:
354360
{{ if .JIRA_URL }}{{ .JIRA_URL }}{{ end }}
355361
```
356362
357-
Add custom variable to git commit message template using `--template_vars` parameter:
363+
Add a custom variable to the git commit message template using the `--template_vars` parameter:
358364
359365
```sh
360366
codegpt commit --preview --template_file your_file_path --template_vars \
361367
JIRA_URL=https://jira.example.com/ABC-123
362368
```
363369
364-
Load custom variable from file using `--template_vars_file` parameter:
370+
Load a custom variable from a file using the `--template_vars_file` parameter:
365371
366372
```sh
367373
codegpt commit --preview --template_file your_file_path --template_vars_file your_file_path
368374
```
369375
370-
See the `template_vars_file` format as following:
376+
See the `template_vars_file` format as follows:
371377
372378
```env
373379
JIRA_URL=https://jira.example.com/ABC-123
374380
```
375381
376-
### Git hook
382+
### Git Hook
377383
378384
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.
379385
380386
#### Install
381387
382-
You want to install the hook in the Git repository:
388+
To install the hook in the Git repository:
383389
384390
```sh
385391
codegpt hook install
386392
```
387393
388394
#### Uninstall
389395
390-
You want to remove the hook from the Git repository:
396+
To remove the hook from the Git repository:
391397
392398
```sh
393399
codegpt hook uninstall
@@ -404,9 +410,9 @@ git commit
404410
405411
```sh
406412
$ git commit
407-
Summarize the commit message use gpt-4o model
413+
Summarize the commit message using the gpt-4o model
408414
We are trying to summarize a git diff
409-
We are trying to summarize a title for pull request
415+
We are trying to summarize a title for the pull request
410416
================Commit Summary====================
411417

412418
Improve user experience and documentation for OpenAI tools
@@ -430,7 +436,7 @@ You can use `codegpt` to generate a code review message for your staged changes:
430436
codegpt review
431437
```
432438
433-
or translate all code review messages into a different language (`Traditional Chinese`, `Simplified Chinese` or `Japanese`)
439+
Or translate all code review messages into a different language (`Traditional Chinese`, `Simplified Chinese`, or `Japanese`):
434440
435441
```sh
436442
codegpt review --lang zh-tw

0 commit comments

Comments
 (0)