增加图片质量

This commit is contained in:
zhishi 2026-03-28 17:18:40 +08:00
parent 6c39194964
commit 23ccf19d19
9 changed files with 37 additions and 19 deletions

View File

@ -500,7 +500,7 @@ export default (resTool: ResTool, toolsNames?: string[]) => {
// --- 准备公共数据 ---
const projectData = await u.db("o_project").where("id", resTool.data.projectId).select("videoRatio").first();
const imageModel = resTool.data.imageModel;
const imageModelData = await u.db("o_project").where("id", resTool.data.projectId).select("imageModel", "imageQuality").first();
// 生成单张图片的函数
const generateOneImage = async (item: (typeof images)[0]) => {
@ -519,10 +519,10 @@ export default (resTool: ResTool, toolsNames?: string[]) => {
getStoryboardImageBase64(item.referenceIds),
]);
const imageCls = await u.Ai.Image(imageModel?.modelId).run({
const imageCls = await u.Ai.Image(imageModelData.imageModel).run({
prompt: item.prompt,
imageBase64: [...assetsBase64, ...referenceBase64],
size: imageModel?.quality,
size: imageModelData.imageQuality,
aspectRatio: (projectData?.videoRatio as `${number}:${number}`) ?? "16:9",
taskClass: "生成图片",
describe: "分镜图片生成",
@ -616,20 +616,20 @@ export default (resTool: ResTool, toolsNames?: string[]) => {
}
});
//获取所设置模型
const imageModel = resTool.data.imageModel;
const imageModelData = await u.db("o_project").where("id", resTool.data.projectId).select("imageModel", "imageQuality").first();
for (const item of assetsImage) {
const [imageId] = await u.db("o_image").insert({
// 数据库插入图片记录
assetsId: item.assetId,
model: imageModel?.modelId,
model: imageModelData?.imageModel,
state: "生成中",
resolution: imageModel?.quality,
resolution: imageModelData?.imageQuality,
});
u.Ai.Image(imageModel?.modelId)
u.Ai.Image(imageModelData?.imageModel)
.run({
prompt: item.prompt,
imageBase64: await getAssetsImageBase64(item.id ? [item.id] : []),
size: imageModel?.quality,
size: imageModelData?.imageQuality,
aspectRatio: "16:9",
taskClass: "生成图片",
describe: "资产图片生成",

View File

@ -31,6 +31,7 @@ export default async (knex: Knex, forceInit: boolean = false): Promise<void> =>
table.integer("id");
table.string("projectType");
table.string("imageModel");
table.string("imageQuality");
table.string("videoModel");
table.text("name");
table.text("intro");
@ -64,7 +65,7 @@ export default async (knex: Knex, forceInit: boolean = false): Promise<void> =>
table.string("model");
table.string("key");
table.string("modelName");
table.integer("vendorId");
table.text("vendorId");
table.string("desc");
table.string("name");
table.boolean("disabled").defaultTo(false);

View File

@ -17,9 +17,11 @@ export default router.post(
videoRatio: z.string(),
imageModel: z.string(),
videoModel: z.string(),
imageQuality: z.string()
}),
async (req, res) => {
const { projectType, name, intro, type, artStyle, videoRatio, imageModel, videoModel } = req.body;
const { projectType, name, intro, type, artStyle, videoRatio, imageModel, videoModel,imageQuality } = req.body;
await u.db("o_project").insert({
projectType,
@ -32,6 +34,7 @@ export default router.post(
imageModel,
videoModel,
createTime: Date.now(),
imageQuality
});
res.status(200).send(success({ message: "新增项目成功" }));

View File

@ -17,9 +17,10 @@ export default router.post(
videoRatio: z.string(),
imageModel: z.string(),
videoModel: z.string(),
imageQuality: z.string()
}),
async (req, res) => {
const { id, name, intro, type, artStyle, videoRatio, imageModel, videoModel } = req.body;
const { id, name, intro, type, artStyle, videoRatio, imageModel, videoModel,imageQuality } = req.body;
await u.db("o_project").where("id", id).update({
name,
@ -29,6 +30,7 @@ export default router.post(
videoRatio,
imageModel,
videoModel,
imageQuality
});
res.status(200).send(success({ message: "新增项目成功" }));

View File

@ -15,7 +15,7 @@ export default router.post(
await u.db("o_agentDeploy").whereIn("id", id).where("disabled", "<>", 1).update({
model: "gpt-4.1",
modelName: "toonflow:gpt-4.1",
vendorId: 1,
vendorId: "toonflow",
});
res.status(200).send(success("配置成功"));
},

View File

@ -12,7 +12,7 @@ export default router.post(
name: z.string(),
model: z.string(),
modelName: z.string(),
vendorId: z.number().nullable(),
vendorId: z.string().nullable(),
desc: z.string(),
}),
async (req, res) => {

View File

@ -11,10 +11,12 @@ export default router.post(
}),
async (req, res) => {
const { id } = req.body;
if (id == "toonflow" || id.includes("toonflow")) {
return res.status(400).send(error("此配置无法删除"));
}
await u.db("o_vendorConfig").where("id", id).del();
await u.db("o_agentDeploy").where("vendorId", id).update({
model: null,
key: null,
vendorId: null,
});
res.status(200).send(success("删除成功"));
},
);

View File

@ -1,12 +1,20 @@
// @db-hash 05ecfd675f848d88631c1a546996caea
// @db-hash 509ef34a31d203b2a7dca4e5dc69ae88
//该文件由脚本自动生成,请勿手动修改
export interface _o_script_old_20260327 {
'content'?: string | null;
'createTime'?: number | null;
'id'?: number;
'name'?: string | null;
'projectId'?: number | null;
}
export interface memories {
'content': string;
'createTime': number;
'embedding'?: string | null;
'id'?: string;
'isolationKey': string;
'name'?: string | null;
'relatedMessageIds'?: string | null;
'role'?: string | null;
'summarized'?: number | null;
@ -46,7 +54,6 @@ export interface o_assets {
'name'?: string | null;
'projectId'?: number | null;
'prompt'?: string | null;
'promptState'?: string | null;
'remark'?: string | null;
'scriptId'?: number | null;
'startTime'?: number | null;
@ -110,6 +117,7 @@ export interface o_project {
'createTime'?: number | null;
'id'?: number | null;
'imageModel'?: string | null;
'imageQuality'?: string | null;
'intro'?: string | null;
'name'?: string | null;
'projectType'?: string | null;
@ -121,7 +129,7 @@ export interface o_project {
export interface o_prompt {
'id'?: number;
'name'?: string | null;
'prompt'?: string | null;
'rompt'?: string | null;
}
export interface o_script {
'content'?: string | null;
@ -229,6 +237,7 @@ export interface o_videoConfig {
}
export interface DB {
"_o_script_old_20260327": _o_script_old_20260327;
"memories": memories;
"o_agentDeploy": o_agentDeploy;
"o_agentWorkData": o_agentWorkData;

View File

@ -116,6 +116,7 @@ class AiImage {
return withTaskRecord(this.key, input.taskClass, input.describe, input.relatedObjects, input.projectId, async (modelName) => {
const fn = await getVendorTemplateFn("imageRequest", modelName);
this.result = await fn(input);
console.log("%c Line:119 🌽 this.result", "background:#ed9ec7", this.result);
if (this.result.startsWith("http")) this.result = await urlToBase64(this.result);
return this;
});