From 23ccf19d195b457a58633480604fe89fb502be3e Mon Sep 17 00:00:00 2001 From: zhishi <1951671751@qq.com> Date: Sat, 28 Mar 2026 17:18:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87=E8=B4=A8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agents/productionAgent/tools.ts | 16 ++++++++-------- src/lib/initDB.ts | 3 ++- src/routes/project/addProject.ts | 5 ++++- src/routes/project/editProject.ts | 4 +++- src/routes/setting/agentDeploy/agentSetKey.ts | 2 +- .../setting/agentDeploy/deployAgentModel.ts | 2 +- src/routes/setting/vendorConfig/deleteVendor.ts | 8 +++++--- src/types/database.d.ts | 15 ++++++++++++--- src/utils/ai.ts | 1 + 9 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/agents/productionAgent/tools.ts b/src/agents/productionAgent/tools.ts index 3d6c64a..d660adb 100644 --- a/src/agents/productionAgent/tools.ts +++ b/src/agents/productionAgent/tools.ts @@ -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: "资产图片生成", diff --git a/src/lib/initDB.ts b/src/lib/initDB.ts index 4334863..221786d 100644 --- a/src/lib/initDB.ts +++ b/src/lib/initDB.ts @@ -31,6 +31,7 @@ export default async (knex: Knex, forceInit: boolean = false): Promise => 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 => 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); diff --git a/src/routes/project/addProject.ts b/src/routes/project/addProject.ts index 65f15d9..fefeb69 100644 --- a/src/routes/project/addProject.ts +++ b/src/routes/project/addProject.ts @@ -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: "新增项目成功" })); diff --git a/src/routes/project/editProject.ts b/src/routes/project/editProject.ts index eb4fc8e..223d22e 100644 --- a/src/routes/project/editProject.ts +++ b/src/routes/project/editProject.ts @@ -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: "新增项目成功" })); diff --git a/src/routes/setting/agentDeploy/agentSetKey.ts b/src/routes/setting/agentDeploy/agentSetKey.ts index 47fa251..cfe1fb4 100644 --- a/src/routes/setting/agentDeploy/agentSetKey.ts +++ b/src/routes/setting/agentDeploy/agentSetKey.ts @@ -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("配置成功")); }, diff --git a/src/routes/setting/agentDeploy/deployAgentModel.ts b/src/routes/setting/agentDeploy/deployAgentModel.ts index df5953d..f0894b3 100644 --- a/src/routes/setting/agentDeploy/deployAgentModel.ts +++ b/src/routes/setting/agentDeploy/deployAgentModel.ts @@ -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) => { diff --git a/src/routes/setting/vendorConfig/deleteVendor.ts b/src/routes/setting/vendorConfig/deleteVendor.ts index 1f24a83..a4a58ed 100644 --- a/src/routes/setting/vendorConfig/deleteVendor.ts +++ b/src/routes/setting/vendorConfig/deleteVendor.ts @@ -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("删除成功")); }, ); diff --git a/src/types/database.d.ts b/src/types/database.d.ts index eea92c2..f574476 100644 --- a/src/types/database.d.ts +++ b/src/types/database.d.ts @@ -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; diff --git a/src/utils/ai.ts b/src/utils/ai.ts index e6310b7..1f81734 100644 --- a/src/utils/ai.ts +++ b/src/utils/ai.ts @@ -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; });