mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
refactor(vscode): drop unused supportsFim / generateResponse from AutocompleteModel
supportsFim() unconditionally returned true and generateResponse() only ever threw — leftovers from when the model interface tried to abstract over FIM-capable vs chat-only providers. Both supported autocomplete models (Codestral, Mercury) expose FIM, so neither abstraction is needed.
This commit is contained in:
@@ -4,18 +4,6 @@ import type { KiloConnectionService } from "../cli-backend"
|
||||
const DEFAULT_MODEL = "mistralai/codestral-2508"
|
||||
const PROVIDER_DISPLAY_NAME = "Kilo Gateway"
|
||||
|
||||
/** Chunk from an LLM streaming response */
|
||||
export type ApiStreamChunk =
|
||||
| { type: "text"; text: string }
|
||||
| {
|
||||
type: "usage"
|
||||
totalCost?: number
|
||||
inputTokens?: number
|
||||
outputTokens?: number
|
||||
cacheReadTokens?: number
|
||||
cacheWriteTokens?: number
|
||||
}
|
||||
|
||||
export class AutocompleteModel {
|
||||
private connectionService: KiloConnectionService | null = null
|
||||
public profileName: string | null = null
|
||||
@@ -34,10 +22,6 @@ export class AutocompleteModel {
|
||||
this.connectionService = service
|
||||
}
|
||||
|
||||
public supportsFim(): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a FIM (Fill-in-the-Middle) completion via the CLI backend.
|
||||
* Uses the SDK's kilo.fim() SSE endpoint which handles auth and streaming.
|
||||
@@ -102,20 +86,6 @@ export class AutocompleteModel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate response via chat completions (holefiller fallback).
|
||||
* Not used when FIM is supported, but kept for compatibility.
|
||||
*/
|
||||
public async generateResponse(
|
||||
systemPrompt: string,
|
||||
userPrompt: string,
|
||||
onChunk: (chunk: ApiStreamChunk) => void,
|
||||
): Promise<ResponseMetaData> {
|
||||
// FIM is the primary strategy; this method is a fallback.
|
||||
// For now, throw — callers should use generateFimResponse via supportsFim().
|
||||
throw new Error("Chat-based completions are not supported via CLI backend. Use FIM (supportsFim() returns true).")
|
||||
}
|
||||
|
||||
public getModelName(): string {
|
||||
return DEFAULT_MODEL
|
||||
}
|
||||
|
||||
@@ -75,13 +75,6 @@ describe("AutocompleteModel", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("supportsFim", () => {
|
||||
it("always returns true", () => {
|
||||
const model = new AutocompleteModel()
|
||||
expect(model.supportsFim()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("getModelName", () => {
|
||||
it("returns the default model", () => {
|
||||
const model = new AutocompleteModel()
|
||||
@@ -165,13 +158,4 @@ describe("AutocompleteModel", () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("generateResponse", () => {
|
||||
it("throws because FIM is the primary strategy", async () => {
|
||||
const model = new AutocompleteModel()
|
||||
await expect(model.generateResponse("system", "user", vi.fn())).rejects.toThrow(
|
||||
"Chat-based completions are not supported via CLI backend",
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
-1
@@ -851,7 +851,6 @@ describe("AutocompleteInlineCompletionProvider", () => {
|
||||
}),
|
||||
getModelName: vi.fn().mockReturnValue("test-model"),
|
||||
getProviderDisplayName: vi.fn().mockReturnValue("test-provider"),
|
||||
supportsFim: vi.fn().mockReturnValue(true),
|
||||
hasValidCredentials: vi.fn().mockReturnValue(true), // Default to true for tests
|
||||
} as unknown as AutocompleteModel
|
||||
mockCostTrackingCallback = vi.fn() as CostTrackingCallback
|
||||
|
||||
Reference in New Issue
Block a user