Skip to content

Commit 241577b

Browse files
authored
feat(cz-git,cli): add aiModel option to support multiple OpenAI models (#185)
* Remove AI model `text-davinci-003` and configure field `aiType` * Add configure field `aiModel`: 'gpt-3.5-turbo' | 'gpt-4' | 'gpt-4o' | 'gpt-4o-mini' | string... * (cli): add options `-M=|--ai-model=` and `--api-model=` * The AI Model option only support for the OpenAI API's `/chat/completions` endpoint model now. link #180
1 parent 79a7833 commit 241577b

37 files changed

Lines changed: 599 additions & 355 deletions

File tree

‎.x-cmd/release‎

Lines changed: 0 additions & 49 deletions
This file was deleted.

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ DX first and more engineered, lightweight, customizable, standard output format
7070

7171
```bash
7272
$ npm i -D cz-git
73-
+ cz-git (1.9 MB)
74-
added 1 package in 0.582s
73+
+ cz-git (1.75 MB)
74+
added 1 package in 0.552s
7575
```
7676

7777
[⇒ Why czg](https://cz-git.qbb.sh/cli/why.html)
7878
```bash
7979
$ npm i -g czg
80-
+ czg (1.5 MB)
80+
+ czg (1.31 MB)
8181
added 1 package in 0.531s
8282
```
8383

@@ -179,7 +179,7 @@ added 1 package in 0.531s
179179
[⇒ FAQ](https://cz-git.qbb.sh/faq/)
180180

181181
<a target="_blank" href="https://packagephobia.com/result?p=cz-git,czg">
182-
<img src="https://user-images.githubusercontent.com/40693636/252157675-32634902-fc02-4a07-a12c-a07ec5ee5f1a.png" alt="size-overview"><br>
182+
<img src="https://cdn.jsdelivr.net/gh/Zhengqbbb/Zhengqbbb@v1.1.6/image/cz-git-v1.10.0.png" alt="size-overview"><br>
183183
<sub>https://packagephobia.com/result?p=cz-git,czg</sub>
184184
</a>
185185

‎docs/.vitepress/theme/components/HomePage.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ useMediumZoom()
4848
$ npm install -D cz-git<br>
4949
+ cz-git
5050
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
51-
(<span c-orange-5> 1.9 MB </span>) <br>added &nbsp;<span c-orange-5>1</span>&nbsp; package
52-
in &nbsp;<span c-orange-5>0.582s</span>
51+
(<span c-orange-5> 1.75 MB </span>) <br>added &nbsp;<span c-orange-5>1</span>&nbsp; package
52+
in &nbsp;<span c-orange-5>0.552s</span>
5353
</p>
5454
</div>
5555
<div class="feat">

‎docs/.vitepress/theme/style/main.css‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ img.error {
100100
img.error::before {
101101
content: '';
102102
position: absolute;
103-
left: 0;
103+
left: 0;
104104
top: 0;
105-
width: 100%;
105+
width: 100%;
106106
height: 100%;
107107
color: transparent;
108108
--un-icon: url("data:image/svg+xml,%3Csvg class='icon' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cpath d='M304.128 456.192c48.64 0 88.064-39.424 88.064-88.064s-39.424-88.064-88.064-88.064-88.064 39.424-88.064 88.064 39.424 88.064 88.064 88.064zm0-116.224c15.36 0 28.16 12.288 28.16 28.16s-12.288 28.16-28.16 28.16-28.16-12.288-28.16-28.16 12.288-28.16 28.16-28.16z' fill='%23aaaaaa'/%3E%3Cpath d='M887.296 159.744H136.704C96.768 159.744 64 192 64 232.448v559.104c0 39.936 32.256 72.704 72.704 72.704h198.144L500.224 688.64l-36.352-222.72 162.304-130.56-61.44 143.872 92.672 214.016-105.472 171.008h335.36C927.232 864.256 960 832 960 791.552V232.448c0-39.936-32.256-72.704-72.704-72.704zm-138.752 71.68v.512H857.6c16.384 0 30.208 13.312 30.208 30.208v399.872L673.28 408.064l75.264-176.64zM304.64 792.064H165.888c-16.384 0-30.208-13.312-30.208-30.208v-9.728l138.752-164.352 104.96 124.416-74.752 79.872zm81.92-355.84l37.376 228.864-.512.512-142.848-169.984c-3.072-3.584-9.216-3.584-12.288 0L135.68 652.8V262.144c0-16.384 13.312-30.208 30.208-30.208h474.624L386.56 436.224zm501.248 325.632c0 16.896-13.312 30.208-29.696 30.208H680.96l57.344-93.184-87.552-202.24 7.168-7.68 229.888 272.896z' fill='%23aaaaaa'/%3E%3C/svg%3E");
@@ -114,7 +114,7 @@ img.error::after {
114114
color: inherit;
115115
font-size: 0.85rem;
116116
position: absolute;
117-
left: 0;
117+
left: 0;
118118
bottom: 0;
119119
width: 100%;
120120
background-color: var(--vp-c-bg-nav);
@@ -185,7 +185,7 @@ img.error::after {
185185
.VPHome .VPTeamMembersItem {
186186
border: 1px solid var(--vp-button-alt-border);
187187
}
188-
.VPHome .VPTeamMembersItem .profile {
188+
.VPHome .VPTeamMembersItem .profile {
189189
background: none;
190190
color: var(--vp-button-alt-text);
191191
}
@@ -233,6 +233,11 @@ img.error::after {
233233
color: var(--vp-custom-block-danger-text-deep);
234234
}
235235

236+
.vp-doc .custom-block a {
237+
text-decoration-color: inherit;
238+
-webkit-text-decoration-color: inherit;
239+
}
240+
236241
.vp-doc .custom-block a:hover,
237242
.vp-doc .custom-block a:active {
238243
color: inherit;
@@ -255,7 +260,7 @@ img.error::after {
255260
.dark .DocSearch-Button-Key {
256261
box-shadow: none;
257262
}
258-
.DocSearch-Modal .cls-1,
263+
.DocSearch-Modal .cls-1,
259264
.DocSearch-Modal .cls-2{
260265
fill: var(--vp-c-docsearch-logo-color);
261266
}

‎docs/cli/ai.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ czg --api-key=sk-xxxxx
1818
## Options
1919

2020
| Shorthand, Name | Description |
21-
| --- | --- |
22-
| `-N=<number>`<br>`--ai-num=<number>` | Setting AI return number subjects and Turn on choose mode |
23-
| `--no-ai` | Turn off AI prompt mode in this session |
21+
| --- | --- |
22+
| `-N=<number>`<br>`--ai-num=<number>` | Sets AI return multiple subjects and Turn on choose mode |
23+
| `-M=<model>`<br>`--ai-model=<model>` | Sets AI model in this session |
24+
| `--no-ai` | Turn off AI prompt mode in this session |
2425
| `--api-key=<token>` | Setup OpenAI API secret key to local (.config/.czrc) |
26+
| `--api-model=<model>` | Setup request OpenAI API model to local (.config/.czrc) |
2527
| `--api-proxy=<proxy_URL>` | Setup request OpenAI API proxy to local (.config/.czrc)<br>e.g:<br> 1. `npx czg --api-proxy="socks5://127.0.0.1:1080"`<br>2. `npx czg --api-proxy="http://127.0.0.1:1080"` |
2628
| `--api-endpoint=<url>` | Setup request OpenAI API endpoint to local<br>Default `"https://api.openai.com/v1"` |
2729
| `--unset-proxy` | Unset request API proxy on local configure |

‎docs/cli/index.md‎

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ description: Interactive Commitizen CLI that generate standardized git commit me
2626
<br />
2727

2828
- 🤖 **OpenAI Support.** Let the AI generate your git commit message.
29-
- ⚡️ **Lightweight** : Zero Dependencies (1.6MB)
29+
- ⚡️ **Lightweight** : Zero Dependencies (1.31MB)
3030
- 🤗 **Simpler and Faster** : No plugin, No adapter, No extra steps, You can use `npx` | `npm script` | `global install`... quick start CLI in your any project
3131
- 😎 **Highly Customizable** : Internally contains the core of cz-git. Extend all the features of cz-git. Same behavior, Same configuration loader... You can customize the commit CLI according to your need
3232

@@ -82,41 +82,45 @@ More information about configure file and options. See → [Config](/config/)
8282
https://cz-git.qbb.sh/cli/
8383
https://github.com/Zhengqbbb/cz-git
8484
85-
[33mSYNOPSIS:[0m
85+
[33mSYNOPSIS:[39m
8686
czg [subcommand...] [options...] [git-commit-options...]
8787
88-
SUBCOMMAND:
89-
ai Turn on OpenAI generate subject mode
90-
break Turn on appends a ! after the type/scope
91-
emoji Turn on output message with emoji mode
92-
checkbox Turn on scope checkbox mode
93-
gpg Turn on use GPG sign commit message
94-
95-
OPTIONS:
96-
:, --alias= Directly submit the defined commit message
97-
--config= Specify the configuration file to use
98-
99-
OpenAI:
100-
-N=,--ai-num= Setting AI return number subjects and Turn on choose mode
101-
--api-key= Setup request OpenAI API secret key to local (.config/.czrc)
102-
--api-proxy= Setup request OpenAI API proxy to local (.config/.czrc)
103-
--api-endpoint= Setup request OpenAI API endpoint to local (.config/.czrc)
104-
[default: "https://api.openai.com/v1"]
105-
106-
FLAG:
107-
-r, --retry Directly retry submit by the last message
108-
--no-ai Turn off AI prompt mode in this session
109-
--unset-proxy Unset request API proxy on local configure
110-
-h, --help Show help
111-
-v, --version Show version
112-
113-
EXAMPLES:
114-
czg
115-
czg emoji
116-
czg :fd
117-
czg --config="./config/cz.json"
118-
czg --api-key="sk-XXXXX"
119-
czg ai -N=3
88+
SUBCOMMAND:
89+
ai Turn on OpenAI generate subject mode
90+
break Turn on appends a ! after the type/scope
91+
emoji Turn on output message with emoji mode
92+
checkbox Turn on scope checkbox mode
93+
gpg Turn on use GPG sign commit message
94+
95+
OPTIONS:
96+
:, --alias= Directly submit the defined commit message
97+
--config= Specify the configuration file to use
98+
99+
OpenAI:
100+
-N=,--ai-num= Sets AI return multiple subjects and Turn on choose mode
101+
-M=,--ai-model= Sets AI model in this session
102+
[default: "gpt-4o-mini"]
103+
[example: "gpt-3.5-turbo", "gpt-4o", "gpt-4o-mini" ...]
104+
--api-key= Setup request OpenAI API secret key to local (.config/.czrc)
105+
--api-model= Setup request OpenAI API model to local (.config/.czrc)
106+
--api-proxy= Setup request OpenAI API proxy to local (.config/.czrc)
107+
--api-endpoint= Setup request OpenAI API endpoint to local (.config/.czrc)
108+
[default: "https://api.openai.com/v1"]
109+
110+
FLAG:
111+
-r, --retry Directly retry submit by the last message
112+
--no-ai Turn off AI prompt mode in this session
113+
--unset-proxy Unset request API proxy on local configure
114+
-h, --help Show help
115+
-v, --version Show version
116+
117+
EXAMPLES:
118+
czg
119+
czg emoji
120+
czg :fd
121+
czg --config="./config/cz.json"
122+
czg --api-key="sk-XXXXX"
123+
czg ai -N=3 -M="gpt-4o"
120124
121125
Extends 'git commit' options.
122126
See 'git commit --help' for more information.

‎docs/cli/why.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ $ du -sh ./node_modules
2525
102M ./node_modules
2626
2727
$ npm install -D czg
28-
added 1 package, and audited 2 packages in 408 ms
28+
added 1 package, and audited 2 packages in 531 ms
2929
$ du -sh ./node_modules/*
30-
1.3M ./node_modules/czg
30+
1.31M ./node_modules/czg
3131
```
3232

3333
## What is different from cz-git

‎docs/config/engineer.md‎

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,33 @@ Try running command to **use OpenAI API to auto generate **subject** in the curr
118118
Demo And Usage [⇒ see the recipes](/recipes/openai)
119119
:::
120120

121+
## aiModel
122+
123+
- **description**: Choose the AI model you want to use
124+
- **examples**: `gpt-3.5-turbo` | `gpt-4` | `gpt-4o` | `gpt-4o-mini` <br>... (and models compatible with the [/chat/completions endpoint](https://platform.openai.com/docs/models/model-endpoint-compatibility)) <br>For example: [GitHub models](https://github.com/marketplace/models) and local models ([Ollama](https://ollama.com/library))
125+
- **type**: `string`
126+
- **default**: `gpt-4o-mini`
127+
128+
:::tip
129+
Try running the command to **switch AI models directly in the current session**
130+
- Commitizen CLI + cz-git: `czai=1 cz_aimodel=gpt-3.5-turbo cz`
131+
- czg CLI: `czg ai -M=gpt-3.5-turbo`
132+
133+
Demo And Usage [⇒ see the recipes](/recipes/openai)
134+
:::
135+
136+
:::info
137+
If `aiModel` is set globally or in the project, it will override the value set using `npx czg --api-model=<model>`
138+
139+
<hr>
140+
141+
**Priority explanation, from high to low:**
142+
1. Environment variable specification `cz_aimodel=`, `czg` command parameter specification `-M=|--ai-model=`
143+
2. Global configuration or project configuration: `aiModel` field
144+
3. The `apiModel` field in `~/.config/.czrc` configured via the `npx czg --api-model=<model>` command
145+
:::
146+
147+
121148
## aiNumber
122149

123150
- **description** : If >1 will **turn on select mode**, select generate options like returned by OpenAI
@@ -132,18 +159,6 @@ Try running command to **select multiple results returned by OpenAI in the curre
132159
Demo And Usage [⇒ see the recipes](/recipes/openai)
133160
:::
134161

135-
## aiType
136-
137-
- **description** : Choose the AI model you want to use
138-
139-
| aiType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Model&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Description |
140-
| --- | --- | --- |
141-
| openAI-Turbo | gpt-3.5-turbo | faster and optimized for chat at 1/10th the cost of `text-davinci-003` |
142-
| openAI-Davinci | text-davinci-003 | better quality, longer output, and consistent instruction-following |
143-
144-
- **type** : `"openAI-Turbo" | "openAI-Davinci"`
145-
- **default** : `openAI-Turbo`
146-
147162
## aiDiffIgnore
148163

149164
- **description** : To ignore selection diff codes when sending AI API requests
@@ -165,7 +180,7 @@ export interface GenerateAIPromptType {
165180
diff?: string
166181
}
167182
```
168-
- **example** :
183+
- **example** :
169184

170185
```js
171186
module.exports = {

‎docs/guide/introduction.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ Support OpenAI, and more engineered, lightweight, customizable, standard output
6565

6666
```sh
6767
$ npm install -D cz-git
68-
+ cz-git (1.9 MB)
69-
added 1 package in 0.582s
68+
+ cz-git (1.75 MB)
69+
added 1 package in 0.552s
7070
```
7171

7272
[⇒ Why cz-git](/guide/why.html)

‎docs/guide/why.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $ npm install -D cz-conventional-changelog
3131
added 147 packages in 21s
3232
3333
$ npm install -D cz-git
34-
added 1 package in 0.582s
34+
added 1 package in 0.552s
3535
```
3636

3737
---

0 commit comments

Comments
 (0)