model param and make file

This commit is contained in:
sadath-12 2023-07-16 09:53:10 +05:30
parent 67d43e592a
commit 3f4c1312a5
3 changed files with 22 additions and 13 deletions

13
dist/index.js vendored
View file

@ -16686,13 +16686,13 @@ function getBaseAndHeadShas(owner, repo, pull_number) {
} }
function createPrompt(file, chunk, prDetails) { function createPrompt(file, chunk, prDetails) {
return `Your task is to review pull requests. Instructions: return `Your task is to review pull requests. Instructions:
- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}] - Provide the response in the following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
- Do not give positive comments or compliments. - Do not give positive comments or compliments.
- 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 format. - Write the comment in GitHub Markdown format.
- 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 on the code.
- IMPORTANT: NEVER suggest adding comments to the code. - IMPORTANT: NEVER suggest adding comments to the code.
- If you don't have anything to say just say I don't have anything to say - If you don't have anything to say, just say "I don't have anything to say."
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}
@ -16707,7 +16707,7 @@ Git diff to review:
\`\`\`diff \`\`\`diff
${chunk.content} ${chunk.content}
${chunk.changes ${chunk.changes
// @ts-expect-error - ln and ln2 exists where needed // @ts-expect-error - ln and ln2 exist where needed
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`) .map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
.join('\n')} .join('\n')}
\`\`\` \`\`\`
@ -16812,7 +16812,8 @@ function main() {
console.log(`Review comment created with ${comments.length} comment(s).`); console.log(`Review comment created with ${comments.length} comment(s).`);
} }
else { else {
console.log('No comments to create.'); yield createReviewComment(prDetails.owner, prDetails.repo, prDetails.pull_number, [{ body: 'No comments to create', path: '', line: 0 }]);
console.log("No comments to create. Added a comment saying 'No comments to create'.");
} }
} }
catch (error) { catch (error) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -98,13 +98,13 @@ async function getBaseAndHeadShas(
function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string { function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
return `Your task is to review pull requests. Instructions: return `Your task is to review pull requests. Instructions:
- Provide the response in following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}] - Provide the response in the following JSON format: [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]
- Do not give positive comments or compliments. - Do not give positive comments or compliments.
- 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 format. - Write the comment in GitHub Markdown format.
- 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 on the code.
- IMPORTANT: NEVER suggest adding comments to the code. - IMPORTANT: NEVER suggest adding comments to the code.
- If you don't have anything to say just say I don't have anything to say - If you don't have anything to say, just say "I don't have anything to say."
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.
@ -121,7 +121,7 @@ Git diff to review:
\`\`\`diff \`\`\`diff
${chunk.content} ${chunk.content}
${chunk.changes ${chunk.changes
// @ts-expect-error - ln and ln2 exists where needed // @ts-expect-error - ln and ln2 exist where needed
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`) .map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
.join('\n')} .join('\n')}
\`\`\` \`\`\`
@ -257,7 +257,15 @@ async function main() {
) )
console.log(`Review comment created with ${comments.length} comment(s).`) console.log(`Review comment created with ${comments.length} comment(s).`)
} else { } else {
console.log('No comments to create.') await createReviewComment(
prDetails.owner,
prDetails.repo,
prDetails.pull_number,
[{ body: 'No comments to create', path: '', line: 0 }]
)
console.log(
"No comments to create. Added a comment saying 'No comments to create'."
)
} }
} catch (error) { } catch (error) {
console.error('Error:', error) console.error('Error:', error)