@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.
Files changed (77) hide show
  1. package/dist/extensions/shelly/actions/categorizeMessage/{realTest.test.js → callingRealOpenAITest.test.js} +5 -3
  2. package/dist/extensions/shelly/actions/categorizeMessage/callingRealOpenAITest.test.js.map +1 -0
  3. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js +8 -4
  4. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js.map +1 -1
  5. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.test.js +21 -17
  6. package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.test.js.map +1 -1
  7. package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.d.ts +4 -0
  8. package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.js +4 -0
  9. package/dist/extensions/shelly/actions/categorizeMessage/config/datapoints.js.map +1 -1
  10. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.d.ts +7 -4
  11. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.js +27 -9
  12. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.js.map +1 -1
  13. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.js +19 -17
  14. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.test.js.map +1 -1
  15. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.d.ts +13 -7
  16. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js +15 -5
  17. package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js.map +1 -1
  18. package/dist/extensions/shelly/actions/index.d.ts +19 -5
  19. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.js +16 -2
  20. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.js.map +1 -1
  21. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.test.js +2 -2
  22. package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.test.js.map +1 -1
  23. package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.d.ts +15 -5
  24. package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.js +21 -6
  25. package/dist/extensions/shelly/actions/summarizeCareFlow/config/fields.js.map +1 -1
  26. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/constants.d.ts +2 -0
  27. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/constants.js +37 -0
  28. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/constants.js.map +1 -0
  29. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/index.d.ts +1 -0
  30. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/index.js +6 -0
  31. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/index.js.map +1 -0
  32. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.d.ts +7 -0
  33. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.js +22 -0
  34. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.js.map +1 -0
  35. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.test.d.ts +1 -0
  36. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.test.js +42 -0
  37. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.test.js.map +1 -0
  38. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.js +23 -10
  39. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.js.map +1 -1
  40. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.js +57 -26
  41. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.js.map +1 -1
  42. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlowRealOpenAI.test.d.ts +1 -0
  43. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlowRealOpenAI.test.js +58 -0
  44. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlowRealOpenAI.test.js.map +1 -0
  45. package/dist/extensions/shelly/actions/summarizeForm/config/fields.d.ts +15 -5
  46. package/dist/extensions/shelly/actions/summarizeForm/config/fields.js +21 -6
  47. package/dist/extensions/shelly/actions/summarizeForm/config/fields.js.map +1 -1
  48. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js +2 -1
  49. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js.map +1 -1
  50. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.d.ts +2 -0
  51. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.js +37 -0
  52. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.js.map +1 -0
  53. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.d.ts +1 -0
  54. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.js +6 -0
  55. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.js.map +1 -0
  56. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.d.ts +7 -0
  57. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.js +22 -0
  58. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.js.map +1 -0
  59. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.d.ts +1 -0
  60. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.js +54 -0
  61. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.js.map +1 -0
  62. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js +25 -8
  63. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js.map +1 -1
  64. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js +69 -31
  65. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js.map +1 -1
  66. package/dist/extensions/shelly/actions/summarizeForm/summarizeFormRealOpenAI.test.d.ts +1 -0
  67. package/dist/extensions/shelly/actions/summarizeForm/summarizeFormRealOpenAI.test.js +71 -0
  68. package/dist/extensions/shelly/actions/summarizeForm/summarizeFormRealOpenAI.test.js.map +1 -0
  69. package/dist/extensions/shelly/lib/constants.d.ts +1 -0
  70. package/dist/extensions/shelly/lib/constants.js +2 -1
  71. package/dist/extensions/shelly/lib/constants.js.map +1 -1
  72. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.d.ts +3 -2
  73. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js +20 -3
  74. package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js.map +1 -1
  75. package/package.json +1 -1
  76. package/dist/extensions/shelly/actions/categorizeMessage/realTest.test.js.map +0 -1
  77. /package/dist/extensions/shelly/actions/categorizeMessage/{realTest.test.d.ts → callingRealOpenAITest.test.d.ts} +0 -0
@@ -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 activities performed in a care flow for different stakeholders in a healthcare setting.\n A care flow consists of tracks, steps, and actions that can be performed by a patient, a clinician, or the system itself. These actions may include patient tasks (e.g., form submissions), clinician interventions (e.g., messages sent), or system-triggered activities (e.g., API calls).\n \n Your job is to provide a clear, human-readable summary of these activities in chronological order, ensuring the summary is tailored for the specific stakeholder. Focus on activity names and descriptions, avoiding any mention of IDs or technical details.\n \n Instructions for summarizing:\n - Summarize the care flow activities in the order they were performed, maintaining the chronological sequence.\n - Ensure the summary is concise, clear, and relevant to the stakeholder's needs.\n - Focus on activity names, titles, and the nature of the actions (e.g., patient submitted a form, clinician responded to a message).\n - Do not include any IDs, internal codes, or technical jargon—only human-readable information.\n - Tailor the summary to the specific stakeholder, emphasizing the information most relevant to their role.\n - Avoid making assumptions about actions not explicitly mentioned in the input.\n - Provide the summary as a set of bullet points unless otherwise specified in the instructions. Make it as concise as possible. \n \n Format:\n - Provide the summary as a set of bullet points unless otherwise specified in the instructions. Make it as concise as possible.\n - Format it as an easy-to-grasp timeline with all important values and information. \n - Always mention track, step, and action names if applicable unless otherwise specified in the additional instructions.\n - Never format it in markdown with bold, italic, etc., unless otherwise specified in the additional instructions.\n - Do not list usign words like next, finally, just list sumamries in bullet points, concisely.\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 activities performed in a care flow for different stakeholders in a healthcare setting.
8
+ A care flow consists of tracks, steps, and actions that can be performed by a patient, a clinician, or the system itself. These actions may include patient tasks (e.g., form submissions), clinician interventions (e.g., messages sent), or system-triggered activities (e.g., API calls).
9
+
10
+ Your job is to provide a clear, human-readable summary of these activities in chronological order, ensuring the summary is tailored for the specific stakeholder. Focus on activity names and descriptions, avoiding any mention of IDs or technical details.
11
+
12
+ Instructions for summarizing:
13
+ - Summarize the care flow activities in the order they were performed, maintaining the chronological sequence.
14
+ - Ensure the summary is concise, clear, and relevant to the stakeholder's needs.
15
+ - Focus on activity names, titles, and the nature of the actions (e.g., patient submitted a form, clinician responded to a message).
16
+ - Do not include any IDs, internal codes, or technical jargon—only human-readable information.
17
+ - Tailor the summary to the specific stakeholder, emphasizing the information most relevant to their role.
18
+ - Avoid making assumptions about actions not explicitly mentioned in the input.
19
+ - Provide the summary as a set of bullet points unless otherwise specified in the instructions. Make it as concise as possible.
20
+
21
+ Format:
22
+ - Provide the summary as a set of bullet points unless otherwise specified in the instructions. Make it as concise as possible.
23
+ - Format it as an easy-to-grasp timeline with all important values and information.
24
+ - Always mention track, step, and action names if applicable unless otherwise specified in the additional instructions.
25
+ - Never format it in markdown with bold, italic, etc., unless otherwise specified in the additional instructions.
26
+ - Do not list usign words like next, finally, just list sumamries in bullet points, concisely.
27
+
28
+ Additional Instructions:
29
+ {additionalInstructions}
30
+
31
+ Stakeholder:
32
+ {stakeholder}
33
+
34
+ Content to summarize:
35
+ {input}
36
+ `);
37
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/constants.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE5D,gDAAgD;AACnC,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BzD,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export { summarizeCareFlowWithLLM } from './summarizeCareFlowWithLLM';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.summarizeCareFlowWithLLM = void 0;
4
+ var summarizeCareFlowWithLLM_1 = require("./summarizeCareFlowWithLLM");
5
+ Object.defineProperty(exports, "summarizeCareFlowWithLLM", { enumerable: true, get: function () { return summarizeCareFlowWithLLM_1.summarizeCareFlowWithLLM; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/index.ts"],"names":[],"mappings":";;;AAAA,uEAAqE;AAA5D,oIAAA,wBAAwB,OAAA"}
@@ -0,0 +1,7 @@
1
+ import { type ChatOpenAI } from '@langchain/openai';
2
+ export declare const summarizeCareFlowWithLLM: ({ ChatModelGPT4o, careFlowActivities, stakeholder, additionalInstructions, }: {
3
+ ChatModelGPT4o: ChatOpenAI;
4
+ careFlowActivities: 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.summarizeCareFlowWithLLM = void 0;
4
+ const constants_1 = require("./constants");
5
+ // TODO: remove console logs eventually
6
+ const summarizeCareFlowWithLLM = async ({ ChatModelGPT4o, careFlowActivities, stakeholder, additionalInstructions, }) => {
7
+ const prompt = await constants_1.systemPrompt.format({
8
+ stakeholder,
9
+ additionalInstructions,
10
+ input: careFlowActivities,
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.summarizeCareFlowWithLLM = summarizeCareFlowWithLLM;
22
+ //# sourceMappingURL=summarizeCareFlowWithLLM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeCareFlowWithLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAG1C,uCAAuC;AAChC,MAAM,wBAAwB,GAAG,KAAK,EAAE,EAC7C,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,sBAAsB,GAMvB,EAAmB,EAAE;IACpB,MAAM,MAAM,GAAG,MAAM,wBAAY,CAAC,MAAM,CAAC;QACvC,WAAW;QACX,sBAAsB;QACtB,KAAK,EAAE,kBAAkB;KAC1B,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,wBAAwB,4BAyBpC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("dotenv/config");
4
+ const summarizeCareFlowWithLLM_1 = require("./summarizeCareFlowWithLLM");
5
+ const messages_1 = require("@langchain/core/messages");
6
+ const pathwayActivitiesResponse_1 = require("../../__mocks__/pathwayActivitiesResponse");
7
+ // Describe the test suite
8
+ describe('summarizeCareFlowWithLLM', () => {
9
+ let ChatModelGPT4oMock;
10
+ beforeEach(() => {
11
+ // Define the 'invoke' method in the mock
12
+ ChatModelGPT4oMock = {
13
+ invoke: jest.fn(),
14
+ };
15
+ });
16
+ it('should return a mocked summary for the care flow activities', async () => {
17
+ const mockedSummary = 'On September 11, 2024, a form was completed, followed by a step completion in the care flow. The clinician reviewed and performed several actions to proceed.';
18
+ // Mock the 'invoke' method to return an AIMessage
19
+ ChatModelGPT4oMock.invoke.mockResolvedValueOnce(new messages_1.AIMessageChunk(mockedSummary));
20
+ const careFlowData = pathwayActivitiesResponse_1.mockPathwayActivitiesResponse.activities
21
+ .map((activity) => {
22
+ var _a;
23
+ const { date, status, object, context } = activity;
24
+ return `Date: ${date}\nStatus: ${status}\nType: ${object.type}\nStep ID: ${(_a = context.step_id) !== null && _a !== void 0 ? _a : 'N/A'}`;
25
+ })
26
+ .join('\n\n');
27
+ const stakeholder = 'Clinician';
28
+ const additionalInstructions = 'Summarize the care flow activities, ensuring they are in chronological order.';
29
+ // Call the function with the mocked data
30
+ const summary = await (0, summarizeCareFlowWithLLM_1.summarizeCareFlowWithLLM)({
31
+ ChatModelGPT4o: ChatModelGPT4oMock,
32
+ careFlowActivities: careFlowData,
33
+ stakeholder,
34
+ additionalInstructions,
35
+ });
36
+ console.log('Summary', summary);
37
+ // Check that the returned summary is as expected
38
+ expect(summary).toBe(mockedSummary);
39
+ expect(ChatModelGPT4oMock.invoke).toHaveBeenCalledTimes(1);
40
+ });
41
+ });
42
+ //# sourceMappingURL=summarizeCareFlowWithLLM.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeCareFlowWithLLM.test.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.test.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,yEAAqE;AAErE,uDAAyD;AACzD,yFAAyF;AAEzF,0BAA0B;AAC1B,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAI,kBAA2C,CAAA;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,yCAAyC;QACzC,kBAAkB,GAAG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("../../lib");
6
6
  const config_1 = require("./config");
7
+ const constants_1 = require("../../lib/constants");
8
+ const summarizeCareFlowWithLLM_1 = require("./lib/summarizeCareFlowWithLLM");
7
9
  exports.summarizeCareFlow = {
8
10
  key: 'summarizeCareFlow',
9
11
  category: extensions_core_1.Category.WORKFLOW,
@@ -13,13 +15,13 @@ exports.summarizeCareFlow = {
13
15
  previewable: false,
14
16
  dataPoints: config_1.dataPoints,
15
17
  onEvent: async ({ payload, onComplete, onError, helpers }) => {
16
- const { pathway } = await (0, lib_1.validatePayloadAndCreateSdk)({
18
+ const { ChatModelGPT4o, fields: { additionalInstructions, stakeholder }, pathway, } = await (0, lib_1.validatePayloadAndCreateSdk)({
17
19
  fieldsSchema: config_1.FieldsValidationSchema,
18
20
  payload,
19
21
  });
20
22
  const awellSdk = await helpers.awellSdk();
21
23
  /**
22
- * Limitation: this query is paginated so we might not get all pathway activities
24
+ * Limitation: this query is paginated so we might not get all pathway activities - which is ok for now
23
25
  */
24
26
  const pathwayActivitesUntilNow = await awellSdk.orchestration.query({
25
27
  pathwayActivities: {
@@ -54,14 +56,25 @@ exports.summarizeCareFlow = {
54
56
  },
55
57
  },
56
58
  });
57
- console.log(JSON.stringify(pathwayActivitesUntilNow.pathwayActivities.activities, null, 2));
58
- // Call OpenAI
59
- // const res = await langChainOpenAiSdk.invoke()
60
- await onComplete({
61
- data_points: {
62
- summary: 'Hello world',
63
- },
64
- });
59
+ try {
60
+ const summary = await (0, summarizeCareFlowWithLLM_1.summarizeCareFlowWithLLM)({
61
+ ChatModelGPT4o,
62
+ careFlowActivities: JSON.stringify(pathwayActivitesUntilNow.pathwayActivities.activities, null, 2),
63
+ stakeholder,
64
+ additionalInstructions,
65
+ });
66
+ const finalSummary = `${constants_1.DISCLAIMER_MSG}\n\n${summary}`;
67
+ console.log(finalSummary);
68
+ await onComplete({
69
+ data_points: {
70
+ summary: finalSummary,
71
+ },
72
+ });
73
+ }
74
+ catch (error) {
75
+ console.error('Error summarizing care flow:', error);
76
+ throw new Error('Error summarizing care flow');
77
+ }
65
78
  },
66
79
  };
67
80
  //# sourceMappingURL=summarizeCareFlow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"summarizeCareFlow.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,mCAAuD;AAEvD,qCAAqE;AAExD,QAAA,iBAAiB,GAI1B;IACF,GAAG,EAAE,mBAAmB;IACxB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE,sCAAsC;IACnD,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,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,iCAA2B,EAAC;YACpD,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;QAEzC;;WAEG;QACH,MAAM,wBAAwB,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;YAClE,iBAAiB,EAAE;gBACjB,MAAM,EAAE;oBACN,UAAU,EAAE,OAAO,CAAC,EAAE;oBACtB,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;oBACrC,OAAO,EAAE;wBACP,SAAS,EAAE,MAAM;wBACjB,KAAK,EAAE,MAAM;qBACd;iBACF;gBACD,UAAU,EAAE;oBACV,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE;wBACP,QAAQ,EAAE,IAAI;qBACf;oBACD,MAAM,EAAE;wBACN,QAAQ,EAAE,IAAI;qBACf;oBACD,eAAe,EAAE;wBACf,QAAQ,EAAE,IAAI;qBACf;oBACD,OAAO,EAAE;wBACP,QAAQ,EAAE,IAAI;qBACf;oBACD,KAAK,EAAE;wBACL,QAAQ,EAAE,IAAI;qBACf;oBACD,cAAc,EAAE;wBACd,QAAQ,EAAE,IAAI;qBACf;iBACF;aACF;SACF,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CACZ,wBAAwB,CAAC,iBAAiB,CAAC,UAAU,EACrD,IAAI,EACJ,CAAC,CACF,CACF,CAAA;QAED,cAAc;QACd,gDAAgD;QAEhD,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,OAAO,EAAE,aAAa;aACvB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"summarizeCareFlow.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,mCAAuD;AAEvD,qCAAqE;AACrE,mDAAoD;AACpD,6EAAyE;AAC5D,QAAA,iBAAiB,GAI1B;IACF,GAAG,EAAE,mBAAmB;IACxB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE,sCAAsC;IACnD,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,cAAc,EACd,MAAM,EAAE,EAAE,sBAAsB,EAAE,WAAW,EAAE,EAC/C,OAAO,GACR,GAAG,MAAM,IAAA,iCAA2B,EAAC;YACpC,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;QAEzC;;WAEG;Q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A;SAC/C;IACH,CAAC;CACF,CAAA"}
@@ -4,45 +4,76 @@ const extensions_core_1 = require("@awell-health/extensions-core");
4
4
  const tests_1 = require("@/tests");
5
5
  const _1 = require(".");
6
6
  const pathwayActivitiesResponse_1 = require("./__mocks__/pathwayActivitiesResponse");
7
- describe('Shelly - Summarize care flow', () => {
8
- const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.summarizeCareFlow);
9
- const awellSdkMock = {
10
- orchestration: {
11
- mutation: jest.fn().mockResolvedValue({}),
12
- query: jest.fn().mockResolvedValue({
13
- pathwayActivities: pathwayActivitiesResponse_1.mockPathwayActivitiesResponse,
14
- }),
15
- },
7
+ const constants_1 = require("../../lib/constants");
8
+ // Mock the '@langchain/openai' module
9
+ jest.mock('@langchain/openai', () => {
10
+ // Mock the 'invoke' method to return a resolved value
11
+ const mockInvoke = jest.fn().mockResolvedValue({
12
+ content: 'Mocked care flow summary from LLM',
13
+ });
14
+ // Mock the ChatOpenAI class
15
+ const mockChatOpenAI = jest.fn().mockImplementation(() => ({
16
+ invoke: mockInvoke,
17
+ }));
18
+ return {
19
+ ChatOpenAI: mockChatOpenAI,
16
20
  };
17
- helpers.awellSdk = jest.fn().mockResolvedValue(awellSdkMock);
21
+ });
22
+ // Import ChatOpenAI after mocking
23
+ const openai_1 = require("@langchain/openai");
24
+ describe('summarizeCareFlow - Mocked LLM calls', () => {
25
+ const { onComplete, onError, helpers, extensionAction, clearMocks } = extensions_core_1.TestHelpers.fromAction(_1.summarizeCareFlow);
18
26
  beforeEach(() => {
19
27
  clearMocks();
28
+ jest.clearAllMocks();
20
29
  });
21
- test('Should work', async () => {
30
+ it('Should summarize care flow with LLM', async () => {
31
+ // Spy on the 'summarizeCareFlowWithLLM' function
32
+ const summarizeCareFlowWithLLMSpy = jest.spyOn(require('./lib/summarizeCareFlowWithLLM'), 'summarizeCareFlowWithLLM');
33
+ // Create the test payload
34
+ const payload = (0, tests_1.generateTestPayload)({
35
+ pathway: {
36
+ id: 'ai4rZaYEocjB',
37
+ definition_id: 'whatever',
38
+ },
39
+ fields: {
40
+ stakeholder: 'Clinician',
41
+ additionalInstructions: 'Summarize key activities.',
42
+ },
43
+ settings: {
44
+ openAiApiKey: 'a',
45
+ },
46
+ });
47
+ // Mock the Awell SDK
48
+ const awellSdkMock = {
49
+ orchestration: {
50
+ query: jest.fn().mockResolvedValue({
51
+ pathwayActivities: pathwayActivitiesResponse_1.mockPathwayActivitiesResponse,
52
+ }),
53
+ },
54
+ };
55
+ helpers.awellSdk = jest.fn().mockResolvedValue(awellSdkMock);
56
+ // Execute the action
22
57
  await extensionAction.onEvent({
23
- payload: (0, tests_1.generateTestPayload)({
24
- pathway: {
25
- id: 'whatever',
26
- },
27
- fields: {
28
- prompt: '',
29
- },
30
- settings: {
31
- openAiApiKey: 'a',
32
- },
33
- }),
58
+ payload,
34
59
  onComplete,
35
60
  onError,
36
61
  helpers,
37
62
  });
38
- expect(helpers.awellSdk).toHaveBeenCalledTimes(1);
39
- expect(awellSdkMock.orchestration.query).toHaveBeenCalledTimes(1);
40
- expect(onError).not.toHaveBeenCalled();
63
+ // Assertions
64
+ expect(openai_1.ChatOpenAI).toHaveBeenCalled();
65
+ expect(summarizeCareFlowWithLLMSpy).toHaveBeenCalledWith({
66
+ ChatModelGPT4o: expect.any(Object),
67
+ careFlowActivities: expect.any(String),
68
+ stakeholder: 'Clinician',
69
+ additionalInstructions: 'Summarize key activities.',
70
+ });
41
71
  expect(onComplete).toHaveBeenCalledWith({
42
72
  data_points: {
43
- summary: 'Hello world',
73
+ summary: `${constants_1.DISCLAIMER_MSG}\n\n${'Mocked care flow summary from LLM'}`,
44
74
  },
45
75
  });
76
+ expect(onError).not.toHaveBeenCalled();
46
77
  });
47
78
  });
48
79
  //# sourceMappingURL=summarizeCareFlow.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"summarizeCareFlow.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeCareF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G,CAAC,gBAAgB,EAAE,CAAA;QACtC,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,OAAO,EAAE,aAAa;aACvB;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"summarizeCareFlow.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.ts"],"names":[],"mappings":";;AAAA,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAqC;AACrC,qFAAqF;AACrF,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,mCAAmC;KAC7C,CAAC,CAAA;IAEF,4BAA4B;IAC5B,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QACzD,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC,CAAA;IAEH,OAAO;QACL,UAAU,EAAE,cAAc;KAC3B,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,kCAAkC;AAClC,8CAA8C;AAE9C,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,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,iDAAiD;QACjD,MAAM,2BAA2B,GAAG,IAAI,C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gB,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -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
@@ -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
- prompt: {
4
+ additionalInstructions: {
5
5
  id: string;
6
6
  label: string;
7
7
  description: string;
8
- type: FieldType.TEXT;
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
- prompt: z.ZodOptional<z.ZodString>;
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
- prompt?: string | undefined;
23
+ additionalInstructions: string;
24
+ stakeholder: string;
16
25
  }, {
17
- prompt?: string | undefined;
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
- prompt: {
11
- id: 'prompt',
12
- label: 'Prompt',
13
- description: 'Leave blank to use the default prompt',
14
- type: extensions_core_1.FieldType.TEXT,
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
- prompt: zod_1.default.string().optional(),
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,MAAM,EAAE;QACN,EAAE,EAAE,QAAQ;QACZ,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,uCAAuC;QACpD,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,KAAK;KAChB;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACoB,CAAC,CAAA"}
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
- return `Question label: ${questionDefinition.title}\nQuestion type: ${questionDefinition.userQuestionType}\n${answer}`;
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':
@@ -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,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,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AAc,CAAC,SAAS,CAAC,IAAI,CAC3D,CAAC,CAAC,EAAE,EAAE,CAAC,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"}
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,gB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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
@@ -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>;