From 6f19e155ca991f775b33c7e8bb9cfe6ac0267e39 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:23:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E6=A8=A1=E6=9D=BF=E6=A0=B7?= =?UTF-8?q?=E4=BE=8B=E8=84=9A=E6=9C=AC=E7=9A=84=E5=8D=95=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除单元素模型循环和无操作异常捕获 保留原有请求与错误语义 --- .../scripts/generate-template-samples.mjs | 64 ++++++++----------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/.codex/skills/gpt-image-2-apimart/scripts/generate-template-samples.mjs b/.codex/skills/gpt-image-2-apimart/scripts/generate-template-samples.mjs index aa39d5bb7..07799aea4 100644 --- a/.codex/skills/gpt-image-2-apimart/scripts/generate-template-samples.mjs +++ b/.codex/skills/gpt-image-2-apimart/scripts/generate-template-samples.mjs @@ -226,44 +226,34 @@ async function fetchJson(url, options, timeoutMs) { } async function requestImagePayload(env, template) { - for (const model of [preferredImageModel]) { - const requestBody = { - model, - prompt: buildPrompt(template), - 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 ${template.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(template), + 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 ${template.id}`); + const error = new Error(`VectorEngine returned no image for ${template.id}`); + error.vectorEngineResponseParse = true; + error.vectorEngineBody = JSON.stringify(payload).slice(0, 600); + throw error; } async function downloadUrl(url, timeoutMs) {