@memberjunction/server 2.17.0 → 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 +74 -0
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +523 -63
- package/dist/generated/generated.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.d.ts +1 -1
- package/dist/resolvers/AskSkipResolver.d.ts.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +32 -40
- package/dist/resolvers/AskSkipResolver.js.map +1 -1
- package/package.json +22 -22
- package/src/generated/generated.ts +371 -88
- package/src/resolvers/AskSkipResolver.ts +42 -44
|
@@ -38,6 +38,7 @@ import { MJGlobal, CopyScalarsAndArrays } from '@memberjunction/global';
|
|
|
38
38
|
import { sendPostRequest } from '../util.js';
|
|
39
39
|
import { GetAIAPIKey } from '@memberjunction/ai';
|
|
40
40
|
import { CompositeKeyInputType } from '../generic/KeyInputOutputTypes.js';
|
|
41
|
+
import { AIAgentEntityExtended, AIEngine } from '@memberjunction/aiengine';
|
|
41
42
|
|
|
42
43
|
enum SkipResponsePhase {
|
|
43
44
|
ClarifyingQuestion = 'clarifying_question',
|
|
@@ -345,9 +346,14 @@ export class AskSkipResolver {
|
|
|
345
346
|
);
|
|
346
347
|
}
|
|
347
348
|
|
|
348
|
-
|
|
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[] {
|
|
349
354
|
const md = new Metadata();
|
|
350
|
-
|
|
355
|
+
const approvedQueries = md.Queries.filter((q) => q.Status === status);
|
|
356
|
+
return approvedQueries.map((q) => {
|
|
351
357
|
return {
|
|
352
358
|
id: q.ID,
|
|
353
359
|
name: q.Name,
|
|
@@ -390,51 +396,43 @@ export class AskSkipResolver {
|
|
|
390
396
|
*/
|
|
391
397
|
protected async BuildSkipAgentNotes(contextUser: UserInfo): Promise<{notes: SkipAPIAgentNote[], noteTypes: SkipAPIAgentNoteType[]}> {
|
|
392
398
|
try {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
if (
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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};
|
|
415
431
|
}
|
|
416
432
|
else {
|
|
417
|
-
console.warn(`No AI 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
|
|
418
435
|
}
|
|
419
|
-
|
|
420
|
-
if (md.EntityByName('AI Agent Note Types')) {
|
|
421
|
-
const rv = new RunView();
|
|
422
|
-
const result = await rv.RunView({
|
|
423
|
-
EntityName: "AI Agent Note Types"
|
|
424
|
-
}, contextUser);
|
|
425
|
-
if (result && result.Success) {
|
|
426
|
-
noteTypes = result.Results.map((r) => {
|
|
427
|
-
return {
|
|
428
|
-
id: r.ID,
|
|
429
|
-
name: r.Name,
|
|
430
|
-
description: r.Description
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// now return the notes and note types
|
|
437
|
-
return {notes, noteTypes};
|
|
438
436
|
}
|
|
439
437
|
catch (e) {
|
|
440
438
|
LogError(e);
|