@memberjunction/ai-vectors-memory 6.2.0-edge.1 → 6.2.0-edge.3
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/README.md +73 -12
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/models/MetadataFilterEvaluator.d.ts +37 -0
- package/dist/models/MetadataFilterEvaluator.d.ts.map +1 -0
- package/dist/models/MetadataFilterEvaluator.js +233 -0
- package/dist/models/MetadataFilterEvaluator.js.map +1 -0
- package/dist/models/SimpleVectorDatabase.d.ts +55 -11
- package/dist/models/SimpleVectorDatabase.d.ts.map +1 -1
- package/dist/models/SimpleVectorDatabase.js +148 -35
- package/dist/models/SimpleVectorDatabase.js.map +1 -1
- package/dist/models/SimpleVectorService.d.ts +164 -12
- package/dist/models/SimpleVectorService.d.ts.map +1 -1
- package/dist/models/SimpleVectorService.js +612 -286
- package/dist/models/SimpleVectorService.js.map +1 -1
- package/dist/models/SimpleVectorServiceProvider.d.ts +151 -35
- package/dist/models/SimpleVectorServiceProvider.d.ts.map +1 -1
- package/dist/models/SimpleVectorServiceProvider.js +429 -106
- package/dist/models/SimpleVectorServiceProvider.js.map +1 -1
- package/dist/models/StoredVector.d.ts +35 -0
- package/dist/models/StoredVector.d.ts.map +1 -0
- package/dist/models/StoredVector.js +83 -0
- package/dist/models/StoredVector.js.map +1 -0
- package/dist/models/VectorAccelerator.d.ts +109 -0
- package/dist/models/VectorAccelerator.d.ts.map +1 -0
- package/dist/models/VectorAccelerator.js +97 -0
- package/dist/models/VectorAccelerator.js.map +1 -0
- package/dist/models/VectorKernels.d.ts +117 -0
- package/dist/models/VectorKernels.d.ts.map +1 -0
- package/dist/models/VectorKernels.js +338 -0
- package/dist/models/VectorKernels.js.map +1 -0
- package/dist/models/VectorStore.d.ts +157 -0
- package/dist/models/VectorStore.d.ts.map +1 -0
- package/dist/models/VectorStore.js +376 -0
- package/dist/models/VectorStore.js.map +1 -0
- package/package.json +4 -4
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Use this driver when you want SearchScope multi-provider fusion to include
|
|
5
5
|
* vector search WITHOUT standing up a remote store (Pinecone / pgvector /
|
|
6
|
-
* Qdrant). It reads the rows of a single MJ entity,
|
|
7
|
-
*
|
|
6
|
+
* Qdrant). It reads the rows of a single MJ entity, decodes each row's
|
|
7
|
+
* vector column(s), and uses {@link SimpleVectorService} for
|
|
8
8
|
* cosine ranking — exactly the same primitive `AgentContextInjector` already
|
|
9
9
|
* uses for its `FindSimilarAgentNotes` path.
|
|
10
10
|
*
|
|
@@ -32,14 +32,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
32
32
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
33
33
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
34
34
|
};
|
|
35
|
-
import { RegisterClass } from '@memberjunction/global';
|
|
35
|
+
import { EscapeSQLString, RegisterClass } from '@memberjunction/global';
|
|
36
36
|
import { CompositeKey, Metadata, RunView, LogError, LogStatus } from '@memberjunction/core';
|
|
37
37
|
import { VectorDBBase } from '@memberjunction/ai-vectordb';
|
|
38
38
|
import { SimpleVectorService } from './SimpleVectorService.js';
|
|
39
|
+
import { DecodeVectorBinary, ParseVectorJSON } from './StoredVector.js';
|
|
40
|
+
import { CompileMetadataFilter } from './MetadataFilterEvaluator.js';
|
|
39
41
|
/**
|
|
40
|
-
* Per-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
42
|
+
* Per-index cache of the parsed vectors (indexName → service + rows), so a
|
|
43
|
+
* query whose rows have not changed skips re-parsing every vector. The rows
|
|
44
|
+
* themselves are still read on every query, as the calling user. Cleared on
|
|
45
|
+
* `DeleteAllRecords`; an entry is reused only when the index config and the
|
|
46
|
+
* fingerprint of the rows just read both match (see `rowsFingerprint`).
|
|
43
47
|
*/
|
|
44
48
|
const indexCache = new Map();
|
|
45
49
|
let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
@@ -59,7 +63,7 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
59
63
|
const rv = new RunView();
|
|
60
64
|
const r = await rv.RunView({
|
|
61
65
|
EntityName: 'MJ: Vector Indexes',
|
|
62
|
-
ExtraFilter: `Name='${indexName
|
|
66
|
+
ExtraFilter: `Name='${EscapeSQLString(indexName)}'`,
|
|
63
67
|
Fields: ['ID', 'ProviderConfig'],
|
|
64
68
|
ResultType: 'simple',
|
|
65
69
|
MaxRows: 1,
|
|
@@ -86,6 +90,7 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
86
90
|
return {
|
|
87
91
|
entityName: parsed.entityName,
|
|
88
92
|
vectorField: parsed.vectorField,
|
|
93
|
+
binaryVectorField: parsed.binaryVectorField || undefined,
|
|
89
94
|
filter: parsed.filter,
|
|
90
95
|
titleField: parsed.titleField,
|
|
91
96
|
snippetField: parsed.snippetField,
|
|
@@ -99,13 +104,16 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
99
104
|
/** Materialize the index — load rows from the configured entity, parse
|
|
100
105
|
* each row's vector, and pack them into a `SimpleVectorService`.
|
|
101
106
|
*
|
|
102
|
-
* **Cache freshness model:** the
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
107
|
+
* **Cache freshness model:** the rows are read on every query, as the
|
|
108
|
+
* calling user, so row-level security always applies. The parsed
|
|
109
|
+
* vectors are reused only when the index config is unchanged and the
|
|
110
|
+
* rows just read have the same keys, `__mj_UpdatedAt` values and
|
|
111
|
+
* vector presence as the rows they were built from. A user who sees a
|
|
112
|
+
* different set of rows therefore never receives another user's
|
|
113
|
+
* vectors. An edit that bypasses `BaseEntity` (raw SQL that changes a
|
|
114
|
+
* vector without touching `__mj_UpdatedAt`) is not detected; call
|
|
115
|
+
* `DeleteAllRecords` after one. Production-scale corpora should use
|
|
116
|
+
* Pinecone/Qdrant. */
|
|
109
117
|
async loadIndex(indexName, contextUser) {
|
|
110
118
|
const config = await this.loadIndexConfig(indexName, contextUser);
|
|
111
119
|
if (!config)
|
|
@@ -114,14 +122,43 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
114
122
|
if (fetched == null)
|
|
115
123
|
return null;
|
|
116
124
|
const { entity, rows } = fetched;
|
|
125
|
+
const configJSON = JSON.stringify(config);
|
|
126
|
+
const rowsFingerprint = this.rowsFingerprint(rows, config, entity);
|
|
117
127
|
const cached = indexCache.get(indexName);
|
|
118
|
-
if (cached && cached.
|
|
119
|
-
return { config
|
|
128
|
+
if (cached && cached.configJSON === configJSON && cached.rowsFingerprint === rowsFingerprint) {
|
|
129
|
+
return { config, entity: cached.entity, service: cached.service, rowsByID: cached.rowsByID };
|
|
120
130
|
}
|
|
121
131
|
const { service, rowsByID } = this.buildServiceFromRows(rows, config, entity);
|
|
122
|
-
indexCache.set(indexName, {
|
|
132
|
+
indexCache.set(indexName, { configJSON, entity, service, rowsFingerprint, rowsByID });
|
|
123
133
|
return { config, entity, service, rowsByID };
|
|
124
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Identifies the rows a cached index was built from: the set of columns
|
|
137
|
+
* that came back, then each row's primary key, `__mj_UpdatedAt` and
|
|
138
|
+
* whether it has a vector, in the order read. Far cheaper than re-parsing
|
|
139
|
+
* every vector, and it differs whenever the rows a query sees differ —
|
|
140
|
+
* another user's row-level security, an insert-plus-delete that keeps the
|
|
141
|
+
* count, or a vector added or edited.
|
|
142
|
+
*
|
|
143
|
+
* The column set matters because the cache is shared across users and the
|
|
144
|
+
* provider drops each user's field-level-security-denied columns from the
|
|
145
|
+
* SELECT. Without it, a user who may not read `Title` or `Body` would be
|
|
146
|
+
* served the title and snippet another user's rows carried.
|
|
147
|
+
*/
|
|
148
|
+
rowsFingerprint(rows, config, entity) {
|
|
149
|
+
const parts = new Array(rows.length);
|
|
150
|
+
for (let i = 0; i < rows.length; i++) {
|
|
151
|
+
const row = rows[i];
|
|
152
|
+
const key = CompositeKey.FromEntityRecord(entity, row);
|
|
153
|
+
const updatedAt = row['__mj_UpdatedAt'];
|
|
154
|
+
const stamp = updatedAt instanceof Date ? updatedAt.toISOString() : String(updatedAt ?? '');
|
|
155
|
+
const hasBinary = config.binaryVectorField && row[config.binaryVectorField] ? 1 : 0;
|
|
156
|
+
parts[i] = `${key.ToURLSegment()}\u0001${stamp}\u0001${row[config.vectorField] ? 1 : 0}${hasBinary}`;
|
|
157
|
+
}
|
|
158
|
+
// An index with no rows has no first row to read columns from.
|
|
159
|
+
const columns = rows.length > 0 ? Object.keys(rows[0]).sort().join(',') : '';
|
|
160
|
+
return columns + '\u0003' + parts.join('\u0002');
|
|
161
|
+
}
|
|
125
162
|
/** Run RunView for the configured entity; returns null if the entity is
|
|
126
163
|
* unknown or the RunView call failed (both already logged). The entity's
|
|
127
164
|
* metadata comes back alongside the rows because its primary key column(s)
|
|
@@ -137,6 +174,8 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
137
174
|
ExtraFilter: config.filter,
|
|
138
175
|
ResultType: 'simple',
|
|
139
176
|
BypassCache: true,
|
|
177
|
+
// Binary columns are omitted from RunView unless asked for; fetch the companion when configured.
|
|
178
|
+
...(config.binaryVectorField ? { IncludeBinaryFields: true } : {}),
|
|
140
179
|
}, contextUser);
|
|
141
180
|
if (!r.Success) {
|
|
142
181
|
LogError(`SimpleVectorDatabase.loadIndex: RunView on "${config.entityName}" failed: ${r.ErrorMessage}`);
|
|
@@ -144,39 +183,67 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
144
183
|
}
|
|
145
184
|
return { entity, rows: r.Results ?? [] };
|
|
146
185
|
}
|
|
147
|
-
/**
|
|
186
|
+
/** Decode each row's vector (binary companion first, then the JSON field), and
|
|
148
187
|
* pack the survivors into a fresh `SimpleVectorService` plus the
|
|
149
188
|
* ID→row map used to enrich match metadata. Rows with missing IDs,
|
|
150
189
|
* missing vector columns, or unparseable JSON are silently skipped
|
|
151
190
|
* — callers haven't necessarily embedded every row yet (e.g. only
|
|
152
|
-
* `Status='Active'` rows have embeddings), so logging would spam.
|
|
191
|
+
* `Status='Active'` rows have embeddings), so logging would spam.
|
|
192
|
+
* Rows whose vector size differs from the first one are skipped too,
|
|
193
|
+
* with one log line, since they point at an embedding-model mix-up. */
|
|
153
194
|
buildServiceFromRows(rows, config, entity) {
|
|
154
195
|
const service = new SimpleVectorService();
|
|
155
196
|
const entries = [];
|
|
156
197
|
const rowsByID = new Map();
|
|
198
|
+
let dims = null;
|
|
199
|
+
let mismatched = 0;
|
|
157
200
|
for (const row of rows) {
|
|
158
201
|
// Key each vector by the row's full primary key — any column name(s) — in the prefixed
|
|
159
202
|
// CompositeKey segment form vector metadata carries. `row['ID']` skipped every row of an
|
|
160
203
|
// entity whose key isn't called ID, leaving the index silently empty.
|
|
161
204
|
const key = CompositeKey.FromEntityRecord(entity, row);
|
|
162
|
-
|
|
163
|
-
|
|
205
|
+
if (!key.HasValue)
|
|
206
|
+
continue;
|
|
207
|
+
const vector = this.readRowVector(row, config);
|
|
208
|
+
if (!vector)
|
|
209
|
+
continue;
|
|
210
|
+
// One vector of another size (a re-embed with a different model in progress)
|
|
211
|
+
// must not fail the whole index: skip it, and report the count once below.
|
|
212
|
+
dims ??= vector.length;
|
|
213
|
+
if (vector.length !== dims) {
|
|
214
|
+
mismatched++;
|
|
164
215
|
continue;
|
|
165
|
-
const id = key.ToURLSegment();
|
|
166
|
-
try {
|
|
167
|
-
const vector = typeof vecRaw === 'string' ? JSON.parse(vecRaw) : vecRaw;
|
|
168
|
-
if (Array.isArray(vector) && vector.every(v => typeof v === 'number')) {
|
|
169
|
-
entries.push({ key: id, vector: vector, metadata: row });
|
|
170
|
-
rowsByID.set(id, row);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
catch {
|
|
174
|
-
// Vector column is unparseable — silently skip (see JSDoc above).
|
|
175
216
|
}
|
|
217
|
+
const id = key.ToURLSegment();
|
|
218
|
+
entries.push({ key: id, vector, metadata: row });
|
|
219
|
+
rowsByID.set(id, row);
|
|
220
|
+
}
|
|
221
|
+
if (mismatched > 0) {
|
|
222
|
+
LogError(`SimpleVectorDatabase: skipped ${mismatched} "${config.entityName}" row(s) whose ${config.vectorField} has a different dimension count than the rest (${dims}) — re-embed them with one model`);
|
|
176
223
|
}
|
|
177
224
|
service.LoadVectors(entries);
|
|
178
225
|
return { service, rowsByID };
|
|
179
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Reads one row's vector: the binary companion when configured and valid, else the JSON field
|
|
229
|
+
* (a JSON string, or an already-parsed numeric array). Returns null for a row with no usable
|
|
230
|
+
* vector — callers haven't necessarily embedded every row yet.
|
|
231
|
+
*/
|
|
232
|
+
readRowVector(row, config) {
|
|
233
|
+
if (config.binaryVectorField) {
|
|
234
|
+
const binary = row[config.binaryVectorField];
|
|
235
|
+
const decoded = typeof binary === 'string' ? DecodeVectorBinary(binary) : null;
|
|
236
|
+
if (decoded)
|
|
237
|
+
return decoded;
|
|
238
|
+
}
|
|
239
|
+
const raw = row[config.vectorField];
|
|
240
|
+
if (typeof raw === 'string')
|
|
241
|
+
return ParseVectorJSON(raw);
|
|
242
|
+
if (Array.isArray(raw) && raw.length > 0 && raw.every(v => typeof v === 'number' && Number.isFinite(v))) {
|
|
243
|
+
return raw;
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
180
247
|
/** Build the metadata bag returned in QueryIndex matches. Mirrors what
|
|
181
248
|
* Pinecone/Qdrant return so {@link VectorSearchProvider.convertMatches}
|
|
182
249
|
* can consume it without special-casing. */
|
|
@@ -213,17 +280,25 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
213
280
|
// contextUser is required for RunView's server-side guard. Remote
|
|
214
281
|
// drivers (Pinecone/Qdrant) ignore it; in-process drivers like this
|
|
215
282
|
// one need it to honor row-level security on the source entity.
|
|
216
|
-
if (!indexName || !Array.isArray(queryVector)) {
|
|
283
|
+
if (!indexName || !Array.isArray(queryVector) || queryVector.length === 0) {
|
|
217
284
|
LogError(`SimpleVectorDatabase.QueryIndex: missing indexName="${indexName}" or vector (length ${Array.isArray(queryVector) ? queryVector.length : 'n/a'})`);
|
|
218
285
|
return { success: false, message: 'Missing indexName or vector', data: null };
|
|
219
286
|
}
|
|
287
|
+
// Compile the filter BEFORE loading anything: a search scope's tenant / permission push-down
|
|
288
|
+
// lives in it, so a filter this driver cannot apply fails the query instead of being ignored.
|
|
289
|
+
const compiled = CompileMetadataFilter(p.filter);
|
|
290
|
+
if (compiled.Status === 'unsupported') {
|
|
291
|
+
LogError(`SimpleVectorDatabase.QueryIndex: index="${indexName}" cannot apply its metadata filter — ${compiled.Reason}. The query is refused rather than run unfiltered.`);
|
|
292
|
+
return { success: false, message: `Unsupported metadata filter: ${compiled.Reason}`, data: null };
|
|
293
|
+
}
|
|
220
294
|
const loaded = await this.loadIndex(indexName, contextUser);
|
|
221
295
|
if (!loaded) {
|
|
222
296
|
// loadIndex / loadIndexConfig already logged the specific failure reason
|
|
223
297
|
return { success: false, message: `Index "${indexName}" not configured`, data: null };
|
|
224
298
|
}
|
|
225
|
-
LogStatus(`SimpleVectorDatabase.QueryIndex: index="${indexName}" loaded ${loaded.service.Size} vectors, querying topK=${topK}`);
|
|
226
|
-
const
|
|
299
|
+
LogStatus(`SimpleVectorDatabase.QueryIndex: index="${indexName}" loaded ${loaded.service.Size} vectors, querying topK=${topK}${compiled.Status === 'ok' ? ' with a metadata filter' : ''}`);
|
|
300
|
+
const rowFilter = compiled.Status === 'ok' ? this.rowFilter(compiled.Predicate, loaded.config, loaded.entity) : undefined;
|
|
301
|
+
const matches = loaded.service.FindNearest(queryVector, topK, 0, 'cosine', rowFilter);
|
|
227
302
|
return {
|
|
228
303
|
success: true,
|
|
229
304
|
message: `Returned ${matches.length} match(es)`,
|
|
@@ -236,6 +311,38 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
236
311
|
},
|
|
237
312
|
};
|
|
238
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Adapts a compiled metadata filter to the service's per-row filter. The filter sees the row's
|
|
316
|
+
* own columns plus the fields remote drivers store as vector metadata, so one filter means the
|
|
317
|
+
* same thing on every driver: `Entity` and `EntityName` (the configured entity name —
|
|
318
|
+
* `VectorSearchProvider` filters on the first, `SharedIndexFilterOptions.EntityNames` on the
|
|
319
|
+
* second), `RecordID` (the prefixed primary-key segment) and `SourceType` (`'entity'` — every row
|
|
320
|
+
* here is an entity record). These names take precedence over a row column of the same name.
|
|
321
|
+
*/
|
|
322
|
+
rowFilter(predicate, config, entity) {
|
|
323
|
+
return row => {
|
|
324
|
+
const read = field => {
|
|
325
|
+
switch (field) {
|
|
326
|
+
case 'Entity':
|
|
327
|
+
case 'EntityName': return config.entityName;
|
|
328
|
+
case 'SourceType': return 'entity';
|
|
329
|
+
case 'RecordID': return CompositeKey.FromEntityRecord(entity, row).ToURLSegment();
|
|
330
|
+
default: return row[field];
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
return predicate(read);
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
// ── Driver capabilities ───────────────────────────────────────────────
|
|
337
|
+
/** Vectors live in entity rows written by `BaseEntity` saves; this driver never ingests, so
|
|
338
|
+
* ingestion pipelines should skip it instead of logging an "unsupported" error per batch. */
|
|
339
|
+
get IsReadOnly() {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
/** In-process — it reads entity rows through `RunView` and calls no external service, so it needs no API key. */
|
|
343
|
+
get RequiresAPIKey() {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
239
346
|
// The remaining VectorDBBase methods are not exercised by the SearchEngine
|
|
240
347
|
// path. They throw so any caller that mistakenly uses this driver for
|
|
241
348
|
// ingestion gets a clear signal to use the real Pinecone/pgvector driver.
|
|
@@ -256,8 +363,14 @@ let SimpleVectorDatabase = class SimpleVectorDatabase extends VectorDBBase {
|
|
|
256
363
|
indexCache.clear();
|
|
257
364
|
return { success: true, message: 'cache cleared', data: null };
|
|
258
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Lists no IDs. The vectors are rows of the configured entity, readable only as a calling user
|
|
368
|
+
* (row-level security applies), and this contract carries no user — so there is no honest list
|
|
369
|
+
* to return. Callers that reconcile a remote store against its source skip read-only drivers.
|
|
370
|
+
*/
|
|
259
371
|
ListVectorIDs(_p) {
|
|
260
|
-
|
|
372
|
+
const result = { IDs: [], NextPaginationToken: undefined };
|
|
373
|
+
return Promise.resolve(result);
|
|
261
374
|
}
|
|
262
375
|
unsupported(name) {
|
|
263
376
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleVectorDatabase.js","sourceRoot":"","sources":["../../src/models/SimpleVectorDatabase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAc,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAM3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAkB5D;;;;GAIG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,EAOtB,CAAC;AAGE,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,YAAY;IAClD;;qGAEiG;IACjG;;;;;;OAMG;IACH,YAAY,MAAe,IAAI,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MA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oB,CAoWhC;;AAED;4EAC4E;AAC5E,MAAM,UAAU,wBAAwB;IACpC,6DAA6D;IAC7D,MAAM,IAAI,GAAG,oBAAoB,CAAC;AACtC,CAAC"}
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
import { DistanceMetric, VectorRowsView } from './VectorKernels.js';
|
|
2
|
+
import { VectorPrecision } from './VectorStore.js';
|
|
3
|
+
import { BaseVectorAccelerator, VectorClusterJob, VectorClusterJobResult } from './VectorAccelerator.js';
|
|
4
|
+
export type { DistanceMetric } from './VectorKernels.js';
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
6
|
+
* Construction options for {@link SimpleVectorService}.
|
|
3
7
|
*/
|
|
4
|
-
export
|
|
8
|
+
export interface SimpleVectorServiceOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Element precision of the packed store. `'float64'` (the default) keeps
|
|
11
|
+
* every value and score exactly as given. `'float32'` halves memory and is
|
|
12
|
+
* the right choice for model embeddings, which are float32 at the source;
|
|
13
|
+
* scores then differ from float64 only in the 7th significant digit.
|
|
14
|
+
*/
|
|
15
|
+
Precision?: VectorPrecision;
|
|
16
|
+
/**
|
|
17
|
+
* Accelerator to use instead of the process-wide one resolved through the
|
|
18
|
+
* ClassFactory. Mainly for tests and for callers that must stay in-process.
|
|
19
|
+
*/
|
|
20
|
+
Accelerator?: BaseVectorAccelerator;
|
|
21
|
+
}
|
|
5
22
|
/**
|
|
6
23
|
* Result of clustering operations
|
|
7
24
|
*/
|
|
@@ -27,6 +44,24 @@ export interface ClusterResult<TMetadata = Record<string, unknown>> {
|
|
|
27
44
|
/**
|
|
28
45
|
* Represents a vector entry with a unique key and associated embedding
|
|
29
46
|
*/
|
|
47
|
+
/**
|
|
48
|
+
* The values of a vector supplied to the service. A typed array is copied into the store just like
|
|
49
|
+
* a `number[]` — passing the `Float32Array` that `Base64ToFloat32Vector` (from
|
|
50
|
+
* `@memberjunction/global`) decodes from a binary embedding column avoids building an intermediate
|
|
51
|
+
* `number[]`.
|
|
52
|
+
*/
|
|
53
|
+
export type VectorValues = number[] | Float32Array | Float64Array;
|
|
54
|
+
/**
|
|
55
|
+
* A vector to load into the service: like {@link VectorEntry}, but the values may be a typed array.
|
|
56
|
+
*/
|
|
57
|
+
export interface VectorInputEntry<TMetadata = Record<string, unknown>> {
|
|
58
|
+
/** User-defined unique identifier for the vector */
|
|
59
|
+
key: string;
|
|
60
|
+
/** The embedding values; copied into the store */
|
|
61
|
+
vector: VectorValues;
|
|
62
|
+
/** Optional metadata associated with the vector */
|
|
63
|
+
metadata?: TMetadata;
|
|
64
|
+
}
|
|
30
65
|
export interface VectorEntry<TMetadata = Record<string, unknown>> {
|
|
31
66
|
/** User-defined unique identifier for the vector */
|
|
32
67
|
key: string;
|
|
@@ -70,13 +105,42 @@ export interface VectorSearchResult<TMetadata = Record<string, unknown>> {
|
|
|
70
105
|
* @public
|
|
71
106
|
*/
|
|
72
107
|
export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
73
|
-
private
|
|
108
|
+
private store;
|
|
74
109
|
private expectedDimensions;
|
|
110
|
+
private readonly explicitAccelerator;
|
|
111
|
+
/**
|
|
112
|
+
* @param {SimpleVectorServiceOptions} [options] - Storage precision and an optional explicit accelerator
|
|
113
|
+
*/
|
|
114
|
+
constructor(options?: SimpleVectorServiceOptions);
|
|
115
|
+
/**
|
|
116
|
+
* Builds a read-only service over packed rows produced elsewhere — typically
|
|
117
|
+
* shared memory a worker thread received. Each row in `candidates` (or every
|
|
118
|
+
* live row) is keyed by `String(row)`, so results map straight back to rows.
|
|
119
|
+
*/
|
|
120
|
+
static FromRowsView<T = Record<string, unknown>>(view: VectorRowsView, precision: VectorPrecision, candidates: Int32Array | null): SimpleVectorService<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Runs a clustering job in-process and returns it in rows. This is what a
|
|
123
|
+
* worker thread calls; it reuses the exact clustering code the service runs
|
|
124
|
+
* on the calling thread.
|
|
125
|
+
*/
|
|
126
|
+
static RunClusterJob(job: VectorClusterJob): VectorClusterJobResult;
|
|
127
|
+
/** Process-unique identity of this service's storage, for diagnostics and accelerator caches. */
|
|
128
|
+
get StoreID(): number;
|
|
129
|
+
/** The storage precision chosen at construction. */
|
|
130
|
+
get Precision(): VectorPrecision;
|
|
131
|
+
/**
|
|
132
|
+
* Pre-sizes storage for `additionalVectors` more vectors of `dimensions`
|
|
133
|
+
* each, so a loader adding rows one at a time allocates once instead of
|
|
134
|
+
* growing repeatedly. Optional; `LoadVectors` does this automatically.
|
|
135
|
+
*
|
|
136
|
+
* @throws {Error} If `dimensions` conflicts with vectors already loaded
|
|
137
|
+
*/
|
|
138
|
+
ReserveCapacity(additionalVectors: number, dimensions: number): void;
|
|
75
139
|
/**
|
|
76
140
|
* Loads vectors into memory. Can accept either an array of VectorEntry objects
|
|
77
141
|
* or a Map where keys are identifiers and values are vector arrays.
|
|
78
142
|
*
|
|
79
|
-
* @param {
|
|
143
|
+
* @param {VectorInputEntry<TMetadata>[] | Map<string, VectorValues>} entries - The vectors to load; values may be `number[]` or a typed array
|
|
80
144
|
* @throws {Error} If entries is null or undefined
|
|
81
145
|
*
|
|
82
146
|
* @example
|
|
@@ -97,12 +161,12 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
97
161
|
* @public
|
|
98
162
|
* @method
|
|
99
163
|
*/
|
|
100
|
-
LoadVectors(entries:
|
|
164
|
+
LoadVectors(entries: VectorInputEntry<TMetadata>[] | Map<string, VectorValues>): void;
|
|
101
165
|
/**
|
|
102
166
|
* Adds or updates a single vector in the service
|
|
103
167
|
*
|
|
104
168
|
* @param {string} key - The unique identifier for the vector
|
|
105
|
-
* @param {
|
|
169
|
+
* @param {VectorValues} vector - The vector/embedding values (`number[]` or a typed array; copied)
|
|
106
170
|
* @param {TMetadata} metadata - Optional metadata to associate with the vector
|
|
107
171
|
* @throws {Error} If key is null/undefined, or if vector is invalid
|
|
108
172
|
*
|
|
@@ -117,7 +181,7 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
117
181
|
* @public
|
|
118
182
|
* @method
|
|
119
183
|
*/
|
|
120
|
-
AddVector(key: string, vector:
|
|
184
|
+
AddVector(key: string, vector: VectorValues, metadata?: TMetadata): void;
|
|
121
185
|
/**
|
|
122
186
|
* Finds the K nearest neighbors to a query vector using the specified similarity metric
|
|
123
187
|
*
|
|
@@ -157,6 +221,48 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
157
221
|
* @method
|
|
158
222
|
*/
|
|
159
223
|
FindNearest(queryVector: number[], topK?: number, threshold?: number, metric?: DistanceMetric, filter?: (metadata: TMetadata) => boolean): VectorSearchResult<TMetadata>[];
|
|
224
|
+
/**
|
|
225
|
+
* Async form of {@link FindNearest} with identical arguments and results.
|
|
226
|
+
* Server hosts register an accelerator that runs large searches on a worker
|
|
227
|
+
* thread (and/or a native backend), so the calling thread — typically the
|
|
228
|
+
* one serving every other request — is not blocked by the scan. With no
|
|
229
|
+
* accelerator registered it runs in-process exactly like `FindNearest`.
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
* @method
|
|
233
|
+
*/
|
|
234
|
+
FindNearestAsync(queryVector: number[], topK?: number, threshold?: number, metric?: DistanceMetric, filter?: (metadata: TMetadata) => boolean): Promise<VectorSearchResult<TMetadata>[]>;
|
|
235
|
+
/**
|
|
236
|
+
* Validates a search and turns it into a job over the packed store.
|
|
237
|
+
* Returns null when the search can only produce an empty result.
|
|
238
|
+
*/
|
|
239
|
+
private planSearch;
|
|
240
|
+
private buildSearchJob;
|
|
241
|
+
/** Ascending live rows whose metadata passes the filter (rows without metadata never do). */
|
|
242
|
+
private filterRows;
|
|
243
|
+
/**
|
|
244
|
+
* Turns ranked rows into results. When the rows came from somewhere other
|
|
245
|
+
* than an in-process scan of the current store (another thread, a native
|
|
246
|
+
* backend, an approximate index) they are re-scored against the live store,
|
|
247
|
+
* so a concurrent write or a lower-precision backend can never surface a
|
|
248
|
+
* wrong score. `topK` is applied with `Array.slice` semantics, as before.
|
|
249
|
+
*/
|
|
250
|
+
private finalizeSearch;
|
|
251
|
+
private hitsFromRows;
|
|
252
|
+
/** Maps rows from the dispatch-time snapshot to current rows and scores them exactly. */
|
|
253
|
+
private rescoreRows;
|
|
254
|
+
/**
|
|
255
|
+
* Subclasses that override a metric method keep working: rank with their
|
|
256
|
+
* override, one row at a time, exactly as the service did before packing.
|
|
257
|
+
*/
|
|
258
|
+
private searchWithCustomMetric;
|
|
259
|
+
/** The accelerator this service uses: the explicit one, else the process-wide registration. */
|
|
260
|
+
private get accelerator();
|
|
261
|
+
/**
|
|
262
|
+
* True when a subclass overrides any metric method. The packed kernels
|
|
263
|
+
* cannot call an override, so such subclasses are scored row by row.
|
|
264
|
+
*/
|
|
265
|
+
private get usesCustomMetric();
|
|
160
266
|
/**
|
|
161
267
|
* Finds vectors similar to an existing vector identified by its key.
|
|
162
268
|
* The source vector itself is excluded from the results.
|
|
@@ -546,7 +652,7 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
546
652
|
* Retrieves a specific vector by its key
|
|
547
653
|
*
|
|
548
654
|
* @param {string} key - The key of the vector to retrieve
|
|
549
|
-
* @returns {number[] | undefined}
|
|
655
|
+
* @returns {number[] | undefined} A copy of the vector, or undefined if not found
|
|
550
656
|
*
|
|
551
657
|
* @example
|
|
552
658
|
* ```typescript
|
|
@@ -617,7 +723,7 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
617
723
|
* @method
|
|
618
724
|
*/
|
|
619
725
|
UpdateVector(key: string, updates: {
|
|
620
|
-
vector?:
|
|
726
|
+
vector?: VectorValues;
|
|
621
727
|
metadata?: TMetadata;
|
|
622
728
|
}): boolean;
|
|
623
729
|
/**
|
|
@@ -645,7 +751,7 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
645
751
|
* @public
|
|
646
752
|
* @method
|
|
647
753
|
*/
|
|
648
|
-
AddOrUpdateVector(key: string, vector:
|
|
754
|
+
AddOrUpdateVector(key: string, vector: VectorValues, metadata?: TMetadata): boolean;
|
|
649
755
|
/**
|
|
650
756
|
* Removes a vector from the service
|
|
651
757
|
*
|
|
@@ -682,7 +788,7 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
682
788
|
* Exports all vectors as an array of VectorEntry objects.
|
|
683
789
|
* Useful for persistence or transferring data.
|
|
684
790
|
*
|
|
685
|
-
* @returns {VectorEntry<TMetadata>[]} Array of all vector entries
|
|
791
|
+
* @returns {VectorEntry<TMetadata>[]} Array of all vector entries (vectors are copies)
|
|
686
792
|
*
|
|
687
793
|
* @example
|
|
688
794
|
* ```typescript
|
|
@@ -706,6 +812,7 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
706
812
|
* @method
|
|
707
813
|
*/
|
|
708
814
|
private validateAndSetDimensions;
|
|
815
|
+
private validateAndSetDimensionCount;
|
|
709
816
|
/**
|
|
710
817
|
* Gets the expected vector dimensions for this service instance
|
|
711
818
|
*
|
|
@@ -787,6 +894,8 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
787
894
|
* @method
|
|
788
895
|
*/
|
|
789
896
|
KMeansCluster(k: number, maxIterations?: number, metric?: DistanceMetric, tolerance?: number): ClusterResult<TMetadata>;
|
|
897
|
+
/** Assembles the K-Means result: members per cluster in insertion order, inertia, silhouette. */
|
|
898
|
+
private buildKMeansResult;
|
|
790
899
|
/**
|
|
791
900
|
* K-Means++ initialization for better starting centroids.
|
|
792
901
|
* Chooses initial centroids that are far apart from each other.
|
|
@@ -794,11 +903,23 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
794
903
|
* @private
|
|
795
904
|
*/
|
|
796
905
|
private initializeKMeansPlusPlus;
|
|
906
|
+
/** Index of the nearest centroid for each row (first centroid wins a tie). */
|
|
907
|
+
private assignToNearestCentroid;
|
|
908
|
+
/** Mean of each cluster's members, summed in insertion order like {@link FindCentroid}. */
|
|
909
|
+
private recomputeCentroids;
|
|
910
|
+
/** Largest euclidean distance (1 - similarity) any centroid moved. */
|
|
911
|
+
private maxCentroidMovement;
|
|
912
|
+
private centroidFromRow;
|
|
797
913
|
/**
|
|
798
914
|
* Check if cluster assignments have converged
|
|
799
915
|
* @private
|
|
800
916
|
*/
|
|
801
|
-
private
|
|
917
|
+
private sameAssignments;
|
|
918
|
+
/**
|
|
919
|
+
* Scores rows and centroids with the clustering metric. Subclasses that
|
|
920
|
+
* override a metric method get it honoured here too, row by row.
|
|
921
|
+
*/
|
|
922
|
+
private createScorer;
|
|
802
923
|
/**
|
|
803
924
|
* Performs DBSCAN (Density-Based Spatial Clustering of Applications with Noise) clustering.
|
|
804
925
|
*
|
|
@@ -849,6 +970,12 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
849
970
|
* @method
|
|
850
971
|
*/
|
|
851
972
|
DBSCANCluster(epsilon: number, minPoints: number, metric?: DistanceMetric, filter?: (metadata: TMetadata) => boolean): ClusterResult<TMetadata>;
|
|
973
|
+
/**
|
|
974
|
+
* Each row's neighbours — every row in `rows` scoring at least
|
|
975
|
+
* `similarityThreshold` (itself included) — ranked highest first, ties in
|
|
976
|
+
* insertion order. Indexed by row.
|
|
977
|
+
*/
|
|
978
|
+
private buildNeighborhoods;
|
|
852
979
|
/**
|
|
853
980
|
* Expand a cluster in DBSCAN
|
|
854
981
|
* @private
|
|
@@ -1001,5 +1128,30 @@ export declare class SimpleVectorService<TMetadata = Record<string, unknown>> {
|
|
|
1001
1128
|
* @method
|
|
1002
1129
|
*/
|
|
1003
1130
|
ElbowMethod(minK: number, maxK: number, metric?: DistanceMetric): Map<number, number>;
|
|
1131
|
+
/**
|
|
1132
|
+
* Async form of {@link KMeansCluster} with identical arguments and results.
|
|
1133
|
+
* On a server host with a worker-pool accelerator the whole run — including
|
|
1134
|
+
* the O(n²) silhouette score — happens on a worker thread, so a large
|
|
1135
|
+
* clustering request does not stall every other request on the process.
|
|
1136
|
+
*
|
|
1137
|
+
* @public
|
|
1138
|
+
* @method
|
|
1139
|
+
*/
|
|
1140
|
+
KMeansClusterAsync(k: number, maxIterations?: number, metric?: DistanceMetric, tolerance?: number): Promise<ClusterResult<TMetadata>>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Async form of {@link DBSCANCluster} with identical arguments and results.
|
|
1143
|
+
* The metadata filter runs on the calling thread; the O(n²) neighbourhood
|
|
1144
|
+
* scan and the silhouette score run on a worker when one is available.
|
|
1145
|
+
*
|
|
1146
|
+
* @public
|
|
1147
|
+
* @method
|
|
1148
|
+
*/
|
|
1149
|
+
DBSCANClusterAsync(epsilon: number, minPoints: number, metric?: DistanceMetric, filter?: (metadata: TMetadata) => boolean): Promise<ClusterResult<TMetadata>>;
|
|
1150
|
+
/** Converts a key-based result whose keys are `String(row)` (see {@link FromRowsView}) into rows. */
|
|
1151
|
+
private static clusterResultToRows;
|
|
1152
|
+
/** Maps an off-thread result back to keys using the row→key array captured at dispatch. */
|
|
1153
|
+
private clusterResultFromRows;
|
|
1154
|
+
/** Current rows for `keys`, -1 where a key is not stored. */
|
|
1155
|
+
private rowsForKeys;
|
|
1004
1156
|
}
|
|
1005
1157
|
//# sourceMappingURL=SimpleVectorService.d.ts.map
|