Skip to content

Commit 0eeb6c8

Browse files
authored
Update for API breakages (#6430)
1 parent 7c3da33 commit 0eeb6c8

9 files changed

+53
-460
lines changed

src/@types/vscode.proposed.lmTools.d.ts

Lines changed: 0 additions & 407 deletions
This file was deleted.

src/lm/participants.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import { IToolCall, TOOL_COMMAND_RESULT, TOOL_MARKDOWN_RESULT } from './tools/to
1313
export class ChatParticipantState {
1414
private _messages: vscode.LanguageModelChatMessage[] = [];
1515

16-
get lastToolResult(): (string | vscode.LanguageModelToolResultPart | vscode.LanguageModelToolCallPart)[] {
16+
get lastToolResult(): (vscode.LanguageModelTextPart | vscode.LanguageModelToolResultPart | vscode.LanguageModelToolCallPart)[] {
1717
for (let i = this._messages.length - 1; i >= 0; i--) {
1818
const message = this._messages[i];
19-
for (const part of message.content2) {
19+
for (const part of message.content) {
2020
if (part instanceof vscode.LanguageModelToolResultPart) {
21-
return message.content2;
21+
return message.content;
2222
}
2323
}
2424
}
@@ -90,7 +90,7 @@ export class ChatParticipant implements vscode.Disposable {
9090
return {
9191
name: tool.name,
9292
description: tool.description,
93-
parametersSchema: tool.parametersSchema ?? {}
93+
inputSchema: tool.inputSchema ?? {}
9494
};
9595
});
9696

@@ -133,14 +133,14 @@ export class ChatParticipant implements vscode.Disposable {
133133
throw new Error('Got invalid tool choice: ' + part.name);
134134
}
135135

136-
let parameters: any;
136+
let input: any;
137137
try {
138-
parameters = part.parameters;
138+
input = part.input;
139139
} catch (err) {
140-
throw new Error(`Got invalid tool use parameters: "${JSON.stringify(part.parameters)}". (${(err as Error).message})`);
140+
throw new Error(`Got invalid tool use parameters: "${JSON.stringify(part.input)}". (${(err as Error).message})`);
141141
}
142142

143-
const invocationOptions = { parameters, toolInvocationToken: request.toolInvocationToken, requestedContentTypes: ['text/plain', 'text/markdown', 'text/json', 'text/display', 'command'] };
143+
const invocationOptions: vscode.LanguageModelToolInvocationOptions<any> = { input, toolInvocationToken: request.toolInvocationToken };
144144
toolCalls.push({
145145
call: part,
146146
result: vscode.lm.invokeTool(tool.name, invocationOptions, token),
@@ -151,14 +151,14 @@ export class ChatParticipant implements vscode.Disposable {
151151

152152
if (toolCalls.length) {
153153
const assistantMsg = vscode.LanguageModelChatMessage.Assistant('');
154-
assistantMsg.content2 = toolCalls.map(toolCall => new vscode.LanguageModelToolCallPart(toolCall.call.callId, toolCall.tool.name, toolCall.call.parameters));
154+
assistantMsg.content = toolCalls.map(toolCall => new vscode.LanguageModelToolCallPart(toolCall.call.callId, toolCall.tool.name, toolCall.call.input));
155155
this.state.addMessage(assistantMsg);
156156

157157
let shownToUser = false;
158158
for (const toolCall of toolCalls) {
159159
let toolCallResult = (await toolCall.result);
160160

161-
const additionalContent: string[] = [];
161+
const additionalContent: vscode.LanguageModelTextPart[] = [];
162162
let result: vscode.LanguageModelToolResultPart | undefined;
163163

164164
for (let i = 0; i < toolCallResult.content.length; i++) {
@@ -180,16 +180,16 @@ export class ChatParticipant implements vscode.Disposable {
180180
if (!result) {
181181
result = new vscode.LanguageModelToolResultPart(toolCall.call.callId, [part]);
182182
} else {
183-
additionalContent.push(part.value);
183+
additionalContent.push(part);
184184
}
185185
}
186186
}
187187
const message = vscode.LanguageModelChatMessage.User('');
188-
message.content2 = [result!];
188+
message.content = [result!];
189189
this.state.addMessage(message);
190190
if (additionalContent.length) {
191191
const additionalMessage = vscode.LanguageModelChatMessage.User('');
192-
additionalMessage.content2 = additionalContent;
192+
additionalMessage.content = additionalContent;
193193
this.state.addMessage(additionalMessage);
194194
}
195195
}

src/lm/tools/displayIssuesTool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class DisplayIssuesTool extends ToolBase<DisplayIssuesParameters> {
118118

119119
async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<DisplayIssuesParameters>): Promise<vscode.PreparedToolInvocation> {
120120
const maxDisplay = 10;
121-
const foundIssuesCount = this.foundIssuesCount(options.parameters);
121+
const foundIssuesCount = this.foundIssuesCount(options.input);
122122
const actualDisplay = Math.min(maxDisplay, foundIssuesCount);
123123
if (actualDisplay === 0) {
124124
return {
@@ -137,11 +137,11 @@ export class DisplayIssuesTool extends ToolBase<DisplayIssuesParameters> {
137137

138138
async invoke(options: vscode.LanguageModelToolInvocationOptions<DisplayIssuesParameters>, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult | undefined> {
139139
const issueItemsInfo: vscode.LanguageModelTextPart | undefined = this.chatParticipantState.firstUserMessage;
140-
const issueItems: IssueSearchResultItem[] = options.parameters.arrayOfIssues;
140+
const issueItems: IssueSearchResultItem[] = options.input.arrayOfIssues;
141141
if (issueItems.length === 0) {
142142
return new vscode.LanguageModelToolResult([new vscode.LanguageModelTextPart(vscode.l10n.t('No issues found. Please try another query.'))]);
143143
}
144-
Logger.debug(`Displaying ${this.foundIssuesCount(options.parameters)} issues, first issue ${issueItems[0].number}`, DisplayIssuesTool.ID);
144+
Logger.debug(`Displaying ${this.foundIssuesCount(options.input)} issues, first issue ${issueItems[0].number}`, DisplayIssuesTool.ID);
145145
const importantColumns = await this.getImportantColumns(issueItemsInfo, issueItems, token);
146146

147147
const titleRow = `| ${importantColumns.join(' | ')} |`;

src/lm/tools/fetchIssueTool.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ export class FetchIssueTool extends RepoToolBase<FetchIssueToolParameters> {
3838
public static readonly toolId = 'github-pull-request_issue_fetch';
3939

4040
async invoke(options: vscode.LanguageModelToolInvocationOptions<FetchIssueToolParameters>, _token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult> {
41-
const { owner, name, folderManager } = await this.getRepoInfo({ owner: options.parameters.repo?.owner, name: options.parameters.repo?.name });
42-
const issueOrPullRequest = await folderManager.resolveIssueOrPullRequest(owner, name, options.parameters.issueNumber);
41+
const { owner, name, folderManager } = await this.getRepoInfo({ owner: options.input.repo?.owner, name: options.input.repo?.name });
42+
const issueOrPullRequest = await folderManager.resolveIssueOrPullRequest(owner, name, options.input.issueNumber);
4343
if (!issueOrPullRequest) {
44-
throw new Error(`No issue or PR found for ${owner}/${name}/${options.parameters.issueNumber}. Make sure the issue or PR exists.`);
44+
throw new Error(`No issue or PR found for ${owner}/${name}/${options.input.issueNumber}. Make sure the issue or PR exists.`);
4545
}
4646
const result: FetchIssueResult = {
4747
owner,
@@ -69,15 +69,15 @@ export class FetchIssueTool extends RepoToolBase<FetchIssueToolParameters> {
6969
}
7070

7171
async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<FetchIssueToolParameters>): Promise<vscode.PreparedToolInvocation> {
72-
if (!options.parameters.issueNumber) {
72+
if (!options.input.issueNumber) {
7373
return {
7474
invocationMessage: vscode.l10n.t('Fetching item from GitHub')
7575
};
7676
}
77-
const { owner, name } = await this.getRepoInfo({ owner: options.parameters.repo?.owner, name: options.parameters.repo?.name });
78-
const url = (owner && name) ? `https://github.com/${owner}/${name}/issues/${options.parameters.issueNumber}` : undefined;
77+
const { owner, name } = await this.getRepoInfo({ owner: options.input.repo?.owner, name: options.input.repo?.name });
78+
const url = (owner && name) ? `https://github.com/${owner}/${name}/issues/${options.input.issueNumber}` : undefined;
7979
return {
80-
invocationMessage: url ? vscode.l10n.t('Fetching item [#{0}]({1}) from GitHub', options.parameters.issueNumber, url) : vscode.l10n.t('Fetching item #{0} from GitHub', options.parameters.issueNumber),
80+
invocationMessage: url ? vscode.l10n.t('Fetching item [#{0}]({1}) from GitHub', options.input.issueNumber, url) : vscode.l10n.t('Fetching item #{0} from GitHub', options.input.issueNumber),
8181
};
8282

8383
}

src/lm/tools/fetchNotificationTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class FetchNotificationTool extends RepoToolBase<FetchNotificationToolPar
5252
if (!github) {
5353
return undefined;
5454
}
55-
const threadId = options.parameters.thread_id;
55+
const threadId = options.input.thread_id;
5656
const thread = await github.octokit.api.activity.getThread({
5757
thread_id: threadId
5858
});

src/lm/tools/searchTools.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ You are getting ready to make a GitHub search query. Given a natural language qu
363363
}
364364

365365
async invoke(options: vscode.LanguageModelToolInvocationOptions<ConvertToQuerySyntaxParameters>, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult | undefined> {
366-
const { owner, name, folderManager } = await this.getRepoInfo({ owner: options.parameters.repo?.owner, name: options.parameters.repo?.name });
367-
const firstUserMessage = `${this.chatParticipantState.firstUserMessage?.value}, ${options.parameters.naturalLanguageString}`;
366+
const { owner, name, folderManager } = await this.getRepoInfo({ owner: options.input.repo?.owner, name: options.input.repo?.name });
367+
const firstUserMessage = `${this.chatParticipantState.firstUserMessage?.value}, ${options.input.naturalLanguageString}`;
368368

369369
const allLabels = await folderManager.getLabels(undefined, { owner, repo: name });
370370

@@ -438,17 +438,17 @@ export class SearchTool extends RepoToolBase<SearchToolParameters> {
438438
}
439439

440440
async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<SearchToolParameters>): Promise<vscode.PreparedToolInvocation> {
441-
const parameterQuery = options.parameters.query;
441+
const parameterQuery = options.input.query;
442442

443443
return {
444444
invocationMessage: vscode.l10n.t('Searching for issues with "{0}". [Open on GitHub.com]({1})', escapeMarkdown(parameterQuery), escapeMarkdown(this.toGitHubUrl(parameterQuery)))
445445
};
446446
}
447447

448448
async invoke(options: vscode.LanguageModelToolInvocationOptions<SearchToolParameters>, _token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult | undefined> {
449-
const { folderManager } = await this.getRepoInfo({ owner: options.parameters.repo?.owner, name: options.parameters.repo?.name });
449+
const { folderManager } = await this.getRepoInfo({ owner: options.input.repo?.owner, name: options.input.repo?.name });
450450

451-
const parameterQuery = options.parameters.query;
451+
const parameterQuery = options.input.query;
452452
Logger.debug(`Searching with query \`${parameterQuery}\``, SearchTool.ID);
453453

454454
const searchResult = await folderManager.getIssues(parameterQuery);

src/lm/tools/suggestFixTool.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ export class SuggestFixTool extends RepoToolBase<IssueToolParameters> {
1919

2020
async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<IssueToolParameters>): Promise<vscode.PreparedToolInvocation> {
2121
return {
22-
invocationMessage: options.parameters.issueNumber ? vscode.l10n.t('Suggesting a fix for issue #{0}', options.parameters.issueNumber) : vscode.l10n.t('Suggesting a fix for the issue')
22+
invocationMessage: options.input.issueNumber ? vscode.l10n.t('Suggesting a fix for issue #{0}', options.input.issueNumber) : vscode.l10n.t('Suggesting a fix for the issue')
2323
};
2424
}
2525

2626
async invoke(options: vscode.LanguageModelToolInvocationOptions<IssueToolParameters>, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult | undefined> {
27-
const { folderManager } = await this.getRepoInfo(options.parameters.repo);
27+
const { folderManager } = await this.getRepoInfo(options.input.repo);
2828
if (!folderManager) {
29-
throw new Error(`No folder manager found for ${options.parameters.repo.owner}/${options.parameters.repo.name}. Make sure to have the repository open.`);
29+
throw new Error(`No folder manager found for ${options.input.repo.owner}/${options.input.repo.name}. Make sure to have the repository open.`);
3030
}
31-
const issue = await folderManager.resolveIssue(options.parameters.repo.owner, options.parameters.repo.name, options.parameters.issueNumber, true);
31+
const issue = await folderManager.resolveIssue(options.input.repo.owner, options.input.repo.name, options.input.issueNumber, true);
3232
if (!issue) {
33-
throw new Error(`No issue found for ${options.parameters.repo.owner}/${options.parameters.repo.name}/${options.parameters.issueNumber}. Make sure the issue exists.`);
33+
throw new Error(`No issue found for ${options.input.repo.owner}/${options.input.repo.name}/${options.input.issueNumber}. Make sure the issue exists.`);
3434
}
3535

3636
const result: IssueResult = {
@@ -53,7 +53,7 @@ export class SuggestFixTool extends RepoToolBase<IssueToolParameters> {
5353

5454
const copilotCodebaseResult = await vscode.lm.invokeTool('copilot_codebase', {
5555
toolInvocationToken: undefined,
56-
parameters: {
56+
input: {
5757
query: result.title
5858
}
5959
}, token);
@@ -62,7 +62,7 @@ export class SuggestFixTool extends RepoToolBase<IssueToolParameters> {
6262
if (plainTextResult instanceof vscode.LanguageModelTextPart) {
6363
messages.push(vscode.LanguageModelChatMessage.User(`Below is some potential relevant workspace context to the issue. The user cannot see this result, so you should explain it to the user if referencing it in your answer.`));
6464
const toolMessage = vscode.LanguageModelChatMessage.User('');
65-
toolMessage.content2 = [plainTextResult.value];
65+
toolMessage.content = [plainTextResult];
6666
messages.push(toolMessage);
6767
}
6868

src/lm/tools/summarizeIssueTool.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ export class IssueSummarizationTool implements vscode.LanguageModelTool<FetchIss
1212
public static readonly toolId = 'github-pull-request_issue_summarize';
1313

1414
async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<FetchIssueResult>): Promise<vscode.PreparedToolInvocation> {
15-
if (!options.parameters.title) {
15+
if (!options.input.title) {
1616
return {
1717
invocationMessage: vscode.l10n.t('Summarizing issue')
1818
};
1919
}
20-
const shortenedTitle = options.parameters.title.length > 40;
21-
const maxLengthTitle = shortenedTitle ? options.parameters.title.substring(0, 40) : options.parameters.title;
20+
const shortenedTitle = options.input.title.length > 40;
21+
const maxLengthTitle = shortenedTitle ? options.input.title.substring(0, 40) : options.input.title;
2222
return {
2323
invocationMessage: vscode.l10n.t('Summarizing "{0}', maxLengthTitle)
2424
};
2525
}
2626

2727
async invoke(options: vscode.LanguageModelToolInvocationOptions<FetchIssueResult>, _token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult | undefined> {
2828
let issueOrPullRequestInfo: string = `
29-
Title : ${options.parameters.title}
30-
Body : ${options.parameters.body}
29+
Title : ${options.input.title}
30+
Body : ${options.input.body}
3131
`;
32-
const fileChanges = options.parameters.fileChanges;
32+
const fileChanges = options.input.fileChanges;
3333
if (fileChanges) {
3434
issueOrPullRequestInfo += `
3535
The following are the files changed:
@@ -41,7 +41,7 @@ Patch: ${fileChange.patch}
4141
`;
4242
}
4343
}
44-
const comments = options.parameters.comments;
44+
const comments = options.input.comments;
4545
for (const [index, comment] of comments.entries()) {
4646
issueOrPullRequestInfo += `
4747
Comment ${index} :
@@ -56,7 +56,7 @@ Body: ${comment.body}
5656
const model = models[0];
5757

5858
if (model) {
59-
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions(options.parameters.repo, options.parameters.owner))];
59+
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions(options.input.repo, options.input.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, {});

src/lm/tools/summarizeNotificationsTool.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class NotificationSummarizationTool implements vscode.LanguageModelTool<F
1212
public static readonly toolId = 'github-pull-request_notification_summarize';
1313

1414
async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<FetchNotificationResult>): Promise<vscode.PreparedToolInvocation> {
15-
const parameters = options.parameters;
15+
const parameters = options.input;
1616
if (!parameters.itemType || !parameters.itemNumber) {
1717
return {
1818
invocationMessage: vscode.l10n.t('Summarizing notification')
@@ -27,16 +27,16 @@ export class NotificationSummarizationTool implements vscode.LanguageModelTool<F
2727

2828
async invoke(options: vscode.LanguageModelToolInvocationOptions<FetchNotificationResult>, _token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult | undefined> {
2929
let notificationInfo: string = '';
30-
const lastReadAt = options.parameters.lastReadAt;
30+
const lastReadAt = options.input.lastReadAt;
3131
if (!lastReadAt) {
3232
// First time the thread is viewed, so no lastReadAt field
3333
notificationInfo += `This thread is viewed for the first time. Here is the main item information of the thread:`;
3434
}
3535
notificationInfo += `
36-
Title : ${options.parameters.title}
37-
Body : ${options.parameters.body}
36+
Title : ${options.input.title}
37+
Body : ${options.input.body}
3838
`;
39-
const fileChanges = options.parameters.fileChanges;
39+
const fileChanges = options.input.fileChanges;
4040
if (fileChanges) {
4141
notificationInfo += `
4242
The following are the files changed:
@@ -49,7 +49,7 @@ Patch: ${fileChange.patch}
4949
}
5050
}
5151

52-
const unreadComments = options.parameters.comments;
52+
const unreadComments = options.input.comments;
5353
if (unreadComments && unreadComments.length > 0) {
5454
notificationInfo += `
5555
The following are the unread comments of the thread:
@@ -68,8 +68,8 @@ Body: ${comment.body}
6868
});
6969
const model = models[0];
7070
const content: vscode.LanguageModelTextPart[] = [];
71-
const threadId = options.parameters.threadId;
72-
const notificationKey = options.parameters.notificationKey;
71+
const threadId = options.input.threadId;
72+
const notificationKey = options.input.notificationKey;
7373
if (threadId && notificationKey) {
7474
const markAsReadCommand = {
7575
title: 'Mark As Read',
@@ -80,7 +80,7 @@ Body: ${comment.body}
8080
content.push(new vscode.LanguageModelTextPart(JSON.stringify(markAsReadCommand)));
8181
}
8282
if (model) {
83-
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions(options.parameters.owner, options.parameters.repo))];
83+
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions(options.input.owner, options.input.repo))];
8484
messages.push(vscode.LanguageModelChatMessage.User(`The notification information is as follows:`));
8585
messages.push(vscode.LanguageModelChatMessage.User(notificationInfo));
8686
const response = await model.sendRequest(messages, {});

0 commit comments

Comments
 (0)