1. 修复火山引擎图像生成模型无法使用问题
This commit is contained in:
parent
b44e7b6e59
commit
07d209d1fe
@ -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",
|
||||
|
||||
@ -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));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@ -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<string, any> = {
|
||||
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) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user