Repository navigation
feat(catalog): add kimi-k2.7-code to kmca catalog + qwen-web models discovery #4185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // Regression guard for two catalog fixes shipped in v3.8.29: | ||
| // | ||
| // 1. Task 1 — moonshotai/kimi-k2.7-code added to the kimi-coding-apikey (kmca) | ||
| // provider catalog (KIMI_CODING_SHARED.models in open-sse/config/providers/shared.ts). | ||
| // Requested by @hana189 in discussion #3737. | ||
| // | ||
| // 2. Bug #3 (issue #3931) — qwen-web missing from PROVIDER_MODELS_CONFIG in | ||
| // src/app/api/providers/[id]/models/route.ts, so the model discovery page for | ||
| // the web-cookie provider returned nothing. Identified by @thezukiru in #3895. | ||
|
|
||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
| import fs from "node:fs"; | ||
| import path from "node:path"; | ||
|
|
||
| import { getModelsByProviderId } from "../../open-sse/config/providerModels.ts"; | ||
|
|
||
| // ── Task 1: kimi-k2.7-code in kmca (kimi-coding-apikey) ─────────────────────── | ||
|
|
||
| test("kmca (kimi-coding-apikey) catalog includes moonshotai/kimi-k2.7-code", () => { | ||
| const models = getModelsByProviderId("kmca"); | ||
| const ids = new Set(models.map((m) => m.id)); | ||
| assert.ok( | ||
| ids.has("moonshotai/kimi-k2.7-code"), | ||
| "moonshotai/kimi-k2.7-code missing from kmca — add to KIMI_CODING_SHARED.models in shared.ts" | ||
| ); | ||
| }); | ||
|
|
||
| test("kmca kimi-k2.7-code has 262144 context length and maxOutputTokens", () => { | ||
| const models = getModelsByProviderId("kmca"); | ||
| const model = models.find((m) => m.id === "moonshotai/kimi-k2.7-code"); | ||
| assert.ok(model, "moonshotai/kimi-k2.7-code not found in kmca catalog"); | ||
| assert.equal(model.contextLength, 262144, "kimi-k2.7-code contextLength must be 262144"); | ||
| assert.equal(model.maxOutputTokens, 262144, "kimi-k2.7-code maxOutputTokens must be 262144"); | ||
| }); | ||
|
|
||
| test("kmca still exposes kimi-k2.6 and kimi-k2.6-thinking alongside the new model", () => { | ||
| const ids = new Set(getModelsByProviderId("kmca").map((m) => m.id)); | ||
| assert.ok(ids.has("kimi-k2.6"), "kimi-k2.6 must still be present"); | ||
| assert.ok(ids.has("kimi-k2.6-thinking"), "kimi-k2.6-thinking must still be present"); | ||
| assert.ok(ids.has("moonshotai/kimi-k2.7-code"), "moonshotai/kimi-k2.7-code must be present"); | ||
| }); | ||
|
|
||
| // ── Bug #3 / issue #3931: qwen-web in PROVIDER_MODELS_CONFIG ────────────────── | ||
|
|
||
| const ROUTE_FILE = path.join("src", "app", "api", "providers", "[id]", "models", "route.ts"); | ||
|
|
||
| test("PROVIDER_MODELS_CONFIG contains a qwen-web entry (issue #3931 bug #3)", () => { | ||
| const src = fs.readFileSync(ROUTE_FILE, "utf-8"); | ||
| assert.match( | ||
| src, | ||
| /"qwen-web"\s*:/, | ||
| '"qwen-web" key missing from PROVIDER_MODELS_CONFIG in models/route.ts' | ||
| ); | ||
| }); | ||
|
|
||
| test("qwen-web PROVIDER_MODELS_CONFIG entry targets chat.qwen.ai/api/v2/models", () => { | ||
| const src = fs.readFileSync(ROUTE_FILE, "utf-8"); | ||
| assert.match( | ||
| src, | ||
| /chat\.qwen\.ai\/api\/v2\/models/, | ||
| "qwen-web discovery URL must be https://chat.qwen.ai/api/v2/models" | ||
| ); | ||
| }); | ||
|
|
||
| test("qwen-web parseResponse handles Qwen nested data.data structure", () => { | ||
| const mockResponse = { | ||
| data: { | ||
| data: [ | ||
| { id: "qwen3.7-plus", name: "Qwen3.7-Plus", owned_by: "qwen" }, | ||
| { id: "qwen3-235b-a22b", name: "Qwen3-235B-A22B", owned_by: "qwen" }, | ||
| { id: "qwen3-coder-480b", name: "Qwen3-Coder-480B" }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| // parseResponse logic matches PROVIDER_MODELS_CONFIG["qwen-web"].parseResponse | ||
| const innerData: Array<Record<string, unknown>> = | ||
| (mockResponse?.data?.data as Array<Record<string, unknown>>) || | ||
| (mockResponse?.data as unknown as Array<Record<string, unknown>>) || | ||
| []; | ||
| const models = innerData | ||
| .map((item) => ({ | ||
| id: (item.id || item.name) as string, | ||
| name: (item.name || item.id) as string, | ||
| owned_by: (item.owned_by || "qwen") as string, | ||
| })) | ||
| .filter((m) => m.id); | ||
|
|
||
| assert.equal(models.length, 3); | ||
| assert.equal(models[0].id, "qwen3.7-plus"); | ||
| assert.equal(models[0].name, "Qwen3.7-Plus"); | ||
| assert.equal(models[0].owned_by, "qwen"); | ||
| assert.equal(models[2].owned_by, "qwen", "owned_by defaults to 'qwen' when absent"); | ||
| }); | ||
|
|
||
| test("qwen-web parseResponse handles flat data array fallback", () => { | ||
| const mockResponse = { | ||
| data: [{ id: "qwen3.7-plus", name: "Qwen3.7-Plus" }], | ||
| }; | ||
|
|
||
| const innerData: Array<Record<string, unknown>> = | ||
| (mockResponse?.data as unknown as { data?: Array<Record<string, unknown>> })?.data || | ||
| (mockResponse?.data as unknown as Array<Record<string, unknown>>) || | ||
| []; | ||
| const models = innerData | ||
| .map((item) => ({ | ||
| id: (item.id || item.name) as string, | ||
| name: (item.name || item.id) as string, | ||
| owned_by: (item.owned_by || "qwen") as string, | ||
| })) | ||
| .filter((m) => m.id); | ||
|
|
||
| assert.equal(models.length, 1); | ||
| assert.equal(models[0].id, "qwen3.7-plus"); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test copy-pastes the parsing logic from
route.tsinstead of importing and testing the actual production implementation. This creates a testing anti-pattern where the test will continue to pass even if the production implementation inroute.tsis broken or modified.To fix this, consider exporting
PROVIDER_MODELS_CONFIG(or a specific helper) fromsrc/app/api/providers/[id]/models/route.tsand importing it here to run the assertions directly against the production code.