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);
|
return resolveOpenAISize(aspectRatio, imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveRequestTimeoutMs(baseURL: string, imageSize?: "1K" | "2K" | "4K") {
|
function isLongRunningComflyModel(modelId?: string) {
|
||||||
if (isComflyBaseURL(baseURL) && imageSize === "4K") {
|
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 LONG_RUNNING_COMFLY_TIMEOUT_MS;
|
||||||
}
|
}
|
||||||
return DEFAULT_TIMEOUT_MS;
|
return DEFAULT_TIMEOUT_MS;
|
||||||
@ -461,7 +470,7 @@ async function requestOpenAIImageGeneration(params: {
|
|||||||
typeof aspectRatio === "string" && aspectRatio.trim() && aspectRatio !== "auto"
|
typeof aspectRatio === "string" && aspectRatio.trim() && aspectRatio !== "auto"
|
||||||
? aspectRatio.trim()
|
? aspectRatio.trim()
|
||||||
: undefined;
|
: undefined;
|
||||||
const timeoutMs = resolveRequestTimeoutMs(baseURL, imageSizeLabel);
|
const timeoutMs = resolveRequestTimeoutMs(baseURL, imageSizeLabel, model);
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
||||||
@ -597,7 +606,7 @@ export function createOpenAIImage({ apiKey, baseURL }: OpenAIImageConfig) {
|
|||||||
promptAspectRatio: promptAspectRatio || undefined,
|
promptAspectRatio: promptAspectRatio || undefined,
|
||||||
imageSize,
|
imageSize,
|
||||||
resolutionMode: isComflyBaseURL(baseURL) ? "longest-edge" : "pixel-area",
|
resolutionMode: isComflyBaseURL(baseURL) ? "longest-edge" : "pixel-area",
|
||||||
timeoutMs: resolveRequestTimeoutMs(baseURL, imageSize),
|
timeoutMs: resolveRequestTimeoutMs(baseURL, imageSize, activeModelId),
|
||||||
useBltcyImageCompatParams: shouldUseBltcyImageCompatParams(baseURL),
|
useBltcyImageCompatParams: shouldUseBltcyImageCompatParams(baseURL),
|
||||||
imageCount: imageUrls.length,
|
imageCount: imageUrls.length,
|
||||||
baseURL: normalizeBaseURL(baseURL),
|
baseURL: normalizeBaseURL(baseURL),
|
||||||
|
|||||||
@ -142,6 +142,7 @@ export function classifyAiModelHealthFailure(error: unknown): {
|
|||||||
if (
|
if (
|
||||||
normalized.includes("timeout") ||
|
normalized.includes("timeout") ||
|
||||||
normalized.includes("超时") ||
|
normalized.includes("超时") ||
|
||||||
|
normalized.includes("524") ||
|
||||||
normalized.includes("terminated") ||
|
normalized.includes("terminated") ||
|
||||||
normalized.includes("timed out") ||
|
normalized.includes("timed out") ||
|
||||||
normalized.includes("body timeout") ||
|
normalized.includes("body timeout") ||
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user