Merge branch '108' of https://github.com/HBAI-Ltd/Toonflow-app into 108
# Conflicts: # src/types/database.d.ts
This commit is contained in:
commit
3a260ab8a3
@ -1,58 +0,0 @@
|
||||
[
|
||||
{
|
||||
"skillId": "52c51fa8655f899a1b7aae9b6aad7251",
|
||||
"attribution": "universal_agent.md"
|
||||
},
|
||||
{
|
||||
"skillId": "6d46cdca10b2f49e07e515885d1387a0",
|
||||
"attribution": "universal_agent.md"
|
||||
},
|
||||
{
|
||||
"skillId": "1864df75d1d65f76e275046649ecaef8",
|
||||
"attribution": "universal_agent.md"
|
||||
},
|
||||
{
|
||||
"skillId": "3e5efec258c8d8e6a39bcef12f8ee058",
|
||||
"attribution": "universal_agent.md"
|
||||
},
|
||||
{
|
||||
"skillId": "7fbce6f90d7d85496ba9817e9622e640",
|
||||
"attribution": "universal_agent.md"
|
||||
},
|
||||
{
|
||||
"skillId": "31fb5c5a1f514ec1e66b4eba9f22d4db",
|
||||
"attribution": "script_agent_decision.md"
|
||||
},
|
||||
{
|
||||
"skillId": "27dc2dfc901de2180227d0269217583a",
|
||||
"attribution": "script_agent_execution.md"
|
||||
},
|
||||
{
|
||||
"skillId": "d49fa09504fe784a8e6eb102756c6d56",
|
||||
"attribution": "script_agent_execution.md"
|
||||
},
|
||||
{
|
||||
"skillId": "797906c2ddf0750f050bcdeae23eae3d",
|
||||
"attribution": "script_agent_execution.md"
|
||||
},
|
||||
{
|
||||
"skillId": "1abd8675c0c3e62b20c0b151d2ec0fb1",
|
||||
"attribution": "script_agent_execution.md"
|
||||
},
|
||||
{
|
||||
"skillId": "0b7828d7a6ab458a4b201122f08d6c16",
|
||||
"attribution": "script_agent_supervision.md"
|
||||
},
|
||||
{
|
||||
"skillId": "5c1772b5f9c420d9eae9ca02914ba087",
|
||||
"attribution": "production_agent_decision.md"
|
||||
},
|
||||
{
|
||||
"skillId": "75a45cf996015ca819582873887ec301",
|
||||
"attribution": "production_agent_execution.md"
|
||||
},
|
||||
{
|
||||
"skillId": "fce75f69d704c19bebcb356bc1bd6e81",
|
||||
"attribution": "production_agent_execution.md"
|
||||
}
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
@ -83,13 +83,13 @@ export default router.post(
|
||||
});
|
||||
});
|
||||
const result: ResultItem[] = Object.values(itemMap);
|
||||
// 批量更新所有 item 状态为生成中
|
||||
const assetsIds = items.map((item: { assetsId: number }) => item.assetsId);
|
||||
await u.db("o_assets").whereIn("id", assetsIds).update({ promptState: "生成中" });
|
||||
//查询所有资产,用于判断每个资产是否是衍生资产
|
||||
const assetsDataList = await u.db("o_assets").whereIn("id", assetsIds).select("id", "assetsId");
|
||||
if (!assetsDataList || assetsDataList.length === 0) return res.status(500).send(error("资产不存在"));
|
||||
const assetsDataMap = new Map(assetsDataList.map((a: any) => [a.id, a]));
|
||||
// 所有前置检测通过后,再批量更新状态为生成中
|
||||
await u.db("o_assets").whereIn("id", assetsIds).update({ promptState: "生成中" });
|
||||
|
||||
const getTypeConfig = (
|
||||
isDerivative: boolean,
|
||||
@ -128,7 +128,10 @@ export default router.post(
|
||||
if (!config) return;
|
||||
//获取到视觉手册
|
||||
const visualManual = await u.getArtPrompt(project.artStyle as string, "art_skills", config.visualManual);
|
||||
if (!visualManual) return res.status(500).send(error("视觉手册未定义"));
|
||||
if (!visualManual) {
|
||||
await u.db("o_assets").where("id", item.assetsId).update({ promptState: "生成失败", promptErrorReason: "视觉手册未定义" });
|
||||
return;
|
||||
}
|
||||
findItemByName(result, item.name, config.itemType);
|
||||
const systemPrompt = visualManual;
|
||||
try {
|
||||
|
||||
@ -108,8 +108,6 @@ export default router.post(
|
||||
if (!config.visualManual) return res.status(500).send(error("视觉手册未定义"));
|
||||
//获取到视觉手册
|
||||
const visualManual = await u.getArtPrompt(project.artStyle as string, "art_skills", config.visualManual);
|
||||
console.log("%c Line:111 🍬 visualManual", "background:#6ec1c2", visualManual);
|
||||
return
|
||||
if (!visualManual) return res.status(500).send(error("视觉手册未定义"));
|
||||
findItemByName(result, name, config.itemType);
|
||||
const systemPrompt = visualManual;
|
||||
|
||||
@ -27,7 +27,7 @@ export default router.post(
|
||||
.db("o_assets")
|
||||
.leftJoin("o_image", "o_assets.imageId", "o_image.id")
|
||||
.whereIn("o_assets.id", parentIds as number[])
|
||||
.select("o_assets.id", "o_image.filePath");
|
||||
.select("o_assets.id", "o_image.filePath", "o_assets.describe");
|
||||
const assetsSrcArr = await Promise.all(
|
||||
parentAssetsData.map(async (item) => {
|
||||
return {
|
||||
@ -36,6 +36,12 @@ export default router.post(
|
||||
};
|
||||
}),
|
||||
);
|
||||
assetsDataArr.forEach((i: any) => {
|
||||
const parent = parentAssetsData.find((item) => item.id === i.assetsId);
|
||||
if (parent) {
|
||||
i.parentDescribe = parent.describe;
|
||||
}
|
||||
});
|
||||
const imageUrlRecord: Record<number, string> = {};
|
||||
assetsSrcArr.forEach((item) => {
|
||||
imageUrlRecord[item.id] = item.src;
|
||||
@ -70,7 +76,7 @@ export default router.post(
|
||||
|
||||
const imageData: { id: number; state: string; src: string }[] = [];
|
||||
res.status(200).send(success("开始生成资产图片"));
|
||||
const generateSingleAsset = async (item: (typeof assetsDataArr)[number]) => {
|
||||
const generateSingleAsset = async (item: any) => {
|
||||
const imageId = imageIdMap[item.id!];
|
||||
const typeConfig = promptRecord[item.type!] || promptRecord["role"];
|
||||
|
||||
@ -79,7 +85,9 @@ export default router.post(
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: `资产描述: ${item.describe || "无详细描述"}`,
|
||||
content: `
|
||||
父级资产描述: ${item.parentDescribe || "无详细描述"}
|
||||
当前资产描述: ${item.describe || "无详细描述"}`,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@ -24,7 +24,7 @@ export default router.post(
|
||||
inputValues: JSON.stringify(inputValue),
|
||||
});
|
||||
try {
|
||||
const resText = await u.Ai.Text(`toonflow:gpt-4.1`).invoke({
|
||||
const resText = await u.Ai.Text(`toonflow:claude-haiku-4-5-20251001`).invoke({
|
||||
prompt: "1+1等于几?",
|
||||
});
|
||||
if (resText.text) {
|
||||
@ -46,6 +46,7 @@ export default router.post(
|
||||
res.status(200).send(success("一键填入成功"));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
inputValue.apiKey = "";
|
||||
await u
|
||||
.db("o_vendorConfig")
|
||||
|
||||
@ -76,7 +76,7 @@ export default router.post(
|
||||
for await (const chunk of textStream) {
|
||||
fullResponse += chunk;
|
||||
}
|
||||
if(!fullResponse) return res.status(500).send(error("模型未返回结果"));
|
||||
if (!fullResponse) return res.status(500).send(error("模型未返回结果"));
|
||||
res.status(200).send(success(fullResponse));
|
||||
} else {
|
||||
const aiTypeFn = {
|
||||
@ -87,11 +87,11 @@ export default router.post(
|
||||
...reqConfig.modelData,
|
||||
});
|
||||
await reqFn.save(type == "video" ? "test.mp4" : "testImage.jpg");
|
||||
|
||||
const resultUrl = await u.oss.getFileUrl(type == "video" ? "test.mp4" : "testImage.jpg");
|
||||
res.status(200).send(success(resultUrl));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
const msg = u.error(err).message;
|
||||
console.error(msg);
|
||||
res.status(500).send(error(msg));
|
||||
|
||||
@ -1,36 +1,12 @@
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import u from "@/utils";
|
||||
import fs from "fs";
|
||||
import Memory from "@/utils/agent/memory";
|
||||
|
||||
|
||||
function buildMemPrompt(mem: Awaited<ReturnType<Memory["get"]>>): string {
|
||||
let memoryContext = "";
|
||||
if (mem.rag.length) {
|
||||
memoryContext += `[相关记忆]\n${mem.rag.map((r) => r.content).join("\n")}`;
|
||||
}
|
||||
if (mem.summaries.length) {
|
||||
if (memoryContext) memoryContext += "\n\n";
|
||||
memoryContext += `[历史摘要]\n${mem.summaries.map((s, i) => `${i + 1}. ${s.content}`).join("\n")}`;
|
||||
}
|
||||
if (mem.shortTerm.length) {
|
||||
if (memoryContext) memoryContext += "\n\n";
|
||||
memoryContext += `[近期对话]\n${mem.shortTerm.map((m) => `${m.role}: ${m.content}`).join("\n")}`;
|
||||
}
|
||||
return `## Memory\n以下是你对用户的记忆,可作为参考但不要主动提及:\n${memoryContext}`;
|
||||
}
|
||||
import fs from 'fs';
|
||||
|
||||
export default router.get("/", async (req, res) => {
|
||||
return res.send("ok");
|
||||
const test = await u.db("o_vendorConfig").select("*");
|
||||
fs.writeFileSync("test.json", JSON.stringify(test, null, 2));
|
||||
|
||||
const isolationKey = "1:productionAgent:1";
|
||||
const input = "你好"
|
||||
|
||||
const memory = new Memory("productionAgent", isolationKey);
|
||||
await memory.add("user", input);
|
||||
|
||||
|
||||
const mem = buildMemPrompt(await memory.get(input));
|
||||
|
||||
res.send(mem);
|
||||
res.send(test);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user