mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-05 09:46:30 +00:00
Introduce runtime-configurable payload mutation/filter rules with file reload support and a settings API so upstream request bodies can be customized per model and protocol without restarts. Expand search support with Google PSE, Linkup, SearchAPI, and SearXNG, including validation, routing, analytics costing, MCP schema updates, and search-type-aware provider selection. Update Pollinations to support anonymous access, endpoint failover, and the latest public model lineup. Add OmniRoute response metadata headers/SSE comments, per-connection model exclusion rules, combo tag-based routing, buffered spend writes, and scheduled daily/weekly/monthly budget resets. Update model catalog and dashboard UIs to surface source labels and hide models excluded by all active connections.
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
getConnectionExcludedModels,
|
|
hasEligibleConnectionForModel,
|
|
isModelExcludedByConnection,
|
|
normalizeExcludedModelPatterns,
|
|
} from "../../src/domain/connectionModelRules.ts";
|
|
|
|
test("normalizeExcludedModelPatterns accepts arrays and CSV strings, trims values, and removes duplicates", () => {
|
|
assert.deepEqual(normalizeExcludedModelPatterns([" gpt-4o* ", "gpt-4o*", "", "**"]), ["gpt-4o*"]);
|
|
assert.deepEqual(normalizeExcludedModelPatterns("gpt-4.1*, gpt-4o*, gpt-4.1*"), [
|
|
"gpt-4.1*",
|
|
"gpt-4o*",
|
|
]);
|
|
});
|
|
|
|
test("isModelExcludedByConnection matches both provider-scoped and raw model ids", () => {
|
|
const providerSpecificData = {
|
|
excludedModels: ["gpt-4o*", "claude-opus-*"],
|
|
};
|
|
|
|
assert.equal(isModelExcludedByConnection("openai/gpt-4o-mini", providerSpecificData), true);
|
|
assert.equal(isModelExcludedByConnection("gpt-4o-mini", providerSpecificData), true);
|
|
assert.equal(isModelExcludedByConnection("claude-sonnet-4-5", providerSpecificData), false);
|
|
});
|
|
|
|
test("hasEligibleConnectionForModel only returns true when at least one connection can serve the model", () => {
|
|
const connections = [
|
|
{ providerSpecificData: { excludedModels: ["gpt-4o*"] } },
|
|
{ providerSpecificData: { excludedModels: ["gpt-4.1*"] } },
|
|
];
|
|
|
|
assert.equal(hasEligibleConnectionForModel(connections, "gpt-4o-mini"), true);
|
|
assert.equal(
|
|
hasEligibleConnectionForModel(
|
|
[
|
|
{ providerSpecificData: { excludedModels: ["gpt-4o*"] } },
|
|
{ providerSpecificData: { excludedModels: ["gpt-4o-mini"] } },
|
|
],
|
|
"gpt-4o-mini"
|
|
),
|
|
false
|
|
);
|
|
assert.deepEqual(getConnectionExcludedModels({ excluded_models: ["gpt-4o*"] }), ["gpt-4o*"]);
|
|
});
|