1
- # 代碼審查機器人
1
+ # 程式碼審查機器人
2
2
3
- > 由 ChatGPT 提供支持的代碼審查機器人
3
+ > 由 ChatGPT 提供支援的程式碼審查機器人
4
4
5
- 翻譯版本:[ 英語 ] ( ./README.md ) \| [ 中文簡體 ] ( ./README.zh-CN.md ) \| [ 中文繁體 ] ( ./README.zh-TW.md ) \ | [ 한국어] ( ./README.ko.md ) \ | [ 日本語] ( ./README.ja.md )
5
+ 翻譯版本:[ English ] ( ./README.md ) | [ 簡體中文 ] ( ./README.zh-CN.md ) | [ 繁體中文 ] ( ./README.zh-TW.md ) | [ 한국어] ( ./README.ko.md ) | [ 日本語] ( ./README.ja.md )
6
6
7
- ## 用法
7
+ ## 機器人使用方式
8
+
9
+ ❗️⚠️ ` 由於成本考量,BOT 目前僅用於測試目的,並部署在有限制的 AWS Lambda 上。因此,不穩定的情況是完全正常的。建議自行部署 app。 `
8
10
9
11
### 安裝
10
12
11
13
安裝:[ apps/cr-gpt] ( https://github.com/apps/cr-gpt ) ;
12
14
13
- ### 配置
15
+ ### 設定
14
16
15
- 1 . 轉到你要集成此機器人的倉庫首頁
16
- 2 . 點擊` settings `
17
- 3 . 點擊` actions ` 在下面` secrets and variables `
18
- 4 . 切換到` Variables ` 選項,創建一個新變量` OPENAI_API_KEY ` ,值為你的 open api 的 key<img width =" 1465 " alt =" image " src =" https://user-images.githubusercontent.com/13167934/218533628-3974b70f-c423-44b0-b096-d1ec2ace85ea.png " >
17
+ 1 . 轉到你要整合此機器人的倉庫首頁
18
+ 2 . 點選 ` settings `
19
+ 3 . 點選 ` actions ` 在下面的 ` secrets and variables `
20
+ 4 . 切換到 ` Variables ` 選項,建立一個新變數 ` OPENAI_API_KEY ` ,值為你的 open api key (如果是 Github Action 整合,則設定在 secrets 中)
21
+ <img width =" 1465 " alt =" image " src =" https://user-images.githubusercontent.com/13167934/218533628-3974b70f-c423-44b0-b096-d1ec2ace85ea.png " >
19
22
20
23
### 開始使用
21
24
22
- 1 . 當你創建一個新的 Pull request 時,機器人會自動進行代碼審查,審查信息將顯示在 pr timeline / file changes 部分。
23
- 2 . 在 ` git push ` 更新 PR 之後,cr bot 將重新審查更改的文件
25
+ 1 . 當你建立一個新的 Pull request 時,機器人會自動進行程式碼審查,審查訊息將顯示在 pr timeline / file changes 部分。
26
+ 2 . 在 ` git push ` 更新 Pull request 之後,cr bot 將重新審查更改的文件
24
27
25
- 例子 :
28
+ 範例 :
26
29
27
30
[ ChatGPT-CodeReview/pull/21] ( https://github.com/anc95/ChatGPT-CodeReview/pull/21 )
28
31
29
32
<img width =" 1052 " alt =" image " src =" https://user-images.githubusercontent.com/13167934/218999459-812206e1-d8d2-4900-8ce8-19b5b6e1f5cb.png " >
30
33
31
- ### 使用 Github Action
32
-
33
- > 這是推薦的方式,因為 github bot 在一個不起眼的 vps 上服務,我不能確保它總是穩定的
34
+ ## 使用 Github Actions
34
35
35
36
[ actions/chatgpt-codereviewer] ( https://github.com/marketplace/actions/chatgpt-codereviewer )
36
37
37
- 1 . 添加 ` OPENAI_API_KEY ` 到你的 github action 密鑰
38
- 2 . 創建 ` .github/workflows/cr.yml ` 添加以下內容
38
+ 1 . 新增 ` OPENAI_API_KEY ` 到你的 github actions secrets
39
+ 2 . 建立 ` .github/workflows/cr.yml ` 新增以下內容
39
40
40
41
``` yml
41
42
name : Code Review
@@ -46,45 +47,56 @@ permissions:
46
47
47
48
on :
48
49
pull_request :
49
- types : [opened, reopened]
50
+ types : [opened, reopened, synchronize ]
50
51
51
52
jobs :
52
53
test :
54
+ # if: ${{ contains(github.event.*.labels.*.name, 'gpt review') }} # Optional; to run only when a label is attached
53
55
runs-on : ubuntu-latest
54
56
steps :
55
57
- uses : anc95/ChatGPT-CodeReview@main
56
58
env :
57
59
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
58
60
OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
59
- # optional
60
- PROMPT :
61
+ # Optional
62
+ LANGUAGE : Chinese
63
+ OPENAI_API_ENDPOINT : https://api.openai.com/v1
64
+ MODEL : gpt-3.5-turbo # https://platform.openai.com/docs/models
65
+ PROMPT : # example: Please check if there are any confusions or irregularities in the following code diff:
66
+ top_p : 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p
67
+ temperature : 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature
68
+ max_tokens : 10000
69
+ MAX_PATCH_LENGTH : 10000 # if the patch/diff length is large than MAX_PATCH_LENGTH, will be ignored and won't review. By default, with no MAX_PATCH_LENGTH set, there is also no limit for the patch/diff length.
61
70
` ` `
62
71
63
- ## 自托管
72
+ ## 自我託管
64
73
65
- 1. 克隆代碼
66
- 2. 復製 ` .env.example`到 `.env`, 並填寫環境變量
67
- 3. 安裝 deps 並運行
74
+ 1. 複製程式碼
75
+ 2. 複製 ` .env.example` 到 `.env`, 並填寫環境變數
76
+ 3. 安裝相依性並執行
68
77
69
78
` ` ` sh
70
79
npm i
71
- npm -i g pm2
80
+ npm i - g pm2
72
81
npm run build
73
82
pm2 start pm2.config.cjs
74
83
` ` `
75
84
76
- [機器人 ](https://probot.github.io/docs/development/)了解更多詳情
85
+ [probot ](https://probot.github.io/docs/development/) 了解更多詳情
77
86
78
87
# # 開發
79
88
80
- # ## 設置
89
+ # ## 設定
81
90
82
91
` ` ` sh
83
92
# Install dependencies
84
93
npm install
85
94
95
+ # Build code
96
+ npm run build
97
+
86
98
# Run the bot
87
- npm start
99
+ npm run start
88
100
` ` `
89
101
90
102
# ## Docker
@@ -99,13 +111,13 @@ docker run -e APP_ID=<app-id> -e PRIVATE_KEY=<pem-value> cr-bot
99
111
100
112
# # 貢獻
101
113
102
- 如果您對如何改進 cr-bot 有建議,或者想報告錯誤,請打開一個問題!我們會喜歡所有的貢獻 。
114
+ 如果您對如何改進 cr-bot 有建議,或者想報告錯誤,請開啟一個問題!我們喜歡所有的貢獻 。
103
115
104
- 有關更多信息,請查看[投稿指南 ](CONTRIBUTING.md).
116
+ 有關更多信息,請查看[貢獻指南 ](CONTRIBUTING.md).
105
117
106
118
# # 靈感
107
119
108
- 這個項目的靈感來自[代碼審查 .gpt](https://github.com/sturdy-dev/codereview.gpt)
120
+ 這個項目的靈感來自[codereview .gpt](https://github.com/sturdy-dev/codereview.gpt)
109
121
110
122
# # License
111
123
0 commit comments