mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 06:12:10 +03:00
OmniRoute is an intelligent API gateway that unifies 20+ AI providers behind a single OpenAI-compatible endpoint. Features include intelligent routing with 6 strategies, multi-format translation (OpenAI/Claude/Gemini/Responses API), circuit breakers, semantic caching, combo fallback chains, real-time health monitoring, and a full dashboard with provider management, analytics, and CLI tool integration. Key highlights: - 20+ providers (Claude Code, Codex, Gemini CLI, GitHub Copilot, iFlow, Qwen, Kiro, etc.) - 6 routing strategies (Fill First, Round Robin, P2C, Random, Least Used, Cost Optimized) - Export/Import database backup with full archive support - Translator Playground with 4 modes (Playground, Chat Tester, Test Bench, Live Monitor) - 100% TypeScript across src/ and open-sse/ - Docker support with multi-stage builds - Comprehensive documentation and 9 dashboard screenshots
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
/**
|
|
* Combo Configuration Resolver
|
|
*
|
|
* Implements 3-layer cascade: Global Defaults → Provider Overrides → Per-Combo Config
|
|
* Most specific wins.
|
|
*/
|
|
|
|
const DEFAULT_COMBO_CONFIG = {
|
|
strategy: "priority",
|
|
maxRetries: 1,
|
|
retryDelayMs: 2000,
|
|
timeoutMs: 120000,
|
|
concurrencyPerModel: 3, // max simultaneous requests per model (round-robin)
|
|
queueTimeoutMs: 30000, // max wait time in semaphore queue (round-robin)
|
|
healthCheckEnabled: true,
|
|
healthCheckTimeoutMs: 3000,
|
|
maxComboDepth: 3,
|
|
trackMetrics: true,
|
|
};
|
|
|
|
/**
|
|
* Resolve effective config for a combo, applying cascade:
|
|
* DEFAULT_COMBO_CONFIG → settings.comboDefaults → settings.providerOverrides[provider] → combo.config
|
|
*
|
|
* @param {Object} combo - The combo object { config, ... }
|
|
* @param {Object} settings - App settings from localDb
|
|
* @param {string} [provider] - Optional provider to apply provider-level overrides
|
|
* @returns {Object} Resolved config
|
|
*/
|
|
export function resolveComboConfig(combo, settings, provider?: any) {
|
|
const global = settings?.comboDefaults || {};
|
|
const providerOverride = provider ? settings?.providerOverrides?.[provider] || {} : {};
|
|
const comboConfig = combo?.config || {};
|
|
|
|
// Clean undefined values before spreading
|
|
const clean = (obj) =>
|
|
Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined && v !== null));
|
|
|
|
return {
|
|
...DEFAULT_COMBO_CONFIG,
|
|
...clean(global),
|
|
...clean(providerOverride),
|
|
...clean(comboConfig),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get the default combo config (used when no overrides exist)
|
|
*/
|
|
export function getDefaultComboConfig() {
|
|
return { ...DEFAULT_COMBO_CONFIG };
|
|
}
|