- 装配只认 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:真假上游抓包对比工具、三份预设的机制结论与实测报告
71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { Blackboard } from "../src/blackboard/blackboard.js";
|
|
import { DIALOGUE_HISTORY_TAG } from "../src/skills/dialogue-history.js";
|
|
import {
|
|
CURRENT_TURN_TAG,
|
|
resolveWorldInfoMarker,
|
|
worldInfoPackFromSegments,
|
|
} from "../src/preset/world-info-pack.js";
|
|
import {
|
|
CURRENT_TURN,
|
|
WORLD_BOOK_AFTER,
|
|
WORLD_BOOK_BEFORE,
|
|
} from "../src/preset/markers.js";
|
|
import type { ContextSegmentDef } from "../src/skills/context-segments.js";
|
|
|
|
describe("worldInfoPackFromSegments", () => {
|
|
it("splits lore / history / after-history / turn by the two anchors", () => {
|
|
const bb = new Blackboard();
|
|
const segments: ContextSegmentDef[] = [
|
|
{
|
|
id: "stage",
|
|
tier: "static",
|
|
tags: [],
|
|
inline: "古镇夜雨",
|
|
label: "## 舞台骨架",
|
|
},
|
|
{
|
|
id: "hist",
|
|
tier: "dynamic",
|
|
tags: [DIALOGUE_HISTORY_TAG],
|
|
},
|
|
{
|
|
id: "vars",
|
|
tier: "dynamic",
|
|
tags: ["变量.当前"],
|
|
label: "## 变量",
|
|
},
|
|
{
|
|
id: "turn",
|
|
tier: "dynamic",
|
|
tags: [CURRENT_TURN_TAG],
|
|
},
|
|
{
|
|
id: "note",
|
|
tier: "dynamic",
|
|
tags: [],
|
|
inline: "尾注",
|
|
label: "## 本轮后",
|
|
},
|
|
];
|
|
const pack = worldInfoPackFromSegments({
|
|
segments,
|
|
inputs: {
|
|
[DIALOGUE_HISTORY_TAG]: "用户:你好",
|
|
"变量.当前": "HP 3",
|
|
[CURRENT_TURN_TAG]: "我推门进去",
|
|
},
|
|
blackboard: bb,
|
|
});
|
|
expect(pack.worldBookBefore.map((e) => e.content)).toEqual(["古镇夜雨"]);
|
|
expect(pack.history.map((m) => m.content).join("\n")).toContain("你好");
|
|
expect(pack.worldBookAfter.map((e) => e.content)).toEqual(["HP 3"]);
|
|
expect(pack.turn).toBe("我推门进去");
|
|
expect(pack.postTurn.map((e) => e.content)).toEqual(["尾注"]);
|
|
expect(resolveWorldInfoMarker(pack, WORLD_BOOK_BEFORE)).toContain("古镇夜雨");
|
|
expect(resolveWorldInfoMarker(pack, WORLD_BOOK_AFTER)).toContain("HP 3");
|
|
expect(resolveWorldInfoMarker(pack, CURRENT_TURN)).toBe("我推门进去");
|
|
expect(resolveWorldInfoMarker(pack, "charDescription")).toBeNull();
|
|
});
|
|
});
|