Merge branch '108' of https://github.com/HBAI-Ltd/Toonflow-app into 108
This commit is contained in:
commit
3a3b756e14
@ -260,6 +260,101 @@ export default async (knex: Knex, forceInit: boolean = false): Promise<void> =>
|
||||
type: "assetsPromptGeneration",
|
||||
data: "# 资产提示词生成指令 根据提供的项目参数和资产设定,生成符合要求的提示词\n\n请根据以下参数生成提示词:\n\n**基础参数:**\n- 风格: {风格}\n- 小说类型: {小说类型}\n- 小说背景: {小说背景}\n\n**资产设定:**\n- 类型: {角色/场景/道具}\n- 名称:{名称}\n- 描述:{描述}\n\n请严格按照skill规范生成提示词。",
|
||||
},
|
||||
{
|
||||
name: "剧本资产提取",
|
||||
type: "scriptAssetExtraction",
|
||||
data: `
|
||||
---
|
||||
name: universal_agent
|
||||
description: 专注于从剧本内容中提取所使用的资产(角色、场景、道具)并生成结构化资产列表的助手。
|
||||
---
|
||||
|
||||
# Script Assets Extract
|
||||
|
||||
你是一个专业的剧本内容分析助手,专注于从剧本文本中识别和提取所有涉及的资产(角色、场景、道具),并为每项资产生成可供下游制作流程使用的结构化描述和提示词。
|
||||
|
||||
## 何时使用
|
||||
|
||||
用户提供剧本内容,你需要逐段阅读并提取其中涉及的所有资产(人物角色、场景地点、道具物件),输出为结构化的资产列表。产出的资产描述将用于后续 AI 图片生成和制作流程。
|
||||
|
||||
## 与系统的对应关系
|
||||
|
||||
- 资产类型:
|
||||
- \`role\` — 角色(对应 \`o_assets.type = "role"\`)
|
||||
- \`scene\` — 场景(对应 \`o_assets.type = "scene"\`)
|
||||
- \`tool\` — 道具(对应 \`o_assets.type = "tool"\`)
|
||||
- 下游用途:资产提示词生成 → AI 资产图生成 → 分镜制作
|
||||
|
||||
## 输出要求
|
||||
|
||||
**必须通过调用 \`resultTool\` 工具返回结果**,禁止以纯文本、Markdown 表格或 JSON 代码块等形式直接输出资产列表。
|
||||
\`resultTool\` 的 schema 会对字段类型和枚举值做强校验,调用时请严格按照下方字段定义填写,确保数据结构正确、字段完整、类型匹配。
|
||||
|
||||
每个资产对象包含以下字段:
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| ---- | ---- | ---- | ---- |
|
||||
| \`name\` | string | 是 | 资产名称,使用剧本中的原始称呼,不做其他多余描述 |
|
||||
| \`desc\` | string | 是 | 资产描述,30-80 字的视觉化描述 |
|
||||
| \`prompt\` | string | 是 | 生成提示词,英文,用于 AI 图片生成 |
|
||||
| \`type\` | enum | 是 | 资产类型:\`role\` / \`scene\` / \`tool\` |
|
||||
|
||||
## 提取规则
|
||||
|
||||
### 角色(role)
|
||||
|
||||
- 提取剧本中出现的所有有名字的角色
|
||||
- \`desc\`:包含外貌特征、服饰风格、体态气质等视觉要素
|
||||
- \`prompt\`:英文提示词,描述角色的外观特征,适用于 AI 角色图生成
|
||||
- 同一角色有多个称呼时,取最常用的作为 \`name\`
|
||||
- 无名龙套(如"路人甲"、"士兵")可跳过,除非其造型对剧情有重要视觉意义
|
||||
|
||||
### 场景(scene)
|
||||
|
||||
- 提取剧本中出现的所有场景/地点
|
||||
- \`desc\`:包含空间结构、光照氛围、关键陈设、色调基调等视觉要素
|
||||
- \`prompt\`:英文提示词,描述场景的整体视觉风格,适用于 AI 场景图生成
|
||||
- 同一场景的不同状态(如白天/夜晚)不重复提取,在 \`desc\` 中注明即可
|
||||
|
||||
### 道具(tool)
|
||||
|
||||
- 提取剧本中出现的重要道具/物品
|
||||
- \`desc\`:包含外观形状、颜色材质、尺寸参考、特殊效果等视觉要素
|
||||
- \`prompt\`:英文提示词,描述道具的外观细节,适用于 AI 道具图生成
|
||||
- 仅提取有独立视觉意义或剧情功能的道具,通用物品可跳过
|
||||
|
||||
|
||||
## 提示词(prompt)生成规范
|
||||
|
||||
- 采用逗号分隔的关键词/短语格式
|
||||
- 优先描述**视觉特征**,避免抽象概念
|
||||
- 包含风格关键词(如 anime style, manga style 等,根据项目风格决定)
|
||||
- 角色 prompt 示例:\`a young man, sharp eyebrows, black hair, pale skin, wearing a gray Taoist robe, slender build, cold expression\`
|
||||
- 场景 prompt 示例:\`dark cave interior, glowing crystals on walls, misty atmosphere, dim blue lighting, stone altar in center\`
|
||||
- 道具 prompt 示例:\`ancient jade pendant, oval shape, translucent green, carved dragon pattern, glowing faintly\`
|
||||
|
||||
## 提取流程
|
||||
|
||||
1. 通读剧本全文,识别所有出现的角色、场景、道具
|
||||
2. 对每个资产生成结构化的 \`name\`、\`desc\`、\`prompt\`、\`type\`
|
||||
3. 去重:同一资产不重复提取
|
||||
4. **必须通过调用 \`resultTool\` 工具输出完整资产列表**,不要分多次调用,一次性将所有资产放入 \`assetsList\` 数组中提交
|
||||
|
||||
## 提取原则
|
||||
|
||||
1. **忠于剧本**:所有提取基于剧本中的实际内容,不臆造未出现的资产
|
||||
2. **视觉优先**:描述和提示词聚焦视觉特征,便于 AI 图片生成
|
||||
3. **精简实用**:只提取对制作有实际意义的资产,避免过度提取
|
||||
4. **分类准确**:严格按照 role/scene/tool 分类,不混淆
|
||||
5. **提示词质量**:英文提示词应具体、可执行,能直接用于 AI 图片生成
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 资产列表中**不要包含剧本内容本身**,仅提取所使用到的资产
|
||||
- 角色的随身物品如果有独立剧情功能,应单独作为道具提取
|
||||
- 场景中的固定陈设不需要单独提取为道具,除非该物件有独立剧情作用
|
||||
`,
|
||||
},
|
||||
]);
|
||||
},
|
||||
},
|
||||
|
||||
@ -156,13 +156,13 @@ export default router.post(
|
||||
});
|
||||
|
||||
try {
|
||||
const skill = await useSkill("universal_agent.md");//todo:改为AI
|
||||
const data = await u.db("o_prompt").where("type", "scriptAssetExtraction").first("data");
|
||||
await intansce.invoke({
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content:
|
||||
skill.prompt +
|
||||
data?.data +
|
||||
"\n\n提取剧本中涉及的资产(角色、场景、道具),参考技能 script_assets_extract 规范,结果必须通过 resultTool 工具返回。",
|
||||
},
|
||||
{
|
||||
@ -170,13 +170,16 @@ export default router.post(
|
||||
content: `请根据以下剧本提取对应的剧本资产(角色、场景、道具、素材片段):\n\n${script.content}`,
|
||||
},
|
||||
],
|
||||
tools: { ...skill.tools, resultTool },
|
||||
tools: { resultTool },
|
||||
});
|
||||
} catch (e: any) {
|
||||
const msg = e?.message || String(e);
|
||||
console.error(`[extractAssets] scriptId=${scriptId} name=${script.name} 提取失败:`, msg);
|
||||
errors.push({ scriptId, error: script.name + ":" + u.error(e).message });
|
||||
await u.db("o_script").where("id", scriptId).update({ extractState: -1, errorReason: u.error(e).message });
|
||||
await u
|
||||
.db("o_script")
|
||||
.where("id", scriptId)
|
||||
.update({ extractState: -1, errorReason: u.error(e).message });
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
21
src/types/database.d.ts
vendored
21
src/types/database.d.ts
vendored
@ -1,12 +1,18 @@
|
||||
// @db-hash f7bc2fdb80756d5536929eb47155578b
|
||||
// @db-hash e24c7c99757472b92af11f26a2b2b8c7
|
||||
//该文件由脚本自动生成,请勿手动修改
|
||||
|
||||
export interface _o_script_old_20260327 {
|
||||
'content'?: string | null;
|
||||
export interface _o_project_old_20260328 {
|
||||
'artStyle'?: string | null;
|
||||
'createTime'?: number | null;
|
||||
'id'?: number;
|
||||
'id'?: number | null;
|
||||
'imageModel'?: string | null;
|
||||
'intro'?: string | null;
|
||||
'name'?: string | null;
|
||||
'projectId'?: number | null;
|
||||
'projectType'?: string | null;
|
||||
'type'?: string | null;
|
||||
'userId'?: number | null;
|
||||
'videoModel'?: string | null;
|
||||
'videoRatio'?: string | null;
|
||||
}
|
||||
export interface memories {
|
||||
'content': string;
|
||||
@ -54,6 +60,7 @@ export interface o_assets {
|
||||
'name'?: string | null;
|
||||
'projectId'?: number | null;
|
||||
'prompt'?: string | null;
|
||||
'promptState'?: string | null;
|
||||
'remark'?: string | null;
|
||||
'scriptId'?: number | null;
|
||||
'startTime'?: number | null;
|
||||
@ -173,7 +180,7 @@ export interface o_storyboard {
|
||||
'filePath'?: string | null;
|
||||
'frameMode'?: string | null;
|
||||
'id'?: number;
|
||||
'index'?: string | null;
|
||||
'index'?: number | null;
|
||||
'lines'?: string | null;
|
||||
'mode'?: string | null;
|
||||
'model'?: string | null;
|
||||
@ -238,7 +245,7 @@ export interface o_videoConfig {
|
||||
}
|
||||
|
||||
export interface DB {
|
||||
"_o_script_old_20260327": _o_script_old_20260327;
|
||||
"_o_project_old_20260328": _o_project_old_20260328;
|
||||
"memories": memories;
|
||||
"o_agentDeploy": o_agentDeploy;
|
||||
"o_agentWorkData": o_agentWorkData;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user