Skip to content

Commit 8c88363

Browse files
authored
Linkifying the output links in the summary for summarization tools (#6396)
* adding repo owner * adding also the same for notifications summary
1 parent 4978dce commit 8c88363

5 files changed

Lines changed: 47 additions & 7 deletions

File tree

package.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,6 +3213,14 @@
32133213
"type": "string",
32143214
"description": "The body of the issue/PR"
32153215
},
3216+
"owner": {
3217+
"type": "string",
3218+
"description": "The owner of the repo in which the issue/PR is located"
3219+
},
3220+
"repo": {
3221+
"type": "string",
3222+
"description": "The repo in which the issue/PR is located"
3223+
},
32163224
"comments": {
32173225
"type": "array",
32183226
"items": {
@@ -3241,7 +3249,9 @@
32413249
"required": [
32423250
"title",
32433251
"body",
3244-
"comments"
3252+
"comments",
3253+
"owner",
3254+
"repo"
32453255
]
32463256
},
32473257
"when": "config.githubPullRequests.experimental.chat"
@@ -3280,6 +3290,14 @@
32803290
"type": "string",
32813291
"description": "The body of the notification issue/PR"
32823292
},
3293+
"owner": {
3294+
"type": "string",
3295+
"description": "The owner of the repo in which the issue/PR is located"
3296+
},
3297+
"repo": {
3298+
"type": "string",
3299+
"description": "The repo in which the issue/PR is located"
3300+
},
32833301
"unreadComments": {
32843302
"type": "array",
32853303
"items": {
@@ -3323,7 +3341,9 @@
33233341
"lastUpdatedAt",
33243342
"unread",
33253343
"threadId",
3326-
"notificationKey"
3344+
"notificationKey",
3345+
"owner",
3346+
"repo"
33273347
]
33283348
},
33293349
"when": "config.githubPullRequests.experimental.chat"
@@ -3708,4 +3728,4 @@
37083728
"vsls": "^0.3.967"
37093729
},
37103730
"license": "MIT"
3711-
}
3731+
}

src/lm/tools/fetchIssueTool.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface FetchIssueResult {
2929
author: string;
3030
body: string;
3131
}[];
32+
owner: string;
33+
repo: string;
3234
fileChanges?: FileChange[];
3335
}
3436

@@ -42,6 +44,8 @@ export class FetchIssueTool extends RepoToolBase<FetchIssueToolParameters> {
4244
throw new Error(`No issue or PR found for ${owner}/${name}/${options.parameters.issueNumber}. Make sure the issue or PR exists.`);
4345
}
4446
const result: FetchIssueResult = {
47+
owner,
48+
repo: name,
4549
title: issueOrPullRequest.title,
4650
body: issueOrPullRequest.body,
4751
comments: issueOrPullRequest.item.comments?.map(c => ({ body: c.body, author: c.author.login })) ?? []

src/lm/tools/fetchNotificationTool.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export interface FetchNotificationResult {
2828
unreadComments: {
2929
body: string;
3030
}[];
31+
owner: string;
32+
repo: string;
3133
fileChanges?: FileChange[];
3234
threadId: number,
3335
notificationKey: string
@@ -85,6 +87,8 @@ export class FetchNotificationTool extends RepoToolBase<FetchNotificationToolPar
8587
notificationKey,
8688
title: issueOrPR.title,
8789
body: issueOrPR.body,
90+
owner,
91+
repo: name
8892
};
8993
if (issueOrPR instanceof PullRequestModel) {
9094
const fileChanges = await issueOrPR.getFileChangesInfo();

src/lm/tools/summarizeIssueTool.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Body: ${comment.body}
5656
const model = models[0];
5757

5858
if (model) {
59-
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions())];
59+
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions(options.parameters.repo, options.parameters.owner))];
6060
messages.push(vscode.LanguageModelChatMessage.User(`The issue or pull request information is as follows:`));
6161
messages.push(vscode.LanguageModelChatMessage.User(issueOrPullRequestInfo));
6262
const response = await model.sendRequest(messages, {});
@@ -67,12 +67,18 @@ Body: ${comment.body}
6767
}
6868
}
6969

70-
private summarizeInstructions(): string {
70+
private summarizeInstructions(repo: string, owner: string): string {
7171
return `
7272
You are an AI assistant who is very proficient in summarizing issues and PRs.
7373
You will be given information relative to an issue or PR : the title, the body and the comments. In the case of a PR you will also be given patches of the PR changes.
7474
Your task is to output a summary of all this information.
7575
Do not output code. When you try to summarize PR changes, summarize in a textual format.
76+
Output references to other issues and PRs as Markdown links. The current issue has owner ${owner} and is in the repo ${repo}.
77+
If a comment references for example issue or PR #123, then output either of the following in the summary depending on if it is an issue or a PR:
78+
79+
[#123](https://github.com/${owner}/${repo}/issues/123)
80+
[#123](https://github.com/${owner}/${repo}/pull/123)
81+
7682
When you summarize comments, give a summary of each comment and mention the author clearly.
7783
Make sure the summary is at least as short or shorter than the issue or PR with the comments and the patches if there are.
7884
`;

src/lm/tools/summarizeNotificationsTool.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Body: ${comment.body}
6161
}]
6262
};
6363
if (model) {
64-
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions())];
64+
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions(options.parameters.owner, options.parameters.repo))];
6565
messages.push(vscode.LanguageModelChatMessage.User(`The notification information is as follows:`));
6666
messages.push(vscode.LanguageModelChatMessage.User(notificationInfo));
6767
const response = await model.sendRequest(messages, {});
@@ -77,12 +77,18 @@ Body: ${comment.body}
7777
}
7878
}
7979

80-
private summarizeInstructions(): string {
80+
private summarizeInstructions(owner: string, repo: string): string {
8181
return `
8282
You are an AI assistant who is very proficient in summarizing notification threads.
8383
You will be given information relative to a notification thread : the title, the body and the comments. In the case of a PR you will also be given patches of the PR changes.
8484
Since you are reviewing a notification thread, part of the content is by definition unread. You will be told what part of the content is yet unread. This can be the comments or it can be both the thread issue/PR as well as the comments.
8585
Your task is to output a summary of all this notification thread information and give an update to the user concerning the unread part of the thread.
86+
Output references to issues and PRs as Markdown links. The current notification is for a thread that has owner ${owner} and is in the repo ${repo}.
87+
If a comment references for example issue or PR #123, then output either of the following in the summary depending on if it is an issue or a PR:
88+
89+
[#123](https://github.com/${owner}/${repo}/issues/123)
90+
[#123](https://github.com/${owner}/${repo}/pull/123)
91+
8692
Always include in your output, which part of the thread is unread by prefixing that part with the markdown heading of level 1 with text "Unread Thread" or "Unread Comments".
8793
Make sure the summary is at least as short or shorter than the issue or PR with the comments and the patches if there are.
8894
Example output:

0 commit comments

Comments
 (0)