@batalabs/virlow-memory 3.13.0 → 3.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/embedder.js +15 -5
- package/dist/embedder.d.ts.map +1 -1
- package/dist/embedder.js +11 -1
- package/dist/embedder.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/embedder.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEmbedder = createEmbedder;
|
|
4
|
-
const transformers_1 = require("@huggingface/transformers");
|
|
5
4
|
const constants_js_1 = require("./constants.js");
|
|
5
|
+
let transformers = null;
|
|
6
|
+
function loadTransformers() {
|
|
7
|
+
// On rejection, clear the memo so the next call retries rather than replaying
|
|
8
|
+
// a rejected promise forever — the same reason mcp-core does it around this.
|
|
9
|
+
transformers ??= Promise.resolve().then(() => require('@huggingface/transformers')).catch((err) => {
|
|
10
|
+
transformers = null;
|
|
11
|
+
throw err;
|
|
12
|
+
});
|
|
13
|
+
return transformers;
|
|
14
|
+
}
|
|
6
15
|
/**
|
|
7
16
|
* Load the pinned embedding model. In Node, `cacheDir` controls where the
|
|
8
17
|
* public ONNX weights are cached (the MCP server passes ~/.virlow-mcp/models);
|
|
@@ -16,14 +25,15 @@ const constants_js_1 = require("./constants.js");
|
|
|
16
25
|
* `<localModelPath><EMBEDDING_MODEL_ID>/...` instead of hitting the Hub.
|
|
17
26
|
*/
|
|
18
27
|
async function createEmbedder(opts = {}) {
|
|
28
|
+
const { env, pipeline } = await loadTransformers();
|
|
19
29
|
if (opts.cacheDir) {
|
|
20
|
-
|
|
30
|
+
env.cacheDir = opts.cacheDir;
|
|
21
31
|
}
|
|
22
32
|
if (opts.localModelPath) {
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
env.allowRemoteModels = false;
|
|
34
|
+
env.localModelPath = opts.localModelPath;
|
|
25
35
|
}
|
|
26
|
-
const extractor = await
|
|
36
|
+
const extractor = await pipeline('feature-extraction', constants_js_1.EMBEDDING_MODEL_ID, {
|
|
27
37
|
dtype: 'q8',
|
|
28
38
|
revision: constants_js_1.EMBEDDING_MODEL_REVISION,
|
|
29
39
|
});
|
package/dist/embedder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedder.d.ts","sourceRoot":"","sources":["../src/embedder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"embedder.d.ts","sourceRoot":"","sources":["../src/embedder.ts"],"names":[],"mappings":"AA0CA,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5C;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,OAAO,CAAC,QAAQ,CAAC,CAoBnB"}
|
package/dist/embedder.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { env, pipeline } from '@huggingface/transformers';
|
|
2
1
|
import { EMBEDDING_MODEL_ID, EMBEDDING_MODEL_REVISION } from './constants.js';
|
|
2
|
+
let transformers = null;
|
|
3
|
+
function loadTransformers() {
|
|
4
|
+
// On rejection, clear the memo so the next call retries rather than replaying
|
|
5
|
+
// a rejected promise forever — the same reason mcp-core does it around this.
|
|
6
|
+
transformers ??= import('@huggingface/transformers').catch((err) => {
|
|
7
|
+
transformers = null;
|
|
8
|
+
throw err;
|
|
9
|
+
});
|
|
10
|
+
return transformers;
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* Load the pinned embedding model. In Node, `cacheDir` controls where the
|
|
5
14
|
* public ONNX weights are cached (the MCP server passes ~/.virlow-mcp/models);
|
|
@@ -13,6 +22,7 @@ import { EMBEDDING_MODEL_ID, EMBEDDING_MODEL_REVISION } from './constants.js';
|
|
|
13
22
|
* `<localModelPath><EMBEDDING_MODEL_ID>/...` instead of hitting the Hub.
|
|
14
23
|
*/
|
|
15
24
|
export async function createEmbedder(opts = {}) {
|
|
25
|
+
const { env, pipeline } = await loadTransformers();
|
|
16
26
|
if (opts.cacheDir) {
|
|
17
27
|
env.cacheDir = opts.cacheDir;
|
|
18
28
|
}
|
package/dist/embedder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedder.js","sourceRoot":"","sources":["../src/embedder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"embedder.js","sourceRoot":"","sources":["../src/embedder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AA8B9E,IAAI,YAAY,GAAuC,IAAI,CAAC;AAE5D,SAAS,gBAAgB;IACvB,8EAA8E;IAC9E,6EAA6E;IAC7E,YAAY,KAAK,MAAM,CAAC,2BAA2B,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QAC1E,YAAY,GAAG,IAAI,CAAC;QACpB,MAAM,GAAG,CAAC;IACZ,CAAC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC;AAMD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAuD,EAAE;IAEzD,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAEnD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,CAAC;IACD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;QACxB,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC;QAC9B,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAC3C,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,oBAAoB,EAAE,kBAAkB,EAAE;QACzE,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,wBAAwB;KACnC,CAAC,CAAC;IACH,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,IAAY;YACtB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3E,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,IAAoB,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batalabs/virlow-memory",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Virlow Memories shared core: embeddings, similarity ranking, dedupe, and encrypted memory payloads.",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@huggingface/transformers": "^3.4.0",
|
|
32
|
-
"@batalabs/virlow-crypto": "3.
|
|
32
|
+
"@batalabs/virlow-crypto": "3.14.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^22.10.0",
|