@plur-ai/core 0.2.5 → 0.2.6
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/index.d.ts +4 -1
- package/dist/index.js +38 -8
- package/package.json +1 -4
- package/dist/chunk-2ZDO52B4.js +0 -52
- package/dist/onnxruntime_binding-5QEF3SUC.node +0 -0
- package/dist/onnxruntime_binding-BKPKNEGC.node +0 -0
- package/dist/onnxruntime_binding-FMOXGIUT.node +0 -0
- package/dist/onnxruntime_binding-OI2KMXC5.node +0 -0
- package/dist/onnxruntime_binding-UX44MLAZ.node +0 -0
- package/dist/onnxruntime_binding-Y2W7N7WY.node +0 -0
- package/dist/transformers.node-PH5YK5EA.js +0 -46777
package/dist/index.d.ts
CHANGED
|
@@ -769,8 +769,11 @@ declare class Plur {
|
|
|
769
769
|
private _filterEngrams;
|
|
770
770
|
/** Reactivate accessed engrams (bump retrieval strength, frequency, last_accessed) */
|
|
771
771
|
private _reactivateResults;
|
|
772
|
-
/** Scored injection within token budget. Returns formatted strings. */
|
|
772
|
+
/** Scored injection within token budget (BM25 only). Returns formatted strings. */
|
|
773
773
|
inject(task: string, options?: InjectOptions): InjectionResult;
|
|
774
|
+
/** Scored injection with embedding boost when available. Falls back to BM25 if embeddings not installed. */
|
|
775
|
+
injectHybrid(task: string, options?: InjectOptions): Promise<InjectionResult>;
|
|
776
|
+
private _formatInjection;
|
|
774
777
|
/** Update feedback_signals and adjust retrieval_strength. */
|
|
775
778
|
feedback(id: string, signal: 'positive' | 'negative' | 'neutral'): void;
|
|
776
779
|
/** Set engram status to 'retired'. */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./chunk-2ZDO52B4.js";
|
|
2
|
-
|
|
3
1
|
// src/storage.ts
|
|
4
2
|
import { existsSync, mkdirSync } from "fs";
|
|
5
3
|
import { join } from "path";
|
|
@@ -511,7 +509,7 @@ function fillTokenBudget(scored, maxTokens) {
|
|
|
511
509
|
}
|
|
512
510
|
return { selected: result, tokens_used: tokensUsed };
|
|
513
511
|
}
|
|
514
|
-
function selectAndSpread(ctx, personalEngrams, packs, config) {
|
|
512
|
+
function selectAndSpread(ctx, personalEngrams, packs, config, embeddingBoosts) {
|
|
515
513
|
const spreadCap = config?.spread_cap ?? 3;
|
|
516
514
|
const spreadBudget = config?.spread_budget ?? 480;
|
|
517
515
|
const promptLower = ctx.prompt.toLowerCase();
|
|
@@ -523,7 +521,13 @@ function selectAndSpread(ctx, personalEngrams, packs, config) {
|
|
|
523
521
|
for (const engram of personalEngrams) {
|
|
524
522
|
if (engram.status !== "active") continue;
|
|
525
523
|
engramMap.set(engram.id, engram);
|
|
526
|
-
|
|
524
|
+
let raw = scoreEngram(engram, promptLower, promptWords, [], ctx.scope, false);
|
|
525
|
+
const embBoost = embeddingBoosts?.get(engram.id) ?? 0;
|
|
526
|
+
if (raw === 0 && embBoost > 0.3) {
|
|
527
|
+
raw = embBoost * 2;
|
|
528
|
+
} else if (raw > 0 && embBoost > 0) {
|
|
529
|
+
raw += embBoost;
|
|
530
|
+
}
|
|
527
531
|
if (raw > 0) {
|
|
528
532
|
scored.push({ ...engram, keyword_match: raw, raw_score: raw, score: raw });
|
|
529
533
|
}
|
|
@@ -535,7 +539,13 @@ function selectAndSpread(ctx, personalEngrams, packs, config) {
|
|
|
535
539
|
for (const engram of pack.engrams) {
|
|
536
540
|
if (engram.status !== "active") continue;
|
|
537
541
|
engramMap.set(engram.id, engram);
|
|
538
|
-
|
|
542
|
+
let raw = scoreEngram(engram, promptLower, promptWords, matchTerms, ctx.scope, true);
|
|
543
|
+
const embBoost = embeddingBoosts?.get(engram.id) ?? 0;
|
|
544
|
+
if (raw === 0 && embBoost > 0.3) {
|
|
545
|
+
raw = embBoost * 2;
|
|
546
|
+
} else if (raw > 0 && embBoost > 0) {
|
|
547
|
+
raw += embBoost;
|
|
548
|
+
}
|
|
539
549
|
if (raw > 0) {
|
|
540
550
|
scored.push({ ...engram, keyword_match: raw, raw_score: raw, score: raw });
|
|
541
551
|
}
|
|
@@ -739,7 +749,7 @@ async function getEmbedder() {
|
|
|
739
749
|
if (transformersUnavailable) return null;
|
|
740
750
|
if (!embedPipeline) {
|
|
741
751
|
try {
|
|
742
|
-
const { pipeline } = await import("
|
|
752
|
+
const { pipeline } = await import("@huggingface/transformers");
|
|
743
753
|
embedPipeline = await pipeline("feature-extraction", "Xenova/bge-small-en-v1.5", {
|
|
744
754
|
dtype: "fp32"
|
|
745
755
|
});
|
|
@@ -1346,8 +1356,27 @@ var Plur = class {
|
|
|
1346
1356
|
}
|
|
1347
1357
|
if (modified) saveEngrams(this.paths.engrams, allEngrams);
|
|
1348
1358
|
}
|
|
1349
|
-
/** Scored injection within token budget. Returns formatted strings. */
|
|
1359
|
+
/** Scored injection within token budget (BM25 only). Returns formatted strings. */
|
|
1350
1360
|
inject(task, options) {
|
|
1361
|
+
return this._formatInjection(task, options);
|
|
1362
|
+
}
|
|
1363
|
+
/** Scored injection with embedding boost when available. Falls back to BM25 if embeddings not installed. */
|
|
1364
|
+
async injectHybrid(task, options) {
|
|
1365
|
+
let embeddingBoosts;
|
|
1366
|
+
try {
|
|
1367
|
+
const engrams = loadEngrams(this.paths.engrams).filter((e) => e.status === "active");
|
|
1368
|
+
const results = await embeddingSearch(engrams, task, engrams.length, this.paths.root);
|
|
1369
|
+
if (results.length > 0) {
|
|
1370
|
+
embeddingBoosts = /* @__PURE__ */ new Map();
|
|
1371
|
+
for (let i = 0; i < results.length; i++) {
|
|
1372
|
+
embeddingBoosts.set(results[i].id, 1 / (1 + i * 0.1));
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
} catch {
|
|
1376
|
+
}
|
|
1377
|
+
return this._formatInjection(task, options, embeddingBoosts);
|
|
1378
|
+
}
|
|
1379
|
+
_formatInjection(task, options, embeddingBoosts) {
|
|
1351
1380
|
const engrams = loadEngrams(this.paths.engrams);
|
|
1352
1381
|
const packs = loadAllPacks(this.paths.packs);
|
|
1353
1382
|
const budget = options?.budget ?? this.config.injection_budget ?? 2e3;
|
|
@@ -1362,7 +1391,8 @@ var Plur = class {
|
|
|
1362
1391
|
{
|
|
1363
1392
|
spread_cap: this.config.injection?.spread_cap,
|
|
1364
1393
|
spread_budget: this.config.injection?.spread_budget
|
|
1365
|
-
}
|
|
1394
|
+
},
|
|
1395
|
+
embeddingBoosts
|
|
1366
1396
|
);
|
|
1367
1397
|
const formatEngrams = (wires) => {
|
|
1368
1398
|
if (wires.length === 0) return "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plur-ai/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
"js-yaml": "^4.1.0",
|
|
12
12
|
"zod": "^3.23.0"
|
|
13
13
|
},
|
|
14
|
-
"optionalDependencies": {
|
|
15
|
-
"@huggingface/transformers": "^3.8.1"
|
|
16
|
-
},
|
|
17
14
|
"devDependencies": {
|
|
18
15
|
"@types/js-yaml": "^4.0.0",
|
|
19
16
|
"@types/node": "^25.5.0"
|
package/dist/chunk-2ZDO52B4.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __glob = (map) => (path) => {
|
|
14
|
-
var fn = map[path];
|
|
15
|
-
if (fn) return fn();
|
|
16
|
-
throw new Error("Module not found in bundle: " + path);
|
|
17
|
-
};
|
|
18
|
-
var __esm = (fn, res) => function __init() {
|
|
19
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
20
|
-
};
|
|
21
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
22
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
23
|
-
};
|
|
24
|
-
var __export = (target, all) => {
|
|
25
|
-
for (var name in all)
|
|
26
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
-
};
|
|
28
|
-
var __copyProps = (to, from, except, desc) => {
|
|
29
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
-
for (let key of __getOwnPropNames(from))
|
|
31
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
-
}
|
|
34
|
-
return to;
|
|
35
|
-
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
-
mod
|
|
43
|
-
));
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
__require,
|
|
47
|
-
__glob,
|
|
48
|
-
__esm,
|
|
49
|
-
__commonJS,
|
|
50
|
-
__export,
|
|
51
|
-
__toESM
|
|
52
|
-
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|