mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 06:42:12 +03:00
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.
42 lines
1.2 KiB
TypeScript
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);
|
|
}
|
|
}
|