mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-16 20:22:21 +03:00
fix(combo): propagate selected connection ID to fallback error responses for correct model lockout (#4809)
Integrated into release/v3.8.36
This commit is contained in:
@@ -30,11 +30,7 @@ function toInteger(
|
||||
const min = options.min ?? 0;
|
||||
const max = options.max ?? Number.MAX_SAFE_INTEGER;
|
||||
const parsed =
|
||||
typeof value === "number"
|
||||
? value
|
||||
: typeof value === "string"
|
||||
? Number(value)
|
||||
: fallback;
|
||||
typeof value === "number" ? value : typeof value === "string" ? Number(value) : fallback;
|
||||
return Number.isFinite(parsed) ? Math.max(min, Math.min(max, Math.trunc(parsed))) : fallback;
|
||||
}
|
||||
|
||||
@@ -65,10 +61,14 @@ export function resolveModelLockoutSettings(
|
||||
process.execArgv.includes("--test") ||
|
||||
process.argv.some((arg) => typeof arg === "string" && arg.includes("test"));
|
||||
|
||||
const baseCooldownMs = toInteger(raw.baseCooldownMs, DEFAULT_MODEL_LOCKOUT_SETTINGS.baseCooldownMs, {
|
||||
min: isTest ? 0 : 5_000,
|
||||
max: 600_000,
|
||||
});
|
||||
const baseCooldownMs = toInteger(
|
||||
raw.baseCooldownMs,
|
||||
DEFAULT_MODEL_LOCKOUT_SETTINGS.baseCooldownMs,
|
||||
{
|
||||
min: isTest ? 0 : 5_000,
|
||||
max: 600_000,
|
||||
}
|
||||
);
|
||||
const maxCooldownMs = Math.max(
|
||||
toInteger(raw.maxCooldownMs, DEFAULT_MODEL_LOCKOUT_SETTINGS.maxCooldownMs, {
|
||||
min: isTest ? 0 : 5_000,
|
||||
|
||||
@@ -1055,7 +1055,7 @@ async function handleSingleModelChat(
|
||||
breaker._onFailure();
|
||||
}
|
||||
|
||||
return handleNoCredentials(
|
||||
const noCredsRes = handleNoCredentials(
|
||||
credentials,
|
||||
excludedConnectionIds.size > 0 ? Array.from(excludedConnectionIds)[0] : null,
|
||||
provider,
|
||||
@@ -1063,6 +1063,11 @@ async function handleSingleModelChat(
|
||||
lastError,
|
||||
lastStatus
|
||||
);
|
||||
const lastFailedConnectionId =
|
||||
excludedConnectionIds.size > 0
|
||||
? Array.from(excludedConnectionIds)[excludedConnectionIds.size - 1]
|
||||
: null;
|
||||
return withSelectedConnectionHeader(noCredsRes, lastFailedConnectionId);
|
||||
}
|
||||
|
||||
const accountId = credentials.connectionId.slice(0, 8);
|
||||
|
||||
Reference in New Issue
Block a user