mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2024-11-23 04:29:03 +00:00
Merge pull request #5 from freeedcom/improve-the-AI-output
Improve the ai output
This commit is contained in:
commit
9f3b507340
2
.github/workflows/code_review.yml
vendored
2
.github/workflows/code_review.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Code Review
|
- name: Code Review
|
||||||
uses: freeedcom/ai-codereviewer@main
|
uses: freeedcom/ai-codereviewer@improve-the-AI-output
|
||||||
with:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
|
11
dist/index.js
vendored
11
dist/index.js
vendored
@ -105,12 +105,12 @@ function analyzeCode(parsedDiff, prDetails) {
|
|||||||
}
|
}
|
||||||
function createPrompt(file, chunk, prDetails) {
|
function createPrompt(file, chunk, prDetails) {
|
||||||
return `- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
|
return `- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
|
||||||
|
- Do not give positive comments or compliments.
|
||||||
|
- Refrain from suggesting to comment on the code.
|
||||||
- Provide comments and suggestions ONLY if there is something to improve, otherwise return an empty array.
|
- Provide comments and suggestions ONLY if there is something to improve, otherwise return an empty array.
|
||||||
- Write the comment in GitHub markdown.
|
- Write the comment in GitHub markdown.
|
||||||
- Don't give positive comments.
|
|
||||||
- Use the given description only for the overall context and only comment the code.
|
- Use the given description only for the overall context and only comment the code.
|
||||||
- Calculate the line number from \`@@ -WW,XX +YY,ZZ @@\` using following formula: \`YY + L = line_number\`, where \`YY\` is the starting line number from the diff hunk, and \`L\` is the number of lines (including unchanged lines) from the starting line until the line you want to comment on. Pay special attention to this instruction and ensure that you count lines accurately.
|
|
||||||
|
|
||||||
Review the following code diff in the file "${file.to}" and take the pull request title and description into account when writing the response.
|
Review the following code diff in the file "${file.to}" and take the pull request title and description into account when writing the response.
|
||||||
|
|
||||||
Pull request title: ${prDetails.title}
|
Pull request title: ${prDetails.title}
|
||||||
@ -124,7 +124,10 @@ Git diff to review:
|
|||||||
|
|
||||||
\`\`\`diff
|
\`\`\`diff
|
||||||
${chunk.content}
|
${chunk.content}
|
||||||
${chunk.changes.map((c) => c.content).join("\n")}
|
${chunk.changes
|
||||||
|
// @ts-expect-error - ln and ln2 exists where needed
|
||||||
|
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
|
||||||
|
.join("\n")}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
11
src/main.ts
11
src/main.ts
@ -80,12 +80,12 @@ async function analyzeCode(
|
|||||||
|
|
||||||
function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
|
function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
|
||||||
return `- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
|
return `- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
|
||||||
|
- Do not give positive comments or compliments.
|
||||||
|
- Refrain from suggesting to comment on the code.
|
||||||
- Provide comments and suggestions ONLY if there is something to improve, otherwise return an empty array.
|
- Provide comments and suggestions ONLY if there is something to improve, otherwise return an empty array.
|
||||||
- Write the comment in GitHub markdown.
|
- Write the comment in GitHub markdown.
|
||||||
- Don't give positive comments.
|
|
||||||
- Use the given description only for the overall context and only comment the code.
|
- Use the given description only for the overall context and only comment the code.
|
||||||
- Calculate the line number from \`@@ -WW,XX +YY,ZZ @@\` using following formula: \`YY + L = line_number\`, where \`YY\` is the starting line number from the diff hunk, and \`L\` is the number of lines (including unchanged lines) from the starting line until the line you want to comment on. Pay special attention to this instruction and ensure that you count lines accurately.
|
|
||||||
|
|
||||||
Review the following code diff in the file "${
|
Review the following code diff in the file "${
|
||||||
file.to
|
file.to
|
||||||
}" and take the pull request title and description into account when writing the response.
|
}" and take the pull request title and description into account when writing the response.
|
||||||
@ -101,7 +101,10 @@ Git diff to review:
|
|||||||
|
|
||||||
\`\`\`diff
|
\`\`\`diff
|
||||||
${chunk.content}
|
${chunk.content}
|
||||||
${chunk.changes.map((c) => c.content).join("\n")}
|
${chunk.changes
|
||||||
|
// @ts-expect-error - ln and ln2 exists where needed
|
||||||
|
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
|
||||||
|
.join("\n")}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user