修改查询生成视频api返回数据,修改资产提示词生成结构
This commit is contained in:
parent
3b65143565
commit
02f6aac04c
@ -45,7 +45,7 @@ export default router.post(
|
|||||||
id: row.id,
|
id: row.id,
|
||||||
filePath: row.filePath ? await u.oss.getFileUrl(row.filePath) : "",
|
filePath: row.filePath ? await u.oss.getFileUrl(row.filePath) : "",
|
||||||
selected: selectedIds.has(row.id),
|
selected: selectedIds.has(row.id),
|
||||||
storyboard: row.storyboardId,
|
videoParametersId: row.videoParametersId,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -107,25 +107,21 @@ export default router.post(
|
|||||||
if (!visualManual) return res.status(500).send(error("视觉手册未定义"));
|
if (!visualManual) return res.status(500).send(error("视觉手册未定义"));
|
||||||
findItemByName(result, item.name, config.itemType);
|
findItemByName(result, item.name, config.itemType);
|
||||||
|
|
||||||
const systemPrompt = `
|
const systemPrompt = visualManual;
|
||||||
请根据以下参数生成${config.label}提示词:
|
|
||||||
|
|
||||||
**基础参数:**
|
|
||||||
- 小说类型: ${project?.type || "未指定"}
|
|
||||||
- 小说背景: ${project?.intro || "未指定"}
|
|
||||||
|
|
||||||
**${config.nameLabel}设定:**
|
|
||||||
- ${config.nameLabel}名称:${item.name},
|
|
||||||
- ${config.nameLabel}描述:${item.describe},
|
|
||||||
|
|
||||||
请严格按照skill规范生成${item.type === "role" ? "人物角色四视图" : config.label}提示词。
|
|
||||||
${visualManual}
|
|
||||||
`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { _output } = (await u.Ai.Text("universalAi").invoke({
|
const { _output } = (await u.Ai.Text("universalAi").invoke({
|
||||||
system: systemPrompt,
|
system: systemPrompt,
|
||||||
messages: [{ role: "user", content: "小说原文" + novelText }],
|
messages: [
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: `
|
||||||
|
**基础参数:**
|
||||||
|
**${config.nameLabel}设定:**
|
||||||
|
- ${config.nameLabel}名称:${item.name},
|
||||||
|
- ${config.nameLabel}描述:${item.describe},`,
|
||||||
|
},
|
||||||
|
],
|
||||||
})) as any;
|
})) as any;
|
||||||
|
|
||||||
if (!_output) {
|
if (!_output) {
|
||||||
|
|||||||
@ -101,25 +101,20 @@ export default router.post(
|
|||||||
const novelData = (await u.db("o_novel").whereIn("chapterIndex", [1]).select("*")) as NovelChapter[];
|
const novelData = (await u.db("o_novel").whereIn("chapterIndex", [1]).select("*")) as NovelChapter[];
|
||||||
const novelText = mergeNovelText(novelData);
|
const novelText = mergeNovelText(novelData);
|
||||||
|
|
||||||
const systemPrompt = `
|
const systemPrompt = visualManual;
|
||||||
请根据以下参数生成${config.label}提示词:
|
|
||||||
|
|
||||||
**基础参数:**
|
|
||||||
- 小说类型: ${project?.type || "未指定"}
|
|
||||||
- 小说背景: ${project?.intro || "未指定"}
|
|
||||||
|
|
||||||
**${config.nameLabel}设定:**
|
|
||||||
- ${config.nameLabel}名称:${name},
|
|
||||||
- ${config.nameLabel}描述:${describe},
|
|
||||||
|
|
||||||
请严格按照skill规范生成${type === "role" ? "人物角色四视图" : config.label}提示词
|
|
||||||
${visualManual}。
|
|
||||||
`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { _output } = (await u.Ai.Text("universalAi").invoke({
|
const { _output } = (await u.Ai.Text("universalAi").invoke({
|
||||||
system: systemPrompt,
|
system: systemPrompt,
|
||||||
messages: [{ role: "user", content: "小说原文" + novelText }],
|
messages: [
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: `**基础参数:**
|
||||||
|
**${config.nameLabel}设定:**
|
||||||
|
- ${config.nameLabel}名称:${name},
|
||||||
|
- ${config.nameLabel}描述:${describe},`,
|
||||||
|
},
|
||||||
|
],
|
||||||
})) as any;
|
})) as any;
|
||||||
|
|
||||||
if (!_output) return res.status(500).send("失败");
|
if (!_output) return res.status(500).send("失败");
|
||||||
|
|||||||
@ -73,11 +73,24 @@ export default router.post(
|
|||||||
storyboard: [],
|
storyboard: [],
|
||||||
//todo:矫正workbench数据
|
//todo:矫正workbench数据
|
||||||
workbench: {
|
workbench: {
|
||||||
name: scriptData?.name ?? "",
|
videoList: [
|
||||||
duration: "01:03",
|
{
|
||||||
resolution: "1920×1080",
|
id: 1,
|
||||||
fps: "30fps",
|
prompt: "动起来",
|
||||||
gradient: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
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:矫正封面数据
|
//todo:矫正封面数据
|
||||||
poster: {
|
poster: {
|
||||||
|
|||||||
@ -7,36 +7,25 @@ const router = express.Router();
|
|||||||
export default router.post(
|
export default router.post(
|
||||||
"/",
|
"/",
|
||||||
validateFields({
|
validateFields({
|
||||||
scriptId: z.number(),
|
ids: z.array(z.number()),
|
||||||
projectId: z.number(),
|
|
||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { scriptId, projectId } = req.body;
|
const { ids } = 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 storyboardConfigs = await u.db("o_videoConfig").whereIn("storyboardId", storyboardIds).select("*");
|
const storyboardConfigs = await u.db("o_videoConfig").whereIn("storyboardId", ids).select("*");
|
||||||
const storyboardConfigsList = await Promise.all(
|
|
||||||
storyboardConfigs.map(async (item) => {
|
//查询视频数据
|
||||||
if (item.data) {
|
const videos = await u.db("o_video").whereIn("storyboardId", ids).select("*");
|
||||||
const parsedData = JSON.parse(item.data);
|
|
||||||
|
//组装数据
|
||||||
|
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(
|
const dataWithFilePath = await Promise.all(
|
||||||
parsedData.map(async (d: { type: string; id: number }) => {
|
parsedData.map(async (d: { type: string; id: number }) => {
|
||||||
if (d.type === "assets" && d.id) {
|
if (d.type === "assets" && d.id) {
|
||||||
@ -61,35 +50,25 @@ export default router.post(
|
|||||||
return null;
|
return null;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
config = { ...configRow, data: dataWithFilePath };
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
data: dataWithFilePath,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}),
|
|
||||||
);
|
|
||||||
//查询视频数据
|
|
||||||
const videos = await u.db("o_video").whereIn("storyboardId", storyboardIds).select("*");
|
|
||||||
|
|
||||||
const videosList = await Promise.all(
|
// 处理视频
|
||||||
videos.map(async (item) => {
|
const storyboardVideos = videos.filter((v) => v.storyboardId === storyboardId);
|
||||||
|
const videosList = await Promise.all(
|
||||||
|
storyboardVideos.map(async (item) => ({
|
||||||
|
...item,
|
||||||
|
filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : null,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
id: storyboardId,
|
||||||
filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : null,
|
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));
|
return res.status(200).send(success(data));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -8,12 +8,12 @@ const router = express.Router();
|
|||||||
export default router.post(
|
export default router.post(
|
||||||
"/",
|
"/",
|
||||||
validateFields({
|
validateFields({
|
||||||
scriptId: z.number(),
|
id: z.number(),
|
||||||
specifyIds: z.array(z.number()),
|
specifyIds: z.array(z.number()),
|
||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { scriptId, specifyIds } = req.body;
|
const { id, specifyIds } = req.body;
|
||||||
const data = await u.db("o_video").where("scriptId", scriptId).whereIn("id", specifyIds).andWhere("state", "生成中").select("*");
|
const data = await u.db("o_video").where("id", id).whereIn("id", specifyIds).andWhere("state", "生成中").select("*");
|
||||||
res.status(200).send(success(data));
|
res.status(200).send(success(data));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
Loading…
x
Reference in New Issue
Block a user