mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-06-14 02:40:45 +08:00
feat(extraction): split default extraction prompts
This commit is contained in:
@@ -351,4 +351,54 @@ assert.match(
|
||||
/旧 POV 记忆/,
|
||||
);
|
||||
|
||||
// Verify objective template: no pov_memory or cognitionUpdates in format/rules blocks
|
||||
const objPromptBuild = await buildTaskPrompt(settings, "extract_objective", {
|
||||
taskName: "extract_objective",
|
||||
charDescription: "角色描述",
|
||||
recentMessages: "A: 你好\nB: 世界",
|
||||
graphStats: "node_count=3",
|
||||
schema: "event(title, summary)",
|
||||
currentRange: "1 ~ 2",
|
||||
});
|
||||
const objPayload = buildTaskLlmPayload(objPromptBuild, "fallback-user");
|
||||
const objFormatBlock = objPayload.promptMessages.find((m) => m.blockName === "输出格式");
|
||||
const objRulesBlock = objPayload.promptMessages.find((m) => m.blockName === "行为规则");
|
||||
assert.equal(
|
||||
(objPayload.promptMessages || [])
|
||||
.filter((m) => m.role === "user")
|
||||
.map((m) => m.blockName)
|
||||
.join(","),
|
||||
"输出格式,行为规则",
|
||||
"extract_objective should have format + rules user blocks",
|
||||
);
|
||||
assert.match(String(objFormatBlock?.content || ""), /batchStoryTime/);
|
||||
assert.match(String(objFormatBlock?.content || ""), /regionUpdates/);
|
||||
assert.match(String(objFormatBlock?.content || ""), /\"type\": \"event\"/);
|
||||
assert.match(String(objFormatBlock?.content || ""), /\"region\": \"钟楼\"/);
|
||||
assert.match(String(objFormatBlock?.content || ""), /\"adjacent\": \[\"旧城区\", \"内廷\"\]/);
|
||||
assert.doesNotMatch(String(objFormatBlock?.content || ""), /\\\"region\\\"/);
|
||||
assert.doesNotMatch(String(objFormatBlock?.content || ""), /\\n\s*\{\\\"region/);
|
||||
assert.doesNotMatch(String(objFormatBlock?.content || ""), /pov_memory/);
|
||||
assert.doesNotMatch(String(objFormatBlock?.content || ""), /cognitionUpdates/);
|
||||
assert.match(String(objRulesBlock?.content || ""), /禁止输出/);
|
||||
assert.doesNotMatch(String(objRulesBlock?.content || ""), /POV 记忆字段/);
|
||||
|
||||
// Verify subjective template: no objective types in format block
|
||||
const subPromptBuild = await buildTaskPrompt(settings, "extract_subjective", {
|
||||
taskName: "extract_subjective",
|
||||
charDescription: "角色描述",
|
||||
recentMessages: "A: 你好\nB: 世界",
|
||||
graphStats: "node_count=3",
|
||||
schema: "event(title, summary)",
|
||||
currentRange: "1 ~ 2",
|
||||
});
|
||||
const subPayload = buildTaskLlmPayload(subPromptBuild, "fallback-user");
|
||||
const subFormatBlock = subPayload.promptMessages.find((m) => m.blockName === "输出格式");
|
||||
const subRulesBlock = subPayload.promptMessages.find((m) => m.blockName === "行为规则");
|
||||
assert.match(String(subFormatBlock?.content || ""), /pov_memory/);
|
||||
assert.match(String(subFormatBlock?.content || ""), /cognitionUpdates/);
|
||||
assert.doesNotMatch(String(subFormatBlock?.content || ""), /\"type\": \"event\"/);
|
||||
assert.doesNotMatch(String(subFormatBlock?.content || ""), /\\\"type\\\"/);
|
||||
assert.match(String(subRulesBlock?.content || ""), /POV 记忆字段/);
|
||||
|
||||
console.log("prompt-builder-defaults tests passed");
|
||||
|
||||
Reference in New Issue
Block a user