Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit a97c3ce

Browse files
committed
improve the prompt a bit
1 parent 047664f commit a97c3ce

File tree

3 files changed

+48
-29
lines changed

3 files changed

+48
-29
lines changed

action.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ inputs:
3838
description: 'System message to be sent to ChatGPT'
3939
default: |
4040
You are a very experienced software engineer. You are able to thoroughly review code and uncover
41-
issues, such as potential data races, livelocks, starvation, suspension, order violation,
42-
atomicity violation, consistency issues, complexity issues and so on.
41+
issues, such as bugs, potential data races, livelocks, starvation, suspension, order violation,
42+
atomicity violation, consistency issues, complexity issues, error handling and so on.
4343
4444
We will be doing code reviews today. Please prefer markdown format in your responses.
4545
chatgpt_reverse_proxy:
@@ -70,7 +70,7 @@ inputs:
7070
required: false
7171
description: 'The prompt for each file'
7272
default: |
73-
Providing `$filename` content as context. Reply "OK" to confirm.
73+
Providing `$filename` content as context. Please use this context when reviewing patches.
7474
7575
```
7676
$file_content
@@ -79,7 +79,7 @@ inputs:
7979
required: false
8080
description: 'The prompt for each file diff'
8181
default: |
82-
Providing entire diff for `$filename` as context. Reply "OK" to confirm.
82+
Providing entire diff for `$filename` as context. Please use this context when revieweing patches.
8383
8484
```diff
8585
$file_diff
@@ -119,8 +119,9 @@ inputs:
119119
> $description.
120120
121121
Next, I will be providing you diffs for each file for you to summarize. In every response,
122-
you will update the high-level summary of the entire pull request, and the table for each file's
123-
diff summary.
122+
you will update the high-level summary of the entire pull request, the table for each file's
123+
diff summary and any feedback you might want to give to the developer, including compliments
124+
or suggestions on how to do better next time.
124125
125126
Reply "OK" to confirm that you are ready to receive the diffs for summarization.
126127
summarize_file_diff:
@@ -131,8 +132,8 @@ inputs:
131132
132133
I would like you to summarize the diff and add the summary for this file in the table.
133134
134-
In response, please provide the updated high-level summary and the summary table of the files
135-
we have summarized so far.
135+
In response, please provide the updated high-level summary, the summary table of the files
136+
we have summarized so far and your overall feedback to the developer.
136137
137138
```diff
138139
$file_diff
@@ -143,10 +144,12 @@ inputs:
143144
default: |
144145
This is the end of summarization session. Please provide the final response as follows in
145146
the `markdown` format with the following content:
147+
- Thank the user for letting you participate in the code review.
146148
- High-level summary (focus on the purpose and intent within 50 words)
149+
- Your feedback to the developer (within 50 words)
147150
- Table of files and their summaries
148151
149-
Do not provide additional commentary as this summary will be added as a comment on the PR.
152+
Do not provide any additional commentary as this summary will be added as a comment on the PR.
150153
summarize_release_notes:
151154
required: false
152155
description: 'The prompt for generating release notes'

dist/index.js

Lines changed: 17 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/review.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const token = core.getInput('token')
1212
const octokit = new Octokit({auth: `token ${token}`})
1313
const context = github.context
1414
const repo = context.repo
15+
const description_tag =
16+
'<!-- This is an auto-generated comment: release notes by chatgpt -->'
17+
const description_tag_end =
18+
'<!-- end of auto-generated comment: release notes by chatgpt -->'
1519

1620
const MAX_TOKENS_FOR_EXTRA_CONTENT = 2500
1721

@@ -39,6 +43,14 @@ export const codeReview = async (
3943
inputs.title = context.payload.pull_request.title
4044
if (context.payload.pull_request.body) {
4145
inputs.description = context.payload.pull_request.body
46+
// remove our summary from description by looking for description_tag and description_tag_end
47+
const start = inputs.description.indexOf(description_tag)
48+
const end = inputs.description.indexOf(description_tag_end)
49+
if (start >= 0 && end >= 0) {
50+
inputs.description =
51+
inputs.description.slice(0, start) +
52+
inputs.description.slice(end + description_tag_end.length)
53+
}
4254
}
4355
// as gpt-3.5-turbo isn't paying attention to system message, add to inputs for now
4456
inputs.system_message = options.system_message
@@ -243,24 +255,20 @@ export const codeReview = async (
243255
next_summarize_ids = release_notes_ids
244256
// add this response to the description field of the PR as release notes by looking
245257
// for the tag (marker)
246-
const tag =
247-
'<!-- This is an auto-generated comment: release notes by chatgpt -->'
248-
const tag_end =
249-
'<!-- end of auto-generated comment: release notes by chatgpt -->'
250258
try {
251259
const description = inputs.description
252260

253261
// find the tag in the description and replace the content between the tag and the tag_end
254262
// if not found, add the tag and the content to the end of the description
255-
const tag_index = description.indexOf(tag)
256-
const tag_end_index = description.indexOf(tag_end)
263+
const tag_index = description.indexOf(description_tag)
264+
const tag_end_index = description.indexOf(description_tag_end)
257265
if (tag_index === -1 || tag_end_index === -1) {
258266
let new_description = description
259-
new_description += tag
267+
new_description += description_tag
260268
new_description += '\n### Summary by ChatGPT\n'
261269
new_description += release_notes_response
262270
new_description += '\n'
263-
new_description += tag_end
271+
new_description += description_tag_end
264272
await octokit.pulls.update({
265273
owner: repo.owner,
266274
repo: repo.repo,
@@ -269,13 +277,13 @@ export const codeReview = async (
269277
})
270278
} else {
271279
let new_description = description.substring(0, tag_index)
272-
new_description += tag
280+
new_description += description_tag
273281
new_description += '\n### Summary by ChatGPT\n'
274282
new_description += release_notes_response
275283
new_description += '\n'
276-
new_description += tag_end
284+
new_description += description_tag_end
277285
new_description += description.substring(
278-
tag_end_index + tag_end.length
286+
tag_end_index + description_tag_end.length
279287
)
280288
await octokit.pulls.update({
281289
owner: repo.owner,

0 commit comments

Comments
 (0)