@memberjunction/server 2.16.1 → 2.18.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/generated/generated.d.ts +372 -43
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +4161 -2107
- package/dist/generated/generated.js.map +1 -1
- package/dist/generic/ResolverBase.d.ts.map +1 -1
- package/dist/generic/ResolverBase.js +1 -1
- package/dist/generic/ResolverBase.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.d.ts +6 -3
- package/dist/resolvers/AskSkipResolver.d.ts.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +44 -29
- package/dist/resolvers/AskSkipResolver.js.map +1 -1
- package/package.json +22 -22
- package/src/generated/generated.ts +9219 -7941
- package/src/generic/ResolverBase.ts +5 -2
- package/src/resolvers/AskSkipResolver.ts +56 -30
|
@@ -573,8 +573,11 @@ export class ResolverBase {
|
|
|
573
573
|
return this.MapFieldNamesToCodeNames(entityName, entityObject.GetAll());
|
|
574
574
|
}
|
|
575
575
|
// save failed, return null
|
|
576
|
-
else
|
|
577
|
-
|
|
576
|
+
else
|
|
577
|
+
throw entityObject.LatestResult?.Message;
|
|
578
|
+
}
|
|
579
|
+
else
|
|
580
|
+
return null;
|
|
578
581
|
}
|
|
579
582
|
|
|
580
583
|
// Before/After CREATE Event Hooks for Sub-Classes to Override
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
SkipAPIRequestAPIKey,
|
|
20
20
|
SkipRequestPhase,
|
|
21
21
|
SkipAPIAgentNote,
|
|
22
|
+
SkipAPIAgentNoteType,
|
|
22
23
|
} from '@memberjunction/skip-types';
|
|
23
24
|
|
|
24
25
|
import { PUSH_STATUS_UPDATES_TOPIC } from '../generic/PushStatusResolver.js';
|
|
@@ -37,6 +38,7 @@ import { MJGlobal, CopyScalarsAndArrays } from '@memberjunction/global';
|
|
|
37
38
|
import { sendPostRequest } from '../util.js';
|
|
38
39
|
import { GetAIAPIKey } from '@memberjunction/ai';
|
|
39
40
|
import { CompositeKeyInputType } from '../generic/KeyInputOutputTypes.js';
|
|
41
|
+
import { AIAgentEntityExtended, AIEngine } from '@memberjunction/aiengine';
|
|
40
42
|
|
|
41
43
|
enum SkipResponsePhase {
|
|
42
44
|
ClarifyingQuestion = 'clarifying_question',
|
|
@@ -232,7 +234,7 @@ export class AskSkipResolver {
|
|
|
232
234
|
): Promise<SkipAPIRequest> {
|
|
233
235
|
const entities = includeEntities ? this.BuildSkipEntities() : [];
|
|
234
236
|
const queries = includeQueries ? this.BuildSkipQueries() : [];
|
|
235
|
-
const notes = includeNotes ? await this.BuildSkipAgentNotes(contextUser) : [];
|
|
237
|
+
const {notes, noteTypes} = includeNotes ? await this.BuildSkipAgentNotes(contextUser) : {notes: [], noteTypes: []};
|
|
236
238
|
const input: SkipAPIRequest = {
|
|
237
239
|
apiKeys: this.buildSkipAPIKeys(),
|
|
238
240
|
organizationInfo: configInfo?.askSkip?.organizationInfo,
|
|
@@ -243,7 +245,8 @@ export class AskSkipResolver {
|
|
|
243
245
|
requestPhase: requestPhase,
|
|
244
246
|
entities: entities,
|
|
245
247
|
queries: queries,
|
|
246
|
-
notes: notes
|
|
248
|
+
notes: notes,
|
|
249
|
+
noteTypes: noteTypes
|
|
247
250
|
};
|
|
248
251
|
return input;
|
|
249
252
|
}
|
|
@@ -343,9 +346,14 @@ export class AskSkipResolver {
|
|
|
343
346
|
);
|
|
344
347
|
}
|
|
345
348
|
|
|
346
|
-
|
|
349
|
+
/**
|
|
350
|
+
* Packages up the Approved queries from the metadata
|
|
351
|
+
* @returns
|
|
352
|
+
*/
|
|
353
|
+
protected BuildSkipQueries(status: "Pending" | "In-Review" | "Approved" | "Rejected" | "Obsolete" = 'Approved'): SkipQueryInfo[] {
|
|
347
354
|
const md = new Metadata();
|
|
348
|
-
|
|
355
|
+
const approvedQueries = md.Queries.filter((q) => q.Status === status);
|
|
356
|
+
return approvedQueries.map((q) => {
|
|
349
357
|
return {
|
|
350
358
|
id: q.ID,
|
|
351
359
|
name: q.Name,
|
|
@@ -386,38 +394,49 @@ export class AskSkipResolver {
|
|
|
386
394
|
/**
|
|
387
395
|
* Builds up the array of notes that are applicable for Skip to receive from MJAPI
|
|
388
396
|
*/
|
|
389
|
-
protected async BuildSkipAgentNotes(contextUser: UserInfo): Promise<SkipAPIAgentNote[]> {
|
|
397
|
+
protected async BuildSkipAgentNotes(contextUser: UserInfo): Promise<{notes: SkipAPIAgentNote[], noteTypes: SkipAPIAgentNoteType[]}> {
|
|
390
398
|
try {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
399
|
+
// if already configured this does nothing, just makes sure we're configured
|
|
400
|
+
await AIEngine.Instance.Config(false, contextUser);
|
|
401
|
+
|
|
402
|
+
const agent: AIAgentEntityExtended = AIEngine.Instance.GetAgentByName('Skip');
|
|
403
|
+
if (agent) {
|
|
404
|
+
let notes: SkipAPIAgentNote[] = [];
|
|
405
|
+
let noteTypes: SkipAPIAgentNoteType[] = [];
|
|
406
|
+
|
|
407
|
+
notes = agent.Notes.map((r) => {
|
|
408
|
+
return {
|
|
409
|
+
id: r.ID,
|
|
410
|
+
agentNoteTypeId: r.AgentNoteTypeID,
|
|
411
|
+
agentNoteType: r.AgentNoteType,
|
|
412
|
+
note: r.Note,
|
|
413
|
+
type: r.Type,
|
|
414
|
+
userId: r.UserID,
|
|
415
|
+
user: r.User,
|
|
416
|
+
createdAt: r.__mj_CreatedAt,
|
|
417
|
+
updatedAt: r.__mj_UpdatedAt,
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
noteTypes = AIEngine.Instance.AgentNoteTypes.map((r) => {
|
|
422
|
+
return {
|
|
423
|
+
id: r.ID,
|
|
424
|
+
name: r.Name,
|
|
425
|
+
description: r.Description
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// now return the notes and note types
|
|
430
|
+
return {notes, noteTypes};
|
|
412
431
|
}
|
|
413
432
|
else {
|
|
414
|
-
console.warn(`No AI Agent
|
|
415
|
-
return []; // no agent
|
|
433
|
+
console.warn(`No AI Agent found with the name 'Skip' in the AI Engine, so no notes will be sent to Skip`);
|
|
434
|
+
return {notes: [], noteTypes: []}; // no agent found, so nothing to do
|
|
416
435
|
}
|
|
417
436
|
}
|
|
418
437
|
catch (e) {
|
|
419
438
|
LogError(e);
|
|
420
|
-
return []; // non- fatal error just return
|
|
439
|
+
return {notes: [], noteTypes: []}; // non- fatal error just return empty arrays
|
|
421
440
|
}
|
|
422
441
|
}
|
|
423
442
|
|
|
@@ -629,7 +648,7 @@ export class AskSkipResolver {
|
|
|
629
648
|
const md = new Metadata();
|
|
630
649
|
const e = md.Entities.find((e) => e.Name === 'Conversation Details');
|
|
631
650
|
const sql = `SELECT
|
|
632
|
-
${maxHistoricalMessages ? 'TOP ' + maxHistoricalMessages : ''}
|
|
651
|
+
${maxHistoricalMessages ? 'TOP ' + maxHistoricalMessages : ''} *
|
|
633
652
|
FROM
|
|
634
653
|
${e.SchemaName}.${e.BaseView}
|
|
635
654
|
WHERE
|
|
@@ -689,6 +708,13 @@ export class AskSkipResolver {
|
|
|
689
708
|
content: skipRole === 'system' ? outputMessage : r.Message,
|
|
690
709
|
role: skipRole,
|
|
691
710
|
conversationDetailID: r.ID,
|
|
711
|
+
hiddenToUser: r.HiddenToUser,
|
|
712
|
+
userRating: r.UserRating,
|
|
713
|
+
userFeedback: r.UserFeedback,
|
|
714
|
+
reflectionInsights: r.ReflectionInsights,
|
|
715
|
+
summaryOfEarlierConveration: r.SummaryOfEarlierConversation,
|
|
716
|
+
createdAt: r.__mj_CreatedAt,
|
|
717
|
+
updatedAt: r.__mj_UpdatedAt,
|
|
692
718
|
};
|
|
693
719
|
return m;
|
|
694
720
|
});
|