加一套抓真实请求做预设对比的工具,并把三份预设的机制差异记进 README。
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// 从本仓库存的预设包里把原始酒馆 JSON 抠出来,两边用同一个文件。
|
||||
// 用法: node extract-preset.mjs [预设包路径] [输出名]
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const input =
|
||||
process.argv[2] ??
|
||||
path.join(os.homedir(), ".writing-agent", "presets", "linux_1-3-9c636433.json");
|
||||
const name = process.argv[3] ?? "linux_1-3";
|
||||
|
||||
const pkg = JSON.parse(readFileSync(input, "utf8"));
|
||||
const raw = pkg.raw ?? pkg;
|
||||
if (!raw.prompts || !raw.prompt_order) {
|
||||
throw new Error("这份预设里没有 prompts / prompt_order,不是酒馆格式");
|
||||
}
|
||||
raw.name = name;
|
||||
|
||||
const outDir = path.join(HERE, "presets");
|
||||
mkdirSync(outDir, { recursive: true });
|
||||
const file = path.join(outDir, name + ".json");
|
||||
writeFileSync(file, JSON.stringify(raw, null, 2), "utf8");
|
||||
console.log("写出 " + file + " (prompts=" + raw.prompts.length + ", prompt_order=" + raw.prompt_order.length + ")");
|
||||
Reference in New Issue
Block a user