mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-07 07:42:13 +03:00
feat(core): add payload rules, tag routing, and scheduled budgets
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.
This commit is contained in:
71
src/shared/utils/modelCatalogSearch.ts
Normal file
71
src/shared/utils/modelCatalogSearch.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
export type ModelCatalogSource = "system" | "custom" | "api-sync" | "fallback" | "alias";
|
||||
|
||||
type ModelCatalogTarget = {
|
||||
modelId?: string | null;
|
||||
modelName?: string | null;
|
||||
alias?: string | null;
|
||||
source?: string | null;
|
||||
};
|
||||
|
||||
function normalizeText(value: string | null | undefined): string {
|
||||
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
||||
}
|
||||
|
||||
export function normalizeModelCatalogSource(source?: string | null): ModelCatalogSource {
|
||||
const normalized = normalizeText(source);
|
||||
|
||||
if (normalized === "api-sync" || normalized === "synced") return "api-sync";
|
||||
if (normalized === "fallback") return "fallback";
|
||||
if (normalized === "alias") return "alias";
|
||||
if (normalized === "custom" || normalized === "manual" || normalized === "imported") {
|
||||
return "custom";
|
||||
}
|
||||
|
||||
return "system";
|
||||
}
|
||||
|
||||
export function getModelCatalogSourceLabel(source?: string | null): string {
|
||||
switch (normalizeModelCatalogSource(source)) {
|
||||
case "api-sync":
|
||||
return "Synced";
|
||||
case "custom":
|
||||
return "Custom";
|
||||
case "fallback":
|
||||
return "Fallback";
|
||||
case "alias":
|
||||
return "Alias";
|
||||
case "system":
|
||||
default:
|
||||
return "Built-in";
|
||||
}
|
||||
}
|
||||
|
||||
function getModelCatalogSourceSearchText(source?: string | null): string {
|
||||
switch (normalizeModelCatalogSource(source)) {
|
||||
case "api-sync":
|
||||
return "synced api imported discovered";
|
||||
case "custom":
|
||||
return "custom manual imported";
|
||||
case "fallback":
|
||||
return "fallback compatible";
|
||||
case "alias":
|
||||
return "alias shortcut";
|
||||
case "system":
|
||||
default:
|
||||
return "built-in builtin official catalog";
|
||||
}
|
||||
}
|
||||
|
||||
export function matchesModelCatalogQuery(query: string, target: ModelCatalogTarget): boolean {
|
||||
const normalizedQuery = normalizeText(query);
|
||||
if (!normalizedQuery) return true;
|
||||
|
||||
const haystacks = [
|
||||
normalizeText(target.modelId),
|
||||
normalizeText(target.modelName),
|
||||
normalizeText(target.alias),
|
||||
getModelCatalogSourceSearchText(target.source),
|
||||
].filter(Boolean);
|
||||
|
||||
return haystacks.some((value) => value.includes(normalizedQuery));
|
||||
}
|
||||
Reference in New Issue
Block a user