fix: remove dimension detection error for ollama

Signed-off-by: ChengZi <chen.zhang@zilliz.com>
This commit is contained in:
ChengZi
2025-08-21 11:30:53 +08:00
committed by Cheney Zhang
parent ada7503c51
commit 2605d09c44

View File

@@ -92,13 +92,11 @@ export class OllamaEmbedding extends Embedding {
// Preprocess all texts // Preprocess all texts
const processedTexts = this.preprocessTexts(texts); const processedTexts = this.preprocessTexts(texts);
// Detect dimension on first use // Detect dimension on first use if not configured
if (!this.dimensionDetected && !this.config.dimension) { if (!this.dimensionDetected && !this.config.dimension) {
this.dimension = await this.detectDimension(); this.dimension = await this.detectDimension();
this.dimensionDetected = true; this.dimensionDetected = true;
console.log(`📏 Detected Ollama embedding dimension: ${this.dimension} for model: ${this.config.model}`); console.log(`📏 Detected Ollama embedding dimension: ${this.dimension} for model: ${this.config.model}`);
} else {
throw new Error('Failed to detect dimension for model ' + this.config.model);
} }
// Use Ollama's native batch embedding API // Use Ollama's native batch embedding API