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