Update ena-planner.js for vector log and sequence
This commit is contained in:
@@ -1086,6 +1086,7 @@ async function buildPlannerMessages(rawUserInput) {
|
||||
|
||||
// --- Story memory: try fresh recall with current user input ---
|
||||
let cachedSummary = '';
|
||||
let _recallSource = 'none'; // ← 新增
|
||||
try {
|
||||
const vectorCfg = getVectorConfig();
|
||||
if (vectorCfg?.enabled) {
|
||||
@@ -1093,6 +1094,7 @@ async function buildPlannerMessages(rawUserInput) {
|
||||
pendingUserMessage: rawUserInput,
|
||||
});
|
||||
cachedSummary = r?.text?.trim() || '';
|
||||
if (cachedSummary) _recallSource = 'fresh'; // ← 新增
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Ena] Fresh vector recall failed, falling back to cached data:', e);
|
||||
@@ -1100,7 +1102,9 @@ async function buildPlannerMessages(rawUserInput) {
|
||||
// Fallback: use stale cache from previous generation
|
||||
if (!cachedSummary) {
|
||||
cachedSummary = getCachedStorySummary();
|
||||
if (cachedSummary) _recallSource = 'stale'; // ← 新增
|
||||
}
|
||||
console.log(`[Ena] Story memory source: ${_recallSource}`); // ← 新增
|
||||
|
||||
// --- Chat history: last 2 AI messages (floors N-1 & N-3) ---
|
||||
// Two messages instead of one to avoid cross-device cache miss:
|
||||
@@ -1140,14 +1144,14 @@ async function buildPlannerMessages(rawUserInput) {
|
||||
// 3) Worldbook
|
||||
if (String(worldbook).trim()) messages.push({ role: 'system', content: worldbook });
|
||||
|
||||
// 3.5) Story memory (小白X <剧情记忆> — fresh recall when available, stale cache as fallback)
|
||||
// 4) Chat history (last 2 AI responses — floors N-1 & N-3)
|
||||
if (String(recentChat).trim()) messages.push({ role: 'system', content: recentChat });
|
||||
|
||||
// 4.5) Story memory (小白X <剧情记忆> — after chat context, before plots)
|
||||
if (storySummary.trim()) {
|
||||
messages.push({ role: 'system', content: `<story_summary>\n${storySummary}\n</story_summary>` });
|
||||
}
|
||||
|
||||
// 4) Chat history (last 2 AI responses — floors N-1 & N-3)
|
||||
if (String(recentChat).trim()) messages.push({ role: 'system', content: recentChat });
|
||||
|
||||
// 5) Vector recall — now merged into story_summary above, kept for compatibility
|
||||
// (vectorRaw is empty; this block intentionally does nothing)
|
||||
if (String(vector).trim()) messages.push({ role: 'system', content: vector });
|
||||
|
||||
Reference in New Issue
Block a user