@futdevpro/nts-dynamo 1.15.71 → 1.15.72
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/.dynamo/logs/cicd-pipeline/output.log +1655 -1562
- package/.dynamo/logs/cicd-pipeline/status.json +38 -38
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.d.ts +15 -0
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.d.ts.map +1 -1
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.js +34 -6
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.js.map +1 -1
- package/package.json +1 -1
- package/src/_modules/local-vector-search/_services/lvs-vector-pool.control-service.spec.ts +52 -0
- package/src/_modules/local-vector-search/_services/lvs-vector-pool.control-service.ts +39 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"pid":
|
|
3
|
-
"startedAt": "2026-06-21T00:
|
|
4
|
-
"startedAtMs":
|
|
2
|
+
"pid": 6137,
|
|
3
|
+
"startedAt": "2026-06-21T00:34:15.872Z",
|
|
4
|
+
"startedAtMs": 1782002055872,
|
|
5
5
|
"phase": "npm-publish",
|
|
6
6
|
"pipelineComplete": false,
|
|
7
7
|
"serverRunning": false,
|
|
@@ -10,83 +10,83 @@
|
|
|
10
10
|
"steps": {
|
|
11
11
|
"validate-secrets": {
|
|
12
12
|
"status": "ok",
|
|
13
|
-
"startedAt": "2026-06-21T00:
|
|
13
|
+
"startedAt": "2026-06-21T00:34:15.910Z",
|
|
14
14
|
"logLineStart": 2,
|
|
15
15
|
"logLineEnd": 7,
|
|
16
|
-
"durationSec":
|
|
16
|
+
"durationSec": 1.6
|
|
17
17
|
},
|
|
18
18
|
"discord-start": {
|
|
19
19
|
"status": "ok",
|
|
20
|
-
"startedAt": "2026-06-21T00:
|
|
20
|
+
"startedAt": "2026-06-21T00:34:18.482Z",
|
|
21
21
|
"logLineStart": 8,
|
|
22
22
|
"logLineEnd": 13,
|
|
23
|
-
"durationSec":
|
|
23
|
+
"durationSec": 4.1
|
|
24
24
|
},
|
|
25
25
|
"pre-flight": {
|
|
26
26
|
"status": "ok",
|
|
27
|
-
"startedAt": "2026-06-21T00:
|
|
27
|
+
"startedAt": "2026-06-21T00:34:23.536Z",
|
|
28
28
|
"logLineStart": 14,
|
|
29
29
|
"logLineEnd": 16,
|
|
30
30
|
"durationSec": 0.2
|
|
31
31
|
},
|
|
32
32
|
"install": {
|
|
33
33
|
"status": "ok",
|
|
34
|
-
"startedAt": "2026-06-21T00:
|
|
34
|
+
"startedAt": "2026-06-21T00:34:24.765Z",
|
|
35
35
|
"logLineStart": 17,
|
|
36
|
-
"logLineEnd":
|
|
37
|
-
"durationSec":
|
|
36
|
+
"logLineEnd": 154,
|
|
37
|
+
"durationSec": 63.8
|
|
38
38
|
},
|
|
39
39
|
"check-dev-leftovers": {
|
|
40
40
|
"status": "ok",
|
|
41
|
-
"startedAt": "2026-06-21T00:
|
|
42
|
-
"logLineStart":
|
|
43
|
-
"logLineEnd":
|
|
44
|
-
"durationSec":
|
|
41
|
+
"startedAt": "2026-06-21T00:35:29.554Z",
|
|
42
|
+
"logLineStart": 155,
|
|
43
|
+
"logLineEnd": 162,
|
|
44
|
+
"durationSec": 3.8
|
|
45
45
|
},
|
|
46
46
|
"build": {
|
|
47
47
|
"status": "ok",
|
|
48
|
-
"startedAt": "2026-06-21T00:
|
|
49
|
-
"logLineStart":
|
|
50
|
-
"logLineEnd":
|
|
51
|
-
"durationSec":
|
|
48
|
+
"startedAt": "2026-06-21T00:35:34.359Z",
|
|
49
|
+
"logLineStart": 163,
|
|
50
|
+
"logLineEnd": 164,
|
|
51
|
+
"durationSec": 29.3
|
|
52
52
|
},
|
|
53
53
|
"test": {
|
|
54
54
|
"status": "ok",
|
|
55
|
-
"startedAt": "2026-06-21T00:04
|
|
56
|
-
"logLineStart":
|
|
57
|
-
"logLineEnd":
|
|
58
|
-
"durationSec":
|
|
55
|
+
"startedAt": "2026-06-21T00:36:04.719Z",
|
|
56
|
+
"logLineStart": 165,
|
|
57
|
+
"logLineEnd": 2869,
|
|
58
|
+
"durationSec": 47.5,
|
|
59
59
|
"testSummary": {
|
|
60
|
-
"totalSpecs":
|
|
60
|
+
"totalSpecs": 1429,
|
|
61
61
|
"failures": 0,
|
|
62
|
-
"passed":
|
|
63
|
-
"testDurationSec":
|
|
62
|
+
"passed": 1429,
|
|
63
|
+
"testDurationSec": 8.566
|
|
64
64
|
},
|
|
65
65
|
"errors": [
|
|
66
66
|
{
|
|
67
|
-
"line":
|
|
67
|
+
"line": 247,
|
|
68
68
|
"text": "❌❌ Error handleMessage: Error: Test error",
|
|
69
|
-
"details": "at UserContext.<anonymous> (/tmp/pipeline-runs/
|
|
70
|
-
"detailLineEnd":
|
|
69
|
+
"details": "at UserContext.<anonymous> (/tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/build/_modules/assistant/_services/ass-io.control-service.spec.js:68:136)\nat QueueRunner.attempt (/tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8414:40)\nat QueueRunner.run (/tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8452:27)\nat runNext (/tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8355:16)\nat /tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8361:11\nat /tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8241:9",
|
|
70
|
+
"detailLineEnd": 253
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
|
-
"line":
|
|
73
|
+
"line": 260,
|
|
74
74
|
"text": "❌❌ Error handleMessage: Error: Test error",
|
|
75
|
-
"details": "at UserContext.<anonymous> (/tmp/pipeline-runs/
|
|
76
|
-
"detailLineEnd":
|
|
75
|
+
"details": "at UserContext.<anonymous> (/tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/build/_modules/assistant/_services/ass-io.control-service.spec.js:92:136)\nat QueueRunner.attempt (/tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8414:40)\nat QueueRunner.run (/tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8452:27)\nat runNext (/tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8355:16)\nat /tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8361:11\nat /tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/node_modules/.pnpm/jasmine-core@5.10.0/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8241:9",
|
|
76
|
+
"detailLineEnd": 266
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
"line":
|
|
80
|
-
"text": "
|
|
81
|
-
"details": "📍 /tmp/pipeline-runs/
|
|
82
|
-
"detailLineEnd":
|
|
79
|
+
"line": 1467,
|
|
80
|
+
"text": "...............................❌ getDataByDependencyId failed, dependencyKey is missing from service! (test_data)",
|
|
81
|
+
"details": "'Test API Call' was UNSUCCESSFUL\n📍 /tmp/pipeline-runs/32ad17ba-0cce-4f24-a15f-6679bde2dbfd/build/_services/base/data.service.spec.js:182:87",
|
|
82
|
+
"detailLineEnd": 1468
|
|
83
83
|
}
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"npm-publish": {
|
|
87
87
|
"status": "running",
|
|
88
|
-
"startedAt": "2026-06-21T00:
|
|
89
|
-
"logLineStart":
|
|
88
|
+
"startedAt": "2026-06-21T00:36:53.406Z",
|
|
89
|
+
"logLineStart": 2870,
|
|
90
90
|
"logLineEnd": null,
|
|
91
91
|
"durationSec": null
|
|
92
92
|
}
|
|
@@ -16,6 +16,16 @@ export declare class LVS_VectorPool_ControlService {
|
|
|
16
16
|
* Key: vektor ID, Value: L2 normalizált vektor értékek
|
|
17
17
|
*/
|
|
18
18
|
private normalizedVectorPool;
|
|
19
|
+
/**
|
|
20
|
+
* `normalizedOnly` mód: ha `true`, a pool NEM tárolja a nyers vektorokat (`vectorPool`) — CSAK a
|
|
21
|
+
* normalizált másolatot. A kizárólag-cosine fogyasztóknak (pl. RAG-keresés) ez ~50% memória-megtakarítás
|
|
22
|
+
* (a két párhuzamos pool helyett egy). Ekkor az `l2Distance`-keresés és a `getAll()` nyers-érték-olvasása
|
|
23
|
+
* N/A (a `size()` + a `cosineSimilarity`-keresés továbbra is helyes). Default `false` (visszafelé kompatibilis).
|
|
24
|
+
*/
|
|
25
|
+
private readonly normalizedOnly;
|
|
26
|
+
constructor(set?: {
|
|
27
|
+
normalizedOnly?: boolean;
|
|
28
|
+
});
|
|
19
29
|
/**
|
|
20
30
|
* Hozzáad egy vektort a pool-hoz
|
|
21
31
|
* Opcionálisan L2 normalizált másolatot is tárol
|
|
@@ -29,6 +39,11 @@ export declare class LVS_VectorPool_ControlService {
|
|
|
29
39
|
* Frissít egy vektort a pool-ban
|
|
30
40
|
*/
|
|
31
41
|
updateVector(id: string, vector: number[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* A pool elemszáma. Mindkét módban helyes (a `normalizedVectorPool` a forrás), így `normalizedOnly`
|
|
44
|
+
* módban is — szemben a `getAll().size`-szal, ami ott üres (a nyers pool nincs tárolva).
|
|
45
|
+
*/
|
|
46
|
+
size(): number;
|
|
32
47
|
/**
|
|
33
48
|
* Törli az összes vektort a pool-ból
|
|
34
49
|
*/
|
package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lvs-vector-pool.control-service.d.ts","sourceRoot":"","sources":["../../../../src/_modules/local-vector-search/_services/lvs-vector-pool.control-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E;;;;GAIG;AACH,qBAAa,6BAA6B;IACxC;;;OAGG;IACH,OAAO,CAAC,UAAU,CAAsD;IAExE;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAAsD;IAElF;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"lvs-vector-pool.control-service.d.ts","sourceRoot":"","sources":["../../../../src/_modules/local-vector-search/_services/lvs-vector-pool.control-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E;;;;GAIG;AACH,qBAAa,6BAA6B;IACxC;;;OAGG;IACH,OAAO,CAAC,UAAU,CAAsD;IAExE;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAAsD;IAElF;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;gBAE7B,GAAG,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE;IAI9C;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IA0B7C;;OAEG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAK9B;;OAEG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAShD;;;OAGG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;;OAGG;IACH,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAI/B;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAa1B;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM;IAsBzD;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM;IAiBnD;;;;;;;;;;;;OAYG;IACH,MAAM,CACJ,KAAK,EAAE,MAAM,EAAE,EACf,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,eAAe,EACrB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,gBAAgB,EAAE;CA6EtB"}
|
|
@@ -18,6 +18,16 @@ class LVS_VectorPool_ControlService {
|
|
|
18
18
|
* Key: vektor ID, Value: L2 normalizált vektor értékek
|
|
19
19
|
*/
|
|
20
20
|
normalizedVectorPool = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* `normalizedOnly` mód: ha `true`, a pool NEM tárolja a nyers vektorokat (`vectorPool`) — CSAK a
|
|
23
|
+
* normalizált másolatot. A kizárólag-cosine fogyasztóknak (pl. RAG-keresés) ez ~50% memória-megtakarítás
|
|
24
|
+
* (a két párhuzamos pool helyett egy). Ekkor az `l2Distance`-keresés és a `getAll()` nyers-érték-olvasása
|
|
25
|
+
* N/A (a `size()` + a `cosineSimilarity`-keresés továbbra is helyes). Default `false` (visszafelé kompatibilis).
|
|
26
|
+
*/
|
|
27
|
+
normalizedOnly;
|
|
28
|
+
constructor(set) {
|
|
29
|
+
this.normalizedOnly = set?.normalizedOnly ?? false;
|
|
30
|
+
}
|
|
21
31
|
/**
|
|
22
32
|
* Hozzáad egy vektort a pool-hoz
|
|
23
33
|
* Opcionálisan L2 normalizált másolatot is tárol
|
|
@@ -35,8 +45,10 @@ class LVS_VectorPool_ControlService {
|
|
|
35
45
|
throw new Error(`Vector must contain only finite numbers at index ${i}`);
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
|
-
// Tároljuk az eredeti vektort
|
|
39
|
-
this.
|
|
48
|
+
// Tároljuk az eredeti vektort — KIVÉVE normalizedOnly módban (akkor a nyers pool kihagyva, ~50% memória).
|
|
49
|
+
if (!this.normalizedOnly) {
|
|
50
|
+
this.vectorPool.set(id, vector);
|
|
51
|
+
}
|
|
40
52
|
// L2 normalizált másolatot is tárolunk a cosine similarity számításokhoz
|
|
41
53
|
const normalized = LVS_VectorPool_ControlService.l2Normalize(vector);
|
|
42
54
|
this.normalizedVectorPool.set(id, normalized);
|
|
@@ -52,11 +64,19 @@ class LVS_VectorPool_ControlService {
|
|
|
52
64
|
* Frissít egy vektort a pool-ban
|
|
53
65
|
*/
|
|
54
66
|
updateVector(id, vector) {
|
|
55
|
-
|
|
67
|
+
// A `normalizedVectorPool` a forrás (mindkét módban populált; `normalizedOnly`-ban a `vectorPool` üres).
|
|
68
|
+
if (!this.normalizedVectorPool.has(id)) {
|
|
56
69
|
throw new Error(`Vector with ID "${id}" does not exist`);
|
|
57
70
|
}
|
|
58
71
|
this.addVector(id, vector);
|
|
59
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* A pool elemszáma. Mindkét módban helyes (a `normalizedVectorPool` a forrás), így `normalizedOnly`
|
|
75
|
+
* módban is — szemben a `getAll().size`-szal, ami ott üres (a nyers pool nincs tárolva).
|
|
76
|
+
*/
|
|
77
|
+
size() {
|
|
78
|
+
return this.normalizedVectorPool.size;
|
|
79
|
+
}
|
|
60
80
|
/**
|
|
61
81
|
* Törli az összes vektort a pool-ból
|
|
62
82
|
*/
|
|
@@ -147,11 +167,19 @@ class LVS_VectorPool_ControlService {
|
|
|
147
167
|
if (k <= 0) {
|
|
148
168
|
throw new Error('k must be a positive number');
|
|
149
169
|
}
|
|
150
|
-
|
|
170
|
+
// `normalizedOnly` módban nincs nyers pool → l2Distance nem számolható (csak cosine).
|
|
171
|
+
if (this.normalizedOnly && mode === lvs_search_mode_enum_1.LVS_Search_Mode.l2Distance) {
|
|
172
|
+
throw new Error('l2Distance search is not available in normalizedOnly mode (raw vectors are not stored)');
|
|
173
|
+
}
|
|
174
|
+
// Üres pool → üres eredmény. A `normalizedVectorPool` a forrás (mindkét módban populált; a nyers
|
|
175
|
+
// `vectorPool` `normalizedOnly`-ban üres, ezért NEM azon ellenőrzünk).
|
|
176
|
+
if (this.normalizedVectorPool.size === 0) {
|
|
151
177
|
return [];
|
|
152
178
|
}
|
|
153
|
-
// Validáljuk, hogy minden vektor ugyanolyan dimenziójú-e
|
|
154
|
-
|
|
179
|
+
// Validáljuk, hogy minden vektor ugyanolyan dimenziójú-e. A referencia-pool mód-függő: l2 a nyers,
|
|
180
|
+
// cosine a normalizált (azonos dimenzió, de `normalizedOnly`-ban a nyers pool üres).
|
|
181
|
+
const referencePool = mode === lvs_search_mode_enum_1.LVS_Search_Mode.l2Distance ? this.vectorPool : this.normalizedVectorPool;
|
|
182
|
+
const firstVector = Array.from(referencePool.values())[0];
|
|
155
183
|
if (firstVector && firstVector.length !== query.length) {
|
|
156
184
|
throw new Error(`Query vector dimension (${query.length}) does not match pool vector ` +
|
|
157
185
|
`dimension (${firstVector.length})`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lvs-vector-pool.control-service.js","sourceRoot":"","sources":["../../../../src/_modules/local-vector-search/_services/lvs-vector-pool.control-service.ts"],"names":[],"mappings":";;;AAAA,yEAAiE;AAGjE;;;;GAIG;AACH,MAAa,6BAA6B;IACxC;;;OAGG;IACK,UAAU,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAExE;;;OAGG;IACK,oBAAoB,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAElF;;;OAGG;IACH,SAAS,CAAC,EAAU,EAAE,MAAgB;QACpC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QAED,0CAA0C;QAC1C,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/C,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,EAAE,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,
|
|
1
|
+
{"version":3,"file":"lvs-vector-pool.control-service.js","sourceRoot":"","sources":["../../../../src/_modules/local-vector-search/_services/lvs-vector-pool.control-service.ts"],"names":[],"mappings":";;;AAAA,yEAAiE;AAGjE;;;;GAIG;AACH,MAAa,6BAA6B;IACxC;;;OAGG;IACK,UAAU,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAExE;;;OAGG;IACK,oBAAoB,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAElF;;;;;OAKG;IACc,cAAc,CAAU;IAEzC,YAAY,GA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AAE,6BAA6B,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;YACvF,CAAC;YACD,4DAA4D;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAmB,EAAE,CAAmB,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QAChF,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,gCAAgC;QAChC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF;AAtQD,sEAsQC"}
|
package/package.json
CHANGED
|
@@ -451,5 +451,57 @@ describe('| LVS_VectorPool_ControlService', () => {
|
|
|
451
451
|
expect(results.length).toBe(0);
|
|
452
452
|
});
|
|
453
453
|
});
|
|
454
|
+
|
|
455
|
+
describe('| normalizedOnly mode (memory-optimized cosine-only pool)', () => {
|
|
456
|
+
let pool: LVS_VectorPool_ControlService;
|
|
457
|
+
|
|
458
|
+
beforeEach(() => {
|
|
459
|
+
pool = new LVS_VectorPool_ControlService({ normalizedOnly: true });
|
|
460
|
+
pool.addVector('vec1', [1, 0, 0]);
|
|
461
|
+
pool.addVector('vec2', [0, 1, 0]);
|
|
462
|
+
pool.addVector('vec3', [1, 1, 0]);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
it('| should NOT store raw vectors (getAll empty) but size() correct', () => {
|
|
466
|
+
expect(pool.getAll().size).toBe(0);
|
|
467
|
+
expect(pool.size()).toBe(3);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it('| cosine search works identically to a normal pool', () => {
|
|
471
|
+
const normal: LVS_VectorPool_ControlService = new LVS_VectorPool_ControlService();
|
|
472
|
+
normal.addVector('vec1', [1, 0, 0]);
|
|
473
|
+
normal.addVector('vec2', [0, 1, 0]);
|
|
474
|
+
normal.addVector('vec3', [1, 1, 0]);
|
|
475
|
+
|
|
476
|
+
const query: number[] = [1, 0.2, 0];
|
|
477
|
+
const a: LVS_SearchResult[] = pool.search(query, 3, LVS_Search_Mode.cosineSimilarity);
|
|
478
|
+
const b: LVS_SearchResult[] = normal.search(query, 3, LVS_Search_Mode.cosineSimilarity);
|
|
479
|
+
expect(a.length).toBe(b.length);
|
|
480
|
+
for (let i: number = 0; i < a.length; i++) {
|
|
481
|
+
expect(a[i].id).toBe(b[i].id);
|
|
482
|
+
expect(a[i].score).toBeCloseTo(b[i].score, 12);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
it('| cosine search honors candidateIds in normalizedOnly mode', () => {
|
|
487
|
+
const results: LVS_SearchResult[] = pool.search(
|
|
488
|
+
[1, 0, 0], 10, LVS_Search_Mode.cosineSimilarity, new Set<string>(['vec2', 'vec3'])
|
|
489
|
+
);
|
|
490
|
+
expect(results.length).toBe(2);
|
|
491
|
+
for (const r of results) {
|
|
492
|
+
expect(['vec2', 'vec3']).toContain(r.id);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it('| l2Distance throws in normalizedOnly mode (no raw vectors)', () => {
|
|
497
|
+
expect(() => pool.search([1, 0, 0], 3, LVS_Search_Mode.l2Distance))
|
|
498
|
+
.toThrowError(/normalizedOnly/);
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
it('| updateVector works (checks normalized pool, not raw)', () => {
|
|
502
|
+
expect(() => pool.updateVector('vec1', [0, 0, 1])).not.toThrow();
|
|
503
|
+
expect(() => pool.updateVector('missing', [0, 0, 1])).toThrowError(/does not exist/);
|
|
504
|
+
});
|
|
505
|
+
});
|
|
454
506
|
});
|
|
455
507
|
|
|
@@ -19,6 +19,18 @@ export class LVS_VectorPool_ControlService {
|
|
|
19
19
|
*/
|
|
20
20
|
private normalizedVectorPool: Map<string, number[]> = new Map<string, number[]>();
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* `normalizedOnly` mód: ha `true`, a pool NEM tárolja a nyers vektorokat (`vectorPool`) — CSAK a
|
|
24
|
+
* normalizált másolatot. A kizárólag-cosine fogyasztóknak (pl. RAG-keresés) ez ~50% memória-megtakarítás
|
|
25
|
+
* (a két párhuzamos pool helyett egy). Ekkor az `l2Distance`-keresés és a `getAll()` nyers-érték-olvasása
|
|
26
|
+
* N/A (a `size()` + a `cosineSimilarity`-keresés továbbra is helyes). Default `false` (visszafelé kompatibilis).
|
|
27
|
+
*/
|
|
28
|
+
private readonly normalizedOnly: boolean;
|
|
29
|
+
|
|
30
|
+
constructor(set?: { normalizedOnly?: boolean }) {
|
|
31
|
+
this.normalizedOnly = set?.normalizedOnly ?? false;
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
/**
|
|
23
35
|
* Hozzáad egy vektort a pool-hoz
|
|
24
36
|
* Opcionálisan L2 normalizált másolatot is tárol
|
|
@@ -39,8 +51,10 @@ export class LVS_VectorPool_ControlService {
|
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
|
|
42
|
-
// Tároljuk az eredeti vektort
|
|
43
|
-
this.
|
|
54
|
+
// Tároljuk az eredeti vektort — KIVÉVE normalizedOnly módban (akkor a nyers pool kihagyva, ~50% memória).
|
|
55
|
+
if (!this.normalizedOnly) {
|
|
56
|
+
this.vectorPool.set(id, vector);
|
|
57
|
+
}
|
|
44
58
|
|
|
45
59
|
// L2 normalizált másolatot is tárolunk a cosine similarity számításokhoz
|
|
46
60
|
const normalized: number[] = LVS_VectorPool_ControlService.l2Normalize(vector);
|
|
@@ -59,13 +73,22 @@ export class LVS_VectorPool_ControlService {
|
|
|
59
73
|
* Frissít egy vektort a pool-ban
|
|
60
74
|
*/
|
|
61
75
|
updateVector(id: string, vector: number[]): void {
|
|
62
|
-
|
|
76
|
+
// A `normalizedVectorPool` a forrás (mindkét módban populált; `normalizedOnly`-ban a `vectorPool` üres).
|
|
77
|
+
if (!this.normalizedVectorPool.has(id)) {
|
|
63
78
|
throw new Error(`Vector with ID "${id}" does not exist`);
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
this.addVector(id, vector);
|
|
67
82
|
}
|
|
68
83
|
|
|
84
|
+
/**
|
|
85
|
+
* A pool elemszáma. Mindkét módban helyes (a `normalizedVectorPool` a forrás), így `normalizedOnly`
|
|
86
|
+
* módban is — szemben a `getAll().size`-szal, ami ott üres (a nyers pool nincs tárolva).
|
|
87
|
+
*/
|
|
88
|
+
size(): number {
|
|
89
|
+
return this.normalizedVectorPool.size;
|
|
90
|
+
}
|
|
91
|
+
|
|
69
92
|
/**
|
|
70
93
|
* Törli az összes vektort a pool-ból
|
|
71
94
|
*/
|
|
@@ -181,12 +204,22 @@ export class LVS_VectorPool_ControlService {
|
|
|
181
204
|
throw new Error('k must be a positive number');
|
|
182
205
|
}
|
|
183
206
|
|
|
184
|
-
|
|
207
|
+
// `normalizedOnly` módban nincs nyers pool → l2Distance nem számolható (csak cosine).
|
|
208
|
+
if (this.normalizedOnly && mode === LVS_Search_Mode.l2Distance) {
|
|
209
|
+
throw new Error('l2Distance search is not available in normalizedOnly mode (raw vectors are not stored)');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Üres pool → üres eredmény. A `normalizedVectorPool` a forrás (mindkét módban populált; a nyers
|
|
213
|
+
// `vectorPool` `normalizedOnly`-ban üres, ezért NEM azon ellenőrzünk).
|
|
214
|
+
if (this.normalizedVectorPool.size === 0) {
|
|
185
215
|
return [];
|
|
186
216
|
}
|
|
187
217
|
|
|
188
|
-
// Validáljuk, hogy minden vektor ugyanolyan dimenziójú-e
|
|
189
|
-
|
|
218
|
+
// Validáljuk, hogy minden vektor ugyanolyan dimenziójú-e. A referencia-pool mód-függő: l2 a nyers,
|
|
219
|
+
// cosine a normalizált (azonos dimenzió, de `normalizedOnly`-ban a nyers pool üres).
|
|
220
|
+
const referencePool: Map<string, number[]> =
|
|
221
|
+
mode === LVS_Search_Mode.l2Distance ? this.vectorPool : this.normalizedVectorPool;
|
|
222
|
+
const firstVector: number[] | undefined = Array.from(referencePool.values())[0];
|
|
190
223
|
if (firstVector && firstVector.length !== query.length) {
|
|
191
224
|
throw new Error(
|
|
192
225
|
`Query vector dimension (${query.length}) does not match pool vector ` +
|