Skip to content

Commit a082e96

Browse files
committed
Update lmTools API
1 parent 1f83dd7 commit a082e96

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Extension/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6452,7 +6452,10 @@
64526452
"modelDescription": "For the active C or C++ file, this tool provides: the language (C, C++, or CUDA), the language standard version (such as C++11, C++14, C++17, or C++20), the compiler (such as GCC, Clang, or MSVC), the target platform (such as x86, x64, or ARM), and the target architecture (such as 32-bit or 64-bit).",
64536453
"icon": "$(file-code)",
64546454
"parametersSchema": {},
6455-
"when": "(config.C_Cpp.experimentalFeatures =~ /^[eE]nabled$/)"
6455+
"when": "(config.C_Cpp.experimentalFeatures =~ /^[eE]nabled$/)",
6456+
"supportedContentTypes": [
6457+
"text/plain"
6458+
]
64566459
}
64576460
]
64586461
},

Extension/src/LanguageServer/lmTool.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ const knownValues: { [Property in keyof ChatContextResult]?: { [id: string]: str
4444
}
4545
};
4646

47-
class StringLanguageModelToolResult implements vscode.LanguageModelToolResult {
48-
public constructor(public readonly value: string) { }
49-
public toString(): string { return this.value; }
50-
}
47+
const plainTextContentType = 'text/plain';
5148

5249
export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTool {
53-
public async invoke(_parameters: any, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult> {
54-
return new StringLanguageModelToolResult(await this.getContext(token));
50+
public async invoke(options: vscode.LanguageModelToolInvocationOptions, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult> {
51+
const result: vscode.LanguageModelToolResult = {};
52+
if (options.requestedContentTypes.includes(plainTextContentType)) {
53+
result[plainTextContentType] = await this.getContext(token);
54+
}
55+
return result;
5556
}
5657

5758
private async getContext(token: vscode.CancellationToken): Promise<string> {

0 commit comments

Comments
 (0)