xiaozuoassistant 0.2.30 → 0.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -51,6 +51,18 @@ export class VectorMemory {
|
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
this.table = await this.db.openTable('memories');
|
|
54
|
+
// 如果表存在,且当前模型变更导致查询时维度不匹配,必须提供处理机制或抛出明确错误
|
|
55
|
+
// 为了稳定运行,我们在打开表时验证当前模型的维度是否与表结构匹配
|
|
56
|
+
console.log(`[VectorMemory] Validating embedding dimension for existing table...`);
|
|
57
|
+
const testVector = await this.getEmbedding('init');
|
|
58
|
+
if (testVector && testVector.length > 0) {
|
|
59
|
+
// 读取表中的一行来获取表的维度
|
|
60
|
+
const sample = await this.table.search(Array(testVector.length).fill(0)).limit(1).execute().catch(() => null);
|
|
61
|
+
if (sample && sample.length > 0 && sample[0].vector.length !== testVector.length) {
|
|
62
|
+
console.error(`[VectorMemory] CRITICAL: Existing database dimension (${sample[0].vector.length}) does not match current model dimension (${testVector.length}).`);
|
|
63
|
+
console.error(`[VectorMemory] You MUST delete the vector database directory manually to reset it.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
54
66
|
}
|
|
55
67
|
this.isInitialized = true;
|
|
56
68
|
}
|