Skip to content

Commit

Permalink
Update lmTools API (#12755)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmcmorran authored Sep 23, 2024
1 parent 1f83dd7 commit b92dbb4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
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

0 comments on commit b92dbb4

Please sign in to comment.