@customize-agent/knowledge 4.0.4 → 4.0.5

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.
@@ -496,10 +496,14 @@ export class KnowledgeBaseManager {
496
496
  }
497
497
  this.reportProgress({ stage: 'vectorizing', percent: 85, message: `正在写入 HNSWLib 向量库,共 ${chunks.length} 个切片`, chunkCount: chunks.length });
498
498
  const indexer = new VectorIndexer(this.embeddingProvider, this.vectorStores);
499
+ let lastVectorPercent = -1;
499
500
  try {
500
501
  const results = await indexer.indexChunks(chunks, {
501
502
  onProgress: progress => {
502
503
  const percent = 85 + Math.round((progress.processedChunks / Math.max(1, progress.totalChunks)) * 14);
504
+ if (percent === lastVectorPercent && progress.processedChunks < progress.totalChunks)
505
+ return;
506
+ lastVectorPercent = percent;
503
507
  const message = `正在分批向量化并写入:${progress.processedChunks}/${progress.totalChunks} 个切片`;
504
508
  this.reportProgress({ stage: 'vectorizing', percent, message, chunkCount: progress.totalChunks });
505
509
  if (options.relativePath)
@@ -1,8 +1,8 @@
1
1
  function resolveVectorIndexBatchSize(configured) {
2
2
  const raw = configured ?? Number(process.env.CUSTOMIZE_VECTOR_INDEX_BATCH_SIZE ?? process.env.KB_VECTOR_INDEX_BATCH_SIZE);
3
3
  if (!Number.isFinite(raw) || raw <= 0)
4
- return 32;
5
- return Math.max(1, Math.min(256, Math.floor(raw)));
4
+ return 128;
5
+ return Math.max(1, Math.min(512, Math.floor(raw)));
6
6
  }
7
7
  /** 向量索引器,负责将文本切片生成 Embedding 并写入向量存储 */
8
8
  export class VectorIndexer {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@customize-agent/knowledge",
3
- "version": "4.0.4",
3
+ "version": "4.0.5",
4
4
  "description": "Local knowledge base infrastructure for customize-agent",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",