From 6e9f991a769e3a1f650bd452e2b8252b1165742b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Mon, 21 Sep 2026 15:16:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E7=8C=AB=E6=8F=92=E7=94=BB?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E7=9A=84=E5=8D=95=E6=A8=A1=E5=9E=8B=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除单元素模型循环和无操作异常捕获 保留原有请求与错误语义 --- .../generate-anthro-cat-illustrations.mjs | 62 ++++++++----------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/.codex/skills/gpt-image-2-apimart/scripts/generate-anthro-cat-illustrations.mjs b/.codex/skills/gpt-image-2-apimart/scripts/generate-anthro-cat-illustrations.mjs index 97bbae547..712366cf8 100644 --- a/.codex/skills/gpt-image-2-apimart/scripts/generate-anthro-cat-illustrations.mjs +++ b/.codex/skills/gpt-image-2-apimart/scripts/generate-anthro-cat-illustrations.mjs @@ -256,42 +256,34 @@ async function fetchJson(url, options, timeoutMs) { } async function requestImagePayload(env, entry) { - for (const model of [preferredImageModel]) { - const requestBody = { - model, - prompt: buildPrompt(entry), - n: 1, - size: '1024x1024', - }; - try { - const payload = await fetchJson( - buildVectorEngineImagesGenerationUrl(env.baseUrl), - { - method: 'POST', - headers: { - Authorization: `Bearer ${env.apiKey}`, - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify(requestBody), - }, - env.timeoutMs, - ); - const base64Image = decodeStrictBase64Image( - extractBase64Images(payload)[0], - ); - if (extractImageUrls(payload)[0] || base64Image) { - return payload; - } - const error = new Error(`VectorEngine returned no image for ${entry.id}`); - error.vectorEngineResponseParse = true; - error.vectorEngineBody = JSON.stringify(payload).slice(0, 600); - throw error; - } catch (error) { - throw error; - } + const model = preferredImageModel; + const requestBody = { + model, + prompt: buildPrompt(entry), + n: 1, + size: '1024x1024', + }; + const payload = await fetchJson( + buildVectorEngineImagesGenerationUrl(env.baseUrl), + { + method: 'POST', + headers: { + Authorization: `Bearer ${env.apiKey}`, + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify(requestBody), + }, + env.timeoutMs, + ); + const base64Image = decodeStrictBase64Image(extractBase64Images(payload)[0]); + if (extractImageUrls(payload)[0] || base64Image) { + return payload; } - throw new Error(`VectorEngine returned no image for ${entry.id}`); + const error = new Error(`VectorEngine returned no image for ${entry.id}`); + error.vectorEngineResponseParse = true; + error.vectorEngineBody = JSON.stringify(payload).slice(0, 600); + throw error; } async function downloadUrl(url, timeoutMs) {