mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
refactor(vscode): drop unreachable postprocessing branches
postprocessCompletion contained model-specific branches for qwen3, granite, gemini and gemma — models that are never selected. Keep the Codestral and Mercury branches (both are user-selectable via kilo-code.new.autocomplete.model) and also collapse Mercury's two adjacent branches into one block.
This commit is contained in:
+2
-12
@@ -42,25 +42,15 @@ describe("postprocessAutocompleteSuggestion", () => {
|
||||
expect(result).toBe("test")
|
||||
})
|
||||
|
||||
it("handles Mercury/Granite prefix duplication", () => {
|
||||
it("handles Mercury prefix duplication", () => {
|
||||
const result = postprocessAutocompleteSuggestion({
|
||||
suggestion: "const x = 42",
|
||||
prefix: "const x = ",
|
||||
suffix: "",
|
||||
model: "granite-20b",
|
||||
model: "inception/mercury-edit",
|
||||
})
|
||||
expect(result).toBe("42")
|
||||
})
|
||||
|
||||
it("handles Gemini/Gemma file separator", () => {
|
||||
const result = postprocessAutocompleteSuggestion({
|
||||
suggestion: "const x = 1<|file_separator|>",
|
||||
prefix: "",
|
||||
suffix: "",
|
||||
model: "gemini-pro",
|
||||
})
|
||||
expect(result).toBe("const x = 1")
|
||||
})
|
||||
})
|
||||
|
||||
describe("extreme repetition filtering", () => {
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ function normalizeToCompleteLine(params: AutocompleteSuggestion): AutocompleteSu
|
||||
* @param params.suggestion - The suggested text to insert
|
||||
* @param params.prefix - The text before the cursor position
|
||||
* @param params.suffix - The text after the cursor position
|
||||
* @param params.model - The model string (e.g., "codestral", "qwen3", etc.)
|
||||
* @param params.model - The model string (e.g., "codestral", "mercury", etc.)
|
||||
* @param params.languageId - Optional language ID for language-specific filtering
|
||||
* @returns The processed suggestion text, or undefined if it should be filtered out
|
||||
*/
|
||||
|
||||
+10
-26
@@ -133,34 +133,18 @@ export function postprocessCompletion({
|
||||
}
|
||||
}
|
||||
|
||||
if (llm.model.includes("qwen3")) {
|
||||
// Qwen3 always starts from special thinking markers, and we don't want them to output these contents
|
||||
// Remove all content from "
|
||||
completion = completion.replace(/<think>.*?<\/think>/s, "")
|
||||
completion = completion.replace(/<\/think>/, "")
|
||||
|
||||
// Remove any number of newline characters at the beginning and end
|
||||
completion = completion.replace(/^\n+|\n+$/g, "")
|
||||
}
|
||||
|
||||
if (llm.model.includes("mercury") || llm.model.includes("granite")) {
|
||||
if (llm.model.includes("mercury")) {
|
||||
completion = removePrefixOverlap(completion, prefix)
|
||||
}
|
||||
|
||||
// // If completion starts with multiple whitespaces, but the cursor is at the end of the line
|
||||
// // then it should probably be on a new line
|
||||
if (
|
||||
llm.model.includes("mercury") &&
|
||||
(completion.startsWith(" ") || completion.startsWith("\t")) &&
|
||||
!prefix.endsWith("\n") &&
|
||||
(suffix.startsWith("\n") || suffix.trim().length === 0)
|
||||
) {
|
||||
completion = "\n" + completion
|
||||
}
|
||||
|
||||
if ((llm.model.includes("gemini") || llm.model.includes("gemma")) && completion.endsWith("<|file_separator|>")) {
|
||||
// "<|file_separator|>" is 18 characters long
|
||||
completion = completion.slice(0, -18)
|
||||
// If completion starts with multiple whitespaces, but the cursor is at the
|
||||
// end of the line then it should probably be on a new line
|
||||
if (
|
||||
(completion.startsWith(" ") || completion.startsWith("\t")) &&
|
||||
!prefix.endsWith("\n") &&
|
||||
(suffix.startsWith("\n") || suffix.trim().length === 0)
|
||||
) {
|
||||
completion = "\n" + completion
|
||||
}
|
||||
}
|
||||
|
||||
// If prefix ends with space and so does completion, then remove the space from completion
|
||||
|
||||
Reference in New Issue
Block a user