Skip to content

Commit

Permalink
fix: delete unused console & improve prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
fiqryq committed May 19, 2024
1 parent 830da99 commit 1046af1
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ const reviewCodeWithOpenAI = async (code) => {
},
{
role: 'user',
content: `Please review the following code and provide feedback. Additionally, kindly offer your best suggestions for improvement and provide sample code if possible:\n\n${code}`,
content: `Please review the following code and provide feedback. Additionally, kindly offer your best suggestions for improvement and provide sample code if possible.
Example response with code suggestion:
Feedback:
// Feedback
Suggestions for improvement:
// Suggestions
Code suggestion:
\`\`\`ts
// code
\`\`\`
${code}`,
},
],
max_tokens: 150,
Expand All @@ -37,6 +49,7 @@ const reviewCodeWithOpenAI = async (code) => {
);
return response.data.choices[0].message.content.trim();
};

const run = async () => {
try {
const context = github.context;
Expand All @@ -58,10 +71,6 @@ const run = async () => {
const pullRequestUrl = payload.issue.pull_request.url;
const pullRequestNumber = pullRequestUrl.split('/').pop();

console.log(
`Fetching files for PR ${pullRequestNumber} in repo ${owner}/${repo}`
);

try {
const { data: files } = await octokit.pulls.listFiles({
owner,
Expand All @@ -74,7 +83,7 @@ const run = async () => {
for (const file of files) {
if (file.patch) {
const review = await reviewCodeWithOpenAI(file.patch);
reviewComments += `### Review for ${file.filename}:\n\n${review}\n\n`;
reviewComments += `#### Review for ${file.filename}:\n\n${review}\n\n`;
}
}

Expand Down

0 comments on commit 1046af1

Please sign in to comment.