refactor: 优化嵌入生成过程,调整批处理大小和内存管理策略

This commit is contained in:
catlog22
2025-12-21 23:37:34 +08:00
parent 210f0f1012
commit fa64e11a77
2 changed files with 15 additions and 21 deletions

View File

@@ -410,9 +410,8 @@ function parseProgressLine(line: string): ProgressInfo | null {
if (line.includes('Generating embeddings') || line.includes('Creating embeddings')) {
return { stage: 'embeddings', message: 'Generating embeddings...', percent: 70 };
}
if (line.includes('Finalizing') || line.includes('Complete')) {
return { stage: 'complete', message: 'Finalizing...', percent: 95 };
}
// Note: "Finalizing index" and "Building ANN" are handled separately below
// Only match generic "Complete" here (not "Finalizing" which has specific handlers)
// Parse indexed count: "Indexed X files" - FTS complete, but embeddings may follow
const indexedMatch = line.match(/Indexed (\d+) files/i);
@@ -460,6 +459,11 @@ function parseProgressLine(line: string): ProgressInfo | null {
};
}
// Parse generic completion (but not "Embeddings complete" which is handled above)
if (line.includes('Complete') && !line.toLowerCase().includes('embeddings complete')) {
return { stage: 'complete', message: 'Complete', percent: 98 };
}
return null;
}