mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-01 12:52:11 +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
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
const MAX_TRANSLATION_EVENTS = 200;
|
|
const DEFAULT_TRANSLATION_EVENT_LIMIT = 50;
|
|
|
|
function ensureEventsBuffer() {
|
|
if (!globalThis.__translatorEvents) {
|
|
globalThis.__translatorEvents = [];
|
|
}
|
|
return globalThis.__translatorEvents;
|
|
}
|
|
|
|
export function logTranslationEvent(event) {
|
|
if (!event || typeof event !== "object") return;
|
|
|
|
const events = ensureEventsBuffer();
|
|
events.unshift({
|
|
id: `evt_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
timestamp: new Date().toISOString(),
|
|
...event,
|
|
});
|
|
|
|
if (events.length > MAX_TRANSLATION_EVENTS) {
|
|
events.length = MAX_TRANSLATION_EVENTS;
|
|
}
|
|
}
|
|
|
|
export function getTranslationEvents(limit = DEFAULT_TRANSLATION_EVENT_LIMIT) {
|
|
const numericLimit = Number(limit);
|
|
const boundedLimit =
|
|
Number.isFinite(numericLimit) && numericLimit > 0
|
|
? Math.min(Math.floor(numericLimit), MAX_TRANSLATION_EVENTS)
|
|
: DEFAULT_TRANSLATION_EVENT_LIMIT;
|
|
|
|
const events = ensureEventsBuffer();
|
|
return {
|
|
events: events.slice(0, boundedLimit),
|
|
total: events.length,
|
|
};
|
|
}
|
|
|
|
export { MAX_TRANSLATION_EVENTS };
|