Files
OmniRoute/tests/unit/playground-model-qualify.test.ts
Diego Rodrigues de Sa e Souza 5f7f74dc6a fix(dashboard): qualify vendor-namespaced Playground models with provider prefix (#3050) (#3102)
The provider Playground (LlmChatCard) only added the providerId/ prefix to models without a slash, so vendor-namespaced ids (moonshotai/kimi-k2.6, nvidia/zyphra/...) were sent bare and rejected with 'Ambiguous model' when the same id exists under multiple providers. Extracted qualifyPlaygroundModel() which always prefixes with the provider unless already qualified. Bug 1 ('unhashable type: dict') is an upstream NVIDIA NIM server error, not OmniRoute. Tests: 4 cases for the qualifier.
2026-06-03 07:56:16 -03:00

32 lines
1.4 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
const { qualifyPlaygroundModel } = await import(
"../../src/app/(dashboard)/dashboard/media-providers/components/LlmChatCard.tsx"
);
// #3050 — vendor-namespaced model ids already contain a "/", so the old
// `.includes("/")` heuristic skipped the provider prefix and the request was
// rejected with "Ambiguous model 'moonshotai/kimi-k2.6'".
test("qualifyPlaygroundModel prefixes a vendor-namespaced model with providerId (#3050)", () => {
assert.equal(qualifyPlaygroundModel("moonshotai/kimi-k2.6", "nim"), "nim/moonshotai/kimi-k2.6");
assert.equal(
qualifyPlaygroundModel("nvidia/zyphra/zamba2-7b-instruct", "nim"),
"nim/nvidia/zyphra/zamba2-7b-instruct"
);
});
test("qualifyPlaygroundModel prefixes a bare model", () => {
assert.equal(qualifyPlaygroundModel("gpt-4o", "openai"), "openai/gpt-4o");
});
test("qualifyPlaygroundModel does not double-prefix an already-qualified model", () => {
assert.equal(qualifyPlaygroundModel("nim/moonshotai/kimi-k2.6", "nim"), "nim/moonshotai/kimi-k2.6");
assert.equal(qualifyPlaygroundModel("nim", "nim"), "nim");
});
test("qualifyPlaygroundModel returns the model unchanged without a providerId", () => {
assert.equal(qualifyPlaygroundModel("moonshotai/kimi-k2.6", ""), "moonshotai/kimi-k2.6");
assert.equal(qualifyPlaygroundModel("", "nim"), "");
});