Skip to content

Commit

Permalink
tweak prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Stanga committed Nov 10, 2024
1 parent 57eeabc commit d66423c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default async function runSummaryPrompt(
- Keep in mind that the 'Original title', 'Original description' and 'Commit messages' sections may be partial, simplistic, non-informative or out of date. Hence, compare them to the PR diff code, and use them only as a reference.
- The generated title and description should prioritize the most significant changes.
- When quoting variables or names from the code, use backticks (\`).
- Return a summary for each single affected file or "no summary" if there is nothing to summarize.
- Return a summary for each single affected file or if there is nothing to summarize simply use the status of the change (ie. "New file").
- Start the overview with a verb at past tense like "Started", "Commented", "Generated" etc...
\n`;

let userPrompt = `
Expand Down Expand Up @@ -213,12 +214,12 @@ ${pr.files.map((file) => generateFileCodeDiff(file)).join("\n\n")}
start_line: z
.number()
.describe(
"The relevant line number, from a '__new hunk__' section, where the comment starts (inclusive). Should be derived from the hunk line numbers, and correspond to the beginning of the 'existing code' snippet above. If comment spans a single line, it should equal the 'end_line'"
"The relevant line number, from a '__new hunk__' section, where the comment starts (inclusive). Should correspond to the prefix of the first line in the 'highlighted_code' snippet. If comment spans a single line, it should equal the 'end_line'"
),
end_line: z
.number()
.describe(
"The relevant line number, from a '__new hunk__' section, where the comment ends (inclusive). Should be derived from the hunk line numbers, and correspond to the end of the 'existing code' snippet above. If comment spans a single line, it should equal the 'start_line'"
"The relevant line number, from a '__new hunk__' section, where the comment ends (inclusive). Should correspond to the prefix of the last line in the 'highlighted_code' snippet. If comment spans a single line, it should equal the 'start_line'"
),
content: z
.string()
Expand Down
11 changes: 8 additions & 3 deletions src/pull_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export async function handlePullRequest() {
info(`successfully fetched commit messages`);

// Find or create overview comment with the summary
const { data: comments } = await octokit.rest.issues.listComments({
const { data: existingComments } = await octokit.rest.issues.listComments({
...context.repo,
issue_number: pull_request.number,
});
let overviewComment = comments.find((comment) =>
let overviewComment = existingComments.find((comment) =>
comment.body?.includes(OVERVIEW_MESSAGE_SIGNATURE)
);
if (overviewComment) {
Expand Down Expand Up @@ -104,17 +104,22 @@ export async function handlePullRequest() {
prDescription: pull_request.body || "",
prSummary: summary.description,
});
console.log("Review: ", review.review);
console.log("Comments: ", review.comments);
info(`reviewed pull request`);

// Post review comments
const comments = review.comments.filter(
(c) => c.content.trim() !== "" && files.some((f) => f.filename === c.file)
);
await submitReview(
octokit,
context,
{
number: pull_request.number,
headSha: pull_request.head.sha,
},
review.comments
comments
);
info(`posted review comments`);
}
Expand Down

0 comments on commit d66423c

Please sign in to comment.