1. 修复火山引擎图像生成模型无法使用问题

This commit is contained in:
ACT丶流星雨 2026-01-31 17:11:02 +08:00
parent b44e7b6e59
commit 07d209d1fe
3 changed files with 21 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "toonflow-serve", "name": "toonflow-serve",
"version": "1.0.4", "version": "1.0.5",
"description": "ToonFlow Serve - Electron Application", "description": "ToonFlow Serve - Electron Application",
"main": "build/main.js", "main": "build/main.js",
"author": "ToonFlow Team", "author": "ToonFlow Team",

View File

@ -36,7 +36,8 @@ export default router.post(
); );
res.status(200).send(success(contentStr)); res.status(200).send(success(contentStr));
} catch (err: any) { } 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));
} }
}, },
); );

View File

@ -112,13 +112,25 @@ const uploadBase64ToRunninghub = async (base64Image: string, apiKey: string, bas
const generators = { const generators = {
volcengine: async (config: ImageConfig, apiKey: string, baseURL: string, model: string) => { volcengine: async (config: ImageConfig, apiKey: string, baseURL: string, model: string) => {
if (config.size == "1K") config.size = "2K";
apiKey = apiKey.replace("Bearer ", ""); apiKey = apiKey.replace("Bearer ", "");
const res = await axios.post( const body: Record<string, any> = {
`https://api.volcengineapi.com/v1/images/generations`, model,
{ model, prompt: config.systemPrompt, image: config.imageBase64, size: config.size, watermark: false }, prompt: config.prompt,
{ headers: { Authorization: `Bearer ${apiKey}` } }, size: config.size,
); response_format: "url",
return res.data[0].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) => { gemini: async (config: ImageConfig, apiKey: string, baseURL: string, model: string) => {