From 716e5abaf4e51923f8a6e0069c73fe29c5802607 Mon Sep 17 00:00:00 2001 From: Youzini-afk <13153778771cx@gmail.com> Date: Tue, 24 Mar 2026 21:17:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=82=E6=95=B0=E5=8C=96=E6=A3=80?= =?UTF-8?q?=E7=B4=A2=E9=93=BE=E8=B7=AF=E4=B8=8E=E6=B3=A8=E5=85=A5=E8=AF=AD?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++- index.js | 31 ++++-- panel.html | 87 +++++++++++++---- panel.js | 63 +++++++++++- retriever.js | 37 ++++--- style.css | 26 +++++ tests/default-settings.mjs | 37 +++++++ tests/retrieval-config.mjs | 191 +++++++++++++++++++++++++++++++++++++ 8 files changed, 429 insertions(+), 55 deletions(-) create mode 100644 tests/default-settings.mjs create mode 100644 tests/retrieval-config.mjs diff --git a/README.md b/README.md index 9e264b8..f5b29ac 100644 --- a/README.md +++ b/README.md @@ -185,10 +185,12 @@ git clone https://github.com/pjm0616/ST-Bionic-Memory-Ecology.git st-bme | 设置 | 默认 | 说明 | |------|------|------| -| 召回上下文轮数 | 3 | 让 AI 根据最近几轮来召回 | -| 向量候选数 | 15 | 向量搜索返回多少候选 | -| 扩散深度 | 2 | 在图上沿关系扩散几层 | -| 最终注入数 | 12 | 最终注入多少条记忆 | +| 提取上下文轮数 | 2 | 按轮计的提取上下文,通常约等于向前补 4 层普通消息 | +| 向量预筛 Top-K | 20 | 向量预筛阶段最多保留多少个候选 | +| LLM 精排候选池 | 30 | 进入 LLM 精排阶段前的候选池大小 | +| LLM 最终选择上限 | 8 | LLM 精排后最多保留多少条记忆 | +| 图扩散 Top-K | 100 | 图扩散阶段最多保留多少个候选 | +| 注入深度 | 9999 | 当前走 IN_CHAT@Depth,数值越大越靠前插入 | | Token 预算 | 1500 | 注入的最大 token 估算 | --- @@ -230,6 +232,8 @@ git clone https://github.com/pjm0616/ST-Bionic-Memory-Ecology.git st-bme - 面板外观 桌面端会显示左侧竖向子导航,右侧显示宽版配置表单;移动端则改成顶部横向子页切换。 +检索流水线现在可以分别配置向量预筛、图扩散、混合评分和 LLM 精排。 +注入深度使用 `IN_CHAT@Depth` 语义,默认 `9999` 表示尽量靠前插入,减少对最近几层对话的直接控制感。 ### 图谱可视化 桌面端右侧大区域显示力导向图谱,节点可拖拽、缩放、点击查看详情。支持 4 套配色主题切换。 diff --git a/index.js b/index.js index d63bd3a..a560a97 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ import { eventSource, event_types, + extension_prompt_types, getRequestHeaders, saveSettingsDebounced, } from "../../../../script.js"; @@ -75,13 +76,17 @@ const defaultSettings = { // 召回设置 recallEnabled: true, - recallTopK: 15, // 混合评分 Top-K + recallTopK: 20, // 向量预筛 Top-K recallMaxNodes: 8, // LLM 召回最大节点数 recallEnableLLM: true, // 是否启用 LLM 精确召回 + recallEnableVectorPrefilter: true, // 是否启用向量预筛 + recallEnableGraphDiffusion: true, // 是否启用图扩散 + recallDiffusionTopK: 100, // 图扩散阶段保留的候选上限 + recallLlmCandidatePool: 30, // 传给 LLM 精排的候选池大小 // 注入设置 injectPosition: "atDepth", // 注入位置 - injectDepth: 4, // 注入深度(atDepth 模式) + injectDepth: 9999, // IN_CHAT@Depth 注入深度,数值越大越靠前 injectRole: 0, // 0=system, 1=user, 2=assistant // 混合评分权重 @@ -273,7 +278,12 @@ function clearInjectionState() { try { const context = getContext(); - context.setExtensionPrompt(MODULE_NAME, "", 1, 0); + context.setExtensionPrompt( + MODULE_NAME, + "", + extension_prompt_types.IN_CHAT, + 0, + ); } catch (error) { console.warn("[ST-BME] 清理旧注入失败:", error); } @@ -538,7 +548,12 @@ function updateModuleSettings(patch = {}) { ) { try { const context = getContext(); - context.setExtensionPrompt(MODULE_NAME, "", 1, 0); + context.setExtensionPrompt( + MODULE_NAME, + "", + extension_prompt_types.IN_CHAT, + 0, + ); lastInjectionContent = ""; lastRecalledItems = []; } catch (error) { @@ -1194,6 +1209,10 @@ async function runRecall() { topK: settings.recallTopK, maxRecallNodes: settings.recallMaxNodes, enableLLMRecall: settings.recallEnableLLM, + enableVectorPrefilter: settings.recallEnableVectorPrefilter, + enableGraphDiffusion: settings.recallEnableGraphDiffusion, + diffusionTopK: settings.recallDiffusionTopK, + llmCandidatePool: settings.recallLlmCandidatePool, recallPrompt: settings.recallPrompt || undefined, weights: { graphWeight: settings.graphWeight, @@ -1224,8 +1243,8 @@ async function runRecall() { context.setExtensionPrompt( MODULE_NAME, injectionText, - 1, // extension_prompt_types.IN_PROMPT - clampInt(settings.injectDepth, 4, 0, 9999), + extension_prompt_types.IN_CHAT, // 当前注入走 IN_CHAT@Depth + clampInt(settings.injectDepth, 9999, 0, 9999), ); // 保存召回结果和访问强化 diff --git a/panel.html b/panel.html index cd89a28..2e162bc 100644 --- a/panel.html +++ b/panel.html @@ -512,13 +512,6 @@ -