From 07d209d1fecbba6ef5dc03962fa3f432fbfabb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ACT=E4=B8=B6=E6=B5=81=E6=98=9F=E9=9B=A8?= <1340145680@qq.com> Date: Sat, 31 Jan 2026 17:11:02 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E7=81=AB=E5=B1=B1?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E5=9B=BE=E5=83=8F=E7=94=9F=E6=88=90=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/routes/other/testImage.ts | 3 ++- src/utils/ai.ts | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 60ce3c8..2c7aced 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "toonflow-serve", - "version": "1.0.4", + "version": "1.0.5", "description": "ToonFlow Serve - Electron Application", "main": "build/main.js", "author": "ToonFlow Team", diff --git a/src/routes/other/testImage.ts b/src/routes/other/testImage.ts index 54d1be8..d0d3a6e 100644 --- a/src/routes/other/testImage.ts +++ b/src/routes/other/testImage.ts @@ -36,7 +36,8 @@ export default router.post( ); res.status(200).send(success(contentStr)); } catch (err: any) { - res.status(500).send(error(err.error.message || "模型调用失败")); + const message = err?.response?.data?.error?.message || err?.error?.message || "模型调用失败"; + res.status(500).send(error(message)); } }, ); diff --git a/src/utils/ai.ts b/src/utils/ai.ts index d7b4eda..a0488aa 100644 --- a/src/utils/ai.ts +++ b/src/utils/ai.ts @@ -112,13 +112,25 @@ const uploadBase64ToRunninghub = async (base64Image: string, apiKey: string, bas const generators = { volcengine: async (config: ImageConfig, apiKey: string, baseURL: string, model: string) => { + if (config.size == "1K") config.size = "2K"; apiKey = apiKey.replace("Bearer ", ""); - const res = await axios.post( - `https://api.volcengineapi.com/v1/images/generations`, - { model, prompt: config.systemPrompt, image: config.imageBase64, size: config.size, watermark: false }, - { headers: { Authorization: `Bearer ${apiKey}` } }, - ); - return res.data[0].url; + const body: Record = { + model, + prompt: config.prompt, + size: config.size, + response_format: "url", + sequential_image_generation: "disabled", + stream: false, + watermark: false, + }; + // 图生图:存在图片时添加 image 字段 + if (config.imageBase64) { + body.image = config.imageBase64; + } + const res = await axios.post(`https://ark.cn-beijing.volces.com/api/v3/images/generations`, body, { + headers: { Authorization: `Bearer ${apiKey}` }, + }); + return res.data.data[0].url; }, gemini: async (config: ImageConfig, apiKey: string, baseURL: string, model: string) => {