Update recall entity weighting and prompt sections

This commit is contained in:
2026-02-02 14:02:12 +08:00
parent d8849c5e8b
commit d3f772073f
3 changed files with 229 additions and 98 deletions

View File

@@ -91,9 +91,9 @@ function cleanSummary(summary) {
function buildSystemPreamble() {
return [
"以上内容为因上下文窗口限制保留的可见历史",
"以下【剧情记忆】是对可见与不可见历史的总结",
"• 【世界约束】记录着已确立的事实",
"以上是还留在眼前的对话",
"以下是脑海里的记忆",
"• [定了的事] 这些是不会变的",
"• 其余部分是过往经历的回忆碎片",
"",
"请内化这些记忆:",
@@ -103,7 +103,7 @@ function buildSystemPreamble() {
function buildPostscript() {
return [
"",
"——",
"这些记忆是真实的,请自然地记住它们。",
].join("\n");
}
@@ -594,49 +594,36 @@ async function buildVectorPrompt(store, recallResult, causalById, queryEntities
}
// ═══════════════════════════════════════════════════════════════════
// 按注入顺序拼接 sections
// ═══════════════════════════════════════════════════════════════════
// ═══════════════════════════════════════════════════════════════════════
// 按注入顺序拼接 sections
// ═══════════════════════════════════════════════════════════════════════
const sections = [];
// 1. 世界约束 → 定了的事
if (assembled.world.lines.length) {
sections.push(`[定了的事] 已确立的事实\n${assembled.world.lines.join("\n")}`);
}
// 2. 核心经历 → 印象深的事
if (assembled.events.direct.length) {
sections.push(`[印象深的事] 记得很清楚\n\n${assembled.events.direct.join("\n\n")}`);
}
// 3. 过往背景 → 好像有关的事
if (assembled.events.similar.length) {
sections.push(`[好像有关的事] 听说过或有点模糊\n\n${assembled.events.similar.join("\n\n")}`);
}
// 4. 远期片段 → 更早以前
if (assembled.orphans.lines.length) {
sections.push(`[更早以前] 记忆里残留的老画面\n${assembled.orphans.lines.join("\n")}`);
}
// 5. 待整理 → 刚发生的
if (assembled.recentOrphans.lines.length) {
sections.push(`[刚发生的] 还没来得及想明白\n${assembled.recentOrphans.lines.join("\n")}`);
}
// 6. 人物弧光 → 这些人
if (assembled.arcs.lines.length) {
sections.push(`[这些人] 他们现在怎样了\n${assembled.arcs.lines.join("\n")}`);
}
const sections = [];
// 1. 世界约束
if (assembled.world.lines.length) {
sections.push(`[世界约束] 已确立的事实\n${assembled.world.lines.join("\n")}`);
}
// 2. 核心经历
if (assembled.events.direct.length) {
sections.push(`[核心经历] 深刻的记忆\n\n${assembled.events.direct.join("\n\n")}`);
}
// 3. 过往背景
if (assembled.events.similar.length) {
sections.push(`[过往背景] 听别人说起或比较模糊的往事\n\n${assembled.events.similar.join("\n\n")}`);
}
// 4. 远期片段
if (assembled.orphans.lines.length) {
sections.push(`[远期片段] 记忆里残留的一些老画面\n${assembled.orphans.lines.join("\n")}`);
}
// 5. 待整理
if (assembled.recentOrphans.lines.length) {
sections.push(`[待整理] 最近发生但尚未梳理的原始记忆\n${assembled.recentOrphans.lines.join("\n")}`);
}
// 6. 人物弧光(最后注入,但预算已在优先级 2 预留)
if (assembled.arcs.lines.length) {
sections.push(`[人物弧光]\n${assembled.arcs.lines.join("\n")}`);
}
// ═══════════════════════════════════════════════════════════════════
// 统计 & 返回
// ═══════════════════════════════════════════════════════════════════
// 总预算 = 主装配 + 待整理
injectionStats.budget.used = total.used + (recentOrphanStats.tokens || 0);
if (!sections.length) {
if (!sections.length) {
return { promptText: "", injectionLogText: "", injectionStats };
}
@@ -848,4 +835,4 @@ export async function buildVectorPromptText(excludeLastAi = false, hooks = {}) {
}
return { text: finalText, logText: (recallResult.logText || "") + (injectionLogText || "") };
}
}