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

Commit 0b7d342

Browse files
harjotgillaschelch
andauthored
Update triage prompt (#218)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI Release Notes: - Documentation: README file updated to provide more detailed information about the GitHub Action and its usage. - Refactor: Options prompt updated to provide clear guidelines for triaging code changes based on their potential impact. - Refactor: Review prompt updated to clarify instructions for grouping related changes and provide more details about changesets. > "Code review made better, > With clearer prompts and docs to tether. > Bugs and vulnerabilities we'll sever, > Thanks to this PR's clever endeavor." <!-- end of auto-generated comment: release notes by openai --> --------- Co-authored-by: Aurélien Schelcher <[email protected]>
1 parent 2aca8e0 commit 0b7d342

File tree

6 files changed

+43
-43
lines changed

6 files changed

+43
-43
lines changed

.github/workflows/openai-review.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ permissions:
55
pull-requests: write
66

77
on:
8-
pull_request:
8+
pull_request_target:
9+
types: [opened, synchronize, reopened]
910
pull_request_review_comment:
1011
types: [created]
1112

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ changes (`openai_light_model` in configuration) and `gpt-4` for more complex
111111
review and commenting tasks (`openai_heavy_model` in configuration).
112112

113113
Costs: `gpt-3.5-turbo` is dirt cheap. `gpt-4` is orders of magnitude more
114-
expensive, but the results are vastly superior. We are typically spending $50 a
114+
expensive, but the results are vastly superior. We are typically spending $20 a
115115
day for a 20 developer team with `gpt-4` based review and commenting.
116116

117117
### Prompts & Configuration

dist/index.js

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

src/bot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class Bot {
2525
this.api = new openai.ChatGPTAPI({
2626
systemMessage: options.system_message,
2727
apiKey: process.env.OPENAI_API_KEY,
28-
apiOrg: process.env.OPENAI_API_ORG ?? null,
28+
apiOrg: process.env.OPENAI_API_ORG ?? undefined,
2929
debug: options.debug,
3030
maxModelTokens: openaiOptions.token_limits.max_tokens,
3131
maxResponseTokens: openaiOptions.token_limits.response_tokens,

src/options.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,19 @@ export class Prompts {
2929
render_summarize_file_diff(inputs: Inputs): string {
3030
const prompt = `${this.summarize_file_diff}
3131
32-
Below the summary, I would also like you to triage the diff
33-
as \`NEEDS_REVIEW\` or \`APPROVED\` based on the following
34-
criteria:
32+
Below the summary, I would also like you to triage the diff as \`NEEDS_REVIEW\` or
33+
\`APPROVED\` based on the following criteria:
3534
36-
- If the diff introduces new functionality, modifies existing logic,
37-
or has potential for bugs, triage it as \`NEEDS_REVIEW\`.
38-
- If the diff only contains minor changes, such as fixing typos,
39-
formatting, renaming variables, triage it as \`APPROVED\`.
35+
- If the diff involves any modifications to the logic or functionality, even if they
36+
seem minor, triage it as \`NEEDS_REVIEW\`. This includes changes to control structures,
37+
function calls, or variable assignments that might impact the behavior of the code.
38+
- If the diff only contains very minor changes that don't affect the code logic, such as
39+
fixing typos, formatting, or renaming variables for clarity, triage it as \`APPROVED\`.
4040
41-
Please evaluate the diff thoroughly and take into account factors
42-
such as the number of lines changed, the potential impact on the
43-
overall system, and the likelihood of introducing new bugs or
44-
security vulnerabilities.
45-
46-
Use the following format to triage the diff and add no additional text:
47-
[TRIAGE]: <NEEDS_REVIEW or APPROVED>
41+
Please evaluate the diff thoroughly and take into account factors such as the number of
42+
lines changed, the potential impact on the overall system, and the likelihood of
43+
introducing new bugs or security vulnerabilities.
44+
When in doubt, always err on the side of caution and triage the diff as \`NEEDS_REVIEW\`.
4845
`
4946

5047
return inputs.render(prompt)

src/review.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const codeReview = async (
155155
}
156156
}
157157
} catch (error) {
158-
core.warning(`Failed to get file contents: ${error}, skipping.`)
158+
core.warning(`Failed to get file contents: ${error}`)
159159
}
160160

161161
let file_diff = ''
@@ -324,13 +324,15 @@ ${filename}: ${summary}
324324
}
325325
// ask chatgpt to summarize the summaries
326326
const prompt = `
327-
Provided below are changesets in this pull request.
328-
The format consists of filename(s) and the summary of changes
329-
for those files. There is a separator between each changeset.
327+
Provided below are changesets in this pull request. Changesets
328+
are in chronlogical order and new changesets are appended to the
329+
end of the list. The format consists of filename(s) and the summary
330+
of changes for those files. There is a separator between each changeset.
330331
Your task is to de-deduplicate and group together files with
331-
related/similar changes into a single changeset. Respond with the
332-
updated changesets using the same format as the input.
332+
related/similar changes into a single changeset. Respond with the updated
333+
changesets using the same format as the input.
333334
335+
Changesets:
334336
${inputs.raw_summary}
335337
`
336338
const [summarize_resp] = await heavyBot.chat(prompt, {})

0 commit comments

Comments
 (0)