Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6452,7 +6452,10 @@
"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).",
"icon": "$(file-code)",
"parametersSchema": {},
"when": "(config.C_Cpp.experimentalFeatures =~ /^[eE]nabled$/)"
"when": "(config.C_Cpp.experimentalFeatures =~ /^[eE]nabled$/)",
"supportedContentTypes": [
"text/plain"
]
}
]
},
Expand Down
13 changes: 7 additions & 6 deletions Extension/src/LanguageServer/lmTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ const knownValues: { [Property in keyof ChatContextResult]?: { [id: string]: str
}
};

class StringLanguageModelToolResult implements vscode.LanguageModelToolResult {
public constructor(public readonly value: string) { }
public toString(): string { return this.value; }
}
const plainTextContentType = 'text/plain';

export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTool {
public async invoke(_parameters: any, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult> {
return new StringLanguageModelToolResult(await this.getContext(token));
public async invoke(options: vscode.LanguageModelToolInvocationOptions, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult> {
const result: vscode.LanguageModelToolResult = {};
if (options.requestedContentTypes.includes(plainTextContentType)) {
result[plainTextContentType] = await this.getContext(token);
}
return result;
}

private async getContext(token: vscode.CancellationToken): Promise<string> {
Expand Down
Loading