生成视频提示词api

This commit is contained in:
小帅 2026-03-30 16:58:14 +08:00
parent e306a14c11
commit a854c2ed32
5 changed files with 57 additions and 25 deletions

View File

@ -111,7 +111,6 @@ export default router.post(
${config.label} ${config.label}
**** ****
- 风格: ${project?.artStyle || "未指定"}
- 小说类型: ${project?.type || "未指定"} - 小说类型: ${project?.type || "未指定"}
- 小说背景: ${project?.intro || "未指定"} - 小说背景: ${project?.intro || "未指定"}

View File

@ -5,7 +5,6 @@ import { success } from "@/lib/responseFormat";
import { validateFields } from "@/middleware/middleware"; import { validateFields } from "@/middleware/middleware";
const router = express.Router(); const router = express.Router();
import compressing from "compressing"; import compressing from "compressing";
import { flowDataSchema } from "@/agents/productionAgent/tools";
import path from "path"; import path from "path";
import getPath from "@/utils/getPath"; import getPath from "@/utils/getPath";

View File

@ -102,6 +102,7 @@ export default router.post(
3. 3.
4. 4.
5. `; 5. `;
console.log("%c Line:110 🍑 prompt", "background:#b03734", prompt);
const aiVideo = u.Ai.Video(model); const aiVideo = u.Ai.Video(model);
await aiVideo.run({ await aiVideo.run({

View File

@ -3,24 +3,23 @@ import u from "@/utils";
import { z } from "zod"; import { z } from "zod";
import { success } from "@/lib/responseFormat"; import { success } from "@/lib/responseFormat";
import { validateFields } from "@/middleware/middleware"; import { validateFields } from "@/middleware/middleware";
import { Output } from "ai";
const router = express.Router(); const router = express.Router();
export default router.post( export default router.post(
"/", "/",
validateFields({ validateFields({
projectId: z.number(), projectId: z.number(),
storyboardId: z.array(z.number()), storyboardIds: z.array(z.number()),
}), }),
async (req, res) => { async (req, res) => {
const { projectId, storyboardId } = req.body; const { projectId, storyboardIds } = req.body;
// 查询分镜及其关联的资产提示词 // 查询分镜及其关联的资产提示词
const data = await u const data = await u
.db("o_storyboard") .db("o_storyboard")
.leftJoin("o_assets2Storyboard", "o_storyboard.id", "o_assets2Storyboard.storyboardId") .leftJoin("o_assets2Storyboard", "o_storyboard.id", "o_assets2Storyboard.storyboardId")
.leftJoin("o_assets", "o_assets2Storyboard.assetId", "o_assets.id") .leftJoin("o_assets", "o_assets2Storyboard.assetId", "o_assets.id")
.leftJoin("o_videoConfig", "o_storyboard.id", "o_videoConfig.storyboardId") .leftJoin("o_videoConfig", "o_storyboard.id", "o_videoConfig.storyboardId")
.whereIn("o_storyboard.id", storyboardId) .whereIn("o_storyboard.id", storyboardIds)
.select("o_storyboard.id", "o_storyboard.prompt", "o_assets.prompt as assetPrompt", "o_videoConfig.model as videoModel"); .select("o_storyboard.id", "o_storyboard.prompt", "o_assets.prompt as assetPrompt", "o_videoConfig.model as videoModel");
// 按分镜id分组聚合资产提示词 // 按分镜id分组聚合资产提示词
@ -44,7 +43,7 @@ export default router.post(
const videoModel = await u.db("o_project").where("id", projectId).select("videoModel").first(); const videoModel = await u.db("o_project").where("id", projectId).select("videoModel").first();
model = videoModel?.videoModel || ""; model = videoModel?.videoModel || "";
} }
if (!model) return res.status(400).json({ error: "未找到视频模型,请检查项目配置" }); if (!model) continue; //分镜没有指定视频模型,且项目也没有默认视频模型,跳过生成提示词
const systemPrompt = `你是一个专业的${model}视频生成助手。请根据分镜提示词和关联资产提示词,生成一段完整的、可直接用于视频生成模型的中文提示词。`; const systemPrompt = `你是一个专业的${model}视频生成助手。请根据分镜提示词和关联资产提示词,生成一段完整的、可直接用于视频生成模型的中文提示词。`;
const userContent = `分镜提示词:${prompt || "无"}\n资产提示词${assetPrompts.length > 0 ? assetPrompts.join("\n") : "无"}`; const userContent = `分镜提示词:${prompt || "无"}\n资产提示词${assetPrompts.length > 0 ? assetPrompts.join("\n") : "无"}`;

View File

@ -1,26 +1,62 @@
<<<<<<< HEAD // @db-hash ea0c51ccb8c93a2f019139db9621721e
// @db-hash 93b2462070c45c2b449e9a18c4e88763
//该文件由脚本自动生成,请勿手动修改 //该文件由脚本自动生成,请勿手动修改
======= export interface _o_project_old_20260330 {
// @db-hash f7bc2fdb80756d5536929eb47155578b 'artStyle'?: string | null;
//该文件由脚本自动生成,请勿手动修改
export interface _o_script_old_20260327 {
'content'?: string | null;
'createTime'?: number | null; 'createTime'?: number | null;
'id'?: number; 'id'?: number | null;
'intro'?: string | null;
'name'?: string | null; 'name'?: string | null;
'projectId'?: number | null; 'projectType'?: string | null;
'type'?: string | null;
'userId'?: number | null;
'videoRatio'?: string | null;
}
export interface _o_storyboard_old_20260325 {
'camera'?: string | null;
'createTime'?: number | null;
'description'?: string | null;
'duration'?: string | null;
'filePath'?: string | null;
'frameMode'?: string | null;
'id'?: number;
'lines'?: string | null;
'mode'?: string | null;
'model'?: string | null;
'prompt'?: string | null;
'reason'?: string | null;
'resolution'?: string | null;
'scriptId'?: number | null;
'sound'?: string | null;
'state'?: string | null;
'title'?: string | null;
}
export interface _o_storyboard_old_20260330 {
'camera'?: string | null;
'createTime'?: number | null;
'description'?: string | null;
'duration'?: string | null;
'filePath'?: string | null;
'frameMode'?: string | null;
'id'?: number;
'index'?: string | null;
'lines'?: string | null;
'mode'?: string | null;
'model'?: string | null;
'prompt'?: string | null;
'reason'?: string | null;
'resolution'?: string | null;
'scriptId'?: number | null;
'sound'?: string | null;
'state'?: string | null;
'title'?: string | null;
} }
>>>>>>> 9da2610cdedc1e293b351ed3ab67fbc6fcd989f1
export interface memories { export interface memories {
'content': string; 'content': string;
'createTime': number; 'createTime': number;
'embedding'?: string | null; 'embedding'?: string | null;
'id'?: string; 'id'?: string;
'isolationKey': string; 'isolationKey': string;
'name'?: string | null;
'relatedMessageIds'?: string | null; 'relatedMessageIds'?: string | null;
'role'?: string | null; 'role'?: string | null;
'summarized'?: number | null; 'summarized'?: number | null;
@ -141,8 +177,6 @@ export interface o_prompt {
export interface o_script { export interface o_script {
'content'?: string | null; 'content'?: string | null;
'createTime'?: number | null; 'createTime'?: number | null;
'errorReason'?: string | null;
'extractState'?: number | null;
'id'?: number; 'id'?: number;
'name'?: string | null; 'name'?: string | null;
'projectId'?: number | null; 'projectId'?: number | null;
@ -190,6 +224,7 @@ export interface o_storyboard {
'sound'?: string | null; 'sound'?: string | null;
'state'?: string | null; 'state'?: string | null;
'title'?: string | null; 'title'?: string | null;
'videoPrompt'?: string | null;
} }
export interface o_tasks { export interface o_tasks {
'describe'?: string | null; 'describe'?: string | null;
@ -244,10 +279,9 @@ export interface o_videoConfig {
} }
export interface DB { export interface DB {
<<<<<<< HEAD "_o_project_old_20260330": _o_project_old_20260330;
======= "_o_storyboard_old_20260325": _o_storyboard_old_20260325;
"_o_script_old_20260327": _o_script_old_20260327; "_o_storyboard_old_20260330": _o_storyboard_old_20260330;
>>>>>>> 9da2610cdedc1e293b351ed3ab67fbc6fcd989f1
"memories": memories; "memories": memories;
"o_agentDeploy": o_agentDeploy; "o_agentDeploy": o_agentDeploy;
"o_agentWorkData": o_agentWorkData; "o_agentWorkData": o_agentWorkData;