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

Update triage prompt #218

Merged
merged 7 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/openai-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ permissions:
pull-requests: write

on:
pull_request:
pull_request_target:
types: [opened, synchronize, reopened]
pull_request_review_comment:
types: [created]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ changes (`openai_light_model` in configuration) and `gpt-4` for more complex
review and commenting tasks (`openai_heavy_model` in configuration).
harjotgill marked this conversation as resolved.
Show resolved Hide resolved

Costs: `gpt-3.5-turbo` is dirt cheap. `gpt-4` is orders of magnitude more
expensive, but the results are vastly superior. We are typically spending $50 a
expensive, but the results are vastly superior. We are typically spending $20 a
day for a 20 developer team with `gpt-4` based review and commenting.
harjotgill marked this conversation as resolved.
Show resolved Hide resolved

harjotgill marked this conversation as resolved.
Show resolved Hide resolved
### Prompts & Configuration
Expand Down
40 changes: 20 additions & 20 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Bot {
this.api = new openai.ChatGPTAPI({
systemMessage: options.system_message,
apiKey: process.env.OPENAI_API_KEY,
apiOrg: process.env.OPENAI_API_ORG ?? null,
apiOrg: process.env.OPENAI_API_ORG ?? undefined,
debug: options.debug,
maxModelTokens: openaiOptions.token_limits.max_tokens,
maxResponseTokens: openaiOptions.token_limits.response_tokens,
Expand Down
25 changes: 11 additions & 14 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,19 @@ export class Prompts {
render_summarize_file_diff(inputs: Inputs): string {
const prompt = `${this.summarize_file_diff}

Below the summary, I would also like you to triage the diff
as \`NEEDS_REVIEW\` or \`APPROVED\` based on the following
criteria:
Below the summary, I would also like you to triage the diff as \`NEEDS_REVIEW\` or
\`APPROVED\` based on the following criteria:

- If the diff introduces new functionality, modifies existing logic,
or has potential for bugs, triage it as \`NEEDS_REVIEW\`.
- If the diff only contains minor changes, such as fixing typos,
formatting, renaming variables, triage it as \`APPROVED\`.
- If the diff involves any modifications to the logic or functionality, even if they
seem minor, triage it as \`NEEDS_REVIEW\`. This includes changes to control structures,
function calls, or variable assignments that might impact the behavior of the code.
- If the diff only contains very minor changes that don't affect the code logic, such as
fixing typos, formatting, or renaming variables for clarity, triage it as \`APPROVED\`.

Please evaluate the diff thoroughly and take into account factors
such as the number of lines changed, the potential impact on the
overall system, and the likelihood of introducing new bugs or
security vulnerabilities.

Use the following format to triage the diff and add no additional text:
[TRIAGE]: <NEEDS_REVIEW or APPROVED>
Please evaluate the diff thoroughly and take into account factors such as the number of
lines changed, the potential impact on the overall system, and the likelihood of
introducing new bugs or security vulnerabilities.
When in doubt, always err on the side of caution and triage the diff as \`NEEDS_REVIEW\`.
harjotgill marked this conversation as resolved.
Show resolved Hide resolved
`

return inputs.render(prompt)
Expand Down
14 changes: 8 additions & 6 deletions src/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const codeReview = async (
}
}
} catch (error) {
core.warning(`Failed to get file contents: ${error}, skipping.`)
core.warning(`Failed to get file contents: ${error}`)
}
harjotgill marked this conversation as resolved.
Show resolved Hide resolved

let file_diff = ''
Expand Down Expand Up @@ -324,13 +324,15 @@ ${filename}: ${summary}
}
// ask chatgpt to summarize the summaries
const prompt = `
Provided below are changesets in this pull request.
The format consists of filename(s) and the summary of changes
for those files. There is a separator between each changeset.
Provided below are changesets in this pull request. Changesets
are in chronlogical order and new changesets are appended to the
end of the list. The format consists of filename(s) and the summary
of changes for those files. There is a separator between each changeset.
Your task is to de-deduplicate and group together files with
related/similar changes into a single changeset. Respond with the
updated changesets using the same format as the input.
related/similar changes into a single changeset. Respond with the updated
changesets using the same format as the input.

Changesets:
${inputs.raw_summary}
`
const [summarize_resp] = await heavyBot.chat(prompt, {})
Expand Down
Loading