fix(gateway): preserve FIM gateway model passthrough

This commit is contained in:
Mark IJbema
2026-05-26 10:22:16 +02:00
parent 19719ba491
commit e5b2bb8628
3 changed files with 19 additions and 6 deletions
+5 -1
View File
@@ -24,6 +24,10 @@ const CODESTRAL_FIM_URL = "https://codestral.mistral.ai/v1/fim/completions"
const INCEPTION_FIM_URL = "https://api.inceptionlabs.ai/v1/fim/completions"
export function resolveFimTarget(provider?: string, model?: string): FimTarget {
if (!provider || provider === "kilo") {
return { provider: "kilo", model: model ?? "mistralai/codestral-2501", urls: [KILO_FIM_URL] }
}
const info = getAutocompleteModel(provider, model)
if (info.directProvider === "mistral") {
return { provider: "mistral", model: info.requestModel, urls: [MISTRAL_FIM_URL, CODESTRAL_FIM_URL] }
@@ -31,7 +35,7 @@ export function resolveFimTarget(provider?: string, model?: string): FimTarget {
if (info.directProvider === "inception") {
return { provider: "inception", model: info.requestModel, urls: [INCEPTION_FIM_URL] }
}
return { provider: "kilo", model: info.requestModel, urls: [KILO_FIM_URL] }
return { provider: "kilo", model: model ?? "mistralai/codestral-2501", urls: [KILO_FIM_URL] }
}
async function getProxyAuth(Auth: Auth) {
+9 -4
View File
@@ -28,7 +28,12 @@ describe("FIM target resolution", () => {
})
})
test("maps legacy gateway IDs to explicit Kilo Gateway targets", () => {
test("preserves gateway model pass-through behavior", () => {
expect(resolveFimTarget()).toEqual({
provider: "kilo",
model: "mistralai/codestral-2501",
urls: ["https://api.kilo.ai/api/fim/completions"],
})
expect(resolveFimTarget(undefined, "mistralai/codestral-2508")).toEqual({
provider: "kilo",
model: "mistralai/codestral-2508",
@@ -36,12 +41,12 @@ describe("FIM target resolution", () => {
})
expect(resolveFimTarget(undefined, "inception/mercury-edit")).toEqual({
provider: "kilo",
model: "inception/mercury-edit-2",
model: "inception/mercury-edit",
urls: ["https://api.kilo.ai/api/fim/completions"],
})
expect(resolveFimTarget(undefined, "inception/mercury-edit-2")).toEqual({
expect(resolveFimTarget("kilo", "custom/fim-model")).toEqual({
provider: "kilo",
model: "inception/mercury-edit-2",
model: "custom/fim-model",
urls: ["https://api.kilo.ai/api/fim/completions"],
})
})
@@ -52,6 +52,10 @@ const DIRECT_FIM_ENV: Record<Exclude<FimProvider, "kilo">, string[]> = {
}
function resolveFimTarget(provider?: string, model?: string) {
if (!provider || provider === "kilo") {
return { provider: "kilo" as const, model: model ?? "mistralai/codestral-2501", urls: [KILO_FIM_URL] }
}
const info = getAutocompleteModel(provider, model)
if (info.directProvider === "mistral") {
return { provider: "mistral" as const, model: info.requestModel, urls: [MISTRAL_FIM_URL, CODESTRAL_FIM_URL] }
@@ -59,7 +63,7 @@ function resolveFimTarget(provider?: string, model?: string) {
if (info.directProvider === "inception") {
return { provider: "inception" as const, model: info.requestModel, urls: [INCEPTION_FIM_URL] }
}
return { provider: "kilo" as const, model: info.requestModel, urls: [KILO_FIM_URL] }
return { provider: "kilo" as const, model: model ?? "mistralai/codestral-2501", urls: [KILO_FIM_URL] }
}
export const kiloGatewayHandlers = HttpApiBuilder.group(InstanceHttpApi, "kilo", (handlers) =>