Skip to content

Commit 9f3b507

Browse files
authored
Merge pull request #5 from freeedcom/improve-the-AI-output
Improve the ai output
2 parents d20738e + 08e3201 commit 9f3b507

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

.github/workflows/code_review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Checkout repository
1313
uses: actions/checkout@v3
1414
- name: Code Review
15-
uses: freeedcom/ai-codereviewer@main
15+
uses: freeedcom/ai-codereviewer@improve-the-AI-output
1616
with:
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

dist/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ function analyzeCode(parsedDiff, prDetails) {
105105
}
106106
function createPrompt(file, chunk, prDetails) {
107107
return `- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
108+
- Do not give positive comments or compliments.
109+
- Refrain from suggesting to comment on the code.
108110
- Provide comments and suggestions ONLY if there is something to improve, otherwise return an empty array.
109111
- Write the comment in GitHub markdown.
110-
- Don't give positive comments.
111112
- Use the given description only for the overall context and only comment the code.
112-
- 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.
113-
113+
114114
Review the following code diff in the file "${file.to}" and take the pull request title and description into account when writing the response.
115115

116116
Pull request title: ${prDetails.title}
@@ -124,7 +124,10 @@ Git diff to review:
124124

125125
\`\`\`diff
126126
${chunk.content}
127-
${chunk.changes.map((c) => c.content).join("\n")}
127+
${chunk.changes
128+
// @ts-expect-error - ln and ln2 exists where needed
129+
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
130+
.join("\n")}
128131
\`\`\`
129132
`;
130133
}

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ async function analyzeCode(
8080

8181
function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
8282
return `- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
83+
- Do not give positive comments or compliments.
84+
- Refrain from suggesting to comment on the code.
8385
- Provide comments and suggestions ONLY if there is something to improve, otherwise return an empty array.
8486
- Write the comment in GitHub markdown.
85-
- Don't give positive comments.
8687
- Use the given description only for the overall context and only comment the code.
87-
- 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.
88-
88+
8989
Review the following code diff in the file "${
9090
file.to
9191
}" and take the pull request title and description into account when writing the response.
@@ -101,7 +101,10 @@ Git diff to review:
101101
102102
\`\`\`diff
103103
${chunk.content}
104-
${chunk.changes.map((c) => c.content).join("\n")}
104+
${chunk.changes
105+
// @ts-expect-error - ln and ln2 exists where needed
106+
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
107+
.join("\n")}
105108
\`\`\`
106109
`;
107110
}

0 commit comments

Comments
 (0)