@memberjunction/server 2.38.0 → 2.40.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/config.d.ts +99 -30
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +29 -13
- package/dist/config.js.map +1 -1
- package/dist/generated/generated.d.ts +3 -0
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +15 -0
- package/dist/generated/generated.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.d.ts +3 -3
- package/dist/resolvers/AskSkipResolver.d.ts.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +137 -80
- package/dist/resolvers/AskSkipResolver.js.map +1 -1
- package/dist/scheduler/LearningCycleScheduler.d.ts.map +1 -1
- package/dist/scheduler/LearningCycleScheduler.js +4 -1
- package/dist/scheduler/LearningCycleScheduler.js.map +1 -1
- package/package.json +22 -22
- package/src/config.ts +34 -17
- package/src/generated/generated.ts +9 -0
- package/src/resolvers/AskSkipResolver.ts +639 -144
- package/src/scheduler/LearningCycleScheduler.ts +7 -2
|
@@ -72,7 +72,7 @@ export declare class AskSkipResolver {
|
|
|
72
72
|
protected processAddOrUpdateSkipNote(change: SkipLearningCycleNoteChange, agentID: string, user: UserInfo): Promise<boolean>;
|
|
73
73
|
protected processDeleteSkipNote(change: SkipLearningCycleNoteChange, user: UserInfo): Promise<boolean>;
|
|
74
74
|
protected CreateAIMessageConversationDetail(apiResponse: SkipAPIResponse, conversationID: string, user: UserInfo): Promise<string>;
|
|
75
|
-
protected buildBaseSkipRequest(contextUser: UserInfo, dataSource: DataSource, includeEntities: boolean, includeQueries: boolean, includeNotes: boolean, includeRequests: boolean, forceEntitiesRefresh?: boolean, includeCallBackKeyAndAccessToken?: boolean, additionalTokenInfo?: any): Promise<BaseSkipRequest>;
|
|
75
|
+
protected buildBaseSkipRequest(contextUser: UserInfo, dataSource: DataSource, includeEntities: boolean, includeQueries: boolean, includeNotes: boolean, filterUserNotesToContextUser: boolean, includeRequests: boolean, forceEntitiesRefresh?: boolean, includeCallBackKeyAndAccessToken?: boolean, additionalTokenInfo?: any): Promise<BaseSkipRequest>;
|
|
76
76
|
protected buildSkipLearningAPIRequest(learningCycleId: string, lastLearningCycleDate: Date, includeEntities: boolean, includeQueries: boolean, includeNotes: boolean, includeRequests: boolean, dataSource: DataSource, contextUser: UserInfo, forceEntitiesRefresh?: boolean, includeCallBackKeyAndAccessToken?: boolean): Promise<SkipAPILearningCycleRequest>;
|
|
77
77
|
protected BuildSkipLearningCycleNewConversations(lastLearningCycleDate: Date, dataSource: DataSource, contextUser: UserInfo): Promise<SkipConversation[]>;
|
|
78
78
|
protected BuildSkipRequests(contextUser: UserInfo): Promise<SkipAPIAgentRequest[]>;
|
|
@@ -83,7 +83,7 @@ export declare class AskSkipResolver {
|
|
|
83
83
|
protected buildSkipAPIKeys(): SkipAPIRequestAPIKey[];
|
|
84
84
|
ExecuteAskSkipAnalysisQuery(UserQuestion: string, ConversationId: string, { dataSource, userPayload }: AppContext, pubSub: PubSubEngine, DataContextId?: string, ForceEntityRefresh?: boolean): Promise<AskSkipResultType>;
|
|
85
85
|
protected BuildSkipQueries(status?: "Pending" | "In-Review" | "Approved" | "Rejected" | "Obsolete"): SkipQueryInfo[];
|
|
86
|
-
protected BuildSkipAgentNotes(contextUser: UserInfo): Promise<{
|
|
86
|
+
protected BuildSkipAgentNotes(contextUser: UserInfo, filterUserNotesToContextUser: boolean): Promise<{
|
|
87
87
|
notes: SkipAPIAgentNote[];
|
|
88
88
|
noteTypes: SkipAPIAgentNoteType[];
|
|
89
89
|
}>;
|
|
@@ -113,7 +113,7 @@ export declare class AskSkipResolver {
|
|
|
113
113
|
protected FinishConversationAndNotifyUser(apiResponse: SkipAPIAnalysisCompleteResponse, dataContext: DataContext, dataContextEntity: DataContextEntity, md: Metadata, user: UserInfo, convoEntity: ConversationEntity, pubSub: PubSubEngine, userPayload: UserPayload, dataSource: DataSource): Promise<{
|
|
114
114
|
AIMessageConversationDetailID: string;
|
|
115
115
|
}>;
|
|
116
|
-
protected getAgentNoteTypeIDByName(name: string): string;
|
|
116
|
+
protected getAgentNoteTypeIDByName(name: string, defaultNoteType?: string): string;
|
|
117
117
|
protected getViewData(ViewId: string, user: UserInfo): Promise<any>;
|
|
118
118
|
ManuallyExecuteSkipLearningCycle(OrganizationId?: string): Promise<ManualLearningCycleResultType>;
|
|
119
119
|
GetLearningCycleStatus(): Promise<LearningCycleStatusType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskSkipResolver.d.ts","sourceRoot":"","sources":["../../src/resolvers/AskSkipResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,YAAY,EAAmB,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAuB,QAAQ,EAAW,QAAQ,EAAgB,eAAe,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3J,OAAO,EAAE,UAAU,EAAE,WAAW,EAAwB,MAAM,aAAa,CAAC;AAI5E,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAK3D,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACX,+BAA+B,EAC/B,0BAA0B,EAC1B,iCAAiC,EACjC,cAAc,EACd,aAAa,EAEb,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EAIpB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAOL,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAGlB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAOrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAqB,kBAAkB,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AAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,iBAAiB,EACpC,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,kBAAkB,EAC/B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC;QAAE,6BAA6B,EAAE,MAAM,CAAA;KAAE,CAAC;IA6JrD,SAAS,CAAC,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,GAAE,MAAa,GAAG,MAAM;cAoBxE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAenE,gCAAgC,CACqB,cAAc,CAAC,EAAE,MAAM,GAC/E,OAAO,CAAC,6BAA6B,CAAC;IAiDnC,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAiC1D,kCAAkC,CACD,cAAc,EAAE,MAAM,GAC1D,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IAiCpC,gCAAgC,CACC,cAAc,EAAE,MAAM,GAC1D,OAAO,CAAC,2BAA2B,CAAC;CA6BxC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -22,7 +22,7 @@ import { LoadDataContextItemsServer } from '@memberjunction/data-context-server'
|
|
|
22
22
|
import { LearningCycleScheduler } from '../scheduler/LearningCycleScheduler.js';
|
|
23
23
|
LoadDataContextItemsServer();
|
|
24
24
|
import { PUSH_STATUS_UPDATES_TOPIC } from '../generic/PushStatusResolver.js';
|
|
25
|
-
import {
|
|
25
|
+
import { apiKey, baseUrl, configInfo, graphqlPort, mj_core_schema } from '../config.js';
|
|
26
26
|
import { registerEnumType } from 'type-graphql';
|
|
27
27
|
import { MJGlobal, CopyScalarsAndArrays } from '@memberjunction/global';
|
|
28
28
|
import { sendPostRequest } from '../util.js';
|
|
@@ -191,44 +191,60 @@ StopLearningCycleResultType = __decorate([
|
|
|
191
191
|
ObjectType()
|
|
192
192
|
], StopLearningCycleResultType);
|
|
193
193
|
export { StopLearningCycleResultType };
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
194
|
+
function initializeSkipLearningCycleScheduler() {
|
|
195
|
+
try {
|
|
196
|
+
const eventListener = MJGlobal.Instance.GetEventListener(true);
|
|
197
|
+
eventListener.subscribe(event => {
|
|
198
|
+
if (event.eventCode === MJ_SERVER_EVENT_CODE && event.args?.type === 'setupComplete') {
|
|
199
|
+
try {
|
|
200
|
+
const skipConfigInfo = configInfo.askSkip;
|
|
201
|
+
if (!skipConfigInfo) {
|
|
202
|
+
LogStatus('Skip AI Learning Cycle Scheduler not started: Skip configuration not found');
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (!skipConfigInfo.learningCycleEnabled) {
|
|
206
|
+
LogStatus('Skip AI Learning Cycles not enabled in configuration');
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!skipConfigInfo.learningCycleURL || skipConfigInfo.learningCycleURL.trim().length === 0) {
|
|
210
|
+
LogError('Skip AI Learning cycle scheduler not started: Learning cycles are enabled but no Learning Cycle API endpoint is configured');
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const dataSources = event.args.dataSources;
|
|
214
|
+
if (dataSources && dataSources.length > 0) {
|
|
215
|
+
const scheduler = LearningCycleScheduler.Instance;
|
|
216
|
+
scheduler.setDataSources(dataSources);
|
|
217
|
+
const interval = skipConfigInfo.learningCycleIntervalInMinutes ?? 60;
|
|
218
|
+
if (skipConfigInfo.learningCycleRunUponStartup) {
|
|
219
|
+
LogStatus('Skip API Learning Cycle: Run Upon Startup is enabled, running learning cycle immediately');
|
|
216
220
|
scheduler.start(interval);
|
|
217
221
|
}
|
|
218
222
|
else {
|
|
219
|
-
|
|
223
|
+
LogStatus(`Skip API Learning Cycle: Scheduler first run will start after interval of ${interval} minutes. If you want a learing cycle to run immediately, set the learningCycleRunUponStartup property in the config file to true.`);
|
|
224
|
+
setTimeout(() => {
|
|
225
|
+
LogStatus(`Skip API Learning Cycle: Starting scheduler after ${interval} minutes. If you want a learing cycle to run immediately, set the learningCycleRunUponStartup property in the config file to true.`);
|
|
226
|
+
scheduler.start(interval);
|
|
227
|
+
}, interval * 60 * 1000);
|
|
220
228
|
}
|
|
221
229
|
}
|
|
222
|
-
|
|
223
|
-
LogError(
|
|
230
|
+
else {
|
|
231
|
+
LogError('Cannot initialize Skip learning cycle scheduler: No data sources available');
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
LogError(`Error initializing Skip learning cycle scheduler: ${error}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
LogError(`Failed to initialize Skip learning cycle scheduler: ${error}`);
|
|
231
242
|
}
|
|
243
|
+
}
|
|
244
|
+
initializeSkipLearningCycleScheduler();
|
|
245
|
+
let AskSkipResolver = class AskSkipResolver {
|
|
246
|
+
static { AskSkipResolver_1 = this; }
|
|
247
|
+
static _defaultNewChatName = 'New Chat';
|
|
232
248
|
static _maxHistoricalMessages = 30;
|
|
233
249
|
async ExecuteAskSkipRecordChat(UserQuestion, ConversationId, EntityName, compositeKey, { dataSource, userPayload }, pubSub) {
|
|
234
250
|
const user = UserCache.Instance.Users.find((u) => u.Email.trim().toLowerCase() === userPayload.email.trim().toLowerCase());
|
|
@@ -271,17 +287,18 @@ let AskSkipResolver = class AskSkipResolver {
|
|
|
271
287
|
return this.handleSimpleSkipChatPostRequest(input, convoEntity.ID, convoDetailEntity.ID, true, user);
|
|
272
288
|
}
|
|
273
289
|
async ExecuteAskSkipLearningCycle({ dataSource, userPayload }, ForceEntityRefresh) {
|
|
274
|
-
|
|
290
|
+
const skipConfigInfo = configInfo.askSkip;
|
|
291
|
+
if (!skipConfigInfo.learningCycleEnabled) {
|
|
275
292
|
return {
|
|
276
293
|
success: false,
|
|
277
|
-
error: 'Learning cycles are
|
|
294
|
+
error: 'Learning cycles are not enabled in configuration',
|
|
278
295
|
elapsedTime: 0,
|
|
279
296
|
noteChanges: [],
|
|
280
297
|
queryChanges: [],
|
|
281
298
|
requestChanges: []
|
|
282
299
|
};
|
|
283
300
|
}
|
|
284
|
-
if (!
|
|
301
|
+
if (!skipConfigInfo.learningCycleURL || skipConfigInfo.learningCycleURL.trim().length === 0) {
|
|
285
302
|
return {
|
|
286
303
|
success: false,
|
|
287
304
|
error: 'Learning cycle API endpoint is not configured',
|
|
@@ -296,7 +313,7 @@ let AskSkipResolver = class AskSkipResolver {
|
|
|
296
313
|
if (!user)
|
|
297
314
|
throw new Error(`User ${userPayload.email} not found in UserCache`);
|
|
298
315
|
await AIEngine.Instance.Config(false, user);
|
|
299
|
-
const organizationId =
|
|
316
|
+
const organizationId = skipConfigInfo.orgID;
|
|
300
317
|
const scheduler = LearningCycleScheduler.Instance;
|
|
301
318
|
const runningStatus = scheduler.isOrganizationRunningCycle(organizationId);
|
|
302
319
|
if (runningStatus.isRunning) {
|
|
@@ -331,17 +348,36 @@ let AskSkipResolver = class AskSkipResolver {
|
|
|
331
348
|
try {
|
|
332
349
|
LogStatus(`Building Skip Learning API request`);
|
|
333
350
|
const input = await this.buildSkipLearningAPIRequest(learningCycleId, lastCompleteLearningCycleDate, true, true, true, false, dataSource, user, ForceEntityRefresh || false);
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
351
|
+
if (input.newConversations.length === 0) {
|
|
352
|
+
LogStatus(` Skip Learning Cycles: No new conversations to process for learning cycle`);
|
|
353
|
+
learningCycleEntity.Status = 'Complete';
|
|
354
|
+
learningCycleEntity.AgentSummary = 'No new conversations to process, learning cycle skipped, but recorded for audit purposes.';
|
|
355
|
+
learningCycleEntity.EndedAt = new Date();
|
|
356
|
+
if (!(await learningCycleEntity.Save())) {
|
|
357
|
+
LogError(`Failed to update learning cycle record: ${learningCycleEntity.LatestResult.Error}`);
|
|
358
|
+
}
|
|
359
|
+
const result = {
|
|
360
|
+
success: true,
|
|
361
|
+
learningCycleSkipped: true,
|
|
362
|
+
elapsedTime: 0,
|
|
363
|
+
noteChanges: [],
|
|
364
|
+
queryChanges: [],
|
|
365
|
+
requestChanges: [],
|
|
366
|
+
};
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
const response = await this.handleSimpleSkipLearningPostRequest(input, user, learningCycleId, agentID);
|
|
371
|
+
const endTime = new Date();
|
|
372
|
+
const elapsedTimeMs = endTime.getTime() - startTime.getTime();
|
|
373
|
+
LogStatus(`Learning cycle finished with status: ${response.success ? 'Success' : 'Failed'} in ${elapsedTimeMs / 1000} seconds`);
|
|
374
|
+
learningCycleEntity.Status = response.success ? 'Complete' : 'Failed';
|
|
375
|
+
learningCycleEntity.EndedAt = endTime;
|
|
376
|
+
if (!(await learningCycleEntity.Save())) {
|
|
377
|
+
LogError(`Failed to update learning cycle record: ${learningCycleEntity.LatestResult.Error}`);
|
|
378
|
+
}
|
|
379
|
+
return response;
|
|
342
380
|
}
|
|
343
|
-
scheduler.unregisterRunningCycle(organizationId);
|
|
344
|
-
return response;
|
|
345
381
|
}
|
|
346
382
|
catch (error) {
|
|
347
383
|
learningCycleEntity.Status = 'Failed';
|
|
@@ -352,13 +388,21 @@ let AskSkipResolver = class AskSkipResolver {
|
|
|
352
388
|
catch (saveError) {
|
|
353
389
|
LogError(`Failed to update learning cycle record after error: ${saveError}`);
|
|
354
390
|
}
|
|
355
|
-
scheduler.unregisterRunningCycle(organizationId);
|
|
356
391
|
throw error;
|
|
357
392
|
}
|
|
393
|
+
finally {
|
|
394
|
+
try {
|
|
395
|
+
scheduler.unregisterRunningCycle(organizationId);
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
LogError(`Failed to unregister organization ${organizationId} from running cycles: ${error}`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
358
401
|
}
|
|
359
402
|
async handleSimpleSkipLearningPostRequest(input, user, learningCycleId, agentID) {
|
|
360
|
-
|
|
361
|
-
|
|
403
|
+
const skipConfigInfo = configInfo.askSkip;
|
|
404
|
+
LogStatus(` >>> HandleSimpleSkipLearningPostRequest Sending request to Skip API: ${skipConfigInfo.learningCycleURL}`);
|
|
405
|
+
const response = await sendPostRequest(skipConfigInfo.learningCycleURL, input, true, null);
|
|
362
406
|
if (response && response.length > 0) {
|
|
363
407
|
const apiResponse = response[response.length - 1].value;
|
|
364
408
|
LogStatus(` Skip API response: ${apiResponse.success}`);
|
|
@@ -379,8 +423,9 @@ let AskSkipResolver = class AskSkipResolver {
|
|
|
379
423
|
}
|
|
380
424
|
}
|
|
381
425
|
async handleSimpleSkipChatPostRequest(input, conversationID = '', UserMessageConversationDetailId = '', createAIMessageConversationDetail = false, user = null) {
|
|
382
|
-
|
|
383
|
-
|
|
426
|
+
const skipConfigInfo = configInfo.askSkip;
|
|
427
|
+
LogStatus(` >>> HandleSimpleSkipChatPostRequest Sending request to Skip API: ${skipConfigInfo.chatURL}`);
|
|
428
|
+
const response = await sendPostRequest(skipConfigInfo.chatURL, input, true, null);
|
|
384
429
|
if (response && response.length > 0) {
|
|
385
430
|
const apiResponse = response[response.length - 1].value;
|
|
386
431
|
const AIMessageConversationDetailID = createAIMessageConversationDetail
|
|
@@ -445,10 +490,6 @@ let AskSkipResolver = class AskSkipResolver {
|
|
|
445
490
|
}
|
|
446
491
|
}
|
|
447
492
|
else {
|
|
448
|
-
if (change.note.agentNoteType === "Human") {
|
|
449
|
-
LogStatus(`WARNING: Cannot create a new Human note with the learning cycle. Operation ignored.`);
|
|
450
|
-
return false;
|
|
451
|
-
}
|
|
452
493
|
noteEntity.NewRecord();
|
|
453
494
|
noteEntity.AgentID = agentID;
|
|
454
495
|
}
|
|
@@ -506,10 +547,11 @@ cycle.`);
|
|
|
506
547
|
return '';
|
|
507
548
|
}
|
|
508
549
|
}
|
|
509
|
-
async buildBaseSkipRequest(contextUser, dataSource, includeEntities, includeQueries, includeNotes, includeRequests, forceEntitiesRefresh = false, includeCallBackKeyAndAccessToken = false, additionalTokenInfo = {}) {
|
|
550
|
+
async buildBaseSkipRequest(contextUser, dataSource, includeEntities, includeQueries, includeNotes, filterUserNotesToContextUser, includeRequests, forceEntitiesRefresh = false, includeCallBackKeyAndAccessToken = false, additionalTokenInfo = {}) {
|
|
551
|
+
const skipConfigInfo = configInfo.askSkip;
|
|
510
552
|
const entities = includeEntities ? await this.BuildSkipEntities(dataSource, forceEntitiesRefresh) : [];
|
|
511
553
|
const queries = includeQueries ? this.BuildSkipQueries() : [];
|
|
512
|
-
const { notes, noteTypes } = includeNotes ? await this.BuildSkipAgentNotes(contextUser) : { notes: [], noteTypes: [] };
|
|
554
|
+
const { notes, noteTypes } = includeNotes ? await this.BuildSkipAgentNotes(contextUser, filterUserNotesToContextUser) : { notes: [], noteTypes: [] };
|
|
513
555
|
const requests = includeRequests ? await this.BuildSkipRequests(contextUser) : [];
|
|
514
556
|
let accessToken;
|
|
515
557
|
if (includeCallBackKeyAndAccessToken) {
|
|
@@ -529,7 +571,7 @@ cycle.`);
|
|
|
529
571
|
noteTypes,
|
|
530
572
|
requests,
|
|
531
573
|
accessToken,
|
|
532
|
-
organizationID:
|
|
574
|
+
organizationID: skipConfigInfo.orgID,
|
|
533
575
|
organizationInfo: configInfo?.askSkip?.organizationInfo,
|
|
534
576
|
apiKeys: this.buildSkipAPIKeys(),
|
|
535
577
|
callingServerURL: accessToken ? `${baseUrl}:${graphqlPort}` : undefined,
|
|
@@ -538,7 +580,7 @@ cycle.`);
|
|
|
538
580
|
};
|
|
539
581
|
}
|
|
540
582
|
async buildSkipLearningAPIRequest(learningCycleId, lastLearningCycleDate, includeEntities, includeQueries, includeNotes, includeRequests, dataSource, contextUser, forceEntitiesRefresh = false, includeCallBackKeyAndAccessToken = false) {
|
|
541
|
-
const baseRequest = await this.buildBaseSkipRequest(contextUser, dataSource, includeEntities, includeQueries, includeNotes, includeRequests, forceEntitiesRefresh, includeCallBackKeyAndAccessToken);
|
|
583
|
+
const baseRequest = await this.buildBaseSkipRequest(contextUser, dataSource, includeEntities, includeQueries, includeNotes, false, includeRequests, forceEntitiesRefresh, includeCallBackKeyAndAccessToken);
|
|
542
584
|
const newConversations = await this.BuildSkipLearningCycleNewConversations(lastLearningCycleDate, dataSource, contextUser);
|
|
543
585
|
const input = {
|
|
544
586
|
organizationId: baseRequest.organizationID,
|
|
@@ -638,7 +680,7 @@ cycle.`);
|
|
|
638
680
|
conversationId,
|
|
639
681
|
requestPhase,
|
|
640
682
|
};
|
|
641
|
-
const baseRequest = await this.buildBaseSkipRequest(contextUser, dataSource, includeEntities, includeQueries, includeNotes, includeRequests, forceEntitiesRefresh, includeCallBackKeyAndAccessToken, additionalTokenInfo);
|
|
683
|
+
const baseRequest = await this.buildBaseSkipRequest(contextUser, dataSource, includeEntities, includeQueries, includeNotes, true, includeRequests, forceEntitiesRefresh, includeCallBackKeyAndAccessToken, additionalTokenInfo);
|
|
642
684
|
const artifacts = await this.buildSkipAPIArtifacts(contextUser, dataSource, conversationId);
|
|
643
685
|
const input = {
|
|
644
686
|
...baseRequest,
|
|
@@ -804,7 +846,7 @@ cycle.`);
|
|
|
804
846
|
};
|
|
805
847
|
});
|
|
806
848
|
}
|
|
807
|
-
async BuildSkipAgentNotes(contextUser) {
|
|
849
|
+
async BuildSkipAgentNotes(contextUser, filterUserNotesToContextUser) {
|
|
808
850
|
try {
|
|
809
851
|
await AIEngine.Instance.Config(false, contextUser);
|
|
810
852
|
const agent = AIEngine.Instance.GetAgentByName('Skip');
|
|
@@ -824,6 +866,10 @@ cycle.`);
|
|
|
824
866
|
updatedAt: r.__mj_UpdatedAt,
|
|
825
867
|
};
|
|
826
868
|
});
|
|
869
|
+
if (filterUserNotesToContextUser) {
|
|
870
|
+
notes = notes.filter((n) => n.type === 'Global' ||
|
|
871
|
+
(n.type === 'User' && n.userId === contextUser.ID));
|
|
872
|
+
}
|
|
827
873
|
noteTypes = AIEngine.Instance.AgentNoteTypes.map((r) => {
|
|
828
874
|
return {
|
|
829
875
|
id: r.ID,
|
|
@@ -951,7 +997,7 @@ cycle.`);
|
|
|
951
997
|
async refreshSkipEntities(dataSource) {
|
|
952
998
|
try {
|
|
953
999
|
const md = new Metadata();
|
|
954
|
-
const skipSpecialIncludeEntities = (configInfo.askSkip?.
|
|
1000
|
+
const skipSpecialIncludeEntities = (configInfo.askSkip?.entitiesToSend?.includeEntitiesFromExcludedSchemas ?? [])
|
|
955
1001
|
.map((e) => e.trim().toLowerCase());
|
|
956
1002
|
const entities = md.Entities.filter((e) => {
|
|
957
1003
|
if (e.SchemaName !== mj_core_schema || skipSpecialIncludeEntities.includes(e.Name.trim().toLowerCase())) {
|
|
@@ -1261,7 +1307,8 @@ cycle.`);
|
|
|
1261
1307
|
}
|
|
1262
1308
|
}
|
|
1263
1309
|
async HandleSkipChatRequest(input, UserQuestion, user, dataSource, ConversationId, userPayload, pubSub, md, convoEntity, convoDetailEntity, dataContext, dataContextEntity, conversationDetailCount) {
|
|
1264
|
-
|
|
1310
|
+
const skipConfigInfo = configInfo.askSkip;
|
|
1311
|
+
LogStatus(` >>> HandleSkipRequest: Sending request to Skip API: ${skipConfigInfo.chatURL}`);
|
|
1265
1312
|
if (conversationDetailCount > 10) {
|
|
1266
1313
|
pubSub.publish(PUSH_STATUS_UPDATES_TOPIC, {
|
|
1267
1314
|
message: JSON.stringify({
|
|
@@ -1282,7 +1329,7 @@ cycle.`);
|
|
|
1282
1329
|
AIMessageConversationDetailId: '',
|
|
1283
1330
|
};
|
|
1284
1331
|
}
|
|
1285
|
-
const response = await sendPostRequest(
|
|
1332
|
+
const response = await sendPostRequest(skipConfigInfo.chatURL, input, true, null, (message) => {
|
|
1286
1333
|
LogStatus(JSON.stringify(message, null, 4));
|
|
1287
1334
|
if (message.type === 'status_update') {
|
|
1288
1335
|
pubSub.publish(PUSH_STATUS_UPDATES_TOPIC, {
|
|
@@ -1528,11 +1575,14 @@ cycle.`);
|
|
|
1528
1575
|
artifactId = apiResponse.artifactRequest.artifactId;
|
|
1529
1576
|
let newVersion = 0;
|
|
1530
1577
|
if (apiResponse.artifactRequest?.action === 'new_artifact') {
|
|
1531
|
-
const artifactEntity = await md.GetEntityObject('MJ:
|
|
1578
|
+
const artifactEntity = await md.GetEntityObject('MJ: Conversation Artifacts', user);
|
|
1532
1579
|
artifactEntity.NewRecord();
|
|
1533
1580
|
artifactEntity.ConversationID = convoEntity.ID;
|
|
1534
1581
|
artifactEntity.Name = apiResponse.artifactRequest.name;
|
|
1535
1582
|
artifactEntity.Description = apiResponse.artifactRequest.description;
|
|
1583
|
+
await AIEngine.Instance.Config(false, user);
|
|
1584
|
+
artifactEntity.ArtifactTypeID = AIEngine.Instance.ArtifactTypes.find((t) => t.Name === 'Report')?.ID;
|
|
1585
|
+
artifactEntity.SharingScope = 'None';
|
|
1536
1586
|
if (await artifactEntity.Save()) {
|
|
1537
1587
|
artifactId = artifactEntity.ID;
|
|
1538
1588
|
}
|
|
@@ -1542,14 +1592,19 @@ cycle.`);
|
|
|
1542
1592
|
newVersion = 1;
|
|
1543
1593
|
}
|
|
1544
1594
|
else {
|
|
1545
|
-
const ei = md.EntityByName("MJ:
|
|
1546
|
-
const sSQL = `SELECT ISNULL(MAX(Version),0) AS MaxVersion FROM [${ei.SchemaName}].[${ei.BaseView}] WHERE
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1595
|
+
const ei = md.EntityByName("MJ: Conversation Artifact Versions");
|
|
1596
|
+
const sSQL = `SELECT ISNULL(MAX(Version),0) AS MaxVersion FROM [${ei.SchemaName}].[${ei.BaseView}] WHERE ConversationArtifactID = '${artifactId}'`;
|
|
1597
|
+
try {
|
|
1598
|
+
const result = await dataSource.query(sSQL);
|
|
1599
|
+
if (result && result.length > 0) {
|
|
1600
|
+
newVersion = result[0].MaxVersion + 1;
|
|
1601
|
+
}
|
|
1602
|
+
else {
|
|
1603
|
+
LogError(`Error getting max version for artifact ID: ${artifactId}`, undefined, result);
|
|
1604
|
+
}
|
|
1550
1605
|
}
|
|
1551
|
-
|
|
1552
|
-
LogError(`Error getting max version for artifact ID: ${artifactId}`, undefined,
|
|
1606
|
+
catch (e) {
|
|
1607
|
+
LogError(`Error getting max version for artifact ID: ${artifactId}`, undefined, e);
|
|
1553
1608
|
}
|
|
1554
1609
|
}
|
|
1555
1610
|
if (artifactId && newVersion > 0) {
|
|
@@ -1628,14 +1683,14 @@ cycle.`);
|
|
|
1628
1683
|
AIMessageConversationDetailID: convoDetailEntityAI.ID,
|
|
1629
1684
|
};
|
|
1630
1685
|
}
|
|
1631
|
-
getAgentNoteTypeIDByName(name) {
|
|
1686
|
+
getAgentNoteTypeIDByName(name, defaultNoteType = 'AI') {
|
|
1632
1687
|
const noteTypeID = AIEngine.Instance.AgentNoteTypes.find(nt => nt.Name.trim().toLowerCase() === name.trim().toLowerCase())?.ID;
|
|
1633
1688
|
if (noteTypeID) {
|
|
1634
1689
|
return noteTypeID;
|
|
1635
1690
|
}
|
|
1636
1691
|
else {
|
|
1637
|
-
const
|
|
1638
|
-
return
|
|
1692
|
+
const defaultNoteTypeID = AIEngine.Instance.AgentNoteTypes.find(nt => nt.Name.trim().toLowerCase() === defaultNoteType.trim().toLowerCase())?.ID;
|
|
1693
|
+
return defaultNoteTypeID;
|
|
1639
1694
|
}
|
|
1640
1695
|
}
|
|
1641
1696
|
async getViewData(ViewId, user) {
|
|
@@ -1649,19 +1704,20 @@ cycle.`);
|
|
|
1649
1704
|
async ManuallyExecuteSkipLearningCycle(OrganizationId) {
|
|
1650
1705
|
try {
|
|
1651
1706
|
LogStatus('Manual execution of Skip learning cycle requested via API');
|
|
1652
|
-
|
|
1707
|
+
const skipConfigInfo = configInfo.askSkip;
|
|
1708
|
+
if (!skipConfigInfo.learningCycleEnabled) {
|
|
1653
1709
|
return {
|
|
1654
1710
|
Success: false,
|
|
1655
|
-
Message: 'Learning cycles are
|
|
1711
|
+
Message: 'Learning cycles are not enabled in configuration'
|
|
1656
1712
|
};
|
|
1657
1713
|
}
|
|
1658
|
-
if (!
|
|
1714
|
+
if (!skipConfigInfo.learningCycleURL || skipConfigInfo.learningCycleURL.trim().length === 0) {
|
|
1659
1715
|
return {
|
|
1660
1716
|
Success: false,
|
|
1661
1717
|
Message: 'Learning cycle API endpoint is not configured'
|
|
1662
1718
|
};
|
|
1663
1719
|
}
|
|
1664
|
-
const orgId = OrganizationId ||
|
|
1720
|
+
const orgId = OrganizationId || skipConfigInfo.orgID;
|
|
1665
1721
|
const result = await LearningCycleScheduler.Instance.manuallyExecuteLearningCycle(orgId);
|
|
1666
1722
|
return {
|
|
1667
1723
|
Success: result,
|
|
@@ -1703,7 +1759,8 @@ cycle.`);
|
|
|
1703
1759
|
}
|
|
1704
1760
|
async IsOrganizationRunningLearningCycle(OrganizationId) {
|
|
1705
1761
|
try {
|
|
1706
|
-
const
|
|
1762
|
+
const skipConfigInfo = configInfo.askSkip;
|
|
1763
|
+
const orgId = OrganizationId || skipConfigInfo.orgID;
|
|
1707
1764
|
const status = LearningCycleScheduler.Instance.isOrganizationRunningCycle(orgId);
|
|
1708
1765
|
if (!status.isRunning) {
|
|
1709
1766
|
return null;
|
|
@@ -1722,7 +1779,7 @@ cycle.`);
|
|
|
1722
1779
|
}
|
|
1723
1780
|
async StopLearningCycleForOrganization(OrganizationId) {
|
|
1724
1781
|
try {
|
|
1725
|
-
const orgId = OrganizationId ||
|
|
1782
|
+
const orgId = OrganizationId || configInfo.askSkip.orgID;
|
|
1726
1783
|
const result = LearningCycleScheduler.Instance.stopLearningCycleForOrganization(orgId);
|
|
1727
1784
|
return {
|
|
1728
1785
|
Success: result.success,
|