embedding worker fix
All checks were successful
Publish Library / Build NPM Project (push) Successful in 28s
Publish Library / Tag Version (push) Successful in 5s

This commit is contained in:
2026-02-12 20:18:56 -05:00
parent 5bd41f8c6a
commit 8f89f5e3cf
3 changed files with 4 additions and 4 deletions

View File

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