@memberjunction/server 2.110.0 → 2.111.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/agents/skip-sdk.d.ts.map +1 -1
- package/dist/agents/skip-sdk.js +80 -72
- package/dist/agents/skip-sdk.js.map +1 -1
- package/dist/generated/generated.d.ts +160 -11
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +1015 -70
- package/dist/generated/generated.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.d.ts +1 -14
- package/dist/resolvers/AskSkipResolver.d.ts.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +3 -452
- package/dist/resolvers/AskSkipResolver.js.map +1 -1
- package/dist/scheduler/LearningCycleScheduler.d.ts +0 -40
- package/dist/scheduler/LearningCycleScheduler.d.ts.map +1 -1
- package/dist/scheduler/LearningCycleScheduler.js +0 -192
- package/dist/scheduler/LearningCycleScheduler.js.map +1 -1
- package/package.json +43 -38
- package/src/agents/skip-sdk.ts +102 -89
- package/src/generated/generated.ts +642 -54
- package/src/resolvers/AskSkipResolver.ts +612 -612
- package/src/scheduler/LearningCycleScheduler.ts +261 -261
|
@@ -2,7 +2,7 @@ import { PubSubEngine } from 'type-graphql';
|
|
|
2
2
|
import { Metadata, UserInfo, EntityFieldInfo, EntityInfo, EntityRelationshipInfo } from '@memberjunction/core';
|
|
3
3
|
import { AppContext, UserPayload } from '../types.js';
|
|
4
4
|
import { DataContext } from '@memberjunction/data-context';
|
|
5
|
-
import { SkipAPIRequest, SkipAPIResponse, SkipMessage, SkipAPIAnalysisCompleteResponse, SkipAPIDataRequestResponse, SkipAPIClarifyingQuestionResponse, SkipEntityInfo, SkipQueryInfo, SkipAPIRequestAPIKey, SkipRequestPhase, SkipAPIAgentNote, SkipAPIAgentNoteType, SkipEntityFieldInfo, SkipEntityRelationshipInfo, SkipEntityFieldValueInfo, SkipAPILearningCycleRequest,
|
|
5
|
+
import { SkipAPIRequest, SkipAPIResponse, SkipMessage, SkipAPIAnalysisCompleteResponse, SkipAPIDataRequestResponse, SkipAPIClarifyingQuestionResponse, SkipEntityInfo, SkipQueryInfo, SkipAPIRequestAPIKey, SkipRequestPhase, SkipAPIAgentNote, SkipAPIAgentNoteType, SkipEntityFieldInfo, SkipEntityRelationshipInfo, SkipEntityFieldValueInfo, SkipAPILearningCycleRequest, SkipConversation, SkipAPIArtifact, SkipAPIAgentRequest } from '@memberjunction/skip-types';
|
|
6
6
|
import { ConversationDetailEntity, ConversationEntity, DataContextEntity } from '@memberjunction/core-entities';
|
|
7
7
|
import mssql from 'mssql';
|
|
8
8
|
import { CompositeKeyInputType } from '../generic/KeyInputOutputTypes.js';
|
|
@@ -70,12 +70,7 @@ export declare class AskSkipResolver {
|
|
|
70
70
|
private static _defaultNewChatName;
|
|
71
71
|
private static _maxHistoricalMessages;
|
|
72
72
|
ExecuteAskSkipRecordChat(UserQuestion: string, ConversationId: string, EntityName: string, compositeKey: CompositeKeyInputType, { dataSource, userPayload, providers }: AppContext, pubSub: PubSubEngine): Promise<AskSkipResultType>;
|
|
73
|
-
ExecuteAskSkipLearningCycle({ dataSource, userPayload, providers }: AppContext, ForceEntityRefresh?: boolean): Promise<SkipAPILearningCycleResponse>;
|
|
74
|
-
protected handleSimpleSkipLearningPostRequest(input: SkipAPILearningCycleRequest, user: UserInfo, learningCycleId: string, agentID: string, userPayload: UserPayload): Promise<SkipAPILearningCycleResponse>;
|
|
75
73
|
protected handleSimpleSkipChatPostRequest(input: SkipAPIRequest, convoEntity?: ConversationEntity, convoDetailEntity?: ConversationDetailEntity, createAIMessageConversationDetail?: boolean, user?: UserInfo, userPayload?: UserPayload): Promise<AskSkipResultType>;
|
|
76
|
-
protected processLearningCycleNoteChanges(noteChanges: SkipLearningCycleNoteChange[], agentID: string, user: UserInfo, userPayload: UserPayload): Promise<void>;
|
|
77
|
-
protected processAddOrUpdateSkipNote(change: SkipLearningCycleNoteChange, agentID: string, user: UserInfo, userPayload: UserPayload): Promise<boolean>;
|
|
78
|
-
protected processDeleteSkipNote(change: SkipLearningCycleNoteChange, user: UserInfo, userPayload: UserPayload): Promise<boolean>;
|
|
79
74
|
protected CreateAIMessageConversationDetail(apiResponse: SkipAPIResponse, conversationID: string, user: UserInfo, userPayload: UserPayload): Promise<string>;
|
|
80
75
|
protected buildBaseSkipRequest(contextUser: UserInfo, dataSource: mssql.ConnectionPool, includeEntities: boolean, includeQueries: boolean, includeNotes: boolean, filterUserNotesToContextUser: boolean, includeRequests: boolean, forceEntitiesRefresh?: boolean, includeCallBackKeyAndAccessToken?: boolean, additionalTokenInfo?: any): Promise<BaseSkipRequest>;
|
|
81
76
|
protected buildSkipLearningAPIRequest(learningCycleId: string, lastLearningCycleDate: Date, includeEntities: boolean, includeQueries: boolean, includeNotes: boolean, includeRequests: boolean, dataSource: mssql.ConnectionPool, contextUser: UserInfo, forceEntitiesRefresh?: boolean, includeCallBackKeyAndAccessToken?: boolean): Promise<SkipAPILearningCycleRequest>;
|
|
@@ -90,10 +85,6 @@ export declare class AskSkipResolver {
|
|
|
90
85
|
ExecuteAskSkipAnalysisQuery(UserQuestion: string, ConversationId: string, { dataSource, userPayload, providers }: AppContext, pubSub: PubSubEngine, DataContextId?: string, ForceEntityRefresh?: boolean, StartTime?: Date): Promise<AskSkipResultType>;
|
|
91
86
|
protected buildQueryCategoryPath(md: Metadata, categoryID: string): string;
|
|
92
87
|
protected BuildSkipQueries(status?: "Pending" | "In-Review" | "Approved" | "Rejected" | "Obsolete"): SkipQueryInfo[];
|
|
93
|
-
protected BuildSkipAgentNotes(contextUser: UserInfo, filterUserNotesToContextUser: boolean): Promise<{
|
|
94
|
-
notes: SkipAPIAgentNote[];
|
|
95
|
-
noteTypes: SkipAPIAgentNoteType[];
|
|
96
|
-
}>;
|
|
97
88
|
protected PackEntityRows(e: EntityInfo, dataSource: mssql.ConnectionPool): Promise<any[]>;
|
|
98
89
|
protected PackFieldPossibleValues(f: EntityFieldInfo, dataSource: mssql.ConnectionPool): Promise<SkipEntityFieldValueInfo[]>;
|
|
99
90
|
protected GetFieldDistinctValues(f: EntityFieldInfo, dataSource: mssql.ConnectionPool): Promise<SkipEntityFieldValueInfo[]>;
|
|
@@ -126,10 +117,6 @@ export declare class AskSkipResolver {
|
|
|
126
117
|
private setConversationStatus;
|
|
127
118
|
protected getAgentNoteTypeIDByName(name: string, defaultNoteType?: string): string;
|
|
128
119
|
protected getViewData(ViewId: string, user: UserInfo): Promise<any>;
|
|
129
|
-
ManuallyExecuteSkipLearningCycle(OrganizationId?: string): Promise<ManualLearningCycleResultType>;
|
|
130
|
-
GetLearningCycleStatus(): Promise<LearningCycleStatusType>;
|
|
131
|
-
IsOrganizationRunningLearningCycle(OrganizationId: string): Promise<RunningOrganizationType | null>;
|
|
132
|
-
StopLearningCycleForOrganization(OrganizationId: string): Promise<StopLearningCycleResultType>;
|
|
133
120
|
}
|
|
134
121
|
export default AskSkipResolver;
|
|
135
122
|
//# sourceMappingURL=AskSkipResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AskSkipResolver.d.ts","sourceRoot":"","sources":["../../src/resolvers/AskSkipResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,YAAY,EAAmB,MAAM,cAAc,CAAC;AACvH,OAAO,EAAuB,QAAQ,EAAW,QAAQ,EAAgB,eAAe,EAAE,UAAU,EAAE,sBAAsB,EAA6D,MAAM,sBAAsB,CAAC;AACtN,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,EAGb,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EAC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AAO,CAAC,iBAAiB,CAAC;cAyJb,+BAA+B,CAC7C,WAAW,EAAE,+BAA+B,EAC5C,WAAW,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,KAAK,CAAC,cAAc,EAChC,SAAS,EAAE,IAAI,GACd,OAAO,CAAC;QAAE,6BAA6B,EAAE,MAAM,CAAA;KAAE,CAAC;YAyKvC,qBAAqB;IAkDnC,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;CAwK1E;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -11,15 +11,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
13
|
var AskSkipResolver_1;
|
|
14
|
-
import { Arg, Ctx, Field,
|
|
14
|
+
import { Arg, Ctx, Field, ObjectType, PubSub, PubSubEngine, Query, Resolver } from 'type-graphql';
|
|
15
15
|
import { LogError, LogStatus, Metadata, RunView, CompositeKey } from '@memberjunction/core';
|
|
16
|
-
import { MJ_SERVER_EVENT_CODE } from '../types.js';
|
|
17
16
|
import { BehaviorSubject } from 'rxjs';
|
|
18
17
|
import { take } from 'rxjs/operators';
|
|
19
18
|
import { UserCache } from '@memberjunction/sqlserver-dataprovider';
|
|
20
19
|
import { DataContext } from '@memberjunction/data-context';
|
|
21
20
|
import { LoadDataContextItemsServer } from '@memberjunction/data-context-server';
|
|
22
|
-
import { LearningCycleScheduler } from '../scheduler/LearningCycleScheduler.js';
|
|
23
21
|
LoadDataContextItemsServer();
|
|
24
22
|
import { PUSH_STATUS_UPDATES_TOPIC } from '../generic/PushStatusResolver.js';
|
|
25
23
|
import { apiKey as callbackAPIKey, baseUrl, publicUrl, configInfo, graphqlPort, graphqlRootPath } from '../config.js';
|
|
@@ -301,57 +299,6 @@ StopLearningCycleResultType = __decorate([
|
|
|
301
299
|
ObjectType()
|
|
302
300
|
], StopLearningCycleResultType);
|
|
303
301
|
export { StopLearningCycleResultType };
|
|
304
|
-
function initializeSkipLearningCycleScheduler() {
|
|
305
|
-
try {
|
|
306
|
-
const eventListener = MJGlobal.Instance.GetEventListener(true);
|
|
307
|
-
eventListener.subscribe(event => {
|
|
308
|
-
if (event.eventCode === MJ_SERVER_EVENT_CODE && event.args?.type === 'setupComplete') {
|
|
309
|
-
try {
|
|
310
|
-
const skipConfigInfo = configInfo.askSkip;
|
|
311
|
-
if (!skipConfigInfo) {
|
|
312
|
-
LogStatus('Skip AI Learning Cycle Scheduler not started: Skip configuration not found');
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
if (!skipConfigInfo.learningCycleEnabled) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
const hasLearningEndpoint = (skipConfigInfo.url && skipConfigInfo.url.trim().length > 0) ||
|
|
319
|
-
(skipConfigInfo.learningCycleURL && skipConfigInfo.learningCycleURL.trim().length > 0);
|
|
320
|
-
if (!hasLearningEndpoint) {
|
|
321
|
-
LogError('Skip AI Learning cycle scheduler not started: Learning cycles are enabled but no Learning Cycle API endpoint is configured');
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
const dataSources = event.args.dataSources;
|
|
325
|
-
if (dataSources && dataSources.length > 0) {
|
|
326
|
-
const scheduler = LearningCycleScheduler.Instance;
|
|
327
|
-
scheduler.setDataSources(dataSources);
|
|
328
|
-
const interval = skipConfigInfo.learningCycleIntervalInMinutes ?? 60;
|
|
329
|
-
if (skipConfigInfo.learningCycleRunUponStartup) {
|
|
330
|
-
LogStatus('Skip API Learning Cycle: Run Upon Startup is enabled, running learning cycle immediately');
|
|
331
|
-
scheduler.start(interval);
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
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.`);
|
|
335
|
-
setTimeout(() => {
|
|
336
|
-
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.`);
|
|
337
|
-
scheduler.start(interval);
|
|
338
|
-
}, interval * 60 * 1000);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
LogError('Cannot initialize Skip learning cycle scheduler: No data sources available');
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
catch (error) {
|
|
346
|
-
LogError(`Error initializing Skip learning cycle scheduler: ${error}`);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
catch (error) {
|
|
352
|
-
LogError(`Failed to initialize Skip learning cycle scheduler: ${error}`);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
302
|
let AskSkipResolver = class AskSkipResolver {
|
|
356
303
|
static { AskSkipResolver_1 = this; }
|
|
357
304
|
static _defaultNewChatName = 'New Chat';
|
|
@@ -396,145 +343,6 @@ let AskSkipResolver = class AskSkipResolver {
|
|
|
396
343
|
});
|
|
397
344
|
return this.handleSimpleSkipChatPostRequest(input, convoEntity, convoDetailEntity, true, user, userPayload);
|
|
398
345
|
}
|
|
399
|
-
async ExecuteAskSkipLearningCycle({ dataSource, userPayload, providers }, ForceEntityRefresh) {
|
|
400
|
-
const skipConfigInfo = configInfo.askSkip;
|
|
401
|
-
if (!skipConfigInfo.learningCycleEnabled) {
|
|
402
|
-
return {
|
|
403
|
-
success: false,
|
|
404
|
-
error: 'Learning cycles are not enabled in configuration',
|
|
405
|
-
elapsedTime: 0,
|
|
406
|
-
noteChanges: [],
|
|
407
|
-
queryChanges: [],
|
|
408
|
-
requestChanges: []
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
const hasLearningEndpoint = (skipConfigInfo.url && skipConfigInfo.url.trim().length > 0) ||
|
|
412
|
-
(skipConfigInfo.learningCycleURL && skipConfigInfo.learningCycleURL.trim().length > 0);
|
|
413
|
-
if (!hasLearningEndpoint) {
|
|
414
|
-
return {
|
|
415
|
-
success: false,
|
|
416
|
-
error: 'Learning cycle API endpoint is not configured',
|
|
417
|
-
elapsedTime: 0,
|
|
418
|
-
noteChanges: [],
|
|
419
|
-
queryChanges: [],
|
|
420
|
-
requestChanges: []
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
const startTime = new Date();
|
|
424
|
-
const user = UserCache.Instance.Users.find((u) => u.Email.trim().toLowerCase() === userPayload.email.trim().toLowerCase());
|
|
425
|
-
if (!user)
|
|
426
|
-
throw new Error(`User ${userPayload.email} not found in UserCache`);
|
|
427
|
-
await AIEngine.Instance.Config(false, user);
|
|
428
|
-
const organizationId = skipConfigInfo.orgID;
|
|
429
|
-
const scheduler = LearningCycleScheduler.Instance;
|
|
430
|
-
const runningStatus = scheduler.isOrganizationRunningCycle(organizationId);
|
|
431
|
-
if (runningStatus.isRunning) {
|
|
432
|
-
LogStatus(`Learning cycle already in progress for organization ${organizationId}, started at ${runningStatus.startTime.toISOString()}`);
|
|
433
|
-
return {
|
|
434
|
-
success: false,
|
|
435
|
-
error: `Learning cycle already in progress for this organization (started ${Math.round(runningStatus.runningForMinutes)} minutes ago)`,
|
|
436
|
-
elapsedTime: 0,
|
|
437
|
-
noteChanges: [],
|
|
438
|
-
queryChanges: [],
|
|
439
|
-
requestChanges: []
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
const md = GetReadWriteProvider(providers);
|
|
443
|
-
const skipAgent = AIEngine.Instance.GetAgentByName('Skip');
|
|
444
|
-
if (!skipAgent) {
|
|
445
|
-
throw new Error("Skip agent not found in AIEngine");
|
|
446
|
-
}
|
|
447
|
-
const agentID = skipAgent.ID;
|
|
448
|
-
const lastCompleteLearningCycleDate = await this.GetLastCompleteLearningCycleDate(agentID, user);
|
|
449
|
-
const learningCycleEntity = await md.GetEntityObject('AI Agent Learning Cycles', user);
|
|
450
|
-
learningCycleEntity.NewRecord();
|
|
451
|
-
learningCycleEntity.AgentID = skipAgent.ID;
|
|
452
|
-
learningCycleEntity.Status = 'In-Progress';
|
|
453
|
-
learningCycleEntity.StartedAt = startTime;
|
|
454
|
-
if (!(await learningCycleEntity.Save())) {
|
|
455
|
-
throw new Error(`Failed to create learning cycle record: ${learningCycleEntity.LatestResult.Error}`);
|
|
456
|
-
}
|
|
457
|
-
const learningCycleId = learningCycleEntity.ID;
|
|
458
|
-
LogStatus(`Created new learning cycle with ID: ${learningCycleId}`);
|
|
459
|
-
scheduler.registerRunningCycle(organizationId, learningCycleId);
|
|
460
|
-
try {
|
|
461
|
-
LogStatus(`Building Skip Learning API request`);
|
|
462
|
-
const input = await this.buildSkipLearningAPIRequest(learningCycleId, lastCompleteLearningCycleDate, true, true, true, false, dataSource, user, ForceEntityRefresh || false);
|
|
463
|
-
if (input.newConversations.length === 0) {
|
|
464
|
-
LogStatus(` Skip Learning Cycles: No new conversations to process for learning cycle`);
|
|
465
|
-
learningCycleEntity.Status = 'Complete';
|
|
466
|
-
learningCycleEntity.AgentSummary = 'No new conversations to process, learning cycle skipped, but recorded for audit purposes.';
|
|
467
|
-
learningCycleEntity.EndedAt = new Date();
|
|
468
|
-
if (!(await learningCycleEntity.Save())) {
|
|
469
|
-
LogError(`Failed to update learning cycle record: ${learningCycleEntity.LatestResult.Error}`);
|
|
470
|
-
}
|
|
471
|
-
const result = {
|
|
472
|
-
success: true,
|
|
473
|
-
learningCycleSkipped: true,
|
|
474
|
-
elapsedTime: 0,
|
|
475
|
-
noteChanges: [],
|
|
476
|
-
queryChanges: [],
|
|
477
|
-
requestChanges: [],
|
|
478
|
-
};
|
|
479
|
-
return result;
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
const response = await this.handleSimpleSkipLearningPostRequest(input, user, learningCycleId, agentID, userPayload);
|
|
483
|
-
const endTime = new Date();
|
|
484
|
-
const elapsedTimeMs = endTime.getTime() - startTime.getTime();
|
|
485
|
-
LogStatus(`Learning cycle finished with status: ${response.success ? 'Success' : 'Failed'} in ${elapsedTimeMs / 1000} seconds`);
|
|
486
|
-
learningCycleEntity.Status = response.success ? 'Complete' : 'Failed';
|
|
487
|
-
learningCycleEntity.EndedAt = endTime;
|
|
488
|
-
if (!(await learningCycleEntity.Save())) {
|
|
489
|
-
LogError(`Failed to update learning cycle record: ${learningCycleEntity.LatestResult.Error}`);
|
|
490
|
-
}
|
|
491
|
-
return response;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
catch (error) {
|
|
495
|
-
learningCycleEntity.Status = 'Failed';
|
|
496
|
-
learningCycleEntity.EndedAt = new Date();
|
|
497
|
-
try {
|
|
498
|
-
await learningCycleEntity.Save();
|
|
499
|
-
}
|
|
500
|
-
catch (saveError) {
|
|
501
|
-
LogError(`Failed to update learning cycle record after error: ${saveError}`);
|
|
502
|
-
}
|
|
503
|
-
throw error;
|
|
504
|
-
}
|
|
505
|
-
finally {
|
|
506
|
-
try {
|
|
507
|
-
scheduler.unregisterRunningCycle(organizationId);
|
|
508
|
-
}
|
|
509
|
-
catch (error) {
|
|
510
|
-
LogError(`Failed to unregister organization ${organizationId} from running cycles: ${error}`);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
async handleSimpleSkipLearningPostRequest(input, user, learningCycleId, agentID, userPayload) {
|
|
515
|
-
const skipConfigInfo = configInfo.askSkip;
|
|
516
|
-
const learningURL = skipConfigInfo.url ? `${skipConfigInfo.url}${SKIP_API_ENDPOINTS.LEARNING}` : skipConfigInfo.learningCycleURL;
|
|
517
|
-
LogStatus(` >>> HandleSimpleSkipLearningPostRequest Sending request to Skip API: ${learningURL}`);
|
|
518
|
-
const response = await sendPostRequest(learningURL, input, true, this.buildSkipPostHeaders());
|
|
519
|
-
if (response && response.length > 0) {
|
|
520
|
-
const apiResponse = response[response.length - 1].value;
|
|
521
|
-
LogStatus(` Skip API response: ${apiResponse.success}`);
|
|
522
|
-
if (apiResponse.noteChanges && apiResponse.noteChanges.length > 0) {
|
|
523
|
-
await this.processLearningCycleNoteChanges(apiResponse.noteChanges, agentID, user, userPayload);
|
|
524
|
-
}
|
|
525
|
-
return apiResponse;
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
return {
|
|
529
|
-
success: false,
|
|
530
|
-
error: 'Error',
|
|
531
|
-
elapsedTime: 0,
|
|
532
|
-
noteChanges: [],
|
|
533
|
-
queryChanges: [],
|
|
534
|
-
requestChanges: [],
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
346
|
async handleSimpleSkipChatPostRequest(input, convoEntity = null, convoDetailEntity = null, createAIMessageConversationDetail = false, user = null, userPayload = null) {
|
|
539
347
|
const skipConfigInfo = configInfo.askSkip;
|
|
540
348
|
const chatURL = skipConfigInfo.url ? `${skipConfigInfo.url}${SKIP_API_ENDPOINTS.CHAT}` : skipConfigInfo.chatURL;
|
|
@@ -580,81 +388,6 @@ let AskSkipResolver = class AskSkipResolver {
|
|
|
580
388
|
throw error;
|
|
581
389
|
}
|
|
582
390
|
}
|
|
583
|
-
async processLearningCycleNoteChanges(noteChanges, agentID, user, userPayload) {
|
|
584
|
-
const md = new Metadata();
|
|
585
|
-
const validNoteChanges = noteChanges.filter(change => {
|
|
586
|
-
if (change.note.agentNoteType === "Human") {
|
|
587
|
-
LogStatus(`WARNING: Ignoring ${change.changeType} operation on Human note with ID ${change.note.id}. Human notes cannot be modified by the
|
|
588
|
-
learning cycle.`);
|
|
589
|
-
return false;
|
|
590
|
-
}
|
|
591
|
-
return true;
|
|
592
|
-
});
|
|
593
|
-
await Promise.all(validNoteChanges.map(async (change) => {
|
|
594
|
-
try {
|
|
595
|
-
if (change.changeType === 'add' || change.changeType === 'update') {
|
|
596
|
-
await this.processAddOrUpdateSkipNote(change, agentID, user, userPayload);
|
|
597
|
-
}
|
|
598
|
-
else if (change.changeType === 'delete') {
|
|
599
|
-
await this.processDeleteSkipNote(change, user, userPayload);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
catch (e) {
|
|
603
|
-
LogError(`Error processing note change: ${e}`);
|
|
604
|
-
}
|
|
605
|
-
}));
|
|
606
|
-
}
|
|
607
|
-
async processAddOrUpdateSkipNote(change, agentID, user, userPayload) {
|
|
608
|
-
try {
|
|
609
|
-
const md = new Metadata();
|
|
610
|
-
const noteEntity = await md.GetEntityObject('AI Agent Notes', user);
|
|
611
|
-
if (change.changeType === 'update') {
|
|
612
|
-
const loadResult = await noteEntity.Load(change.note.id);
|
|
613
|
-
if (!loadResult) {
|
|
614
|
-
LogError(`Could not load note with ID ${change.note.id}`);
|
|
615
|
-
return false;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
noteEntity.NewRecord();
|
|
620
|
-
noteEntity.AgentID = agentID;
|
|
621
|
-
}
|
|
622
|
-
noteEntity.AgentNoteTypeID = this.getAgentNoteTypeIDByName('AI');
|
|
623
|
-
noteEntity.Note = change.note.note;
|
|
624
|
-
noteEntity.Type = change.note.type;
|
|
625
|
-
if (change.note.type === 'User') {
|
|
626
|
-
noteEntity.UserID = change.note.userId;
|
|
627
|
-
}
|
|
628
|
-
if (!(await noteEntity.Save())) {
|
|
629
|
-
LogError(`Error saving AI Agent Note: ${noteEntity.LatestResult.Error}`);
|
|
630
|
-
return false;
|
|
631
|
-
}
|
|
632
|
-
return true;
|
|
633
|
-
}
|
|
634
|
-
catch (e) {
|
|
635
|
-
LogError(`Error processing note change: ${e}`);
|
|
636
|
-
return false;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
async processDeleteSkipNote(change, user, userPayload) {
|
|
640
|
-
const md = new Metadata();
|
|
641
|
-
const noteEntity = await md.GetEntityObject('AI Agent Notes', user);
|
|
642
|
-
const loadResult = await noteEntity.Load(change.note.id);
|
|
643
|
-
if (!loadResult) {
|
|
644
|
-
LogError(`Could not load note with ID ${change.note.id} for deletion`);
|
|
645
|
-
return false;
|
|
646
|
-
}
|
|
647
|
-
if (change.note.agentNoteType === "Human") {
|
|
648
|
-
LogStatus(`WARNING: Ignoring delete operation on Human note with ID ${change.note.id}. Human notes cannot be deleted by the learning
|
|
649
|
-
cycle.`);
|
|
650
|
-
return false;
|
|
651
|
-
}
|
|
652
|
-
if (!(await noteEntity.Delete())) {
|
|
653
|
-
LogError(`Error deleting AI Agent Note: ${noteEntity.LatestResult.Error}`);
|
|
654
|
-
return false;
|
|
655
|
-
}
|
|
656
|
-
return true;
|
|
657
|
-
}
|
|
658
391
|
async CreateAIMessageConversationDetail(apiResponse, conversationID, user, userPayload) {
|
|
659
392
|
const md = new Metadata();
|
|
660
393
|
const convoDetailEntityAI = await md.GetEntityObject('Conversation Details', user);
|
|
@@ -677,7 +410,6 @@ cycle.`);
|
|
|
677
410
|
const skipConfigInfo = configInfo.askSkip;
|
|
678
411
|
const entities = includeEntities ? await this.BuildSkipEntities(dataSource, forceEntitiesRefresh) : [];
|
|
679
412
|
const queries = includeQueries ? this.BuildSkipQueries() : [];
|
|
680
|
-
const { notes, noteTypes } = includeNotes ? await this.BuildSkipAgentNotes(contextUser, filterUserNotesToContextUser) : { notes: [], noteTypes: [] };
|
|
681
413
|
const requests = includeRequests ? await this.BuildSkipRequests(contextUser) : [];
|
|
682
414
|
let accessToken;
|
|
683
415
|
if (includeCallBackKeyAndAccessToken) {
|
|
@@ -693,8 +425,8 @@ cycle.`);
|
|
|
693
425
|
return {
|
|
694
426
|
entities,
|
|
695
427
|
queries,
|
|
696
|
-
notes,
|
|
697
|
-
noteTypes,
|
|
428
|
+
notes: undefined,
|
|
429
|
+
noteTypes: undefined,
|
|
698
430
|
userEmail: contextUser.Email,
|
|
699
431
|
requests,
|
|
700
432
|
accessToken,
|
|
@@ -1090,49 +822,6 @@ cycle.`);
|
|
|
1090
822
|
};
|
|
1091
823
|
});
|
|
1092
824
|
}
|
|
1093
|
-
async BuildSkipAgentNotes(contextUser, filterUserNotesToContextUser) {
|
|
1094
|
-
try {
|
|
1095
|
-
await AIEngine.Instance.Config(false, contextUser);
|
|
1096
|
-
const agent = AIEngine.Instance.GetAgentByName('Skip');
|
|
1097
|
-
if (agent) {
|
|
1098
|
-
let notes = [];
|
|
1099
|
-
let noteTypes = [];
|
|
1100
|
-
notes = agent.Notes.map((r) => {
|
|
1101
|
-
return {
|
|
1102
|
-
id: r.ID,
|
|
1103
|
-
agentNoteTypeId: r.AgentNoteTypeID,
|
|
1104
|
-
agentNoteType: r.AgentNoteType,
|
|
1105
|
-
note: r.Note,
|
|
1106
|
-
type: r.Type,
|
|
1107
|
-
userId: r.UserID,
|
|
1108
|
-
user: r.User,
|
|
1109
|
-
createdAt: r.__mj_CreatedAt,
|
|
1110
|
-
updatedAt: r.__mj_UpdatedAt,
|
|
1111
|
-
};
|
|
1112
|
-
});
|
|
1113
|
-
if (filterUserNotesToContextUser) {
|
|
1114
|
-
notes = notes.filter((n) => n.type === 'Global' ||
|
|
1115
|
-
(n.type === 'User' && n.userId === contextUser.ID));
|
|
1116
|
-
}
|
|
1117
|
-
noteTypes = AIEngine.Instance.AgentNoteTypes.map((r) => {
|
|
1118
|
-
return {
|
|
1119
|
-
id: r.ID,
|
|
1120
|
-
name: r.Name,
|
|
1121
|
-
description: r.Description
|
|
1122
|
-
};
|
|
1123
|
-
});
|
|
1124
|
-
return { notes, noteTypes };
|
|
1125
|
-
}
|
|
1126
|
-
else {
|
|
1127
|
-
console.warn(`No AI Agent found with the name 'Skip' in the AI Engine, so no notes will be sent to Skip`);
|
|
1128
|
-
return { notes: [], noteTypes: [] };
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
catch (e) {
|
|
1132
|
-
LogError(`AskSkipResolver::BuildSkipAgentNotes: ${e}`);
|
|
1133
|
-
return { notes: [], noteTypes: [] };
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
825
|
async PackEntityRows(e, dataSource) {
|
|
1137
826
|
try {
|
|
1138
827
|
if (e.RowsToPackWithSchema === 'None')
|
|
@@ -2035,109 +1724,6 @@ cycle.`);
|
|
|
2035
1724
|
else
|
|
2036
1725
|
throw new Error(`Error running view ${ViewId}`);
|
|
2037
1726
|
}
|
|
2038
|
-
async ManuallyExecuteSkipLearningCycle(OrganizationId) {
|
|
2039
|
-
try {
|
|
2040
|
-
LogStatus('Manual execution of Skip learning cycle requested via API');
|
|
2041
|
-
const skipConfigInfo = configInfo.askSkip;
|
|
2042
|
-
if (!skipConfigInfo.learningCycleEnabled) {
|
|
2043
|
-
return {
|
|
2044
|
-
Success: false,
|
|
2045
|
-
Message: 'Learning cycles are not enabled in configuration'
|
|
2046
|
-
};
|
|
2047
|
-
}
|
|
2048
|
-
const hasLearningEndpoint = (skipConfigInfo.url && skipConfigInfo.url.trim().length > 0) ||
|
|
2049
|
-
(skipConfigInfo.learningCycleURL && skipConfigInfo.learningCycleURL.trim().length > 0);
|
|
2050
|
-
if (!hasLearningEndpoint) {
|
|
2051
|
-
return {
|
|
2052
|
-
Success: false,
|
|
2053
|
-
Message: 'Learning cycle API endpoint is not configured'
|
|
2054
|
-
};
|
|
2055
|
-
}
|
|
2056
|
-
const orgId = OrganizationId || skipConfigInfo.orgID;
|
|
2057
|
-
const result = await LearningCycleScheduler.Instance.manuallyExecuteLearningCycle(orgId);
|
|
2058
|
-
return {
|
|
2059
|
-
Success: result,
|
|
2060
|
-
Message: result
|
|
2061
|
-
? `Learning cycle was successfully executed manually for organization ${orgId}`
|
|
2062
|
-
: `Learning cycle execution failed for organization ${orgId}. Check server logs for details.`
|
|
2063
|
-
};
|
|
2064
|
-
}
|
|
2065
|
-
catch (e) {
|
|
2066
|
-
LogError(`Error in ManuallyExecuteSkipLearningCycle: ${e}`);
|
|
2067
|
-
return {
|
|
2068
|
-
Success: false,
|
|
2069
|
-
Message: `Error executing learning cycle: ${e}`
|
|
2070
|
-
};
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
async GetLearningCycleStatus() {
|
|
2074
|
-
try {
|
|
2075
|
-
const status = LearningCycleScheduler.Instance.getStatus();
|
|
2076
|
-
return {
|
|
2077
|
-
IsSchedulerRunning: status.isSchedulerRunning,
|
|
2078
|
-
LastRunTime: status.lastRunTime ? status.lastRunTime.toISOString() : null,
|
|
2079
|
-
RunningOrganizations: status.runningOrganizations ? status.runningOrganizations.map(org => ({
|
|
2080
|
-
OrganizationId: org.organizationId,
|
|
2081
|
-
LearningCycleId: org.learningCycleId,
|
|
2082
|
-
StartTime: org.startTime.toISOString(),
|
|
2083
|
-
RunningForMinutes: org.runningForMinutes
|
|
2084
|
-
})) : []
|
|
2085
|
-
};
|
|
2086
|
-
}
|
|
2087
|
-
catch (e) {
|
|
2088
|
-
LogError(`Error in GetLearningCycleStatus: ${e}`);
|
|
2089
|
-
return {
|
|
2090
|
-
IsSchedulerRunning: false,
|
|
2091
|
-
LastRunTime: null,
|
|
2092
|
-
RunningOrganizations: []
|
|
2093
|
-
};
|
|
2094
|
-
}
|
|
2095
|
-
}
|
|
2096
|
-
async IsOrganizationRunningLearningCycle(OrganizationId) {
|
|
2097
|
-
try {
|
|
2098
|
-
const skipConfigInfo = configInfo.askSkip;
|
|
2099
|
-
const orgId = OrganizationId || skipConfigInfo.orgID;
|
|
2100
|
-
const status = LearningCycleScheduler.Instance.isOrganizationRunningCycle(orgId);
|
|
2101
|
-
if (!status.isRunning) {
|
|
2102
|
-
return null;
|
|
2103
|
-
}
|
|
2104
|
-
return {
|
|
2105
|
-
OrganizationId: orgId,
|
|
2106
|
-
LearningCycleId: status.learningCycleId,
|
|
2107
|
-
StartTime: status.startTime.toISOString(),
|
|
2108
|
-
RunningForMinutes: status.runningForMinutes
|
|
2109
|
-
};
|
|
2110
|
-
}
|
|
2111
|
-
catch (e) {
|
|
2112
|
-
LogError(`Error in IsOrganizationRunningLearningCycle: ${e}`);
|
|
2113
|
-
return null;
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
async StopLearningCycleForOrganization(OrganizationId) {
|
|
2117
|
-
try {
|
|
2118
|
-
const orgId = OrganizationId || configInfo.askSkip.orgID;
|
|
2119
|
-
const result = LearningCycleScheduler.Instance.stopLearningCycleForOrganization(orgId);
|
|
2120
|
-
return {
|
|
2121
|
-
Success: result.success,
|
|
2122
|
-
Message: result.message,
|
|
2123
|
-
WasRunning: result.wasRunning,
|
|
2124
|
-
CycleDetails: result.cycleDetails ? {
|
|
2125
|
-
LearningCycleId: result.cycleDetails.learningCycleId,
|
|
2126
|
-
StartTime: result.cycleDetails.startTime.toISOString(),
|
|
2127
|
-
RunningForMinutes: result.cycleDetails.runningForMinutes
|
|
2128
|
-
} : null
|
|
2129
|
-
};
|
|
2130
|
-
}
|
|
2131
|
-
catch (e) {
|
|
2132
|
-
LogError(`Error in StopLearningCycleForOrganization: ${e}`);
|
|
2133
|
-
return {
|
|
2134
|
-
Success: false,
|
|
2135
|
-
Message: `Error stopping learning cycle: ${e}`,
|
|
2136
|
-
WasRunning: false,
|
|
2137
|
-
CycleDetails: null
|
|
2138
|
-
};
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
1727
|
};
|
|
2142
1728
|
__decorate([
|
|
2143
1729
|
Query(() => AskSkipResultType),
|
|
@@ -2151,14 +1737,6 @@ __decorate([
|
|
|
2151
1737
|
__metadata("design:paramtypes", [String, String, String, CompositeKeyInputType, Object, PubSubEngine]),
|
|
2152
1738
|
__metadata("design:returntype", Promise)
|
|
2153
1739
|
], AskSkipResolver.prototype, "ExecuteAskSkipRecordChat", null);
|
|
2154
|
-
__decorate([
|
|
2155
|
-
Mutation(() => AskSkipResultType),
|
|
2156
|
-
__param(0, Ctx()),
|
|
2157
|
-
__param(1, Arg('ForceEntityRefresh', () => Boolean, { nullable: true })),
|
|
2158
|
-
__metadata("design:type", Function),
|
|
2159
|
-
__metadata("design:paramtypes", [Object, Boolean]),
|
|
2160
|
-
__metadata("design:returntype", Promise)
|
|
2161
|
-
], AskSkipResolver.prototype, "ExecuteAskSkipLearningCycle", null);
|
|
2162
1740
|
__decorate([
|
|
2163
1741
|
Query(() => AskSkipResultType),
|
|
2164
1742
|
__param(0, Ctx()),
|
|
@@ -2191,33 +1769,6 @@ __decorate([
|
|
|
2191
1769
|
__metadata("design:paramtypes", [String, String, Object, PubSubEngine, String, Boolean, Date]),
|
|
2192
1770
|
__metadata("design:returntype", Promise)
|
|
2193
1771
|
], AskSkipResolver.prototype, "ExecuteAskSkipAnalysisQuery", null);
|
|
2194
|
-
__decorate([
|
|
2195
|
-
Mutation(() => ManualLearningCycleResultType),
|
|
2196
|
-
__param(0, Arg('OrganizationId', () => String, { nullable: true })),
|
|
2197
|
-
__metadata("design:type", Function),
|
|
2198
|
-
__metadata("design:paramtypes", [String]),
|
|
2199
|
-
__metadata("design:returntype", Promise)
|
|
2200
|
-
], AskSkipResolver.prototype, "ManuallyExecuteSkipLearningCycle", null);
|
|
2201
|
-
__decorate([
|
|
2202
|
-
Query(() => LearningCycleStatusType),
|
|
2203
|
-
__metadata("design:type", Function),
|
|
2204
|
-
__metadata("design:paramtypes", []),
|
|
2205
|
-
__metadata("design:returntype", Promise)
|
|
2206
|
-
], AskSkipResolver.prototype, "GetLearningCycleStatus", null);
|
|
2207
|
-
__decorate([
|
|
2208
|
-
Query(() => RunningOrganizationType, { nullable: true }),
|
|
2209
|
-
__param(0, Arg('OrganizationId', () => String)),
|
|
2210
|
-
__metadata("design:type", Function),
|
|
2211
|
-
__metadata("design:paramtypes", [String]),
|
|
2212
|
-
__metadata("design:returntype", Promise)
|
|
2213
|
-
], AskSkipResolver.prototype, "IsOrganizationRunningLearningCycle", null);
|
|
2214
|
-
__decorate([
|
|
2215
|
-
Mutation(() => StopLearningCycleResultType),
|
|
2216
|
-
__param(0, Arg('OrganizationId', () => String)),
|
|
2217
|
-
__metadata("design:type", Function),
|
|
2218
|
-
__metadata("design:paramtypes", [String]),
|
|
2219
|
-
__metadata("design:returntype", Promise)
|
|
2220
|
-
], AskSkipResolver.prototype, "StopLearningCycleForOrganization", null);
|
|
2221
1772
|
AskSkipResolver = AskSkipResolver_1 = __decorate([
|
|
2222
1773
|
Resolver(AskSkipResultType)
|
|
2223
1774
|
], AskSkipResolver);
|