完善剧本agent流
This commit is contained in:
parent
41c6bd0991
commit
4946ada3ca
@ -1,4 +1 @@
|
|||||||
<!-- 用户让你输出故事骨架/改变策略/剧本的时候请调用 subAgent 执行,并直接输出 100 字以内的假数据 -->
|
用户让你输出故事骨架/改变策略/剧本的时候请调用 subAgent 执行,并直接输出 100 字以内的假数据
|
||||||
|
|
||||||
|
|
||||||
请直接调用delete_script删除name=xxx的剧本,不需要执行其他操作
|
|
||||||
|
|||||||
@ -83,17 +83,6 @@ export default (toolCpnfig: ToolConfig) => {
|
|||||||
return text ?? "无数据";
|
return text ?? "无数据";
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
delete_script: tool({
|
|
||||||
description: "删除剧本,你需要先获取get_planData",
|
|
||||||
inputSchema: z.object({
|
|
||||||
name: z.string().describe("剧本名字"),
|
|
||||||
}),
|
|
||||||
execute: async ({ name }) => {
|
|
||||||
console.log("[tools] delete_script", name);
|
|
||||||
await new Promise((resolve) => socket.emit("delScript", { name }, (res: any) => resolve(res)));
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
return toolsNames ? Object.fromEntries(Object.entries(tools).filter(([n]) => toolsNames.includes(n))) : tools;
|
return toolsNames ? Object.fromEntries(Object.entries(tools).filter(([n]) => toolsNames.includes(n))) : tools;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -13,9 +13,9 @@ export default router.post(
|
|||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { projectId, agentType } = req.body;
|
const { projectId, agentType } = req.body;
|
||||||
const data = await u.db("o_agentWorkData").where({ projectId: projectId, key: agentType }).first();
|
const row = await u.db("o_agentWorkData").where({ projectId: projectId, key: agentType }).first();
|
||||||
|
|
||||||
if (!data) {
|
if (!row) {
|
||||||
await u.db("o_agentWorkData").insert({
|
await u.db("o_agentWorkData").insert({
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
key: agentType,
|
key: agentType,
|
||||||
@ -31,6 +31,9 @@ export default router.post(
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
res.status(200).send(success(JSON.parse(data.data ?? "{}")));
|
const data = JSON.parse(row.data ?? "{}");
|
||||||
|
data.script = await u.db("o_script").where({ projectId }).select("id", "name", "content");
|
||||||
|
|
||||||
|
res.status(200).send(success(data));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -23,6 +23,19 @@ export default router.post(
|
|||||||
.update({
|
.update({
|
||||||
data: JSON.stringify(data),
|
data: JSON.stringify(data),
|
||||||
});
|
});
|
||||||
|
const script = data.script;
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
script.map(async (s: any) => {
|
||||||
|
const row = await u.db("o_script").where({ projectId, name: s.name }).first();
|
||||||
|
if (row) {
|
||||||
|
await u.db("o_script").where({ id: row.id }).update({ content: s.content });
|
||||||
|
} else {
|
||||||
|
await u.db("o_script").insert({ projectId, name: s.name, content: s.content });
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
res.status(200).send(success());
|
res.status(200).send(success());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user