修正一配置,修正跳转方法

This commit is contained in:
ACT丶流星雨 2026-04-03 07:00:58 +08:00
parent 9923b900d3
commit 467f1f93c1
2 changed files with 235 additions and 218 deletions

File diff suppressed because one or more lines are too long

View File

@ -8,51 +8,68 @@ const router = express.Router();
export default router.post( export default router.post(
"/", "/",
validateFields({ validateFields({
key: z.string(), key: z.string().optional(),
}), }),
async (req, res) => { async (req, res) => {
const { key } = req.body; await u.db("o_agentDeploy").where("key", "scriptAgent").update({
const vendorConfigData = await u.db("o_vendorConfig").where("id", "toonflow").first(); model: "claude-sonnet-4-6",
if (!vendorConfigData) return res.status(500).send(error("未找到该供应商配置")); modelName: "toonflow:claude-sonnet-4-6",
if (!vendorConfigData.inputValues) return res.status(500).send(error("未找到模型配置数据")); vendorId: "toonflow",
const inputValue = JSON.parse(vendorConfigData.inputValues!); });
inputValue.apiKey = key; await u.db("o_agentDeploy").where("key", "productionAgent").update({
await u model: "claude-sonnet-4-6",
.db("o_vendorConfig") modelName: "toonflow:claude-sonnet-4-6",
.where("id", "toonflow") vendorId: "toonflow",
.update({ });
inputValues: JSON.stringify(inputValue), await u.db("o_agentDeploy").where("key", "universalAi").update({
}); model: "claude-haiku-4-5",
try { modelName: "toonflow:claude-haiku-4-5-20251001",
const resText = await u.Ai.Text(`toonflow:claude-haiku-4-5-20251001`).invoke({ vendorId: "toonflow",
prompt: "1+1等于几", });
}); res.status(200).send(success("一键填入成功"));
if (resText.text) {
await u.db("o_agentDeploy").where("key", "scriptAgent").update({ // const { key } = req.body;
model: "claude-sonnet-4-6", // const vendorConfigData = await u.db("o_vendorConfig").where("id", "toonflow").first();
modelName: "toonflow:claude-sonnet-4-6", // if (!vendorConfigData) return res.status(500).send(error("未找到该供应商配置"));
vendorId: "toonflow", // if (!vendorConfigData.inputValues) return res.status(500).send(error("未找到模型配置数据"));
}); // const inputValue = JSON.parse(vendorConfigData.inputValues!);
await u.db("o_agentDeploy").where("key", "productionAgent").update({ // inputValue.apiKey = key;
model: "claude-sonnet-4-6", // await u
modelName: "toonflow:claude-sonnet-4-6", // .db("o_vendorConfig")
vendorId: "toonflow", // .where("id", "toonflow")
}); // .update({
await u.db("o_agentDeploy").where("key", "universalAi").update({ // inputValues: JSON.stringify(inputValue),
model: "claude-haiku-4-5", // });
modelName: "toonflow:claude-haiku-4-5-20251001", // try {
vendorId: "toonflow", // const resText = await u.Ai.Text(`toonflow:gpt-4.1`).invoke({
}); // prompt: "1+1等于几",
res.status(200).send(success("一键填入成功")); // });
} // if (resText.text) {
} catch (err) { // await u.db("o_agentDeploy").where("key", "scriptAgent").update({
console.error(err); // model: "claude-sonnet-4-6",
inputValue.apiKey = ""; // modelName: "toonflow:claude-sonnet-4-6",
await u // vendorId: "toonflow",
.db("o_vendorConfig") // });
.where("id", "toonflow") // await u.db("o_agentDeploy").where("key", "productionAgent").update({
.update({ inputValues: JSON.stringify(inputValue) }); // model: "claude-sonnet-4-6",
res.status(400).send(error("KEY无效请重新输入")); // modelName: "toonflow:claude-sonnet-4-6",
} // vendorId: "toonflow",
// });
// await u.db("o_agentDeploy").where("key", "universalAi").update({
// model: "claude-haiku-4-5",
// modelName: "toonflow:claude-haiku-4-5-20251001",
// vendorId: "toonflow",
// });
// res.status(200).send(success("一键填入成功"));
// }
// } catch (err) {
// console.error(err);
// inputValue.apiKey = "";
// await u
// .db("o_vendorConfig")
// .where("id", "toonflow")
// .update({ inputValues: JSON.stringify(inputValue) });
// res.status(400).send(error("KEY无效请重新输入"));
// }
}, },
); );