@awell-health/awell-extensions 2.0.21 → 2.0.23
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 +16 -2
- package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.js.map +1 -1
- package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.test.js +2 -2
- 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/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/package.json +1 -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
@@ -31,7 +31,8 @@ describe.skip('categorizeMessage - Real LLM calls', () => {
|
|
31
31
|
// Real LangChain function is called
|
32
32
|
expect(onComplete).toHaveBeenCalledWith({
|
33
33
|
data_points: {
|
34
|
-
category: 'Appointment Scheduling',
|
34
|
+
category: 'Appointment Scheduling',
|
35
|
+
explanation: 'The message explicitly states a desire to schedule an appointment, which directly aligns with the Appointment Scheduling category.',
|
35
36
|
},
|
36
37
|
});
|
37
38
|
expect(onError).not.toHaveBeenCalled();
|
@@ -53,10 +54,11 @@ describe.skip('categorizeMessage - Real LLM calls', () => {
|
|
53
54
|
// Real LangChain function is called and returns "None"
|
54
55
|
expect(onComplete).toHaveBeenCalledWith({
|
55
56
|
data_points: {
|
56
|
-
category: 'None',
|
57
|
+
category: 'None',
|
58
|
+
explanation: 'Categorization was ambiguous; we could not find a proper category.',
|
57
59
|
},
|
58
60
|
});
|
59
61
|
expect(onError).not.toHaveBeenCalled();
|
60
62
|
});
|
61
63
|
});
|
62
|
-
//# sourceMappingURL=
|
64
|
+
//# sourceMappingURL=callingRealOpenAITest.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"callingRealOpenAITest.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/callingRealOpenAITest.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAqC;AACrC,yBAAsB;AAEtB,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;CAC1C,CAAA;AAED,8BAA8B;AAC9B,QAAQ,CAAC,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;IACvD,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,CAAC,+BAA+B;QAC5C,IAAI,CAAC,aAAa,EAAE,CAAA,CAAC,2BAA2B;IAClD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yFAAyF,EAAE,KAAK,IAAI,EAAE;QACvG,MAAM,OAAO,GAAG,IAAA,2BAAmB,EAAC;YAClC,MAAM,EAAE;gBACN,OAAO,EAAE,wDAAwD;gBACjE,UAAU,EACR,8FAA8F;aACjG;YACD,QAAQ;SACT,CAAC,CAAA;QAEF,MAAM,eAAe,CAAC,OAAO,CAAC;YAC5B,OAAO;YACP,UAAU;YACV,OAAO;YACP,OAAO;SACR,CAAC,CAAA;QAEF,oCAAoC;QACpC,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,QAAQ,EAAE,wBAAwB;gBAClC,WAAW,EACT,oIAAoI;aACvI;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kFAAkF,EAAE,KAAK,IAAI,EAAE;QAChG,MAAM,OAAO,GAAG,IAAA,2BAAmB,EAAC;YAClC,MAAM,EAAE;gBACN,OAAO,EAAE,iCAAiC;gBAC1C,UAAU,EACR,8FAA8F;aACjG;YACD,QAAQ;SACT,CAAC,CAAA;QAEF,MAAM,eAAe,CAAC,OAAO,CAAC;YAC5B,OAAO;YACP,UAAU;YACV,OAAO;YACP,OAAO;SACR,CAAC,CAAA;QAEF,uDAAuD;QACvD,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,QAAQ,EAAE,MAAM;gBAChB,WAAW,EACT,oEAAoE;aACvE;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -9,24 +9,28 @@ exports.categorizeMessage = {
|
|
9
9
|
key: 'categorizeMessage',
|
10
10
|
category: extensions_core_1.Category.WORKFLOW,
|
11
11
|
title: 'Categorize Message',
|
12
|
-
description: 'Categorize the input message into set of predefined categories',
|
12
|
+
description: 'Categorize the input message into set of predefined categories and provides explanation.',
|
13
13
|
fields: config_1.fields,
|
14
14
|
previewable: false,
|
15
15
|
dataPoints: config_1.dataPoints,
|
16
16
|
onEvent: async ({ payload, onComplete, onError, helpers }) => {
|
17
|
-
const {
|
17
|
+
const { ChatModelGPT4oMini, fields: { categories, message }, } = await (0, lib_1.validatePayloadAndCreateSdk)({
|
18
18
|
fieldsSchema: config_1.FieldsValidationSchema,
|
19
19
|
payload,
|
20
20
|
});
|
21
21
|
try {
|
22
|
-
const
|
23
|
-
|
22
|
+
const categorization_result = await (0, categorizeMessageWithLLM_1.categorizeMessageWithLLM)({
|
23
|
+
ChatModelGPT4oMini,
|
24
24
|
message,
|
25
25
|
categories,
|
26
26
|
});
|
27
|
+
console.log(categorization_result);
|
28
|
+
const category = categorization_result.category;
|
29
|
+
const explanation = categorization_result.explanation;
|
27
30
|
await onComplete({
|
28
31
|
data_points: {
|
29
32
|
category,
|
33
|
+
explanation,
|
30
34
|
},
|
31
35
|
});
|
32
36
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"categorizeMessage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/categorizeMessage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,6EAAyE;AACzE,mCAAuD;AAEvD,qCAAqE;AAExD,QAAA,iBAAiB,GAI1B;IACF,GAAG,EAAE,mBAAmB;IACxB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,oBAAoB;IAC3B,WAAW,
|
1
|
+
{"version":3,"file":"categorizeMessage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/categorizeMessage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,6EAAyE;AACzE,mCAAuD;AAEvD,qCAAqE;AAExD,QAAA,iBAAiB,GAI1B;IACF,GAAG,EAAE,mBAAmB;IACxB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EACT,0FAA0F;IAC5F,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,MAAM,EACJ,kBAAkB,EAClB,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,GAChC,GAAG,MAAM,IAAA,iCAA2B,EAAC;YACpC,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,IAAI;YACF,MAAM,qBAAqB,GAAG,MAAM,IAAA,mDAAwB,EAAC;gBAC3D,kBAAkB;gBAClB,OAAO;gBACP,UAAU;aACX,CAAC,CAAA;YAEF,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;YAClC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAA;YAC/C,MAAM,WAAW,GAAG,qBAAqB,CAAC,WAAW,CAAA;YAErD,MAAM,UAAU,CAAC;gBACf,WAAW,EAAE;oBACX,QAAQ;oBACR,WAAW;iBACZ;aACF,CAAC,CAAA;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;YACnD,4BAA4B;YAC5B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC9C;IACH,CAAC;CACF,CAAA"}
|
@@ -4,15 +4,23 @@ const extensions_core_1 = require("@awell-health/extensions-core");
|
|
4
4
|
const tests_1 = require("@/tests");
|
5
5
|
const _1 = require(".");
|
6
6
|
const openai_1 = require("@langchain/openai");
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
// Mock the module
|
8
|
+
jest.mock('@langchain/openai', () => {
|
9
|
+
const mockInvoke = jest.fn().mockResolvedValue({
|
10
|
+
matched_category: 'Appointment Scheduling',
|
11
|
+
match_explanation: 'The message contains a request for scheduling an appointment.',
|
12
|
+
});
|
13
|
+
const mockChain = {
|
14
|
+
invoke: mockInvoke,
|
15
|
+
};
|
16
|
+
const mockPipe = jest.fn().mockReturnValue(mockChain);
|
17
|
+
const mockChatOpenAI = jest.fn().mockImplementation(() => ({
|
18
|
+
pipe: mockPipe,
|
19
|
+
}));
|
20
|
+
return {
|
21
|
+
ChatOpenAI: mockChatOpenAI,
|
22
|
+
};
|
23
|
+
});
|
16
24
|
describe('categorizeMessage - Mocked LLM calls', () => {
|
17
25
|
const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.categorizeMessage);
|
18
26
|
beforeEach(() => {
|
@@ -20,11 +28,6 @@ describe('categorizeMessage - Mocked LLM calls', () => {
|
|
20
28
|
jest.clearAllMocks();
|
21
29
|
});
|
22
30
|
it('should work', async () => {
|
23
|
-
const mockedOpenAiInstance = new openai_1.OpenAI();
|
24
|
-
jest.spyOn(mockedOpenAiInstance, 'invoke').mockResolvedValue({
|
25
|
-
// @ts-expect-error fine, we have a parser
|
26
|
-
matched_entity: 'Appointment Scheduling',
|
27
|
-
});
|
28
31
|
const categorizeMessageWithLLMSpy = jest.spyOn(require('./lib/categorizeMessageWithLLM'), 'categorizeMessageWithLLM');
|
29
32
|
const payload = (0, tests_1.generateTestPayload)({
|
30
33
|
fields: {
|
@@ -41,9 +44,9 @@ describe('categorizeMessage - Mocked LLM calls', () => {
|
|
41
44
|
onError,
|
42
45
|
helpers,
|
43
46
|
});
|
44
|
-
expect(
|
47
|
+
expect(openai_1.ChatOpenAI).toHaveBeenCalled();
|
45
48
|
expect(categorizeMessageWithLLMSpy).toHaveBeenCalledWith({
|
46
|
-
|
49
|
+
ChatModelGPT4oMini: expect.any(Object),
|
47
50
|
message: 'I would like to schedule an appointment for next week.',
|
48
51
|
categories: [
|
49
52
|
'Appointment Scheduling',
|
@@ -54,7 +57,8 @@ describe('categorizeMessage - Mocked LLM calls', () => {
|
|
54
57
|
});
|
55
58
|
expect(onComplete).toHaveBeenCalledWith({
|
56
59
|
data_points: {
|
57
|
-
category: 'Appointment Scheduling',
|
60
|
+
category: 'Appointment Scheduling',
|
61
|
+
explanation: 'The message contains a request for scheduling an appointment.',
|
58
62
|
},
|
59
63
|
});
|
60
64
|
expect(onError).not.toHaveBeenCalled();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"categorizeMessage.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/categorizeMessage.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAqC;AACrC,
|
1
|
+
{"version":3,"file":"categorizeMessage.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/categorizeMessage.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAqC;AACrC,8CAA8C;AAE9C,kBAAkB;AAClB,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAClC,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;QAC7C,gBAAgB,EAAE,wBAAwB;QAC1C,iBAAiB,EACf,+DAA+D;KAClE,CAAC,CAAA;IAEF,MAAM,SAAS,GAAG;QAChB,MAAM,EAAE,UAAU;KACnB,CAAA;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;IAErD,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QACzD,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC,CAAA;IAEH,OAAO;QACL,UAAU,EAAE,cAAc;KAC3B,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACpD,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,aAAa,EAAE,KAAK,IAAI,EAAE;QAC3B,MAAM,2BAA2B,GAAG,IAAI,CAAC,KAAK,CAC5C,OAAO,CAAC,gCAAgC,CAAC,EACzC,0BAA0B,CAC3B,CAAA;QAED,MAAM,OAAO,GAAG,IAAA,2BAAmB,EAAC;YAClC,MAAM,EAAE;gBACN,OAAO,EAAE,wDAAwD;gBACjE,UAAU,EACR,8FAA8F;aACjG;YACD,QAAQ,EAAE;gBACR,YAAY,EAAE,GAAG;aAClB;SACF,CAAC,CAAA;QAEF,MAAM,eAAe,CAAC,OAAO,CAAC;YAC5B,OAAO;YACP,UAAU;YACV,OAAO;YACP,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,CAAC,mBAAU,CAAC,CAAC,gBAAgB,EAAE,CAAA;QACrC,MAAM,CAAC,2BAA2B,CAAC,CAAC,oBAAoB,CAAC;YACvD,kBAAkB,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YACtC,OAAO,EAAE,wDAAwD;YACjE,UAAU,EAAE;gBACV,wBAAwB;gBACxB,sBAAsB;gBACtB,2BAA2B;gBAC3B,wBAAwB;aACzB;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,QAAQ,EAAE,wBAAwB;gBAClC,WAAW,EACT,+DAA+D;aAClE;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"datapoints.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/categorizeMessage/config/datapoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE;QACR,GAAG,EAAE,UAAU;QACf,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA"}
|
1
|
+
{"version":3,"file":"datapoints.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/categorizeMessage/config/datapoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE;QACR,GAAG,EAAE,UAAU;QACf,SAAS,EAAE,QAAQ;KACpB;IACD,WAAW,EAAE;QACX,GAAG,EAAE,aAAa;QAClB,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA"}
|
@@ -1,6 +1,9 @@
|
|
1
|
-
import { type
|
2
|
-
export declare const categorizeMessageWithLLM: ({
|
3
|
-
|
1
|
+
import { type ChatOpenAI } from '@langchain/openai';
|
2
|
+
export declare const categorizeMessageWithLLM: ({ ChatModelGPT4oMini, message, categories, }: {
|
3
|
+
ChatModelGPT4oMini: ChatOpenAI;
|
4
4
|
message: string;
|
5
5
|
categories: string[];
|
6
|
-
}) => Promise<
|
6
|
+
}) => Promise<{
|
7
|
+
category: string;
|
8
|
+
explanation: string;
|
9
|
+
}>;
|
@@ -2,21 +2,39 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.categorizeMessageWithLLM = void 0;
|
4
4
|
const constants_1 = require("./constants");
|
5
|
-
|
6
|
-
|
5
|
+
// TODO: remove console logs eventually
|
6
|
+
const categorizeMessageWithLLM = async ({ ChatModelGPT4oMini, message, categories, }) => {
|
7
|
+
var _a, _b;
|
7
8
|
const prompt = await constants_1.systemPrompt.format({
|
8
9
|
categories: categories.concat('None').join(', '),
|
9
10
|
input: message,
|
10
11
|
});
|
11
|
-
const chain =
|
12
|
+
const chain = ChatModelGPT4oMini.pipe(constants_1.parser);
|
12
13
|
console.log('Prompt:', prompt);
|
13
|
-
|
14
|
+
let result;
|
15
|
+
try {
|
16
|
+
result = await chain.invoke(prompt);
|
17
|
+
}
|
18
|
+
catch (error) {
|
19
|
+
console.error('Error invoking the chain:', error);
|
20
|
+
throw new Error('Failed to categorize the message due to an internal error.');
|
21
|
+
}
|
14
22
|
console.log('Result', typeof result);
|
15
|
-
const
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
const matchedCategory = (_a = result.matched_category) !== null && _a !== void 0 ? _a : 'None';
|
24
|
+
let category;
|
25
|
+
let explanation = (_b = result.match_explanation) !== null && _b !== void 0 ? _b : '';
|
26
|
+
console.log('Matched Category:', matchedCategory);
|
27
|
+
console.log('Explanation:', explanation);
|
28
|
+
// Check if the matched category is valid
|
29
|
+
if (categories.includes(matchedCategory)) {
|
30
|
+
category = matchedCategory;
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
category = 'None';
|
34
|
+
explanation =
|
35
|
+
'Categorization was ambiguous; we could not find a proper category.';
|
36
|
+
}
|
37
|
+
return { category, explanation };
|
20
38
|
};
|
21
39
|
exports.categorizeMessageWithLLM = categorizeMessageWithLLM;
|
22
40
|
//# sourceMappingURL=categorizeMessageWithLLM.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"categorizeMessageWithLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;
|
1
|
+
{"version":3,"file":"categorizeMessageWithLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAGlD,uCAAuC;AAChC,MAAM,wBAAwB,GAAG,KAAK,EAAE,EAC7C,kBAAkB,EAClB,OAAO,EACP,UAAU,GAKX,EAAsD,EAAE;;IACvD,MAAM,MAAM,GAAG,MAAM,wBAAY,CAAC,MAAM,CAAC;QACvC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAChD,KAAK,EAAE,OAAO;KACf,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,kBAAM,CAAC,CAAA;IAC7C,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAC9B,IAAI,MAAM,CAAA;IACV,IAAI;QACF,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;KACpC;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;QACjD,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;KACF;IAED,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,MAAM,CAAC,CAAA;IAEpC,MAAM,eAAe,GAAG,MAAA,MAAM,CAAC,gBAAgB,mCAAI,MAAM,CAAA;IACzD,IAAI,QAAgB,CAAA;IACpB,IAAI,WAAW,GAAW,MAAA,MAAM,CAAC,iBAAiB,mCAAI,EAAE,CAAA;IAExD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAA;IACjD,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;IACxC,yCAAyC;IACzC,IAAI,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;QACxC,QAAQ,GAAG,eAAe,CAAA;KAC3B;SAAM;QACL,QAAQ,GAAG,MAAM,CAAA;QACjB,WAAW;YACT,oEAAoE,CAAA;KACvE;IAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;AAClC,CAAC,CAAA;AA5CY,QAAA,wBAAwB,4BA4CpC"}
|
@@ -3,18 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
require("dotenv/config");
|
4
4
|
const _1 = require("./");
|
5
5
|
describe('categorizeMessageWithLLM', () => {
|
6
|
-
let
|
6
|
+
let ChatModelGPT4oMiniMock;
|
7
7
|
beforeEach(() => {
|
8
|
-
|
9
|
-
langChainOpenAiSdkMock = {
|
8
|
+
ChatModelGPT4oMiniMock = {
|
10
9
|
pipe: jest.fn().mockReturnThis(),
|
11
|
-
invoke: jest.fn(),
|
10
|
+
invoke: jest.fn(),
|
12
11
|
};
|
13
12
|
});
|
14
13
|
it('should categorize a message about scheduling an appointment using real LLM', async () => {
|
15
|
-
|
14
|
+
ChatModelGPT4oMiniMock.invoke.mockResolvedValue({
|
16
15
|
// @ts-expect-error it's fine, we have a parser
|
17
|
-
|
16
|
+
matched_category: 'Appointment Scheduling',
|
17
|
+
match_explanation: 'The message contains a request for scheduling an appointment.',
|
18
18
|
});
|
19
19
|
const categories = [
|
20
20
|
'Appointment Scheduling',
|
@@ -24,16 +24,17 @@ describe('categorizeMessageWithLLM', () => {
|
|
24
24
|
];
|
25
25
|
const message = 'I would like to schedule an appointment for next week.';
|
26
26
|
const result = await (0, _1.categorizeMessageWithLLM)({
|
27
|
-
|
27
|
+
ChatModelGPT4oMini: ChatModelGPT4oMiniMock,
|
28
28
|
message,
|
29
29
|
categories,
|
30
30
|
});
|
31
|
-
expect(result).toBe('Appointment Scheduling');
|
31
|
+
expect(result.category).toBe('Appointment Scheduling');
|
32
32
|
});
|
33
33
|
it('should categorize a message about medication using real LLM', async () => {
|
34
|
-
|
34
|
+
ChatModelGPT4oMiniMock.invoke.mockResolvedValue({
|
35
35
|
// @ts-expect-error it's fine, we have a parser
|
36
|
-
|
36
|
+
matched_category: 'Medication Questions',
|
37
|
+
match_explanation: 'The message contains a request for medication information.',
|
37
38
|
});
|
38
39
|
const categories = [
|
39
40
|
'Appointment Scheduling',
|
@@ -43,16 +44,17 @@ describe('categorizeMessageWithLLM', () => {
|
|
43
44
|
];
|
44
45
|
const message = 'Can you tell me the correct dosage for my medication?';
|
45
46
|
const result = await (0, _1.categorizeMessageWithLLM)({
|
46
|
-
|
47
|
+
ChatModelGPT4oMini: ChatModelGPT4oMiniMock,
|
47
48
|
message,
|
48
49
|
categories,
|
49
50
|
});
|
50
|
-
expect(result).toBe('Medication Questions');
|
51
|
+
expect(result.category).toBe('Medication Questions');
|
51
52
|
});
|
52
53
|
it('should return "None" when the message does not match any category using real LLM', async () => {
|
53
|
-
|
54
|
+
ChatModelGPT4oMiniMock.invoke.mockResolvedValue({
|
54
55
|
// @ts-expect-error it's fine, we have a parser
|
55
|
-
|
56
|
+
matched_category: 'None',
|
57
|
+
match_explanation: 'The message does not contain any information about scheduling or medication.',
|
56
58
|
});
|
57
59
|
const categories = [
|
58
60
|
'Appointment Scheduling',
|
@@ -60,13 +62,13 @@ describe('categorizeMessageWithLLM', () => {
|
|
60
62
|
'Medication Questions',
|
61
63
|
'Administrative Assistance',
|
62
64
|
];
|
63
|
-
const message = 'Is it going to rain tomorrow?';
|
65
|
+
const message = 'Is it going to rain tomorrow?';
|
64
66
|
const result = await (0, _1.categorizeMessageWithLLM)({
|
65
|
-
|
67
|
+
ChatModelGPT4oMini: ChatModelGPT4oMiniMock,
|
66
68
|
message,
|
67
69
|
categories,
|
68
70
|
});
|
69
|
-
expect(result).toBe('None');
|
71
|
+
expect(result.category).toBe('None');
|
70
72
|
});
|
71
73
|
});
|
72
74
|
//# sourceMappingURL=categorizeMessageWithLLM.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"categorizeMessageWithLLM.test.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,yBAA6C;AAG7C,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAI,
|
1
|
+
{"version":3,"file":"categorizeMessageWithLLM.test.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,yBAA6C;AAG7C,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAI,sBAA+C,CAAA;IAEnD,UAAU,CAAC,GAAG,EAAE;QACd,sBAAsB,GAAG;YACvB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,cAAc,EAAE;YAChC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;SACoB,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4EAA4E,EAAE,KAAK,IAAI,EAAE;QAC1F,sBAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC9C,+CAA+C;YAC/C,gBAAgB,EAAE,wBAAwB;YAC1C,iBAAiB,EACf,+DAA+D;SAClE,CAAC,CAAA;QAEF,MAAM,UAAU,GAAG;YACjB,wBAAwB;YACxB,0BAA0B;YAC1B,sBAAsB;YACtB,2BAA2B;SAC5B,CAAA;QACD,MAAM,OAAO,GAAG,wDAAwD,CAAA;QAExE,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAwB,EAAC;YAC5C,kBAAkB,EAAE,sBAAsB;YAC1C,OAAO;YACP,UAAU;SACX,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,sBAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC9C,+CAA+C;YAC/C,gBAAgB,EAAE,sBAAsB;YACxC,iBAAiB,EACf,4DAA4D;SAC/D,CAAC,CAAA;QAEF,MAAM,UAAU,GAAG;YACjB,wBAAwB;YACxB,0BAA0B;YAC1B,sBAAsB;YACtB,2BAA2B;SAC5B,CAAA;QACD,MAAM,OAAO,GAAG,uDAAuD,CAAA;QAEvE,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAwB,EAAC;YAC5C,kBAAkB,EAAE,sBAAsB;YAC1C,OAAO;YACP,UAAU;SACX,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kFAAkF,EAAE,KAAK,IAAI,EAAE;QAChG,sBAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC9C,+CAA+C;YAC/C,gBAAgB,EAAE,MAAM;YACxB,iBAAiB,EACf,8EAA8E;SACjF,CAAC,CAAA;QAEF,MAAM,UAAU,GAAG;YACjB,wBAAwB;YACxB,0BAA0B;YAC1B,sBAAsB;YACtB,2BAA2B;SAC5B,CAAA;QACD,MAAM,OAAO,GAAG,+BAA+B,CAAA;QAE/C,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAwB,EAAC;YAC5C,kBAAkB,EAAE,sBAAsB;YAC1C,OAAO;YACP,UAAU;SACX,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACtC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.d.ts
CHANGED
@@ -2,17 +2,23 @@ import { ChatPromptTemplate } from '@langchain/core/prompts';
|
|
2
2
|
import { StructuredOutputParser } from 'langchain/output_parsers';
|
3
3
|
import { z } from 'zod';
|
4
4
|
export declare const messageCategoriesSchema: z.ZodObject<{
|
5
|
-
|
5
|
+
matched_category: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
6
|
+
match_explanation: z.ZodString;
|
6
7
|
}, "strip", z.ZodTypeAny, {
|
7
|
-
|
8
|
+
matched_category: string;
|
9
|
+
match_explanation: string;
|
8
10
|
}, {
|
9
|
-
|
11
|
+
match_explanation: string;
|
12
|
+
matched_category?: string | undefined;
|
10
13
|
}>;
|
11
14
|
export declare const parser: StructuredOutputParser<z.ZodObject<{
|
12
|
-
|
15
|
+
matched_category: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
16
|
+
match_explanation: z.ZodString;
|
13
17
|
}, "strip", z.ZodTypeAny, {
|
14
|
-
|
18
|
+
matched_category: string;
|
19
|
+
match_explanation: string;
|
15
20
|
}, {
|
16
|
-
|
21
|
+
match_explanation: string;
|
22
|
+
matched_category?: string | undefined;
|
17
23
|
}>>;
|
18
|
-
export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an expert in categorizing messages
|
24
|
+
export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an expert in categorizing messages different messages in a clinical context.\n Use your expertise to solve the critical task:\n 1. Match the provided message to one of the following categories: {categories}.\n 2. Provide a one-sentence explanation of why the message fits the chosen category.\n \n Instructions for categorization:\n - The message may be in different languages.\n - It is crucial that you only select a category from the provided list.\n - If no match is found, or if the match is ambiguous, return \"None\".\n It is critical to double-check your work before returning the final result.\n \n Respond exclusively with a valid JSON object containing the following keys:\n - matched_category: The selected category or \"None\".\n - match_explanation: A one-sentence explanation of the match. Make sure to provide clear and concise explanation to justify your decision.\n \n Input:\n {input}\n ">, any>;
|
package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js
CHANGED
@@ -6,17 +6,27 @@ const output_parsers_1 = require("langchain/output_parsers");
|
|
6
6
|
const zod_1 = require("zod");
|
7
7
|
// Define the Zod schema for the structured response
|
8
8
|
exports.messageCategoriesSchema = zod_1.z.object({
|
9
|
-
|
9
|
+
matched_category: zod_1.z.string().optional().default('None'),
|
10
|
+
match_explanation: zod_1.z.string(), // One-sentence explanation of the match
|
10
11
|
});
|
11
12
|
// Create a structured output parser
|
12
13
|
exports.parser = output_parsers_1.StructuredOutputParser.fromZodSchema(exports.messageCategoriesSchema);
|
13
|
-
//
|
14
|
+
// TODO: move prompt to LangSmith + further tune
|
14
15
|
exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
|
15
|
-
You are an expert in categorizing messages
|
16
|
-
|
16
|
+
You are an expert in categorizing messages different messages in a clinical context.
|
17
|
+
Use your expertise to solve the critical task:
|
18
|
+
1. Match the provided message to one of the following categories: {categories}.
|
19
|
+
2. Provide a one-sentence explanation of why the message fits the chosen category.
|
17
20
|
|
18
|
-
|
21
|
+
Instructions for categorization:
|
22
|
+
- The message may be in different languages.
|
23
|
+
- It is crucial that you only select a category from the provided list.
|
24
|
+
- If no match is found, or if the match is ambiguous, return "None".
|
25
|
+
It is critical to double-check your work before returning the final result.
|
19
26
|
|
27
|
+
Respond exclusively with a valid JSON object containing the following keys:
|
28
|
+
- matched_category: The selected category or "None".
|
29
|
+
- match_explanation: A one-sentence explanation of the match. Make sure to provide clear and concise explanation to justify your decision.
|
20
30
|
|
21
31
|
Input:
|
22
32
|
{input}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAC5D,6DAAiE;AACjE,6BAAuB;AAEvB,oDAAoD;AACvC,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAC5D,6DAAiE;AACjE,6BAAuB;AAEvB,oDAAoD;AACvC,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IACvD,iBAAiB,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,wCAAwC;CACxE,CAAC,CAAA;AAEF,oCAAoC;AACvB,QAAA,MAAM,GAAG,uCAAsB,CAAC,aAAa,CACxD,+BAAuB,CACxB,CAAA;AAED,gDAAgD;AACnC,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;OAkBrD,CAAC,CAAA"}
|
@@ -1,10 +1,17 @@
|
|
1
1
|
declare const actions: {
|
2
2
|
summarizeForm: import("@awell-health/extensions-core").Action<{
|
3
|
-
|
3
|
+
additionalInstructions: {
|
4
4
|
id: string;
|
5
5
|
label: string;
|
6
6
|
description: string;
|
7
|
-
type: import("@awell-health/extensions-core").FieldType.
|
7
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
8
|
+
required: false;
|
9
|
+
};
|
10
|
+
stakeholder: {
|
11
|
+
id: string;
|
12
|
+
label: string;
|
13
|
+
description: string;
|
14
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
8
15
|
required: false;
|
9
16
|
};
|
10
17
|
}, {
|
@@ -17,11 +24,18 @@ declare const actions: {
|
|
17
24
|
};
|
18
25
|
}, "summary">;
|
19
26
|
summarizeCareFlow: import("@awell-health/extensions-core").Action<{
|
20
|
-
|
27
|
+
additionalInstructions: {
|
21
28
|
id: string;
|
22
29
|
label: string;
|
23
30
|
description: string;
|
24
|
-
type: import("@awell-health/extensions-core").FieldType.
|
31
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
32
|
+
required: false;
|
33
|
+
};
|
34
|
+
stakeholder: {
|
35
|
+
id: string;
|
36
|
+
label: string;
|
37
|
+
description: string;
|
38
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
25
39
|
required: false;
|
26
40
|
};
|
27
41
|
}, {
|
@@ -56,7 +70,7 @@ declare const actions: {
|
|
56
70
|
required: true;
|
57
71
|
description: string;
|
58
72
|
};
|
59
|
-
}, "category">;
|
73
|
+
}, "category" | "explanation">;
|
60
74
|
medicationFromImage: import("@awell-health/extensions-core").Action<{
|
61
75
|
imageUrl: {
|
62
76
|
id: string;
|
@@ -19,8 +19,22 @@ exports.medicationFromImage = {
|
|
19
19
|
payload,
|
20
20
|
});
|
21
21
|
console.log(imageUrl);
|
22
|
-
// Call whatever API with the file URL and get back JSON
|
23
|
-
const data = await Promise.resolve({
|
22
|
+
// Call whatever API with the file URL and get back JSON (ideally in the following format)
|
23
|
+
const data = await Promise.resolve({
|
24
|
+
medications: [
|
25
|
+
{
|
26
|
+
product_rxcui: '809854',
|
27
|
+
product_name: 'hydrochlorothiazide 12.5 MG / quinapril 10 MG Oral Tablet [Accuretic]',
|
28
|
+
brand_name: 'Accuretic',
|
29
|
+
dose_form_name: 'Oral Tablet',
|
30
|
+
prescribable_name: 'Accuretic 10 MG / 12.5 MG Oral Tablet',
|
31
|
+
extracted_medication_name: 'Accuretic',
|
32
|
+
extracted_brand_name: 'Accuretic',
|
33
|
+
extracted_dosage: '10 mg / 12.5 mg',
|
34
|
+
extracted_ndcg: '0006-0711-31', // National Drug Code (optional)
|
35
|
+
},
|
36
|
+
],
|
37
|
+
});
|
24
38
|
await onComplete({
|
25
39
|
data_points: {
|
26
40
|
data: JSON.stringify(data),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"medicationFromImage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/medicationFromImage/medicationFromImage.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,mEAAqE;AACrE,mCAAuD;AAEvD,qCAAqE;AAExD,QAAA,mBAAmB,GAI5B;IACF,GAAG,EAAE,qBAAqB;IAC1B,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,+BAA+B;IACtC,WAAW,EAAE,oDAAoD;IACjE,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,MAAM,EACJ,MAAM,EAAE,EAAE,QAAQ,EAAE,GACrB,GAAG,MAAM,IAAA,iCAA2B,EAAC;YACpC,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"medicationFromImage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/medicationFromImage/medicationFromImage.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,mEAAqE;AACrE,mCAAuD;AAEvD,qCAAqE;AAExD,QAAA,mBAAmB,GAI5B;IACF,GAAG,EAAE,qBAAqB;IAC1B,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,+BAA+B;IACtC,WAAW,EAAE,oDAAoD;IACjE,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,MAAM,EACJ,MAAM,EAAE,EAAE,QAAQ,EAAE,GACrB,GAAG,MAAM,IAAA,iCAA2B,EAAC;YACpC,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAErB,0FAA0F;QAC1F,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC;YACjC,WAAW,EAAE;gBACX;oBACE,aAAa,EAAE,QAAQ;oBACvB,YAAY,EACV,uEAAuE;oBACzE,UAAU,EAAE,WAAW;oBACvB,cAAc,EAAE,aAAa;oBAC7B,iBAAiB,EAAE,uCAAuC;oBAC1D,yBAAyB,EAAE,WAAW;oBACtC,oBAAoB,EAAE,WAAW;oBACjC,gBAAgB,EAAE,iBAAiB;oBACnC,cAAc,EAAE,cAAc,EAAE,gCAAgC;iBACjE;aACF;SACF,CAAC,CAAA;QAEF,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;aAC3B;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
4
4
|
const tests_1 = require("@/tests");
|
5
5
|
const _1 = require(".");
|
6
|
-
describe('Shelly -
|
6
|
+
describe('Shelly - Medication From Image', () => {
|
7
7
|
const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.medicationFromImage);
|
8
8
|
beforeEach(() => {
|
9
9
|
clearMocks();
|
@@ -25,7 +25,7 @@ describe('Shelly - Summarize', () => {
|
|
25
25
|
expect(onError).not.toHaveBeenCalled();
|
26
26
|
expect(onComplete).toHaveBeenCalledWith({
|
27
27
|
data_points: {
|
28
|
-
data:
|
28
|
+
data: expect.any(String),
|
29
29
|
},
|
30
30
|
});
|
31
31
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"medicationFromImage.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/medicationFromImage/medicationFromImage.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAuC;AAEvC,QAAQ,CAAC,
|
1
|
+
{"version":3,"file":"medicationFromImage.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/medicationFromImage/medicationFromImage.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAuC;AAEvC,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,GACjE,6BAAW,CAAC,UAAU,CAAC,sBAAmB,CAAC,CAAA;IAE7C,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,EAAE,CAAA;IACd,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,eAAe,CAAC,OAAO,CAAC;YAC5B,OAAO,EAAE,IAAA,2BAAmB,EAAC;gBAC3B,MAAM,EAAE;oBACN,QAAQ,EACN,2GAA2G;iBAC9G;gBACD,QAAQ,EAAE;oBACR,YAAY,EAAE,GAAG;iBAClB;aACF,CAAC;YACF,UAAU;YACV,OAAO;YACP,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;QACtC,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;aACzB;SACF,CAAC,CAAA;IACJ,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, what to focus on 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/summarizeCareFlow/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/summarizeCareFlow/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,2JAA2J;QAC7J,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"}
|