Files
OmniRoute/src/domain/modelAvailability.ts
Ramel Tecnologia 95944dad92 feat(resilience): expose model cooldown list with manual re-enable (#2146)
Integrated into release/v3.8.0 — adds model cooldowns dashboard card with real-time list and re-enable action. Domain module and unit tests added.
2026-05-11 21:38:26 -03:00

42 lines
1.2 KiB
TypeScript

import {
getAllModelLockouts,
clearModelLock,
type ModelLockoutInfo,
} from "@omniroute/open-sse/services/accountFallback";
export type AvailabilityReportItem = Pick<
ModelLockoutInfo,
"provider" | "model" | "reason" | "remainingMs" | "failureCount"
> & {
connectionId: string;
};
export function getAvailabilityReport(): AvailabilityReportItem[] {
return getAllModelLockouts().map((entry) => ({
provider: entry.provider,
model: entry.model,
connectionId: entry.connectionId,
reason: entry.reason,
remainingMs: entry.remainingMs,
failureCount: entry.failureCount,
}));
}
export function clearModelUnavailability(provider: string, model: string): boolean {
const all = getAllModelLockouts();
const matching = all.filter((e) => e.provider === provider && e.model === model);
if (matching.length === 0) return false;
let cleared = false;
for (const entry of matching) {
if (clearModelLock(provider, entry.connectionId, model)) cleared = true;
}
return cleared;
}
export function resetAllAvailability(): void {
const all = getAllModelLockouts();
for (const entry of all) {
clearModelLock(entry.provider, entry.connectionId, entry.model);
}
}