Fix Comfly 4K image failover timing
This commit is contained in:
parent
686111628e
commit
9e52e1844f
@ -217,8 +217,17 @@ function resolveProviderImageSize(
|
||||
return resolveOpenAISize(aspectRatio, imageSize);
|
||||
}
|
||||
|
||||
function resolveRequestTimeoutMs(baseURL: string, imageSize?: "1K" | "2K" | "4K") {
|
||||
if (isComflyBaseURL(baseURL) && imageSize === "4K") {
|
||||
function isLongRunningComflyModel(modelId?: string) {
|
||||
const normalized = String(modelId || "").trim().toLowerCase();
|
||||
return normalized.includes("gpt-image-2") && normalized.includes("4k");
|
||||
}
|
||||
|
||||
function resolveRequestTimeoutMs(
|
||||
baseURL: string,
|
||||
imageSize?: "1K" | "2K" | "4K",
|
||||
modelId?: string
|
||||
) {
|
||||
if (isComflyBaseURL(baseURL) && (imageSize === "4K" || isLongRunningComflyModel(modelId))) {
|
||||
return LONG_RUNNING_COMFLY_TIMEOUT_MS;
|
||||
}
|
||||
return DEFAULT_TIMEOUT_MS;
|
||||
@ -461,7 +470,7 @@ async function requestOpenAIImageGeneration(params: {
|
||||
typeof aspectRatio === "string" && aspectRatio.trim() && aspectRatio !== "auto"
|
||||
? aspectRatio.trim()
|
||||
: undefined;
|
||||
const timeoutMs = resolveRequestTimeoutMs(baseURL, imageSizeLabel);
|
||||
const timeoutMs = resolveRequestTimeoutMs(baseURL, imageSizeLabel, model);
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
||||
@ -597,7 +606,7 @@ export function createOpenAIImage({ apiKey, baseURL }: OpenAIImageConfig) {
|
||||
promptAspectRatio: promptAspectRatio || undefined,
|
||||
imageSize,
|
||||
resolutionMode: isComflyBaseURL(baseURL) ? "longest-edge" : "pixel-area",
|
||||
timeoutMs: resolveRequestTimeoutMs(baseURL, imageSize),
|
||||
timeoutMs: resolveRequestTimeoutMs(baseURL, imageSize, activeModelId),
|
||||
useBltcyImageCompatParams: shouldUseBltcyImageCompatParams(baseURL),
|
||||
imageCount: imageUrls.length,
|
||||
baseURL: normalizeBaseURL(baseURL),
|
||||
|
||||
@ -142,6 +142,7 @@ export function classifyAiModelHealthFailure(error: unknown): {
|
||||
if (
|
||||
normalized.includes("timeout") ||
|
||||
normalized.includes("超时") ||
|
||||
normalized.includes("524") ||
|
||||
normalized.includes("terminated") ||
|
||||
normalized.includes("timed out") ||
|
||||
normalized.includes("body timeout") ||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user