mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-16 17:09:09 +00:00
⚠️ base-red inherited: #17219 ## Summary Behavior change: the serving provider is now always part of an entry's name, and the editor/upstream moves to a trailing parenthesis. Before, the name builder prefixed every entry with the model's editor/upstream, hiding the route and letting three incompatible `free` conventions and volatile `auto/*` names coexist. Now an entry reads `Provider - Model`, with a leading `🆓 ` when free, combos read `combo - slug`, a route suffix appears only on same-provider name collisions, and `providerTag` becomes the switch for the editor parenthesis: `true` by default, `false` drops it. ## Related Issues - No linked issue — the symptom was reproduced on the release base ## Target Branch Thanks @maxmad64bis.
86 lines
2.8 KiB
TypeScript
86 lines
2.8 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { applyEnrichment } from "../src/shared/enrich.js";
|
|
import type { LegacyModel as ModelV2 } from "../src/legacy-model.js";
|
|
|
|
function model(id: string, name = id): ModelV2 {
|
|
return {
|
|
id,
|
|
name,
|
|
cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
|
|
} as unknown as ModelV2;
|
|
}
|
|
|
|
describe("the enrichment overlay reaches the picker", () => {
|
|
it("renders the upstream provider a model routes to", () => {
|
|
const m = applyEnrichment(model("cc/sonnet"), {
|
|
name: "Claude Sonnet 4.6",
|
|
providerDisplayName: "Claude",
|
|
providerAlias: "cc",
|
|
});
|
|
assert.equal(m.name, "Claude - Claude Sonnet 4.6");
|
|
assert.match(m.name, /Claude/);
|
|
});
|
|
|
|
it("marks a free model and states the budget the user actually gets", () => {
|
|
const m = applyEnrichment(model("pol/grok"), {
|
|
name: "Grok 4 Fast",
|
|
providerDisplayName: "Pollinations",
|
|
freeType: "recurring-monthly" as const,
|
|
monthlyTokens: 1_000_000,
|
|
});
|
|
assert.match(m.name, /^🆓 /);
|
|
assert.match(m.name, /Grok 4 Fast/);
|
|
assert.match(m.name, /Pollinations/);
|
|
assert.match(
|
|
m.name,
|
|
/tokens\/month/,
|
|
"the budget the gateway reports is stated, not just the fact it is free"
|
|
);
|
|
assert.equal(m.name, "🆓 Pollinations - Grok 4 Fast · 1M tokens/month");
|
|
});
|
|
|
|
it("never tags a combo: it routes across providers, not to one", () => {
|
|
const m = applyEnrichment(
|
|
model("combo-fast", "Combo Fast"),
|
|
{ name: "Combo Fast", providerDisplayName: "Claude" },
|
|
{ isCombo: true }
|
|
);
|
|
assert.equal(m.name, "combo - Combo Fast");
|
|
});
|
|
|
|
it("still overlays pricing", () => {
|
|
const m = applyEnrichment(model("x"), { pricing: { input: 3, output: 15 } });
|
|
assert.equal(m.cost.input, 3);
|
|
assert.equal(m.cost.output, 15);
|
|
});
|
|
});
|
|
|
|
describe("free budget under alias and without cap", () => {
|
|
it("renders the budget of an alias-served model", () => {
|
|
const m = applyEnrichment(model("cf/@cf/meta/llama-3.3-70b-instruct-fp8-fast"), {
|
|
name: "Llama 3.3 70B",
|
|
providerDisplayName: "Cloudflare",
|
|
providerAlias: "cf",
|
|
freeType: "recurring-monthly" as const,
|
|
monthlyTokens: 1_000_000,
|
|
});
|
|
assert.equal(m.name, "🆓 Cloudflare - Llama 3.3 70B · 1M tokens/month");
|
|
});
|
|
|
|
it("renders the uncapped label with no counters", () => {
|
|
const m = applyEnrichment(model("cf/open-m"), {
|
|
name: "Open Model",
|
|
providerDisplayName: "Cloudflare",
|
|
providerAlias: "cf",
|
|
freeType: "recurring-uncapped" as const,
|
|
});
|
|
assert.equal(m.name, "🆓 Cloudflare - Open Model · (uncapped)");
|
|
});
|
|
|
|
it("renders nothing extra when the budget is unknown", () => {
|
|
const m = applyEnrichment(model("cf/open-m"), { name: "Open Model" });
|
|
assert.ok(!m.name.includes("·"));
|
|
});
|
|
});
|