better-qdrant-mcp-server
Version:
MCP server for enhanced Qdrant vector database functionality
41 lines • 1.51 kB
JavaScript
import axios from 'axios';
import { BaseEmbeddingService } from './base.js';
export class OllamaEmbeddingService extends BaseEmbeddingService {
constructor(endpoint, model) {
super(undefined, endpoint || 'http://localhost:11434', model || 'nomic-embed-text');
// Vector size depends on the model
// nomic-embed-text produces 768-dimensional embeddings
this.vectorSize = 768;
this.defaultModel = 'nomic-embed-text';
this.defaultEndpoint = 'http://localhost:11434';
this.validateConfig();
}
async generateEmbeddings(texts) {
const embeddings = [];
// Ollama API requires sequential processing of texts
for (const text of texts) {
const response = await axios.post(`${this.endpoint}/api/embeddings`, {
model: this.model || this.defaultModel,
prompt: text,
}, {
headers: {
'Content-Type': 'application/json',
},
});
if (!response.data.embedding || !Array.isArray(response.data.embedding)) {
throw new Error('Invalid response from Ollama API');
}
embeddings.push(response.data.embedding);
}
return embeddings;
}
requiresApiKey() {
return false;
}
validateConfig() {
if (!this.endpoint) {
throw new Error('Ollama endpoint is required');
}
}
}
//# sourceMappingURL=ollama.js.map