tune grsai gpt image health handling

This commit is contained in:
134 2026-06-12 10:43:13 +08:00
parent 1aaf904fd3
commit 36654a6fa3
2 changed files with 7 additions and 1 deletions

View File

@ -533,6 +533,8 @@ function formatImageResponse(
const GRSAI_NANO_BANANA_SUBMIT_TIMEOUT_MS = 30000;
const GRSAI_NANO_BANANA_POLL_TIMEOUT_MS = 30000;
const GRSAI_NANO_BANANA_POLL_INTERVAL_MS = 5000;
const GRSAI_GPT_IMAGE_TIMEOUT_MS = 300000;
const GRSAI_GPT_IMAGE_4K_TIMEOUT_MS = 420000;
function isRecord(value: unknown): value is Record<string, any> {
return Boolean(value && typeof value === "object" && !Array.isArray(value));
@ -1003,7 +1005,10 @@ async function sendGeminiRequest(
`${apiLogPrefix} Resolved size: aspectRatio=${resolvedAspectRatio}, imageSize=${imageParams?.imageSize || "2K"} => ${resolvedSize}`
);
const timeout = imageParams?.imageSize === "4K" ? 300000 : 120000;
const timeout =
imageParams?.imageSize === "4K"
? GRSAI_GPT_IMAGE_4K_TIMEOUT_MS
: GRSAI_GPT_IMAGE_TIMEOUT_MS;
logger.debug(`${apiLogPrefix} Timeout set to ${timeout / 1000} seconds for ${imageParams?.imageSize || "default"}`);
return sendGrsaiGptImageRequest({
baseURL,

View File

@ -70,6 +70,7 @@ export function classifyAiModelHealthFailure(error: unknown): {
if (
normalized.includes("生成结果未通过替换质检") ||
normalized.includes("output_moderation") ||
normalized.includes("quality check") ||
normalized.includes("review result") ||
normalized.includes("content policy") ||