@stackmemoryai/stackmemory
Version:
Lossless, project-scoped memory for AI coding tools. Durable context across sessions with 56 MCP tools, FTS5 search, conductor orchestrator, loop/watch monitoring, snapshot capture, pre-flight overlap checks, Claude/Codex/OpenCode wrappers, Linear sync, a
31 lines (30 loc) • 901 B
JavaScript
import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
class OllamaEmbeddingProvider {
dimension;
baseUrl;
model;
constructor(baseUrl, model, dimension) {
this.baseUrl = baseUrl;
this.model = model;
this.dimension = dimension;
}
async embed(text) {
const res = await fetch(`${this.baseUrl}/api/embeddings`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model: this.model, prompt: text })
});
if (!res.ok) throw new Error(`Ollama embed failed: ${res.status}`);
const data = await res.json();
return data.embedding;
}
async embedBatch(texts) {
return Promise.all(texts.map((t) => this.embed(t)));
}
}
export {
OllamaEmbeddingProvider
};