- 装配只认 prompt_order.enabled;squash_system_messages 只合并相邻 system(新增 system 档,连接符按酒馆用单换行)
- 包装层:new_chat_prompt、示例对话(new_example_chat_prompt + <START> 切段 + name)、角色卡三块与 personality_format/scenario_format、{{user}}/{{char}} 取值、任务契约并进预设条目
- 工具协议:按 ToolBindings / 伪工具协议数据声明真 tools(presetToolPolicy=preset),工具描述用到的条目不再重复作为消息发出
- 正则:promptOnly 作用于对话历史(含 depth 过滤)、写入时脚本改写回复;{{//}} 注释按配平扫描
- tools/st-request-diff:真假上游抓包对比工具、三份预设的机制结论与实测报告
28 lines
1.5 KiB
JavaScript
28 lines
1.5 KiB
JavaScript
// 用本仓库的声明式工具代码看某个预设会声明出什么 tools(不发请求)。
|
||
// 用法: node node_modules/tsx/dist/cli.mjs tools/st-request-diff/inspect-tools-decl.mjs <preset.json>
|
||
import { readFileSync } from "node:fs";
|
||
import path from "node:path";
|
||
import { importSillyTavernPreset } from "../../src/preset/importer.js";
|
||
import { declarePresetTools } from "../../src/preset/tool-declaration.js";
|
||
|
||
const file = process.argv[2];
|
||
const raw = JSON.parse(readFileSync(file, "utf8"));
|
||
const report = importSillyTavernPreset(raw, { name: path.basename(file, ".json") });
|
||
const declared = declarePresetTools(report.preset);
|
||
if (!declared) {
|
||
console.log("没有声明工具(declarePresetTools = null)");
|
||
process.exit(0);
|
||
}
|
||
console.log("来源: " + declared.source + ",toolChoice: " + declared.toolChoice + ",正文参数: " + declared.payloadFields.join(", "));
|
||
for (const tool of declared.tools) {
|
||
const fn = tool.function;
|
||
const params = fn.parameters;
|
||
console.log(" 工具名: " + fn.name);
|
||
console.log(" 描述字数: " + fn.description.length + " 开头: " + fn.description.replace(/\s+/g, " ").slice(0, 60));
|
||
console.log(" 参数: " + JSON.stringify(Object.keys(params.properties ?? {})) + " required=" + JSON.stringify(params.required ?? []));
|
||
for (const [key, value] of Object.entries(params.properties ?? {})) {
|
||
const desc = String(value.description ?? "");
|
||
console.log(" - " + key + " (" + (value.type ?? "") + ") 说明字数 " + desc.length + " 开头: " + desc.replace(/\s+/g, " ").slice(0, 50));
|
||
}
|
||
}
|