修改查询生成视频api返回数据,修改资产提示词生成结构

This commit is contained in:
小帅 2026-03-31 04:01:06 +08:00
parent 3b65143565
commit 02f6aac04c
6 changed files with 72 additions and 89 deletions

View File

@ -45,7 +45,7 @@ export default router.post(
id: row.id,
filePath: row.filePath ? await u.oss.getFileUrl(row.filePath) : "",
selected: selectedIds.has(row.id),
storyboard: row.storyboardId,
videoParametersId: row.videoParametersId,
})),
);

View File

@ -107,25 +107,21 @@ export default router.post(
if (!visualManual) return res.status(500).send(error("视觉手册未定义"));
findItemByName(result, item.name, config.itemType);
const systemPrompt = `
${config.label}
****
- 小说类型: ${project?.type || "未指定"}
- 小说背景: ${project?.intro || "未指定"}
**${config.nameLabel}**
- ${config.nameLabel}名称:${item.name},
- ${config.nameLabel}描述:${item.describe},
skill规范生成${item.type === "role" ? "人物角色四视图" : config.label}
${visualManual}
`;
const systemPrompt = visualManual;
try {
const { _output } = (await u.Ai.Text("universalAi").invoke({
system: systemPrompt,
messages: [{ role: "user", content: "小说原文" + novelText }],
messages: [
{
role: "user",
content: `
****
**${config.nameLabel}**
- ${config.nameLabel}名称:${item.name},
- ${config.nameLabel}描述:${item.describe},`,
},
],
})) as any;
if (!_output) {

View File

@ -101,25 +101,20 @@ export default router.post(
const novelData = (await u.db("o_novel").whereIn("chapterIndex", [1]).select("*")) as NovelChapter[];
const novelText = mergeNovelText(novelData);
const systemPrompt = `
${config.label}
****
- 小说类型: ${project?.type || "未指定"}
- 小说背景: ${project?.intro || "未指定"}
**${config.nameLabel}**
- ${config.nameLabel}名称:${name},
- ${config.nameLabel}描述:${describe},
skill规范生成${type === "role" ? "人物角色四视图" : config.label}
${visualManual}
`;
const systemPrompt = visualManual;
try {
const { _output } = (await u.Ai.Text("universalAi").invoke({
system: systemPrompt,
messages: [{ role: "user", content: "小说原文" + novelText }],
messages: [
{
role: "user",
content: `**基础参数:**
**${config.nameLabel}**
- ${config.nameLabel}名称:${name},
- ${config.nameLabel}描述:${describe},`,
},
],
})) as any;
if (!_output) return res.status(500).send("失败");

View File

@ -73,11 +73,24 @@ export default router.post(
storyboard: [],
//todo矫正workbench数据
workbench: {
name: scriptData?.name ?? "",
duration: "01:03",
resolution: "1920×1080",
fps: "30fps",
gradient: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
videoList: [
{
id: 1,
prompt: "动起来",
filePath: await u.oss.getFileUrl("/artStyle/5d96256a-1610-43a6-a469-c2385cc2287e.jpg"),
duration: 4,
scriptId: 1,
selectedVideoId: 1,
},
{
id: 2,
prompt: "跳起来",
filePath: await u.oss.getFileUrl("/artStyle/5d96256a-1610-43a6-a469-c2385cc2287e.jpg"),
duration: 4,
scriptId: 1,
selectedVideoId: 1,
},
],
},
//todo矫正封面数据
poster: {

View File

@ -7,36 +7,25 @@ const router = express.Router();
export default router.post(
"/",
validateFields({
scriptId: z.number(),
projectId: z.number(),
ids: z.array(z.number()),
}),
async (req, res) => {
const { scriptId, projectId } = req.body;
//查询分镜数据
const storyboards = await u.db("o_storyboard").where("o_storyboard.scriptId", scriptId).select("*").orderBy("index", "asc");
//查询项目默认的视频模型
const project = await u.db("o_project").where("id", projectId).first();
const storyboardsList = await Promise.all(
storyboards.map(async (item) => {
return {
...item,
model: project?.videoModel || null,
filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : null,
};
}),
);
const storyboardIds = storyboardsList.map((s) => s.id as number);
const { ids } = req.body;
//查询分镜配置
const storyboardConfigs = await u.db("o_videoConfig").whereIn("storyboardId", storyboardIds).select("*");
const storyboardConfigsList = await Promise.all(
storyboardConfigs.map(async (item) => {
if (item.data) {
const parsedData = JSON.parse(item.data);
const storyboardConfigs = await u.db("o_videoConfig").whereIn("storyboardId", ids).select("*");
//查询视频数据
const videos = await u.db("o_video").whereIn("storyboardId", ids).select("*");
//组装数据
const data = await Promise.all(
ids.map(async (storyboardId: number) => {
// 处理配置
const configRow = storyboardConfigs.find((item) => item.storyboardId === storyboardId) || null;
let config = null;
if (configRow?.data) {
const parsedData = JSON.parse(configRow.data);
const dataWithFilePath = await Promise.all(
parsedData.map(async (d: { type: string; id: number }) => {
if (d.type === "assets" && d.id) {
@ -61,35 +50,25 @@ export default router.post(
return null;
}),
);
return {
...item,
data: dataWithFilePath,
};
config = { ...configRow, data: dataWithFilePath };
}
}),
);
//查询视频数据
const videos = await u.db("o_video").whereIn("storyboardId", storyboardIds).select("*");
// 处理视频
const storyboardVideos = videos.filter((v) => v.storyboardId === storyboardId);
const videosList = await Promise.all(
videos.map(async (item) => {
return {
storyboardVideos.map(async (item) => ({
...item,
filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : null,
})),
);
return {
id: storyboardId,
config,
videos: videosList,
};
}),
);
//组装数据
const data = storyboardsList.map((storyboard) => {
const config = storyboardConfigsList.find((item) => item?.storyboardId === storyboard.id) || null;
return {
...storyboard,
config,
videos: videosList.filter((video) => video.storyboardId === storyboard.id),
};
});
return res.status(200).send(success(data));
},
);

View File

@ -8,12 +8,12 @@ const router = express.Router();
export default router.post(
"/",
validateFields({
scriptId: z.number(),
id: z.number(),
specifyIds: z.array(z.number()),
}),
async (req, res) => {
const { scriptId, specifyIds } = req.body;
const data = await u.db("o_video").where("scriptId", scriptId).whereIn("id", specifyIds).andWhere("state", "生成中").select("*");
const { id, specifyIds } = req.body;
const data = await u.db("o_video").where("id", id).whereIn("id", specifyIds).andWhere("state", "生成中").select("*");
res.status(200).send(success(data));
},
);