@awell-health/awell-extensions 2.0.22 → 2.0.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/extensions/shelly/actions/categorizeMessage/{realTest.test.js → callingRealOpenAITest.test.js} +5 -3
- package/dist/extensions/shelly/actions/categorizeMessage/callingRealOpenAITest.test.js.map +1 -0
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js +8 -4
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.test.js +21 -17
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.test.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.d.ts +4 -0
- package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.js +4 -0
- package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.d.ts +7 -4
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.js +27 -9
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.js +19 -17
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.d.ts +13 -7
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js +15 -5
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js.map +1 -1
- package/dist/extensions/shelly/actions/index.d.ts +19 -5
- package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.js +37 -23
- package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.js.map +1 -1
- package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.test.js +123 -3
- package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.test.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.d.ts +15 -5
- package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.js +21 -6
- package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/constants.d.ts +2 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/constants.js +37 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/constants.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/index.d.ts +1 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/index.js +6 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/index.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.d.ts +7 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.js +22 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.test.d.ts +1 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.test.js +42 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.test.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.js +23 -10
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.js +57 -26
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlowRealOpenAI.test.d.ts +1 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlowRealOpenAI.test.js +58 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlowRealOpenAI.test.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeForm/config/fields.d.ts +15 -5
- package/dist/extensions/shelly/actions/summarizeForm/config/fields.js +21 -6
- package/dist/extensions/shelly/actions/summarizeForm/config/fields.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js +2 -1
- package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.d.ts +2 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.js +37 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.d.ts +1 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.js +6 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.d.ts +7 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.js +22 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.d.ts +1 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.js +54 -0
- package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js +25 -8
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js +69 -31
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeForm/summarizeFormRealOpenAI.test.d.ts +1 -0
- package/dist/extensions/shelly/actions/summarizeForm/summarizeFormRealOpenAI.test.js +71 -0
- package/dist/extensions/shelly/actions/summarizeForm/summarizeFormRealOpenAI.test.js.map +1 -0
- package/dist/extensions/shelly/lib/api/index.d.ts +1 -0
- package/dist/extensions/shelly/lib/api/index.js +6 -0
- package/dist/extensions/shelly/lib/api/index.js.map +1 -0
- package/dist/extensions/shelly/lib/api/medicationExtractorApi.d.ts +19 -0
- package/dist/extensions/shelly/lib/api/medicationExtractorApi.js +60 -0
- package/dist/extensions/shelly/lib/api/medicationExtractorApi.js.map +1 -0
- package/dist/extensions/shelly/lib/constants.d.ts +1 -0
- package/dist/extensions/shelly/lib/constants.js +2 -1
- package/dist/extensions/shelly/lib/constants.js.map +1 -1
- package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.d.ts +3 -2
- package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js +20 -3
- package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js.map +1 -1
- package/dist/extensions/shelly/types.d.ts +16 -0
- package/dist/extensions/shelly/types.js +3 -0
- package/dist/extensions/shelly/types.js.map +1 -0
- package/package.json +3 -1
- package/dist/extensions/shelly/actions/categorizeMessage/realTest.test.js.map +0 -1
- /package/dist/extensions/shelly/actions/categorizeMessage/{realTest.test.d.ts → callingRealOpenAITest.test.d.ts} +0 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
require("dotenv/config");
|
4
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
|
+
const tests_1 = require("@/tests");
|
6
|
+
const _1 = require(".");
|
7
|
+
const pathwayActivitiesResponse_1 = require("./__mocks__/pathwayActivitiesResponse");
|
8
|
+
// remove .skip to run this test
|
9
|
+
describe.skip('summarizeCareFlow - Real LLM calls with mocked Awell SDK', () => {
|
10
|
+
const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.summarizeCareFlow);
|
11
|
+
beforeEach(() => {
|
12
|
+
clearMocks();
|
13
|
+
jest.clearAllMocks();
|
14
|
+
});
|
15
|
+
it('Should call the real model and use mocked care flow activities', async () => {
|
16
|
+
// Set up payload
|
17
|
+
const payload = (0, tests_1.generateTestPayload)({
|
18
|
+
pathway: {
|
19
|
+
id: 'ai4rZaYEocjB',
|
20
|
+
definition_id: 'whatever',
|
21
|
+
},
|
22
|
+
fields: {
|
23
|
+
stakeholder: 'Clinician',
|
24
|
+
additionalInstructions: 'Summarize activities focusing on important steps.',
|
25
|
+
},
|
26
|
+
settings: {
|
27
|
+
openAiApiKey: process.env.OPENAI_TEST_KEY, // Use your actual OpenAI API key here
|
28
|
+
},
|
29
|
+
});
|
30
|
+
// Mock the Awell SDK to return care flow activities
|
31
|
+
const awellSdkMock = {
|
32
|
+
orchestration: {
|
33
|
+
query: jest.fn().mockResolvedValue({
|
34
|
+
pathwayActivities: pathwayActivitiesResponse_1.mockPathwayActivitiesResponse,
|
35
|
+
}),
|
36
|
+
},
|
37
|
+
};
|
38
|
+
helpers.awellSdk = jest.fn().mockResolvedValue(awellSdkMock);
|
39
|
+
// Execute the action without mocking ChatOpenAI (real call)
|
40
|
+
await extensionAction.onEvent({
|
41
|
+
payload,
|
42
|
+
onComplete,
|
43
|
+
onError,
|
44
|
+
helpers,
|
45
|
+
});
|
46
|
+
// Assertions for the Awell SDK mock
|
47
|
+
expect(helpers.awellSdk).toHaveBeenCalled();
|
48
|
+
expect(awellSdkMock.orchestration.query).toHaveBeenCalledTimes(1);
|
49
|
+
// Ensure that the model has actually been called (real call to ChatOpenAI)
|
50
|
+
expect(onComplete).toHaveBeenCalledWith({
|
51
|
+
data_points: {
|
52
|
+
summary: expect.stringContaining('plugin'),
|
53
|
+
},
|
54
|
+
});
|
55
|
+
expect(onError).not.toHaveBeenCalled();
|
56
|
+
});
|
57
|
+
});
|
58
|
+
//# sourceMappingURL=summarizeCareFlowRealOpenAI.test.js.map
|
package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlowRealOpenAI.test.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"summarizeCareFlowRealOpenAI.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeCareFlow/summarizeCareFlowRealOpenAI.test.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAqC;AACrC,qFAAqF;AAErF,gCAAgC;AAChC,QAAQ,CAAC,IAAI,CAAC,0DAA0D,EAAE,GAAG,EAAE;IAC7E,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,GACjE,6BAAW,CAAC,UAAU,CAAC,oBAAiB,CAAC,CAAA;IAE3C,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,EAAE,CAAA;QACZ,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAC9E,iBAAiB;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAmB,EAAC;YAClC,OAAO,EAAE;gBACP,EAAE,EAAE,cAAc;gBAClB,aAAa,EAAE,UAAU;aAC1B;YACD,MAAM,EAAE;gBACN,WAAW,EAAE,WAAW;gBACxB,sBAAsB,EACpB,mDAAmD;aACtD;YACD,QAAQ,EAAE;gBACR,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,sCAAsC;aAClF;SACF,CAAC,CAAA;QAEF,oDAAoD;QACpD,MAAM,YAAY,GAAG;YACnB,aAAa,EAAE;gBACb,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;oBACjC,iBAAiB,EAAE,yDAA6B;iBACjD,CAAC;aACH;SACF,CAAA;QAED,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAA;QAE5D,4DAA4D;QAC5D,MAAM,eAAe,CAAC,OAAO,CAAC;YAC5B,OAAO;YACP,UAAU;YACV,OAAO;YACP,OAAO;SACR,CAAC,CAAA;QAEF,oCAAoC;QACpC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,gBAAgB,EAAE,CAAA;QAC3C,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAEjE,2EAA2E;QAC3E,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;aAC3C;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -1,18 +1,28 @@
|
|
1
1
|
import { FieldType } from '@awell-health/extensions-core';
|
2
2
|
import z from 'zod';
|
3
3
|
export declare const fields: {
|
4
|
-
|
4
|
+
additionalInstructions: {
|
5
5
|
id: string;
|
6
6
|
label: string;
|
7
7
|
description: string;
|
8
|
-
type: FieldType.
|
8
|
+
type: FieldType.STRING;
|
9
|
+
required: false;
|
10
|
+
};
|
11
|
+
stakeholder: {
|
12
|
+
id: string;
|
13
|
+
label: string;
|
14
|
+
description: string;
|
15
|
+
type: FieldType.STRING;
|
9
16
|
required: false;
|
10
17
|
};
|
11
18
|
};
|
12
19
|
export declare const FieldsValidationSchema: z.ZodObject<{
|
13
|
-
|
20
|
+
additionalInstructions: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
21
|
+
stakeholder: z.ZodEffects<z.ZodOptional<z.ZodString>, string, string | undefined>;
|
14
22
|
}, "strip", z.ZodTypeAny, {
|
15
|
-
|
23
|
+
additionalInstructions: string;
|
24
|
+
stakeholder: string;
|
16
25
|
}, {
|
17
|
-
|
26
|
+
additionalInstructions?: string | undefined;
|
27
|
+
stakeholder?: string | undefined;
|
18
28
|
}>;
|
@@ -7,15 +7,30 @@ exports.FieldsValidationSchema = exports.fields = void 0;
|
|
7
7
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
8
8
|
const zod_1 = __importDefault(require("zod"));
|
9
9
|
exports.fields = {
|
10
|
-
|
11
|
-
id: '
|
12
|
-
label: '
|
13
|
-
description: '
|
14
|
-
type: extensions_core_1.FieldType.
|
10
|
+
additionalInstructions: {
|
11
|
+
id: 'additionalInstructions',
|
12
|
+
label: 'Additional Instructions',
|
13
|
+
description: 'Specify additional instructions for summarization, for example format, length, etc. If not specified, default instructions will be used.',
|
14
|
+
type: extensions_core_1.FieldType.STRING,
|
15
|
+
required: false,
|
16
|
+
},
|
17
|
+
stakeholder: {
|
18
|
+
id: 'stakeholder',
|
19
|
+
label: 'Stakeholder',
|
20
|
+
description: 'Defaults to "Clinician"',
|
21
|
+
type: extensions_core_1.FieldType.STRING,
|
15
22
|
required: false,
|
16
23
|
},
|
17
24
|
};
|
18
25
|
exports.FieldsValidationSchema = zod_1.default.object({
|
19
|
-
|
26
|
+
additionalInstructions: zod_1.default.string().optional().default(''),
|
27
|
+
stakeholder: zod_1.default
|
28
|
+
.string()
|
29
|
+
.optional()
|
30
|
+
.transform((val) => {
|
31
|
+
if (val === undefined || val === '')
|
32
|
+
return 'Clinician';
|
33
|
+
return val;
|
34
|
+
}),
|
20
35
|
});
|
21
36
|
//# sourceMappingURL=fields.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/summarizeForm/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,8CAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/summarizeForm/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,8CAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,sBAAsB,EAAE;QACtB,EAAE,EAAE,wBAAwB;QAC5B,KAAK,EAAE,yBAAyB;QAChC,WAAW,EACT,0IAA0I;QAC5I,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,KAAK;KAChB;IACD,WAAW,EAAE;QACX,EAAE,EAAE,aAAa;QACjB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,yBAAyB;QACtC,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,KAAK;KAChB;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7C,sBAAsB,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACzD,WAAW,EAAE,aAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,SAAS,CAAC,CAAC,GAAG,EAAU,EAAE;QACzB,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE;YAAE,OAAO,WAAW,CAAA;QAEvD,OAAO,GAAG,CAAA;IACZ,CAAC,CAAC;CAC6C,CAAC,CAAA"}
|
@@ -38,7 +38,8 @@ const getMultipleSelectAnswers = (questionDefinition, questionResponse) => {
|
|
38
38
|
const getQuestionAndAnswer = (questionDefinition, questionResponse) => {
|
39
39
|
const userQuestionType = questionDefinition.userQuestionType;
|
40
40
|
const addQuestionLabel = (answer) => {
|
41
|
-
|
41
|
+
var _a;
|
42
|
+
return `Question: ${questionDefinition.title}\nQuestion type: ${(_a = questionDefinition.userQuestionType) !== null && _a !== void 0 ? _a : 'UNKNOWN'}\n${answer}`;
|
42
43
|
};
|
43
44
|
switch (userQuestionType) {
|
44
45
|
case 'YES_NO':
|
package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getResponseText.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.ts"],"names":[],"mappings":";;;AAOA,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IAClD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,YAAY,CAAA;IAEvC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,aAAa,CAAA;IAExC,OAAO,iBAAiB,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAC5B,kBAA4B,EAC5B,gBAAwB,EAChB,EAAE;;IACV,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAA;IAC1C,MAAM,aAAa,GAAG,MAAA,kBAAkB,CAAC,OAAO,mCAAI,EAAE,CAAA;IAEtD,MAAM,gBAAgB,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAClC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,OAAO,KAAK,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,YAAY,GAAG,CAAA;IACrD,CAAC,EACA,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,MAAM,WAAW,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CACrC,CAAC,YA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gB,CAAA;IAE5D,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE
|
1
|
+
{"version":3,"file":"getResponseText.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.ts"],"names":[],"mappings":";;;AAOA,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IAClD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,YAAY,CAAA;IAEvC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,aAAa,CAAA;IAExC,OAAO,iBAAiB,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAC5B,kBAA4B,EAC5B,gBAAwB,EAChB,EAAE;;IACV,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAA;IAC1C,MAAM,aAAa,GAAG,MAAA,kBAAkB,CAAC,OAAO,mCAAI,EAAE,CAAA;IAEtD,MAAM,gBAAgB,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAClC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,OAAO,KAAK,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,YAAY,GAAG,CAAA;IACrD,CAAC,EACA,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,MAAM,WAAW,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CACrC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,YAAY,KAAK,WAAW,CAC5D,0CAAE,KAAK,CAAA;IAER,OAAO,sBAAsB,gBAAgB,aAAa,MAAM,CAC9D,WAAW,CACZ,EAAE,CAAA;AACL,CAAC,CAAA;AAED,MAAM,wBAAwB,GAAG,CAC/B,kBAA4B,EAC5B,gBAAwB,EAChB,EAAE;;IACV,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAErD,CAAA;IACD,MAAM,aAAa,GAAG,MAAA,kBAAkB,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,CAAC,CAAC,EAAE,KAAK,gBAAgB,CAAC,WAAW,CAC7C,CAAA;QAED,IAAI,kBAAkB,KAAK,SAAS,EAAE;YACpC,kBAAkB,CAAC,IAAI,CAAC;gBACtB,UAAU,EAAE,gBAAgB,CAAC,WAAW;gBACxC,MAAM,EACJ,mEAAmE;aACtE,CAAC,CAAA;YACF,OAAM;SACP;QAED,IAAI;YACF,MAAM,MAAM,GAAG,oBAAoB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;YAEzE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;SACzB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;YAE1D,kBAAkB,CAAC,IAAI,CAAC;gBACtB,UAAU,EAAE,gBAAgB,CAAC,WAAW;gBACxC,MAAM,EAAE,4BAA4B,YAAY,EAAE;aACnD,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,0BAA0B,CAAC;QACpD,kBAAkB;KACnB,CAAA;AACH,CAAC,CAAA;AA3CY,QAAA,eAAe,mBA2C3B"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
2
|
+
export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an assistant that provides summaries of forms for different stakeholders in a clinical pathway setting.\n You will be given forms with answers, answer labels, and possible answer options if applicable, to summarize.\n Take into consideration that context of fomrms might weary - from general questions, basic contact information to more medically specific ones.\n Your job is to provide the summary of the context you have. Do not mention what is not present in the form. Do not make any assumtions - this is critical.\n Additionally, you will be given additional instructions on how to summarize the form directly from a stakeholder.\n \n Language:\n Your summary should be in the same language as the form unless otherwise specified in the additional instructions.\n\n Instructions for summarizing:\n - Focus on the specific use case and context you are summarizing.\n - It is extremely important to tailor the summary specifically for the stakeholder to maximize its usefulness to them.\n - Emphasize information that is most pertinent to the stakeholder's needs, including critical data, notable findings, and any insights particularly useful for them.\n - Provide a concise and clear summary that is brief yet comprehensive.\n - Aim for a length that conveys all key points without unnecessary details.\n - Do not list all questions and answers unless specified in the additional instructions.\n - Do not include titles or formatting like bold or italic.\n - Provide quick insights of key points in an easy-to-read format for the stakeholder. Format as buller points unless otherwise specified in the additional instructions.\n - Do not include anything that is not present in form (such as the assumption that the patient visited clinic).\n Do not put titles like Summary: , just provide the summary.\n\n Additional Instructions:\n {additionalInstructions}\n\n Stakeholder:\n {stakeholder}\n\n Content to summarize:\n {input}\n ">, any>;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.systemPrompt = void 0;
|
4
|
+
const prompts_1 = require("@langchain/core/prompts");
|
5
|
+
// TODO: move prompt to LangSmith + further tune
|
6
|
+
exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
|
7
|
+
You are an assistant that provides summaries of forms for different stakeholders in a clinical pathway setting.
|
8
|
+
You will be given forms with answers, answer labels, and possible answer options if applicable, to summarize.
|
9
|
+
Take into consideration that context of fomrms might weary - from general questions, basic contact information to more medically specific ones.
|
10
|
+
Your job is to provide the summary of the context you have. Do not mention what is not present in the form. Do not make any assumtions - this is critical.
|
11
|
+
Additionally, you will be given additional instructions on how to summarize the form directly from a stakeholder.
|
12
|
+
|
13
|
+
Language:
|
14
|
+
Your summary should be in the same language as the form unless otherwise specified in the additional instructions.
|
15
|
+
|
16
|
+
Instructions for summarizing:
|
17
|
+
- Focus on the specific use case and context you are summarizing.
|
18
|
+
- It is extremely important to tailor the summary specifically for the stakeholder to maximize its usefulness to them.
|
19
|
+
- Emphasize information that is most pertinent to the stakeholder's needs, including critical data, notable findings, and any insights particularly useful for them.
|
20
|
+
- Provide a concise and clear summary that is brief yet comprehensive.
|
21
|
+
- Aim for a length that conveys all key points without unnecessary details.
|
22
|
+
- Do not list all questions and answers unless specified in the additional instructions.
|
23
|
+
- Do not include titles or formatting like bold or italic.
|
24
|
+
- Provide quick insights of key points in an easy-to-read format for the stakeholder. Format as buller points unless otherwise specified in the additional instructions.
|
25
|
+
- Do not include anything that is not present in form (such as the assumption that the patient visited clinic).
|
26
|
+
Do not put titles like Summary: , just provide the summary.
|
27
|
+
|
28
|
+
Additional Instructions:
|
29
|
+
{additionalInstructions}
|
30
|
+
|
31
|
+
Stakeholder:
|
32
|
+
{stakeholder}
|
33
|
+
|
34
|
+
Content to summarize:
|
35
|
+
{input}
|
36
|
+
`);
|
37
|
+
//# sourceMappingURL=constants.js.map
|
package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE5D,gDAAgD;AACnC,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BzD,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { summarizeFormWithLLM } from './summarizeFormWithLLM';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.summarizeFormWithLLM = void 0;
|
4
|
+
var summarizeFormWithLLM_1 = require("./summarizeFormWithLLM");
|
5
|
+
Object.defineProperty(exports, "summarizeFormWithLLM", { enumerable: true, get: function () { return summarizeFormWithLLM_1.summarizeFormWithLLM; } });
|
6
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.ts"],"names":[],"mappings":";;;AAAA,+DAA6D;AAApD,4HAAA,oBAAoB,OAAA"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type ChatOpenAI } from '@langchain/openai';
|
2
|
+
export declare const summarizeFormWithLLM: ({ ChatModelGPT4o, formData, stakeholder, additionalInstructions, }: {
|
3
|
+
ChatModelGPT4o: ChatOpenAI;
|
4
|
+
formData: string;
|
5
|
+
stakeholder: string;
|
6
|
+
additionalInstructions: string;
|
7
|
+
}) => Promise<string>;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.summarizeFormWithLLM = void 0;
|
4
|
+
const constants_1 = require("./constants");
|
5
|
+
// TODO: remove console logs eventually
|
6
|
+
const summarizeFormWithLLM = async ({ ChatModelGPT4o, formData, stakeholder, additionalInstructions, }) => {
|
7
|
+
const prompt = await constants_1.systemPrompt.format({
|
8
|
+
stakeholder,
|
9
|
+
additionalInstructions,
|
10
|
+
input: formData,
|
11
|
+
});
|
12
|
+
console.log('Prompt', prompt);
|
13
|
+
const summaryMessage = await ChatModelGPT4o.invoke(prompt);
|
14
|
+
console.log('Type', typeof summaryMessage.content);
|
15
|
+
// TODO: for some reason compiler doesn't know that content is a string
|
16
|
+
const summary = summaryMessage.content;
|
17
|
+
console.log('Type', typeof summary);
|
18
|
+
console.log('Summary', summary);
|
19
|
+
return summary;
|
20
|
+
};
|
21
|
+
exports.summarizeFormWithLLM = summarizeFormWithLLM;
|
22
|
+
//# sourceMappingURL=summarizeFormWithLLM.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"summarizeFormWithLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAG1C,uCAAuC;AAChC,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACzC,cAAc,EACd,QAAQ,EACR,WAAW,EACX,sBAAsB,GAMvB,EAAmB,EAAE;IACpB,MAAM,MAAM,GAAG,MAAM,wBAAY,CAAC,MAAM,CAAC;QACvC,WAAW;QACX,sBAAsB;QACtB,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC7B,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAE1D,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,cAAc,CAAC,OAAO,CAAC,CAAA;IAClD,uEAAuE;IACvE,MAAM,OAAO,GAAG,cAAc,CAAC,OAAiB,CAAA;IAChD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,OAAO,CAAC,CAAA;IACnC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAzBY,QAAA,oBAAoB,wBAyBhC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
import 'dotenv/config';
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
require("dotenv/config");
|
4
|
+
const summarizeFormWithLLM_1 = require("./summarizeFormWithLLM");
|
5
|
+
const messages_1 = require("@langchain/core/messages");
|
6
|
+
const sampleForms = {
|
7
|
+
'General Health Questionnaire': {
|
8
|
+
questions: [
|
9
|
+
'What brings you to the clinic today?',
|
10
|
+
'Can you describe the nature of your back pain?',
|
11
|
+
'Have you taken any medications or treatments for this pain?',
|
12
|
+
'Have you had any recent injuries or accidents?',
|
13
|
+
'Do you have any other symptoms or health concerns?',
|
14
|
+
],
|
15
|
+
answers: [
|
16
|
+
"I've been experiencing persistent back pain for the past two weeks.",
|
17
|
+
"It's a sharp pain in my lower back, especially when I bend over or lift something.",
|
18
|
+
"I've been taking over-the-counter painkillers, but they don't seem to help much.",
|
19
|
+
'No recent injuries, but I started a new job that requires lifting heavy boxes.',
|
20
|
+
'Sometimes I feel numbness in my right leg.',
|
21
|
+
],
|
22
|
+
},
|
23
|
+
};
|
24
|
+
describe('summarizeFormWithLLM', () => {
|
25
|
+
let ChatModelGPT4oMock;
|
26
|
+
beforeEach(() => {
|
27
|
+
// Define the 'invoke' method in the mock
|
28
|
+
ChatModelGPT4oMock = {
|
29
|
+
invoke: jest.fn(),
|
30
|
+
};
|
31
|
+
});
|
32
|
+
it('should return a mocked summary for the General Health Questionnaire', async () => {
|
33
|
+
const mockedSummary = 'Patient reports persistent sharp lower back pain for two weeks, exacerbated by bending or lifting, with numbness in the right leg. No recent injuries but has started a new job involving heavy lifting.';
|
34
|
+
// Mock the 'invoke' method to return an AIMessage
|
35
|
+
ChatModelGPT4oMock.invoke.mockResolvedValueOnce(new messages_1.AIMessageChunk(mockedSummary));
|
36
|
+
const formName = 'General Health Questionnaire';
|
37
|
+
const form = sampleForms[formName];
|
38
|
+
const formData = form.questions
|
39
|
+
.map((question, index) => `Question: ${question}\nAnswer: ${form.answers[index]}\n`)
|
40
|
+
.join('\n');
|
41
|
+
const stakeholder = 'Clinician';
|
42
|
+
const additionalInstructions = 'Highlight any critical symptoms and possible causes.';
|
43
|
+
const summary = await (0, summarizeFormWithLLM_1.summarizeFormWithLLM)({
|
44
|
+
ChatModelGPT4o: ChatModelGPT4oMock,
|
45
|
+
formData: formData,
|
46
|
+
stakeholder,
|
47
|
+
additionalInstructions,
|
48
|
+
});
|
49
|
+
console.log('Summary', summary);
|
50
|
+
expect(summary).toBe(mockedSummary);
|
51
|
+
expect(ChatModelGPT4oMock.invoke).toHaveBeenCalledTimes(1);
|
52
|
+
});
|
53
|
+
});
|
54
|
+
//# sourceMappingURL=summarizeFormWithLLM.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"summarizeFormWithLLM.test.js","sourceRoot":"","sources":["../../../../../../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AAE,kBAAkB;YAClC,QAAQ,EAAE,QAAQ;YAClB,WAAW;YACX,sBAAsB;SACvB,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAE/B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QACnC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;IAC5D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -1,21 +1,25 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.summarizeForm = void 0;
|
4
|
-
const awell_1 = require("../../../../src/lib/awell");
|
5
4
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
6
5
|
const lib_1 = require("../../lib");
|
7
6
|
const config_1 = require("./config");
|
8
7
|
const getResponseText_1 = require("./lib/getResponseText");
|
8
|
+
const summarizeFormWithLLM_1 = require("./lib/summarizeFormWithLLM");
|
9
|
+
const constants_1 = require("../../lib/constants");
|
10
|
+
const awell_1 = require("../../../../src/lib/awell");
|
11
|
+
// TODO get rid of console logs eventually
|
12
|
+
// TODO: Please check stakeholders aand whether I can get them lioke this - it is needed for the LLM call.
|
9
13
|
exports.summarizeForm = {
|
10
14
|
key: 'summarizeForm',
|
11
15
|
category: extensions_core_1.Category.WORKFLOW,
|
12
16
|
title: 'Summarize form',
|
13
|
-
description: 'Summarize the response of a form',
|
17
|
+
description: 'Summarize the response of a form with AI.',
|
14
18
|
fields: config_1.fields,
|
15
19
|
previewable: false,
|
16
20
|
dataPoints: config_1.dataPoints,
|
17
21
|
onEvent: async ({ payload, onComplete, onError, helpers }) => {
|
18
|
-
const { pathway, activity } = await (0, lib_1.validatePayloadAndCreateSdk)({
|
22
|
+
const { ChatModelGPT4o, fields: { additionalInstructions, stakeholder }, pathway, activity, } = await (0, lib_1.validatePayloadAndCreateSdk)({
|
19
23
|
fieldsSchema: config_1.FieldsValidationSchema,
|
20
24
|
payload,
|
21
25
|
});
|
@@ -29,11 +33,24 @@ exports.summarizeForm = {
|
|
29
33
|
formResponse,
|
30
34
|
});
|
31
35
|
console.log(responseText);
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
try {
|
37
|
+
const summary = await (0, summarizeFormWithLLM_1.summarizeFormWithLLM)({
|
38
|
+
ChatModelGPT4o,
|
39
|
+
formData: responseText,
|
40
|
+
stakeholder,
|
41
|
+
additionalInstructions,
|
42
|
+
});
|
43
|
+
console.log(`${constants_1.DISCLAIMER_MSG}\n\n${summary}`);
|
44
|
+
await onComplete({
|
45
|
+
data_points: {
|
46
|
+
summary: `${constants_1.DISCLAIMER_MSG}\n\n${summary}`,
|
47
|
+
},
|
48
|
+
});
|
49
|
+
}
|
50
|
+
catch (error) {
|
51
|
+
console.error('Error summarizing form:', error);
|
52
|
+
throw new Error('Error summarizing form');
|
53
|
+
}
|
37
54
|
},
|
38
55
|
};
|
39
56
|
//# sourceMappingURL=summarizeForm.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"summarizeForm.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"summarizeForm.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,mCAAuD;AAEvD,qCAAqE;AACrE,2DAAuD;AACvD,qEAAiE;AACjE,mDAAoD;AACpD,qDAAsE;AAEtE,0CAA0C;AAC1C,0GAA0G;AAC7F,QAAA,aAAa,GAItB;IACF,GAAG,EAAE,eAAe;IACpB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,2CAA2C;IACxD,MAAM,EAAN,eAAM;IAC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1,93 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
// Import necessary modules and functions
|
3
4
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
4
5
|
const tests_1 = require("@/tests");
|
5
6
|
const _1 = require(".");
|
6
7
|
const pathwayActivitiesResponse_1 = require("./__mocks__/pathwayActivitiesResponse");
|
7
8
|
const formDefinitionResponse_1 = require("./__mocks__/formDefinitionResponse");
|
8
9
|
const formResponseResponse_1 = require("./__mocks__/formResponseResponse");
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
const constants_1 = require("../../lib/constants");
|
11
|
+
// Mock the '@langchain/openai' module
|
12
|
+
jest.mock('@langchain/openai', () => {
|
13
|
+
// Mock the 'invoke' method to return a resolved value
|
14
|
+
const mockInvoke = jest.fn().mockResolvedValue({
|
15
|
+
content: 'Mocked summary from LLM',
|
16
|
+
});
|
17
|
+
// Mock the ChatOpenAI class
|
18
|
+
const mockChatOpenAI = jest.fn().mockImplementation(() => ({
|
19
|
+
invoke: mockInvoke,
|
20
|
+
}));
|
21
|
+
return {
|
22
|
+
ChatOpenAI: mockChatOpenAI,
|
20
23
|
};
|
21
|
-
|
24
|
+
});
|
25
|
+
// Import ChatOpenAI after mocking
|
26
|
+
const openai_1 = require("@langchain/openai");
|
27
|
+
describe('summarizeForm - Mocked LLM calls', () => {
|
28
|
+
const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.summarizeForm);
|
22
29
|
beforeEach(() => {
|
23
30
|
clearMocks();
|
31
|
+
jest.clearAllMocks();
|
24
32
|
});
|
25
|
-
|
33
|
+
it('Should work', async () => {
|
34
|
+
// Spy on the 'summarizeFormWithLLM' function
|
35
|
+
const summarizeFormWithLLMSpy = jest.spyOn(require('./lib/summarizeFormWithLLM'), 'summarizeFormWithLLM');
|
36
|
+
// Create the test payload
|
37
|
+
const payload = (0, tests_1.generateTestPayload)({
|
38
|
+
pathway: {
|
39
|
+
id: 'ai4rZaYEocjB',
|
40
|
+
definition_id: 'whatever',
|
41
|
+
},
|
42
|
+
activity: { id: 'X74HeDQ4N0gtdaSEuzF8s' },
|
43
|
+
patient: { id: 'whatever' },
|
44
|
+
fields: {
|
45
|
+
stakeholder: 'Clinician',
|
46
|
+
additionalInstructions: 'Please focus on key symptoms.',
|
47
|
+
},
|
48
|
+
settings: {
|
49
|
+
openAiApiKey: 'a',
|
50
|
+
},
|
51
|
+
});
|
52
|
+
// Mock the Awell SDK
|
53
|
+
const awellSdkMock = {
|
54
|
+
orchestration: {
|
55
|
+
mutation: jest.fn().mockResolvedValue({}),
|
56
|
+
query: jest
|
57
|
+
.fn()
|
58
|
+
.mockResolvedValueOnce({
|
59
|
+
pathwayActivities: pathwayActivitiesResponse_1.mockPathwayActivitiesResponse,
|
60
|
+
})
|
61
|
+
.mockResolvedValueOnce({
|
62
|
+
form: formDefinitionResponse_1.mockFormDefinitionResponse,
|
63
|
+
})
|
64
|
+
.mockResolvedValueOnce({
|
65
|
+
formResponse: formResponseResponse_1.mockFormResponseResponse,
|
66
|
+
}),
|
67
|
+
},
|
68
|
+
};
|
69
|
+
helpers.awellSdk = jest.fn().mockResolvedValue(awellSdkMock);
|
70
|
+
// Execute the action
|
26
71
|
await extensionAction.onEvent({
|
27
|
-
payload
|
28
|
-
pathway: {
|
29
|
-
id: 'ai4rZaYEocjB',
|
30
|
-
definition_id: 'whatever',
|
31
|
-
},
|
32
|
-
activity: { id: 'X74HeDQ4N0gtdaSEuzF8s' },
|
33
|
-
patient: { id: 'whatever' },
|
34
|
-
fields: {
|
35
|
-
prompt: '',
|
36
|
-
},
|
37
|
-
settings: {
|
38
|
-
openAiApiKey: 'a',
|
39
|
-
},
|
40
|
-
}),
|
72
|
+
payload,
|
41
73
|
onComplete,
|
42
74
|
onError,
|
43
75
|
helpers,
|
44
76
|
});
|
45
|
-
|
46
|
-
expect(
|
47
|
-
expect(
|
77
|
+
// Assertions
|
78
|
+
expect(openai_1.ChatOpenAI).toHaveBeenCalled();
|
79
|
+
expect(summarizeFormWithLLMSpy).toHaveBeenCalledWith({
|
80
|
+
ChatModelGPT4o: expect.any(Object),
|
81
|
+
formData: expect.any(String),
|
82
|
+
stakeholder: 'Clinician',
|
83
|
+
additionalInstructions: 'Please focus on key symptoms.',
|
84
|
+
});
|
48
85
|
expect(onComplete).toHaveBeenCalledWith({
|
49
86
|
data_points: {
|
50
|
-
summary:
|
87
|
+
summary: `${constants_1.DISCLAIMER_MSG}\n\n${'Mocked summary from LLM'}`,
|
51
88
|
},
|
52
89
|
});
|
90
|
+
expect(onError).not.toHaveBeenCalled();
|
53
91
|
});
|
54
92
|
});
|
55
93
|
//# sourceMappingURL=summarizeForm.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"summarizeForm.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAiC;AACjC,qFAAqF;AACrF,+EAA+E;AAC/E,2EAA2E;
|
1
|
+
{"version":3,"file":"summarizeForm.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.test.ts"],"names":[],"mappings":";;AAAA,yCAAyC;AACzC,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAiC;AACjC,qFAAqF;AACrF,+EAA+E;AAC/E,2EAA2E;AAC3E,mDAAoD;AAEpD,sCAAsC;AACtC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAClC,sDAAsD;IACtD,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;QAC7C,OAAO,EAAE,yBAAyB;KACnC,CAAC,CAAA;IAEF,4BAA4B;IAC5B,MAAM,cAAc,GAAG,IAAI,C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qB,CAAC;oBACrB,iBAAiB,EAAE,yDAA6B;iBACjD,CAAC;qBACD,qBAAqB,CAAC;oBACrB,IAAI,EAAE,mDAA0B;iBACjC,CAAC;qBACD,qBAAqB,CAAC;oBACrB,YAAY,EAAE,+CAAwB;iBACvC,CAAC;aACL;SACF,CAAA;QAED,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAA;QAE5D,qBAAqB;QACrB,MAAM,eAAe,CAAC,OAAO,CAAC;YAC5B,OAAO;YACP,UAAU;YACV,OAAO;YACP,OAAO;SACR,CAAC,CAAA;QAEF,aAAa;QACb,MAAM,CAAC,mBAAU,CAAC,CAAC,gBAAgB,EAAE,CAAA;QACrC,MAAM,CAAC,uBAAuB,CAAC,CAAC,oBAAoB,CAAC;YACnD,cAAc,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YAClC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,sBAAsB,EAAE,+BAA+B;SACxD,CAAC,CAAA;QAEF,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,OAAO,EAAE,GAAG,0BAAc,OAAO,yBAAyB,EAAE;aAC7D;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
import 'dotenv/config';
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
require("dotenv/config");
|
4
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
|
+
const tests_1 = require("@/tests");
|
6
|
+
const _1 = require(".");
|
7
|
+
const pathwayActivitiesResponse_1 = require("./__mocks__/pathwayActivitiesResponse");
|
8
|
+
const formDefinitionResponse_1 = require("./__mocks__/formDefinitionResponse");
|
9
|
+
const formResponseResponse_1 = require("./__mocks__/formResponseResponse");
|
10
|
+
// remove skip to run this test
|
11
|
+
describe.skip('summarizeForm - Real LLM calls with mocked Awell SDK', () => {
|
12
|
+
const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.summarizeForm);
|
13
|
+
beforeEach(() => {
|
14
|
+
clearMocks();
|
15
|
+
jest.clearAllMocks();
|
16
|
+
});
|
17
|
+
it('Should call the real model and use mocked form data', async () => {
|
18
|
+
// Set up payload
|
19
|
+
const payload = (0, tests_1.generateTestPayload)({
|
20
|
+
pathway: {
|
21
|
+
id: 'ai4rZaYEocjB',
|
22
|
+
definition_id: 'whatever',
|
23
|
+
},
|
24
|
+
activity: { id: 'X74HeDQ4N0gtdaSEuzF8s' },
|
25
|
+
patient: { id: 'whatever' },
|
26
|
+
fields: {
|
27
|
+
stakeholder: 'Clinician',
|
28
|
+
additionalInstructions: 'Report only contact information',
|
29
|
+
},
|
30
|
+
settings: {
|
31
|
+
openAiApiKey: process.env.OPENAI_TEST_KEY, // Use your actual OpenAI API key here
|
32
|
+
},
|
33
|
+
});
|
34
|
+
// Mock the Awell SDK
|
35
|
+
const awellSdkMock = {
|
36
|
+
orchestration: {
|
37
|
+
mutation: jest.fn().mockResolvedValue({}),
|
38
|
+
query: jest
|
39
|
+
.fn()
|
40
|
+
.mockResolvedValueOnce({
|
41
|
+
pathwayActivities: pathwayActivitiesResponse_1.mockPathwayActivitiesResponse,
|
42
|
+
})
|
43
|
+
.mockResolvedValueOnce({
|
44
|
+
form: formDefinitionResponse_1.mockFormDefinitionResponse,
|
45
|
+
})
|
46
|
+
.mockResolvedValueOnce({
|
47
|
+
formResponse: formResponseResponse_1.mockFormResponseResponse,
|
48
|
+
}),
|
49
|
+
},
|
50
|
+
};
|
51
|
+
helpers.awellSdk = jest.fn().mockResolvedValue(awellSdkMock);
|
52
|
+
// Execute the action without mocking ChatOpenAI
|
53
|
+
await extensionAction.onEvent({
|
54
|
+
payload,
|
55
|
+
onComplete,
|
56
|
+
onError,
|
57
|
+
helpers,
|
58
|
+
});
|
59
|
+
// Assertions for the Awell SDK mock
|
60
|
+
expect(helpers.awellSdk).toHaveBeenCalled();
|
61
|
+
expect(awellSdkMock.orchestration.query).toHaveBeenCalledTimes(3);
|
62
|
+
// Ensure that the model has actually been called (real call to ChatOpenAI)
|
63
|
+
expect(onComplete).toHaveBeenCalledWith({
|
64
|
+
data_points: {
|
65
|
+
summary: expect.stringContaining('32476581696'),
|
66
|
+
},
|
67
|
+
});
|
68
|
+
expect(onError).not.toHaveBeenCalled();
|
69
|
+
});
|
70
|
+
});
|
71
|
+
//# sourceMappingURL=summarizeFormRealOpenAI.test.js.map
|