添加提示词表useData,去掉冗余的associationSkills
This commit is contained in:
parent
a12bfd61bc
commit
04b0d4483f
@ -47,4 +47,5 @@ export default async (knex: Knex): Promise<void> => {
|
|||||||
state: "生成失败",
|
state: "生成失败",
|
||||||
errorReason: "软件退出导致失败",
|
errorReason: "软件退出导致失败",
|
||||||
});
|
});
|
||||||
|
await addColumn("o_prompt", "useData", "text");
|
||||||
};
|
};
|
||||||
|
|||||||
@ -196,6 +196,7 @@ export default async (knex: Knex, forceInit: boolean = false): Promise<void> =>
|
|||||||
table.string("name");
|
table.string("name");
|
||||||
table.string("type");
|
table.string("type");
|
||||||
table.text("data");
|
table.text("data");
|
||||||
|
table.text("useData");
|
||||||
table.primary(["id"]);
|
table.primary(["id"]);
|
||||||
table.unique(["id"]);
|
table.unique(["id"]);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -75,6 +75,12 @@ export default router.post(
|
|||||||
const [id, modelData] = model.split(":");
|
const [id, modelData] = model.split(":");
|
||||||
const projectData = await u.db("o_project").select("*").where({ id: projectId }).first();
|
const projectData = await u.db("o_project").select("*").where({ id: projectId }).first();
|
||||||
const videoPrompt = await u.db("o_prompt").where("type", "videoPromptGeneration").first();
|
const videoPrompt = await u.db("o_prompt").where("type", "videoPromptGeneration").first();
|
||||||
|
let videoPromptGeneration = "" as string | undefined;
|
||||||
|
if (videoPrompt && videoPrompt.useData) {
|
||||||
|
videoPromptGeneration = videoPrompt.useData;
|
||||||
|
} else {
|
||||||
|
videoPromptGeneration = videoPrompt?.data ?? undefined;
|
||||||
|
}
|
||||||
const artStyle = projectData?.artStyle || "无";
|
const artStyle = projectData?.artStyle || "无";
|
||||||
const visualManual = u.getArtPrompt(artStyle, "art_skills", "art_storyboard_video");
|
const visualManual = u.getArtPrompt(artStyle, "art_skills", "art_storyboard_video");
|
||||||
const content = `
|
const content = `
|
||||||
@ -94,7 +100,7 @@ export default router.post(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { text } = await u.Ai.Text("universalAi").invoke({
|
const { text } = await u.Ai.Text("universalAi").invoke({
|
||||||
system: videoPrompt?.data!,
|
system: videoPromptGeneration,
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
|
|||||||
@ -65,7 +65,6 @@ export default router.post(
|
|||||||
|
|
||||||
if (!scriptIds.length) return res.status(400).send(error("请先选择剧本"));
|
if (!scriptIds.length) return res.status(400).send(error("请先选择剧本"));
|
||||||
const scripts = await u.db("o_script").whereIn("id", scriptIds);
|
const scripts = await u.db("o_script").whereIn("id", scriptIds);
|
||||||
|
|
||||||
|
|
||||||
// 构建 scriptId -> script 内容的映射
|
// 构建 scriptId -> script 内容的映射
|
||||||
const scriptMap = new Map(scripts.map((s: o_script) => [s.id, s]));
|
const scriptMap = new Map(scripts.map((s: o_script) => [s.id, s]));
|
||||||
@ -198,7 +197,13 @@ export default router.post(
|
|||||||
return "无需回复用户任何内容";
|
return "无需回复用户任何内容";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const data = await u.db("o_prompt").where("type", "scriptAssetExtraction").first("data");
|
const promptData = await u.db("o_prompt").where("type", "scriptAssetExtraction").first();
|
||||||
|
let scriptAssetExtraction = "" as string | undefined;
|
||||||
|
if (promptData && promptData.useData) {
|
||||||
|
scriptAssetExtraction = promptData.useData;
|
||||||
|
} else {
|
||||||
|
scriptAssetExtraction = promptData?.data ?? undefined;
|
||||||
|
}
|
||||||
const existingHint = existingAssetsList
|
const existingHint = existingAssetsList
|
||||||
? `\n\n【已有资产列表】:${existingAssetsList}\n对于已有资产,如果在剧本中出现,只需在 existingAssetRefs 中给出资产名称和对应的 scriptIds 数组即可,无需重复生成 desc/type。对于新发现的资产(不在已有列表中),请在 newAssets 中给出完整信息。`
|
? `\n\n【已有资产列表】:${existingAssetsList}\n对于已有资产,如果在剧本中出现,只需在 existingAssetRefs 中给出资产名称和对应的 scriptIds 数组即可,无需重复生成 desc/type。对于新发现的资产(不在已有列表中),请在 newAssets 中给出完整信息。`
|
||||||
: "";
|
: "";
|
||||||
@ -207,7 +212,7 @@ export default router.post(
|
|||||||
{
|
{
|
||||||
role: "system",
|
role: "system",
|
||||||
content:
|
content:
|
||||||
data?.data +
|
scriptAssetExtraction +
|
||||||
"\n\n提取剧本中涉及的资产(角色、场景、道具),参考技能 script_assets_extract 规范,结果必须通过 resultTool 工具返回。" +
|
"\n\n提取剧本中涉及的资产(角色、场景、道具),参考技能 script_assets_extract 规范,结果必须通过 resultTool 工具返回。" +
|
||||||
"\n\n注意:本次会同时提供多集剧本,每集剧本以 ===== 【剧本ID: xxx】 ===== 分隔。你需要分析每集剧本使用了哪些资产,并在输出中用 scriptIds 数组标明每个资产在哪些剧本中出现。",
|
"\n\n注意:本次会同时提供多集剧本,每集剧本以 ===== 【剧本ID: xxx】 ===== 分隔。你需要分析每集剧本使用了哪些资产,并在输出中用 scriptIds 数组标明每个资产在哪些剧本中出现。",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,6 +5,14 @@ import { success, error } from "@/lib/responseFormat";
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
export default router.post("/", async (req, res) => {
|
export default router.post("/", async (req, res) => {
|
||||||
const data = await u.db("o_prompt").select("*");
|
const list = await u.db("o_prompt").select("*");
|
||||||
|
const data = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
data: item.useData ? item.useData : item.data,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
res.status(200).send(success(data));
|
res.status(200).send(success(data));
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export default router.post(
|
|||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { id, data } = req.body;
|
const { id, data } = req.body;
|
||||||
await u.db("o_prompt").where("id", id).update({
|
await u.db("o_prompt").where("id", id).update({
|
||||||
data,
|
useData: data,
|
||||||
});
|
});
|
||||||
res.status(200).send(success(123));
|
res.status(200).send(success(123));
|
||||||
},
|
},
|
||||||
|
|||||||
@ -35,7 +35,6 @@ const vendorConfigSchema = z.object({
|
|||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("image"),
|
type: z.literal("image"),
|
||||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||||
associationSkills: z.string().optional(),
|
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
|
|||||||
@ -36,7 +36,6 @@ const vendorConfigSchema = z.object({
|
|||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("image"),
|
type: z.literal("image"),
|
||||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||||
associationSkills: z.string().optional(),
|
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
@ -48,7 +47,6 @@ const vendorConfigSchema = z.object({
|
|||||||
z.array(z.enum(["audioReference", "videoReference", "textReference", "imageReference"])),
|
z.array(z.enum(["audioReference", "videoReference", "textReference", "imageReference"])),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
associationSkills: z.string().optional(),
|
|
||||||
audio: z.union([z.literal("optional"), z.boolean()]),
|
audio: z.union([z.literal("optional"), z.boolean()]),
|
||||||
durationResolutionMap: z.array(
|
durationResolutionMap: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
|
|||||||
@ -33,7 +33,6 @@ export default router.post(
|
|||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("image"),
|
type: z.literal("image"),
|
||||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||||
associationSkills: z.string().optional(),
|
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
@ -45,7 +44,6 @@ export default router.post(
|
|||||||
z.array(z.enum(["audioReference", "videoReference", "textReference", "imageReference"])),
|
z.array(z.enum(["audioReference", "videoReference", "textReference", "imageReference"])),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
associationSkills: z.string().optional(),
|
|
||||||
audio: z.union([z.literal("optional"), z.boolean()]),
|
audio: z.union([z.literal("optional"), z.boolean()]),
|
||||||
durationResolutionMap: z.array(
|
durationResolutionMap: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
|
|||||||
37
src/types/database.d.ts
vendored
37
src/types/database.d.ts
vendored
@ -1,6 +1,37 @@
|
|||||||
// @db-hash 6fa5017e455bc367c9c902ba574d11b4
|
// @db-hash 6cd709d9bdfe00c4dc87961a8ebba149
|
||||||
//该文件由脚本自动生成,请勿手动修改
|
//该文件由脚本自动生成,请勿手动修改
|
||||||
|
|
||||||
|
export interface _o_project_old_20260404 {
|
||||||
|
'artStyle'?: string | null;
|
||||||
|
'createTime'?: number | null;
|
||||||
|
'directorManual'?: string | null;
|
||||||
|
'id'?: number | null;
|
||||||
|
'imageModel'?: string | null;
|
||||||
|
'imageQuality'?: string | null;
|
||||||
|
'intro'?: string | null;
|
||||||
|
'mode'?: string | null;
|
||||||
|
'name'?: string | null;
|
||||||
|
'projectType'?: string | null;
|
||||||
|
'type'?: string | null;
|
||||||
|
'userId'?: number | null;
|
||||||
|
'videoModel'?: string | null;
|
||||||
|
'videoRatio'?: string | null;
|
||||||
|
}
|
||||||
|
export interface _o_prompt_old_20260406 {
|
||||||
|
'data'?: string | null;
|
||||||
|
'id'?: number;
|
||||||
|
'name'?: string | null;
|
||||||
|
'type'?: string | null;
|
||||||
|
'useData'?: string | null;
|
||||||
|
}
|
||||||
|
export interface _o_prompt_old_20260406_1 {
|
||||||
|
'data'?: string | null;
|
||||||
|
'id'?: number;
|
||||||
|
'name'?: string | null;
|
||||||
|
'TEXT'?: any | null;
|
||||||
|
'type'?: string | null;
|
||||||
|
'useData'?: string | null;
|
||||||
|
}
|
||||||
export interface memories {
|
export interface memories {
|
||||||
'content': string;
|
'content': string;
|
||||||
'createTime': number;
|
'createTime': number;
|
||||||
@ -128,6 +159,7 @@ export interface o_prompt {
|
|||||||
'id'?: number;
|
'id'?: number;
|
||||||
'name'?: string | null;
|
'name'?: string | null;
|
||||||
'type'?: string | null;
|
'type'?: string | null;
|
||||||
|
'useData'?: string | null;
|
||||||
}
|
}
|
||||||
export interface o_script {
|
export interface o_script {
|
||||||
'content'?: string | null;
|
'content'?: string | null;
|
||||||
@ -231,6 +263,9 @@ export interface o_videoTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DB {
|
export interface DB {
|
||||||
|
"_o_project_old_20260404": _o_project_old_20260404;
|
||||||
|
"_o_prompt_old_20260406": _o_prompt_old_20260406;
|
||||||
|
"_o_prompt_old_20260406_1": _o_prompt_old_20260406_1;
|
||||||
"memories": memories;
|
"memories": memories;
|
||||||
"o_agentDeploy": o_agentDeploy;
|
"o_agentDeploy": o_agentDeploy;
|
||||||
"o_agentWorkData": o_agentWorkData;
|
"o_agentWorkData": o_agentWorkData;
|
||||||
|
|||||||
@ -27,9 +27,15 @@ class CleanNovel {
|
|||||||
private async processChapter(novel: o_novel): Promise<EventType | null> {
|
private async processChapter(novel: o_novel): Promise<EventType | null> {
|
||||||
try {
|
try {
|
||||||
const prompt = await u.getPrompts("event");
|
const prompt = await u.getPrompts("event");
|
||||||
const data = await u.db("o_prompt").where("type", "eventExtraction").first("data");
|
const promptData = await u.db("o_prompt").where("type", "eventExtraction").first();
|
||||||
|
let eventExtraction = "" as string | undefined;
|
||||||
|
if (promptData && promptData.useData) {
|
||||||
|
eventExtraction = promptData.useData;
|
||||||
|
} else {
|
||||||
|
eventExtraction = promptData?.data ?? undefined;
|
||||||
|
}
|
||||||
const resData = await u.Ai.Text("universalAi").invoke({
|
const resData = await u.Ai.Text("universalAi").invoke({
|
||||||
system: data ? JSON.stringify(data.data) : (prompt as string),
|
system: eventExtraction ? JSON.stringify(eventExtraction) : (prompt as string),
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: "user",
|
role: "user",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user