Skip to content

Commit dc81401

Browse files
lukkabenmcmorran
andauthored
Ensure only wel known values are passed in to the LLM #2293227 (#12907)
Co-authored-by: Ben McMorran <[email protected]>
1 parent 1462b0d commit dc81401

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Diff for: Extension/src/LanguageServer/lmTool.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,29 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
7575
for (const key in knownValues) {
7676
const knownKey = key as keyof ChatContextResult;
7777
if (knownValues[knownKey] && chatContext[knownKey]) {
78-
chatContext[knownKey] = knownValues[knownKey][chatContext[knownKey]] || chatContext[knownKey];
78+
// Clear the value if it's not in the known values.
79+
chatContext[knownKey] = knownValues[knownKey][chatContext[knownKey]] || "";
7980
}
8081
}
8182

82-
return `The user is working on a ${chatContext.language} project. The project uses language version ${chatContext.standardVersion}, compiles using the ${chatContext.compiler} compiler, targets the ${chatContext.targetPlatform} platform, and targets the ${chatContext.targetArchitecture} architecture.`;
83+
let contextString = "";
84+
if (chatContext.language) {
85+
contextString += `The user is working on a ${chatContext.language} project. `;
86+
}
87+
if (chatContext.standardVersion) {
88+
contextString += `The project uses language version ${chatContext.standardVersion}. `;
89+
}
90+
if (chatContext.compiler) {
91+
contextString += `The project compiles using the ${chatContext.compiler} compiler. `;
92+
}
93+
if (chatContext.targetPlatform) {
94+
contextString += `The project targets the ${chatContext.targetPlatform} platform. `;
95+
}
96+
if (chatContext.targetArchitecture) {
97+
contextString += `The project targets the ${chatContext.targetArchitecture} architecture. `;
98+
}
99+
100+
return contextString;
83101
}
84102
catch {
85103
await this.reportError();

0 commit comments

Comments
 (0)