@forge-ml/rag
Version:
A RAG (Retrieval-Augmented Generation) package for Forge ML
25 lines (24 loc) • 919 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const atlas_1 = require("@nomic-ai/atlas");
class NomicEmbedder {
apiKey;
//@TODO set api key with AtlasUser and make api calls instead
constructor({ apiKey }) {
this.apiKey = apiKey;
}
async generateEmbedding(text) {
const embedding = await (0, atlas_1.embed)(text, { model: "nomic-embed-text-v1.5" }, this.apiKey);
return embedding;
}
async embedChunks(chunks, documentId) {
const embeddings = await (0, atlas_1.embed)(chunks.map((chunk) => chunk.text), { model: "nomic-embed-text-v1.5" }, this.apiKey);
const embeddedChunks = chunks.map((chunk, index) => ({
chunkId: chunk.forgeMetadata.chunkId,
documentId: documentId,
embedding: embeddings[index],
}));
return embeddedChunks;
}
}
exports.default = NomicEmbedder;