修复读取skill失败问题
This commit is contained in:
parent
091a96476b
commit
68f2c62c46
2088
data/web/index.html
2088
data/web/index.html
File diff suppressed because one or more lines are too long
@ -63,6 +63,7 @@
|
||||
"knex": "^3.2.5",
|
||||
"lodash": "^4.17.23",
|
||||
"morgan": "^1.10.1",
|
||||
"p-limit": "^7.3.0",
|
||||
"qwen-ai-provider-v5": "^2.1.0",
|
||||
"serialize-error": "^13.0.1",
|
||||
"sharp": "^0.34.5",
|
||||
|
||||
@ -51,7 +51,7 @@ export async function decisionAI(ctx: AgentContext) {
|
||||
const { textStream } = await u.Ai.Text("productionAgent").stream({
|
||||
messages: [
|
||||
{ role: "system", content: prompt },
|
||||
{ role: "system", content: mem },
|
||||
{ role: "assistant", content: mem },
|
||||
{ role: "user", content: text },
|
||||
],
|
||||
abortSignal,
|
||||
@ -174,8 +174,8 @@ function createSubAgent(parentCtx: AgentContext) {
|
||||
}
|
||||
|
||||
async function createArtSkills(artName: string) {
|
||||
const path = u.getPath(["skills", "art_prompts", artName, "driector_skills"]);
|
||||
const skillList = await scanSkills(path + "/*.md");
|
||||
const workerPath = u.getPath(["skills", "art_prompts", artName, "driector_skills"]);
|
||||
const skillList = await scanSkills(workerPath + "/*.md");
|
||||
const mainSkills: { path: string; name: string; description: string }[] = [];
|
||||
for (const skillPath of skillList) {
|
||||
if (!fs.existsSync(skillPath)) throw new Error(`主技能文件不存在: ${skillPath}`);
|
||||
@ -183,8 +183,9 @@ async function createArtSkills(artName: string) {
|
||||
const parsed = parseFrontmatter(content);
|
||||
mainSkills.push({ path: skillPath, ...parsed });
|
||||
}
|
||||
return {
|
||||
const res = {
|
||||
prompt: buildSkillPrompt(mainSkills),
|
||||
tools: createSkillTools(mainSkills, { mainSkill: mainSkills, secondarySkills: [], tertiarySkills: [] }),
|
||||
tools: createSkillTools(mainSkills, { mainSkill: mainSkills, secondarySkills: [], tertiarySkills: [] },workerPath),
|
||||
};
|
||||
}
|
||||
return res
|
||||
}
|
||||
@ -53,7 +53,7 @@ const posterItemSchema = z.object({
|
||||
id: z.number().describe("海报ID"),
|
||||
image: z.string().describe("海报图片路径"),
|
||||
});
|
||||
const flowDataSchema = z.object({
|
||||
export const flowDataSchema = z.object({
|
||||
script: z.string().describe("剧本内容"),
|
||||
scriptPlan: z.string().describe("拍摄计划"),
|
||||
assets: z.array(assetItemSchema).describe("衍生资产"),
|
||||
@ -148,42 +148,6 @@ export default (toolCpnfig: ToolConfig) => {
|
||||
return res ?? "删除成功";
|
||||
},
|
||||
}),
|
||||
|
||||
add_storyboard: tool({
|
||||
description: "新增或更新分镜面板",
|
||||
inputSchema: z.object({
|
||||
id: z.number().nullable().describe("分镜面板ID,如果新增则为空"),
|
||||
title: z.string().describe("分镜面板名称"),
|
||||
desc: z.string().describe("分镜面板描述"),
|
||||
group: z.number().describe("分镜面板分组,根据这个字段 对分镜图片,进行同时生成视频,例如 同一分组的两张图片会被用于首尾帧生成视频"),
|
||||
}),
|
||||
execute: async (storyboard) => {
|
||||
const thinking = msg.thinking("正在操作资产...");
|
||||
const { projectId, scriptId } = resTool.data;
|
||||
const createTime = Date.now();
|
||||
console.log("%c Line:161 🍤 storyboard", "background:#e41a6a", storyboard);
|
||||
|
||||
const data = {
|
||||
id: storyboard.id ?? undefined,
|
||||
title: storyboard.title,
|
||||
description: storyboard.desc,
|
||||
createTime,
|
||||
scriptId,
|
||||
};
|
||||
if (storyboard.id) {
|
||||
await u.db("o_storyboard").where("id", storyboard.id).update(data);
|
||||
thinking.appendText(`已更新分镜面板,ID: ${storyboard.id}\n`);
|
||||
} else {
|
||||
const [insertedId] = await u.db("o_storyboard").insert(data);
|
||||
data.id = insertedId;
|
||||
thinking.appendText(`已新增分镜面板,ID: ${insertedId}\n`);
|
||||
}
|
||||
const res = await new Promise((resolve) => socket.emit("addStoryboard", data, (res: any) => resolve(res)));
|
||||
thinking.updateTitle("分镜面板操作完成");
|
||||
thinking.complete();
|
||||
return res ?? "操作成功";
|
||||
},
|
||||
}),
|
||||
generate_deriveAsset: tool({
|
||||
description: "生成衍生资产",
|
||||
inputSchema: z.object({
|
||||
|
||||
@ -41,7 +41,6 @@ export default router.post(
|
||||
},
|
||||
],
|
||||
});
|
||||
console.log("%c Line:35 🎂 text", "background:#3f7cff", text);
|
||||
|
||||
const repeloadObj = {
|
||||
prompt: text,
|
||||
|
||||
@ -177,9 +177,9 @@ ${skillEntries}
|
||||
</available_skills>`;
|
||||
}
|
||||
|
||||
export function createSkillTools(skills: { name: string; description: string }[], skillPaths: SkillPaths) {
|
||||
export function createSkillTools(skills: { name: string; description: string }[], skillPaths: SkillPaths, rootDir: string = getPath("skills")) {
|
||||
const activated = new Set<string>(); // 已激活技能集合,防止重复加载
|
||||
const skillsRootDir = path.resolve(getPath("skills"));
|
||||
const skillsRootDir = path.resolve(rootDir);
|
||||
const skillNames = skills.map((s) => s.name);
|
||||
const skillMap = new Map(skillPaths.mainSkill.map((s) => [s.name, s]));
|
||||
return {
|
||||
|
||||
12
yarn.lock
12
yarn.lock
@ -4022,6 +4022,13 @@ p-cancelable@^2.0.0:
|
||||
dependencies:
|
||||
yocto-queue "^0.1.0"
|
||||
|
||||
p-limit@^7.3.0:
|
||||
version "7.3.0"
|
||||
resolved "https://registry.npmmirror.com/p-limit/-/p-limit-7.3.0.tgz#821398d91491c6b6a1340ecd09cdc402a9c8d0ee"
|
||||
integrity sha512-7cIXg/Z0M5WZRblrsOla88S4wAK+zOQQWeBYfV3qJuJXMr+LnbYjaadrFaS0JILfEDPVqHyKnZ1Z/1d6J9VVUw==
|
||||
dependencies:
|
||||
yocto-queue "^1.2.1"
|
||||
|
||||
p-map@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.npmmirror.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b"
|
||||
@ -5536,6 +5543,11 @@ yocto-queue@^0.1.0:
|
||||
resolved "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
|
||||
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
|
||||
|
||||
yocto-queue@^1.2.1:
|
||||
version "1.2.2"
|
||||
resolved "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-1.2.2.tgz#3e09c95d3f1aa89a58c114c99223edf639152c00"
|
||||
integrity sha512-4LCcse/U2MHZ63HAJVE+v71o7yOdIe4cZ70Wpf8D/IyjDKYQLV5GD46B+hSTjJsvV5PztjvHoU580EftxjDZFQ==
|
||||
|
||||
zhipu-ai-provider@^0.2.2:
|
||||
version "0.2.2"
|
||||
resolved "https://registry.npmmirror.com/zhipu-ai-provider/-/zhipu-ai-provider-0.2.2.tgz#cbee428475b1c2fca446f273ac09006ef86f6f00"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user