mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
Merge pull request #12378 from Kilo-Org/fix/openrouter-auto-chat-list
fix(gateway): keep image-output models in chat list
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"kilo-code": patch
|
||||
"@kilocode/cli": patch
|
||||
---
|
||||
|
||||
Include image-output models in the Kilo Gateway chat model list.
|
||||
@@ -97,11 +97,6 @@ export async function fetchKiloModels(options?: {
|
||||
const models: Record<string, any> = {}
|
||||
|
||||
for (const model of raw.data) {
|
||||
// Skip image generation models
|
||||
if (model.architecture?.output_modalities?.includes("image")) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Skip models that don't support tools — Kilo requires tool calling
|
||||
if (!model.supported_parameters?.includes("tools")) {
|
||||
continue
|
||||
|
||||
@@ -248,3 +248,85 @@ test("returns error with kind=schema when response body is invalid JSON", async
|
||||
expect(result.models).toEqual({})
|
||||
expect(result.error?.kind).toBe("schema")
|
||||
})
|
||||
|
||||
const MIXED_MODALITY_RESPONSE = JSON.stringify({
|
||||
data: [
|
||||
{
|
||||
id: "openrouter/auto",
|
||||
name: "Auto Router",
|
||||
context_length: 2000000,
|
||||
max_completion_tokens: 16384,
|
||||
architecture: {
|
||||
input_modalities: ["text", "image"],
|
||||
output_modalities: ["text", "image"],
|
||||
},
|
||||
supported_parameters: ["tools", "temperature"],
|
||||
},
|
||||
{
|
||||
id: "openrouter/auto-beta",
|
||||
name: "Auto Router (Beta)",
|
||||
context_length: 2000000,
|
||||
max_completion_tokens: 16384,
|
||||
architecture: {
|
||||
input_modalities: ["text", "image"],
|
||||
output_modalities: ["text", "image"],
|
||||
},
|
||||
supported_parameters: ["tools", "temperature"],
|
||||
},
|
||||
{
|
||||
id: "black-forest-labs/flux-1.1-pro",
|
||||
name: "FLUX 1.1 Pro",
|
||||
context_length: 4096,
|
||||
max_completion_tokens: 4096,
|
||||
architecture: {
|
||||
input_modalities: ["text", "image"],
|
||||
output_modalities: ["image"],
|
||||
},
|
||||
supported_parameters: ["tools"],
|
||||
},
|
||||
{
|
||||
id: "test/no-tools",
|
||||
name: "No Tools Model",
|
||||
context_length: 128000,
|
||||
max_completion_tokens: 16384,
|
||||
architecture: {
|
||||
input_modalities: ["text"],
|
||||
output_modalities: ["text"],
|
||||
},
|
||||
supported_parameters: ["temperature"],
|
||||
},
|
||||
{
|
||||
id: "test/model-a",
|
||||
name: "Test Model A",
|
||||
context_length: 128000,
|
||||
max_completion_tokens: 16384,
|
||||
architecture: {
|
||||
input_modalities: ["text"],
|
||||
output_modalities: ["text"],
|
||||
},
|
||||
supported_parameters: ["tools", "temperature"],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
test("keeps image-output models with tools and drops models without tools", async () => {
|
||||
const orig = globalThis.fetch
|
||||
stubFetch(
|
||||
async () =>
|
||||
new Response(MIXED_MODALITY_RESPONSE, {
|
||||
status: 200,
|
||||
headers: { "content-type": "application/json" },
|
||||
}),
|
||||
)
|
||||
|
||||
const result = await fetchKiloModels({})
|
||||
|
||||
;(globalThis as any).fetch = orig
|
||||
|
||||
expect(result.error).toBeUndefined()
|
||||
expect(result.models["openrouter/auto"]).toBeDefined()
|
||||
expect(result.models["openrouter/auto-beta"]).toBeDefined()
|
||||
expect(result.models["black-forest-labs/flux-1.1-pro"]).toBeDefined()
|
||||
expect(result.models["test/model-a"]).toBeDefined()
|
||||
expect(result.models["test/no-tools"]).toBeUndefined()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user