@memberjunction/ai-vector-sync 1.2.1 → 1.3.0
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/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/generic/EntityDocumentTemplateParser.d.ts +18 -0
- package/dist/generic/EntityDocumentTemplateParser.d.ts.map +1 -0
- package/dist/generic/EntityDocumentTemplateParser.js +145 -0
- package/dist/generic/EntityDocumentTemplateParser.js.map +1 -0
- package/dist/generic/vectorSync.types.d.ts +12 -0
- package/dist/generic/vectorSync.types.d.ts.map +1 -0
- package/dist/generic/{entity.types.js → vectorSync.types.js} +1 -1
- package/dist/generic/vectorSync.types.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/models/EntityDocumentCache.d.ts +19 -0
- package/dist/models/EntityDocumentCache.d.ts.map +1 -0
- package/dist/models/EntityDocumentCache.js +62 -0
- package/dist/models/EntityDocumentCache.js.map +1 -0
- package/dist/models/entityVectorSync.d.ts +19 -45
- package/dist/models/entityVectorSync.d.ts.map +1 -1
- package/dist/models/entityVectorSync.js +177 -251
- package/dist/models/entityVectorSync.js.map +1 -1
- package/package.json +7 -9
- package/dist/generic/entity.types.d.ts +0 -24
- package/dist/generic/entity.types.d.ts.map +0 -1
- package/dist/generic/entity.types.js.map +0 -1
- package/dist/models/vectorSyncBase.d.ts +0 -28
- package/dist/models/vectorSyncBase.d.ts.map +0 -1
- package/dist/models/vectorSyncBase.js +0 -115
- package/dist/models/vectorSyncBase.js.map +0 -1
|
@@ -1,292 +1,218 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
3
|
exports.EntityVectorSyncer = void 0;
|
|
30
|
-
const fs = __importStar(require("fs"));
|
|
31
|
-
const db_1 = __importDefault(require("../db/db"));
|
|
32
|
-
const sqlserver_dataprovider_1 = require("@memberjunction/sqlserver-dataprovider");
|
|
33
|
-
const dbAI_1 = __importDefault(require("../db/dbAI"));
|
|
34
4
|
const core_1 = require("@memberjunction/core");
|
|
35
|
-
const config_1 = require("../config");
|
|
36
5
|
const ai_1 = require("@memberjunction/ai");
|
|
37
6
|
const ai_vectordb_1 = require("@memberjunction/ai-vectordb");
|
|
38
7
|
const global_1 = require("@memberjunction/global");
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
8
|
+
const ai_vectors_1 = require("@memberjunction/ai-vectors");
|
|
9
|
+
const EntityDocumentTemplateParser_1 = require("../generic/EntityDocumentTemplateParser");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const EntityDocumentCache_1 = require("./EntityDocumentCache");
|
|
12
|
+
class EntityVectorSyncer extends ai_vectors_1.VectorBase {
|
|
44
13
|
_startTime;
|
|
45
14
|
_endTime;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
GetAIModel() {
|
|
49
|
-
const model = aiengine_1.AIEngine.Models.find(m => m.AIModelTypeID === 3);
|
|
50
|
-
return model;
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
51
17
|
}
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
throw new Error("No Vector Databases found");
|
|
18
|
+
async VectorizeEntity(request, contextUser) {
|
|
19
|
+
if (!contextUser) {
|
|
20
|
+
throw new Error('ContextUser is required to vectorize the entity');
|
|
58
21
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
-
await this.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const activeCount = entityConfigs.filter((entity) => entity.IncludeInSync).length;
|
|
75
|
-
console.log(`${entityConfigs.length} entity config(s) found, ${activeCount} marked active`);
|
|
76
|
-
for (const entityConfig of entityConfigs) {
|
|
77
|
-
if (entityConfig.IncludeInSync) {
|
|
78
|
-
console.log(`Syncing entity document with ID ${entityConfig.EntityDocumentID}`);
|
|
79
|
-
await this.syncEntityDocument(entityConfig);
|
|
80
|
-
entityConfig.LastRunDate = new Date().toISOString();
|
|
22
|
+
super.CurrentUser = contextUser;
|
|
23
|
+
const parser = EntityDocumentTemplateParser_1.EntityDocumentTemplateParser.CreateInstance();
|
|
24
|
+
const entityDocument = await this.GetEntityDocument(request.entityDocumentID);
|
|
25
|
+
const vectorIndexEntity = await this.GetOrCreateVectorIndex(entityDocument);
|
|
26
|
+
const obj = await this.GetVectorDatabaseAndEmbeddingClassByEntityDocumentID(request.entityDocumentID);
|
|
27
|
+
const allrecords = await super.getRecordsByEntityID(request.entityID);
|
|
28
|
+
const batchSize = 20;
|
|
29
|
+
const chunks = this.chunkArray(allrecords, batchSize);
|
|
30
|
+
(0, core_1.LogStatus)(`Processing ${allrecords.length} records in ${chunks.length} chunks of ${batchSize} records each`);
|
|
31
|
+
let count = 0;
|
|
32
|
+
for (const batch of chunks) {
|
|
33
|
+
const promises = [];
|
|
34
|
+
for (const record of batch) {
|
|
35
|
+
const promise = parser.Parse(entityDocument.Template, request.entityID, record, contextUser);
|
|
36
|
+
promises.push(promise);
|
|
81
37
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
async setupDBConnection() {
|
|
95
|
-
await db_1.default.connect();
|
|
96
|
-
this._provider = await this.setupAndGetSQLServerProvider();
|
|
97
|
-
this._userInfo = this.getDefaultUser(this._provider);
|
|
98
|
-
this._runView = new core_1.RunView();
|
|
99
|
-
}
|
|
100
|
-
setupAndGetSQLServerProvider = async () => {
|
|
101
|
-
const config = new sqlserver_dataprovider_1.SQLServerProviderConfigData(dbAI_1.default, config_1.currentUserEmail);
|
|
102
|
-
return await (0, sqlserver_dataprovider_1.setupSQLServerClient)(config);
|
|
103
|
-
};
|
|
104
|
-
getDefaultUser(provider) {
|
|
105
|
-
return new core_1.UserInfo(provider, { Email: config_1.currentUserEmail,
|
|
106
|
-
UserRoles: [
|
|
107
|
-
{ UserID: 24, RoleName: "Developer", CreatedAt: new Date(), UpdatedAt: new Date(), User: "Jonathan Stfelix" },
|
|
108
|
-
{ UserID: 24, RoleName: "UI", CreatedAt: new Date(), UpdatedAt: new Date(), User: "Jonathan Stfelix" }
|
|
109
|
-
]
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
async timer(ms) {
|
|
113
|
-
return new Promise(res => setTimeout(res, ms));
|
|
114
|
-
}
|
|
115
|
-
async syncEntityDocument(config) {
|
|
116
|
-
const entityDocument = await this.getEntityDocument(config.EntityDocumentID);
|
|
117
|
-
if (!entityDocument) {
|
|
118
|
-
console.log(`Error: no entity document with ID ${config.EntityDocumentID} found`);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (entityDocument.Status !== "Active") {
|
|
122
|
-
console.log(`Entity document with ID ${config.EntityDocumentID} is not set to Active. Is: ${entityDocument.Status}`);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const lastRunDate = new Date(config.LastRunDate);
|
|
126
|
-
console.log(`Last run date for entity document ${entityDocument.ID}: ${lastRunDate}`);
|
|
127
|
-
let offset = 0;
|
|
128
|
-
let fetchNext = 50;
|
|
129
|
-
let limit = 100;
|
|
130
|
-
let shouldContinue = true;
|
|
131
|
-
while (shouldContinue) {
|
|
132
|
-
const rvParams = {
|
|
133
|
-
EntityName: entityDocument.Type,
|
|
134
|
-
OrderBy: `ID OFFSET ${offset} ROWS FETCH NEXT ${fetchNext} ROWS ONLY`,
|
|
135
|
-
IgnoreMaxRows: true
|
|
136
|
-
};
|
|
137
|
-
let result = await this._runView.RunView(rvParams, this._userInfo);
|
|
138
|
-
console.log("processing embedding batch #", (offset / fetchNext) + 1, `of ${entityDocument.Type}-${entityDocument.Name} records`);
|
|
139
|
-
for (const record of result.Results) {
|
|
140
|
-
if (!record.ID || !record.UpdatedAt || record.UpdatedAt <= lastRunDate) {
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
const formattedTemplate = this.parseStringTemplate(entityDocument.Template, record);
|
|
144
|
-
const embedResponse = this._embedding.EmbedText({ text: formattedTemplate, model: null });
|
|
145
|
-
const embeddingRes = (await embedResponse).data;
|
|
146
|
-
await this.timer(100);
|
|
147
|
-
const recordID = record.ID;
|
|
148
|
-
const entityRecordDocument = await this.getEntityRecordDocument(entityDocument.EntityID, recordID, config.VectorIndexID, config.VectorID);
|
|
149
|
-
const erdID = entityRecordDocument ? entityRecordDocument.ID : -1;
|
|
150
|
-
let upsertResult = await this.upsertEntityRecordDocument({
|
|
151
|
-
ID: erdID,
|
|
152
|
-
EntityID: entityDocument.EntityID,
|
|
153
|
-
RecordID: recordID,
|
|
154
|
-
DocumentText: formattedTemplate,
|
|
155
|
-
VectorIndexID: config.VectorIndexID,
|
|
156
|
-
VectorID: config.VectorID,
|
|
157
|
-
VectorJSON: JSON.stringify(embeddingRes),
|
|
158
|
-
EntitiyRecordUpdatedAt: record.UpdatedAt
|
|
159
|
-
});
|
|
160
|
-
let vectorRecordID = upsertResult?.recordset[0].ID?.toString();
|
|
161
|
-
if (!vectorRecordID) {
|
|
162
|
-
vectorRecordID = `${entityDocument.Type}${entityDocument.Name}${recordID}`;
|
|
163
|
-
}
|
|
164
|
-
const existingRecord = (await this._vectorDB.getRecord({ id: vectorRecordID })).data;
|
|
165
|
-
let updateParams = {
|
|
166
|
-
id: null,
|
|
167
|
-
data: {
|
|
168
|
-
id: vectorRecordID,
|
|
169
|
-
values: embeddingRes
|
|
38
|
+
const templates = await Promise.all(promises);
|
|
39
|
+
const embeddings = await obj.embedding.EmbedTexts({ texts: templates, model: null });
|
|
40
|
+
const vectorRecords = embeddings.vectors.map((vector, index) => {
|
|
41
|
+
const recordID = batch[index].PrimaryKeys.map((pk) => `${pk.Name}=${pk.Value}`).join("_");
|
|
42
|
+
return {
|
|
43
|
+
id: `${entityDocument.Entity}_${entityDocument.ID}_${recordID}`,
|
|
44
|
+
values: vector,
|
|
45
|
+
metadata: {
|
|
46
|
+
EntityID: entityDocument.EntityID,
|
|
47
|
+
PrimaryKeys: this.convertPrimaryKeysToList(batch[index].PrimaryKeys),
|
|
48
|
+
Template: templates[index]
|
|
170
49
|
}
|
|
171
50
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
51
|
+
});
|
|
52
|
+
const response = await obj.vectorDB.createRecords(vectorRecords);
|
|
53
|
+
if (response.success && vectorIndexEntity) {
|
|
54
|
+
(0, core_1.LogStatus)("Successfully created vector records, creating associated Entity Record Documents...");
|
|
55
|
+
for (const [index, vectorRecord] of vectorRecords.entries()) {
|
|
56
|
+
try {
|
|
57
|
+
let erdEntity = await super.Metadata.GetEntityObject("Entity Record Documents");
|
|
58
|
+
erdEntity.NewRecord();
|
|
59
|
+
erdEntity.EntityID = entityDocument.EntityID;
|
|
60
|
+
erdEntity.RecordID = batch[index].PrimaryKey.Value;
|
|
61
|
+
erdEntity.DocumentText = templates[index];
|
|
62
|
+
erdEntity.VectorID = vectorRecord.id;
|
|
63
|
+
erdEntity.VectorJSON = JSON.stringify(vectorRecord.values);
|
|
64
|
+
erdEntity.VectorIndexID = vectorIndexEntity.ID;
|
|
65
|
+
erdEntity.EntityRecordUpdatedAt = new Date();
|
|
66
|
+
erdEntity.EntityDocumentID = entityDocument.ID;
|
|
67
|
+
let erdEntitySaveResult = await super.SaveEntity(erdEntity);
|
|
68
|
+
if (!erdEntitySaveResult) {
|
|
69
|
+
(0, core_1.LogError)("Error saving Entity Record Document Entity");
|
|
181
70
|
}
|
|
182
|
-
}
|
|
183
|
-
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
(0, core_1.LogError)("Error saving Entity Record Document Entity");
|
|
74
|
+
(0, core_1.LogError)(err);
|
|
75
|
+
}
|
|
184
76
|
}
|
|
185
77
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
shouldContinue = false;
|
|
78
|
+
else {
|
|
79
|
+
(0, core_1.LogError)(response.message);
|
|
189
80
|
}
|
|
81
|
+
let delayRes = await this.delay(1000);
|
|
82
|
+
count += 1;
|
|
83
|
+
(0, core_1.LogStatus)(`Chunk ${count} of out ${chunks.length} processed`);
|
|
190
84
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
async CreateDefaultEntityDocument(EntityID, VectorDatabase, AIModel) {
|
|
88
|
+
const md = new core_1.Metadata();
|
|
89
|
+
const entity = md.Entities.find(e => e.ID === EntityID);
|
|
90
|
+
if (!entity)
|
|
91
|
+
throw new Error(`Entity with ID ${EntityID} not found.`);
|
|
92
|
+
const EDTemplate = entity.Fields.map(ef => {
|
|
93
|
+
return `${ef.Name}: \$\{${ef.Name}\}`;
|
|
94
|
+
}).join(" ");
|
|
95
|
+
const entityDocument = await md.GetEntityObject("Entity Documents");
|
|
96
|
+
entityDocument.NewRecord();
|
|
97
|
+
entityDocument.Name = `Default duplicate record Entity Document for the ${entity.Name} entity using vector database ${VectorDatabase.Name} and AI Model ${AIModel.Name}`;
|
|
98
|
+
entityDocument.EntityID = EntityID;
|
|
99
|
+
entityDocument.TypeID = constants_1.RECORD_DUPLICATES_TYPE_ID;
|
|
100
|
+
entityDocument.Status = "Active";
|
|
101
|
+
entityDocument.Template = EDTemplate;
|
|
102
|
+
entityDocument.VectorDatabaseID = VectorDatabase.ID;
|
|
103
|
+
entityDocument.AIModelID = AIModel.ID;
|
|
104
|
+
let saveResult = await this.SaveEntity(entityDocument);
|
|
105
|
+
if (saveResult) {
|
|
106
|
+
return entityDocument;
|
|
199
107
|
}
|
|
200
108
|
else {
|
|
201
|
-
|
|
202
|
-
const entityDocument = vdResults[0];
|
|
203
|
-
return entityDocument;
|
|
109
|
+
throw new Error(`Failed to save Entity Document for ${EntityID}`);
|
|
204
110
|
}
|
|
205
111
|
}
|
|
206
|
-
async
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
112
|
+
async GetVectorDatabaseAndEmbeddingClassByEntityDocumentID(entityDocumentID, createDocumentIfNotFound = false) {
|
|
113
|
+
let entityDocument = await this.GetEntityDocument(entityDocumentID) || await this.GetFirstActiveEntityDocumentForEntity(entityDocumentID);
|
|
114
|
+
if (!entityDocument) {
|
|
115
|
+
if (createDocumentIfNotFound) {
|
|
116
|
+
if (!entityDocument) {
|
|
117
|
+
(0, core_1.LogStatus)(`No active Entity Document found for entity ${entityDocumentID}, creating one`);
|
|
118
|
+
const defaultVectorDB = this.getVectorDatabase();
|
|
119
|
+
const defaultAIModel = this.getAIModel();
|
|
120
|
+
entityDocument = await this.CreateDefaultEntityDocument(entityDocumentID, defaultVectorDB, defaultAIModel);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
throw new Error(`No Entity Document found for ID=${entityDocumentID}`);
|
|
125
|
+
}
|
|
213
126
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
127
|
+
(0, core_1.LogStatus)(`Using vector database ${entityDocument.VectorDatabaseID} and AI Model ${entityDocument.AIModelID}`);
|
|
128
|
+
const vectorDBEntity = this.getVectorDatabase(entityDocument.VectorDatabaseID);
|
|
129
|
+
const aiModelEntity = this.getAIModel(entityDocument.AIModelID);
|
|
130
|
+
const embeddingAPIKey = (0, ai_1.GetAIAPIKey)(aiModelEntity.DriverClass);
|
|
131
|
+
const vectorDBAPIKey = (0, ai_1.GetAIAPIKey)(vectorDBEntity.ClassKey);
|
|
132
|
+
if (!embeddingAPIKey) {
|
|
133
|
+
throw Error(`No API Key found for AI Model ${aiModelEntity.DriverClass}`);
|
|
134
|
+
}
|
|
135
|
+
if (!vectorDBAPIKey) {
|
|
136
|
+
throw Error(`No API Key found for Vector Database ${vectorDBEntity.ClassKey}`);
|
|
137
|
+
}
|
|
138
|
+
const embedding = global_1.MJGlobal.Instance.ClassFactory.CreateInstance(ai_1.Embeddings, aiModelEntity.DriverClass, embeddingAPIKey);
|
|
139
|
+
const vectorDB = global_1.MJGlobal.Instance.ClassFactory.CreateInstance(ai_vectordb_1.VectorDBBase, vectorDBEntity.ClassKey, vectorDBAPIKey);
|
|
140
|
+
if (!embedding) {
|
|
141
|
+
throw Error(`Failed to create Embeddings instance for AI Model ${aiModelEntity.DriverClass}`);
|
|
218
142
|
}
|
|
143
|
+
if (!vectorDB) {
|
|
144
|
+
throw Error(`Failed to create Vector Database instance for ${vectorDBEntity.ClassKey}`);
|
|
145
|
+
}
|
|
146
|
+
return { embedding, vectorDB };
|
|
219
147
|
}
|
|
220
|
-
async
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
OrderBy: 'ID'
|
|
225
|
-
}, this._userInfo);
|
|
226
|
-
if (!rvResult || rvResult.RowCount === 0) {
|
|
227
|
-
return null;
|
|
148
|
+
async GetEntityDocument(EntityDocumentID) {
|
|
149
|
+
const cache = EntityDocumentCache_1.EntityDocumentCache.Instance;
|
|
150
|
+
if (!cache.IsLoaded) {
|
|
151
|
+
await cache.Refresh(super.CurrentUser);
|
|
228
152
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
153
|
+
return cache.GetDocument(EntityDocumentID);
|
|
154
|
+
}
|
|
155
|
+
async GetEntityDocumentByName(EntityDocumentName, ContextUser) {
|
|
156
|
+
const cache = EntityDocumentCache_1.EntityDocumentCache.Instance;
|
|
157
|
+
if (!cache.IsLoaded) {
|
|
158
|
+
await cache.Refresh(ContextUser);
|
|
233
159
|
}
|
|
160
|
+
return cache.GetDocumentByName(EntityDocumentName);
|
|
234
161
|
}
|
|
235
|
-
async
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
RecordID: document.RecordID,
|
|
241
|
-
DocumentText: document.DocumentText,
|
|
242
|
-
VectorIndexID: document.VectorIndexID,
|
|
243
|
-
VectorID: document.VectorID,
|
|
244
|
-
VectorJSON: document.VectorJSON,
|
|
245
|
-
EntityRecordUpdatedAt: document.EntitiyRecordUpdatedAt
|
|
246
|
-
};
|
|
247
|
-
if (sp === "admin.spCreateEntityRecordDocument") {
|
|
248
|
-
delete params.ID;
|
|
162
|
+
async GetFirstActiveEntityDocumentForEntity(entityID) {
|
|
163
|
+
const entityDocument = await this.runViewForSingleValue("Entity Documents", `EntityID = ${entityID} AND TypeID = 9 AND Status = 'Active'`);
|
|
164
|
+
if (!entityDocument) {
|
|
165
|
+
(0, core_1.LogError)(`No active Entity Document with entityID=${entityID} found`);
|
|
166
|
+
return null;
|
|
249
167
|
}
|
|
250
|
-
|
|
251
|
-
return result;
|
|
168
|
+
return entityDocument;
|
|
252
169
|
}
|
|
253
|
-
async
|
|
170
|
+
async GetOrCreateVectorIndex(entityDocument) {
|
|
171
|
+
let vectorIndexEntity = await super.runViewForSingleValue("Vector Indexes", `VectorDatabaseID = ${entityDocument.VectorDatabaseID} AND EmbeddingModelID = ${entityDocument.AIModelID}`);
|
|
172
|
+
if (vectorIndexEntity) {
|
|
173
|
+
return vectorIndexEntity;
|
|
174
|
+
}
|
|
175
|
+
(0, core_1.LogStatus)(`No Vector Index found for entityDocument ${entityDocument.ID}, creating one`);
|
|
254
176
|
try {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
177
|
+
vectorIndexEntity = await super.Metadata.GetEntityObject("Vector Indexes");
|
|
178
|
+
vectorIndexEntity.NewRecord();
|
|
179
|
+
vectorIndexEntity.VectorDatabaseID = entityDocument.VectorDatabaseID;
|
|
180
|
+
vectorIndexEntity.EmbeddingModelID = entityDocument.AIModelID;
|
|
181
|
+
vectorIndexEntity.Name = `Vector Index for entityDocument ${entityDocument.EntityID}`;
|
|
182
|
+
vectorIndexEntity.Set("EntityRecordUpdatedAt", new Date());
|
|
183
|
+
vectorIndexEntity.Set("EntityDocumentID", entityDocument.ID);
|
|
184
|
+
vectorIndexEntity.Description = `Vector Index that uses the Vector database ${entityDocument.VectorDatabaseID} and ${entityDocument.AIModelID} as the embedding model`;
|
|
185
|
+
const saveResult = await super.SaveEntity(vectorIndexEntity);
|
|
186
|
+
if (saveResult) {
|
|
187
|
+
(0, core_1.LogStatus)(`Successfully created new Vector Index Entity`);
|
|
188
|
+
return vectorIndexEntity;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
(0, core_1.LogError)("Error saving Vector Index Entity");
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
258
194
|
}
|
|
259
|
-
catch (
|
|
260
|
-
|
|
195
|
+
catch (err) {
|
|
196
|
+
(0, core_1.LogError)(err);
|
|
261
197
|
return null;
|
|
262
198
|
}
|
|
263
199
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
let args = str.match(/[^{\}]+(?=})/g) || [];
|
|
272
|
-
let parameters = args.map(argument => obj[argument] || (obj[argument] === undefined ? "" : obj[argument]));
|
|
273
|
-
return String.raw({ raw: parts }, ...parameters);
|
|
274
|
-
}
|
|
275
|
-
start() {
|
|
276
|
-
this._startTime = new Date();
|
|
277
|
-
}
|
|
278
|
-
end() {
|
|
279
|
-
this._endTime = new Date();
|
|
280
|
-
}
|
|
281
|
-
timeDiff() {
|
|
282
|
-
let timeDiff = this._endTime.valueOf() - this._startTime.valueOf();
|
|
283
|
-
timeDiff /= 1000;
|
|
284
|
-
var seconds = Math.round(timeDiff);
|
|
285
|
-
return seconds;
|
|
200
|
+
chunkArray(array, chunkSize) {
|
|
201
|
+
let arrayCopy = [...array];
|
|
202
|
+
let result = [];
|
|
203
|
+
while (arrayCopy.length) {
|
|
204
|
+
result.push(arrayCopy.splice(0, chunkSize));
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
286
207
|
}
|
|
287
|
-
|
|
288
|
-
|
|
208
|
+
convertPrimaryKeysToList(primaryKeys) {
|
|
209
|
+
return primaryKeys.map((pk) => {
|
|
210
|
+
return `${pk.Name}=${pk.Value}`;
|
|
211
|
+
});
|
|
289
212
|
}
|
|
213
|
+
delay = (delayInms) => {
|
|
214
|
+
return new Promise(resolve => setTimeout(resolve, delayInms));
|
|
215
|
+
};
|
|
290
216
|
}
|
|
291
217
|
exports.EntityVectorSyncer = EntityVectorSyncer;
|
|
292
218
|
//# sourceMappingURL=entityVectorSync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityVectorSync.js","sourceRoot":"","sources":["../../src/models/entityVectorSync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entityVectorSync.js","sourceRoot":"","sources":["../../src/models/entityVectorSync.ts"],"names":[],"mappings":";;;AAAA,+CAA0G;AAC1G,2CAA8E;AAC9E,6DAAuF;AACvF,mDAAkD;AAGlD,2DAAuD;AACvD,0FAAuF;AACvF,4CAAyD;AACzD,+DAA4D;AAE5D,MAAa,kBAAmB,SAAQ,uBAAU;IAC9C,UAAU,CAAO;IACjB,QAAQ,CAAO;IAEf;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,OAA0B,EAAE,WAAqB;QAC1E,IAAG,CAAC,WAAW,EAAC,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvE,CAAC;QAED,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;QAChC,MAAM,MAAM,GAAG,2DAA4B,CAAC,cAAc,EAAE,CAAC;QAC7D,MAAM,cAAc,GAAyB,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACpG,MAAM,iBAAiB,GAAsB,MAAM,IAAI,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC;QAC/F,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,oDAAoD,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACtG,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KAAY,EAAE,SAAiB;QAC9C,IAAI,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;QAC3B,IAAI,MAAM,GAAmB,EAAE,CAAC;QAChC,OAAM,SAAS,CAAC,MAAM,EAAC,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,wBAAwB,CAAC,WAA0B;QACvD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;YAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;QACpC,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,KAAK,GAAG,CAAC,SAAS,EAAE,EAAE;QAC1B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;CACL;AA1PD,gDA0PC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ai-vector-sync",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "MemberJunction: AI Vector/Entity Sync Package - handles synchronization between Vector DB and MJ CDP Data",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,14 +15,12 @@
|
|
|
15
15
|
"author": "MemberJunction.com",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@memberjunction/ai": "~1.
|
|
19
|
-
"@memberjunction/ai-vectordb": "~1.
|
|
20
|
-
"@memberjunction/ai-vectors": "~1.
|
|
21
|
-
"@memberjunction/
|
|
22
|
-
"@memberjunction/
|
|
23
|
-
"@memberjunction/
|
|
24
|
-
"@memberjunction/global": "~1.2.1",
|
|
25
|
-
"@memberjunction/sqlserver-dataprovider": "~1.2.1",
|
|
18
|
+
"@memberjunction/ai": "~1.3.0",
|
|
19
|
+
"@memberjunction/ai-vectordb": "~1.3.0",
|
|
20
|
+
"@memberjunction/ai-vectors": "~1.3.0",
|
|
21
|
+
"@memberjunction/aiengine": "~1.3.0",
|
|
22
|
+
"@memberjunction/core": "~1.3.0",
|
|
23
|
+
"@memberjunction/global": "~1.3.0",
|
|
26
24
|
"dotenv": "^16.0.3",
|
|
27
25
|
"typeorm": "^0.3.20"
|
|
28
26
|
},
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type EntityDocument = {
|
|
2
|
-
ID: number;
|
|
3
|
-
Name: string;
|
|
4
|
-
EntityID: number;
|
|
5
|
-
TypeID: number;
|
|
6
|
-
Status: string;
|
|
7
|
-
Template: string;
|
|
8
|
-
CreatedAt: Date;
|
|
9
|
-
UpdatedAt: Date;
|
|
10
|
-
Type: string;
|
|
11
|
-
VectorIndexID: number;
|
|
12
|
-
VectorID: number;
|
|
13
|
-
};
|
|
14
|
-
export type EntitiyRecordDocument = {
|
|
15
|
-
ID: number;
|
|
16
|
-
EntityID: number;
|
|
17
|
-
RecordID: number;
|
|
18
|
-
DocumentText: string;
|
|
19
|
-
VectorIndexID: number;
|
|
20
|
-
VectorID: number;
|
|
21
|
-
VectorJSON: string;
|
|
22
|
-
EntitiyRecordUpdatedAt: Date;
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=entity.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity.types.d.ts","sourceRoot":"","sources":["../../src/generic/entity.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,IAAI,CAAA;CAC/B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity.types.js","sourceRoot":"","sources":["../../src/generic/entity.types.ts"],"names":[],"mappings":""}
|