Added save directory for embedder
All checks were successful
Publish Library / Build NPM Project (push) Successful in 33s
Publish Library / Tag Version (push) Successful in 4s

This commit is contained in:
2026-02-11 21:45:54 -05:00
parent c8d5660b1a
commit 013aa942c0
3 changed files with 12 additions and 4 deletions

View File

@@ -3,8 +3,11 @@ import { parentPort } from 'worker_threads';
let embedder: any;
parentPort?.on('message', async ({ id, text, model }) => {
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model, {quantized: true});
parentPort?.on('message', async ({ id, text, model, path }) => {
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model, {
quantized: true,
cache_dir: path,
});
const output = await embedder(text, { pooling: 'mean', normalize: true });
const embedding = Array.from(output.data);
parentPort?.postMessage({ id, embedding });