mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
refactor(open-sse): registry consolidation + DRY media/oauth/adhoc cleanup
- Single-source registry: oauth clientId/tokenUrl, usage URLs, image/embed configs, search defaultModel, codex fixedPort, google token url derive. - Remove 29 unused OmniRoute providers (registry 100→71); media intact. - De-adhoc: codex literals → registry format/oauth flags; reasoningInject, image/embed openrouter headers + xai bodyFields config-driven. - Add REGISTRY_TEMPLATE.js + expand PROVIDER_DEFAULTS/schema JSDoc. - Baselines updated; PROVIDERS 62 + alias 90 byte-for-byte, golden snapshots. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Guards C2: regex name fallback (no catalog). Terse entries derive name; existing names untouched.
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { deriveModelName } from "../../open-sse/providers/models/namePatterns.js";
|
||||
import { normalizeModel } from "../../open-sse/providers/models/schema.js";
|
||||
|
||||
describe("model name regex fallback (C2)", () => {
|
||||
it("derives display name from id per family", () => {
|
||||
expect(deriveModelName("kimi-k2.5")).toBe("Kimi K2.5");
|
||||
expect(deriveModelName("glm-4.6v")).toBe("GLM 4.6V (Vision)");
|
||||
expect(deriveModelName("minimax-m2.7")).toBe("MiniMax M2.7");
|
||||
expect(deriveModelName("gpt-5.4-mini")).toBe("GPT 5.4 Mini");
|
||||
expect(deriveModelName("grok-4")).toBe("Grok 4");
|
||||
});
|
||||
|
||||
it("falls back to id verbatim when no pattern matches", () => {
|
||||
expect(deriveModelName("some-unknown-model")).toBe("some-unknown-model");
|
||||
});
|
||||
|
||||
it("normalizeModel: explicit name always wins over regex", () => {
|
||||
expect(normalizeModel({ id: "kimi-k2.5", name: "Custom" }).name).toBe("Custom");
|
||||
});
|
||||
|
||||
it("normalizeModel: terse string id becomes object with derived name", () => {
|
||||
const m = normalizeModel("glm-5");
|
||||
expect(m.id).toBe("glm-5");
|
||||
expect(m.name).toBe("GLM 5");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user