Files
OmniRoute/tests/unit/cheaperinference-image-models.test.ts
Praveen K Palaniswamy 65e81158ab fix(ollama): route models by advertised capability (#11088)
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host.

Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean.

Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
2026-08-23 11:45:01 -03:00

54 lines
2.5 KiB
TypeScript

// Cheaper Inference image models + the Adobe Firefly collision guard.
//
// nano-banana-pro / nano-banana-2 exist in BOTH providers. parseImageModel resolves a
// bare id by first-match over IMAGE_PROVIDERS iteration order, so the bare ids must
// keep going to adobe-firefly (pre-existing behaviour) and Cheaper Inference must be
// reachable only via its prefix. Operator decision 2026-07-31.
import { test } from "node:test";
import assert from "node:assert/strict";
import { IMAGE_PROVIDERS, parseImageModel } from "@omniroute/open-sse/config/imageRegistry.ts";
test("cheaperinference is registered as an image provider with the 3 measured models", () => {
const provider = IMAGE_PROVIDERS.cheaperinference;
assert.ok(provider, "cheaperinference missing from IMAGE_PROVIDERS");
assert.equal(provider.baseUrl, "https://api.cheaperinference.com/v1/images/generations");
assert.equal(provider.authType, "apikey");
assert.equal(provider.authHeader, "bearer");
assert.equal(provider.format, "openai");
assert.equal(provider.alias, "cinf");
const ids = provider.models.map((m) => m.id).sort();
assert.deepEqual(ids, ["grok-imagine", "nano-banana-2", "nano-banana-pro"]);
});
test("prefixed ids resolve to cheaperinference", () => {
assert.deepEqual(parseImageModel("cheaperinference/nano-banana-2"), {
provider: "cheaperinference",
model: "nano-banana-2",
});
assert.deepEqual(parseImageModel("cinf/grok-imagine"), {
provider: "cheaperinference",
model: "grok-imagine",
});
});
test("REGRESSION GUARD: bare nano-banana ids still route to adobe-firefly", () => {
// If this flips to cheaperinference, someone added an IMAGE_MODEL_ALIASES entry
// (forbidden) or declared cheaperinference before adobe-firefly in IMAGE_PROVIDERS.
assert.equal(parseImageModel("nano-banana-2").provider, "adobe-firefly");
assert.equal(parseImageModel("nano-banana-pro").provider, "adobe-firefly");
});
test("cheaperinference image models are NOT in the chat registry", async () => {
const { REGISTRY } = await import("@omniroute/open-sse/config/providers/index.ts");
const chatIds = new Set(
(REGISTRY.cheaperinference as unknown as { models: Array<{ id: string }> }).models.map(
(m) => m.id
)
);
// Upstream returns HTTP 400 for these on /v1/chat/completions:
// "…is an image-generation model. Use POST /v1/images/generations."
for (const id of ["grok-imagine", "nano-banana-2", "nano-banana-pro"]) {
assert.ok(!chatIds.has(id), `${id} must not be routable as a chat model`);
}
});