Improve story summary logging

This commit is contained in:
2026-02-01 15:07:06 +08:00
parent 5dd9fb6f97
commit 4eeebdd935
5 changed files with 650 additions and 663 deletions

View File

@@ -59,7 +59,7 @@ export async function searchStateAtoms(queryVector, vectorConfig) {
const atoms = getStateAtoms();
const atomMap = new Map(atoms.map(a => [a.atomId, a]));
// 计算相似
// 计算匹配
const scored = stateVectors
.map(sv => {
const atom = atomMap.get(sv.atomId);
@@ -92,8 +92,8 @@ export function buildL0FloorBonus(l0Results, bonusFactor = 0.10) {
const floorBonus = new Map();
for (const r of l0Results || []) {
// 每个楼层只加一次,取最高相似度对应的 bonus
// 简化处理:统一加 bonusFactor不区分相似度高低
// 每个楼层只加一次,取最高匹配度对应的 bonus
// 简化处理:统一加 bonusFactor不区分匹配度高低
if (!floorBonus.has(r.floor)) {
floorBonus.set(r.floor, bonusFactor);
}
@@ -132,13 +132,13 @@ export function stateToVirtualChunks(l0Results) {
/**
* 合并 L0 和 L1 chunks每楼层最多保留 limit 条
* @param {Array} l0Chunks - 虚拟 chunks已按相似度排序)
* @param {Array} l1Chunks - 真实 chunks已按相似度排序)
* @param {Array} l0Chunks - 虚拟 chunks已按匹配度排序)
* @param {Array} l1Chunks - 真实 chunks已按匹配度排序)
* @param {number} limit - 每楼层上限
* @returns {Array} 合并后的 chunks
*/
export function mergeAndSparsify(l0Chunks, l1Chunks, limit = 2) {
// 合并并按相似度排序
// 合并并按匹配度排序
const all = [...(l0Chunks || []), ...(l1Chunks || [])]
.sort((a, b) => b.similarity - a.similarity);
@@ -153,7 +153,7 @@ export function mergeAndSparsify(l0Chunks, l1Chunks, limit = 2) {
}
}
// 扁平化并保持相似度排序
// 扁平化并保持匹配度排序
return Array.from(byFloor.values())
.flat()
.sort((a, b) => b.similarity - a.similarity);