mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
fix(vscode): preserve 'Free' in model names like 'Kilo Auto Free'
Only strip the parenthesized '(free)' suffix; bare trailing 'Free' is part of the name and must be kept. A separate Free label is rendered elsewhere.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"kilo-code": patch
|
||||
---
|
||||
|
||||
Preserve "Free" when it is part of a model's name (such as "Kilo Auto Free"). The parenthesized "(free)" suffix is still stripped so the separate Free label can be shown instead.
|
||||
@@ -66,24 +66,20 @@ describe("sanitizeName", () => {
|
||||
expect(sanitizeName("Llama 3 (free)")).toBe("Llama 3")
|
||||
})
|
||||
|
||||
it("strips trailing free suffix", () => {
|
||||
expect(sanitizeName("Mixtral free")).toBe("Mixtral")
|
||||
})
|
||||
|
||||
it("strips trailing :free suffix", () => {
|
||||
expect(sanitizeName("Mistral:free")).toBe("Mistral")
|
||||
})
|
||||
|
||||
it("strips trailing -free suffix", () => {
|
||||
expect(sanitizeName("Gemma-free")).toBe("Gemma")
|
||||
})
|
||||
|
||||
it("is case-insensitive", () => {
|
||||
it("is case-insensitive for parenthesized suffix", () => {
|
||||
expect(sanitizeName("Model (Free)")).toBe("Model")
|
||||
expect(sanitizeName("Model FREE")).toBe("Model")
|
||||
expect(sanitizeName("Model (FREE)")).toBe("Model")
|
||||
})
|
||||
|
||||
it("leaves names without free suffix unchanged", () => {
|
||||
it("preserves bare trailing Free in names like 'Kilo Auto Free'", () => {
|
||||
expect(sanitizeName("Kilo Auto Free")).toBe("Kilo Auto Free")
|
||||
expect(sanitizeName("Mixtral free")).toBe("Mixtral free")
|
||||
expect(sanitizeName("Mistral:free")).toBe("Mistral:free")
|
||||
expect(sanitizeName("Gemma-free")).toBe("Gemma-free")
|
||||
expect(sanitizeName("Model FREE")).toBe("Model FREE")
|
||||
})
|
||||
|
||||
it("leaves names without (free) suffix unchanged", () => {
|
||||
expect(sanitizeName("GPT-4o")).toBe("GPT-4o")
|
||||
expect(sanitizeName("Claude Sonnet")).toBe("Claude Sonnet")
|
||||
})
|
||||
@@ -92,9 +88,9 @@ describe("sanitizeName", () => {
|
||||
expect(sanitizeName("FreeAgent Pro")).toBe("FreeAgent Pro")
|
||||
})
|
||||
|
||||
it("handles extra whitespace around suffix", () => {
|
||||
it("handles extra whitespace around (free) suffix", () => {
|
||||
expect(sanitizeName("Llama 3 (free) ")).toBe("Llama 3")
|
||||
expect(sanitizeName("Model free ")).toBe("Model")
|
||||
expect(sanitizeName("Model (free) ")).toBe("Model")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -22,13 +22,11 @@ export function isFree(model: Pick<EnrichedModel, "isFree">): boolean {
|
||||
return model.isFree === true
|
||||
}
|
||||
|
||||
// Strips trailing free-indicator suffixes from model display names, e.g.
|
||||
// "Llama 3 (free)" → "Llama 3", "Mixtral free" → "Mixtral"
|
||||
// Strips trailing "(free)" parenthesized suffix from model display names, e.g.
|
||||
// "Llama 3 (free)" → "Llama 3". A separate "Free" label/tag is rendered
|
||||
// elsewhere, so preserve bare trailing "Free" words (e.g. "Kilo Auto Free").
|
||||
export function sanitizeName(name: string): string {
|
||||
return name
|
||||
.replace(/[\s:_-]*\(free\)\s*$/i, "")
|
||||
.replace(/[\s:_-]+free\s*$/i, "")
|
||||
.trim()
|
||||
return name.replace(/[\s:_-]*\(free\)\s*$/i, "").trim()
|
||||
}
|
||||
|
||||
export function stripSubProviderPrefix(name: string): string {
|
||||
|
||||
Reference in New Issue
Block a user