@awell-health/awell-extensions 2.0.38 → 2.0.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. package/dist/extensions/markdown.json +1 -1
  2. package/dist/extensions/shelly/actions/generateMessage/generateMessage.js +3 -1
  3. package/dist/extensions/shelly/actions/generateMessage/generateMessage.js.map +1 -1
  4. package/dist/extensions/shelly/actions/generateMessage/generateMessage.test.js +2 -2
  5. package/dist/extensions/shelly/actions/generateMessage/generateMessage.test.js.map +1 -1
  6. package/dist/extensions/shelly/actions/generateMessage/generateMessageRealOpenAI.test.js +1 -1
  7. package/dist/extensions/shelly/actions/generateMessage/generateMessageRealOpenAI.test.js.map +1 -1
  8. package/dist/extensions/shelly/actions/index.d.ts +26 -2
  9. package/dist/extensions/shelly/actions/index.js +2 -0
  10. package/dist/extensions/shelly/actions/index.js.map +1 -1
  11. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.js +0 -2
  12. package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.js.map +1 -1
  13. package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.test.js +1 -1
  14. package/dist/extensions/shelly/actions/summarizeForm/config/fields.d.ts +12 -8
  15. package/dist/extensions/shelly/actions/summarizeForm/config/fields.js +23 -17
  16. package/dist/extensions/shelly/actions/summarizeForm/config/fields.js.map +1 -1
  17. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js +9 -11
  18. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js.map +1 -1
  19. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js +12 -17
  20. package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.test.js.map +1 -1
  21. package/dist/extensions/shelly/actions/summarizeForm/summarizeFormRealOpenAI.test.js +71 -22
  22. package/dist/extensions/shelly/actions/summarizeForm/summarizeFormRealOpenAI.test.js.map +1 -1
  23. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/datapoints.d.ts +6 -0
  24. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/datapoints.js +10 -0
  25. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/datapoints.js.map +1 -0
  26. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/fields.d.ts +32 -0
  27. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/fields.js +42 -0
  28. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/fields.js.map +1 -0
  29. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/index.d.ts +2 -0
  30. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/index.js +9 -0
  31. package/dist/extensions/shelly/actions/summarizeFormsInStep/config/index.js.map +1 -0
  32. package/dist/extensions/shelly/actions/summarizeFormsInStep/index.d.ts +1 -0
  33. package/dist/extensions/shelly/actions/summarizeFormsInStep/index.js +6 -0
  34. package/dist/extensions/shelly/actions/summarizeFormsInStep/index.js.map +1 -0
  35. package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.d.ts +4 -0
  36. package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.js +59 -0
  37. package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.js.map +1 -0
  38. package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.test.d.ts +1 -0
  39. package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.test.js +95 -0
  40. package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.test.js.map +1 -0
  41. package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStepRealOpenAI.test.js +128 -0
  42. package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStepRealOpenAI.test.js.map +1 -0
  43. package/dist/extensions/shelly/lib/constants.d.ts +2 -1
  44. package/dist/extensions/shelly/lib/constants.js +3 -2
  45. package/dist/extensions/shelly/lib/constants.js.map +1 -1
  46. package/dist/extensions/shelly/{actions/summarizeForm/lib/getResponseText/getResponseText.d.ts → lib/getFormResponseText/getFormResponseText.d.ts} +12 -1
  47. package/dist/extensions/shelly/{actions/summarizeForm/lib/getResponseText/getResponseText.js → lib/getFormResponseText/getFormResponseText.js} +28 -4
  48. package/dist/extensions/shelly/lib/getFormResponseText/getFormResponseText.js.map +1 -0
  49. package/dist/extensions/shelly/lib/getFormResponseText/index.d.ts +1 -0
  50. package/dist/extensions/shelly/lib/getFormResponseText/index.js +7 -0
  51. package/dist/extensions/shelly/lib/getFormResponseText/index.js.map +1 -0
  52. package/dist/extensions/shelly/lib/summarizeFormWithLLM/constants.d.ts +3 -0
  53. package/dist/extensions/shelly/lib/summarizeFormWithLLM/constants.js +110 -0
  54. package/dist/extensions/shelly/lib/summarizeFormWithLLM/constants.js.map +1 -0
  55. package/dist/extensions/shelly/lib/summarizeFormWithLLM/index.js.map +1 -0
  56. package/dist/extensions/shelly/{actions/summarizeForm/lib → lib}/summarizeFormWithLLM/summarizeFormWithLLM.d.ts +3 -3
  57. package/dist/extensions/shelly/{actions/summarizeForm/lib → lib}/summarizeFormWithLLM/summarizeFormWithLLM.js +7 -7
  58. package/dist/extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.js.map +1 -0
  59. package/dist/extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.d.ts +1 -0
  60. package/dist/extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.js +93 -0
  61. package/dist/extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.js.map +1 -0
  62. package/package.json +1 -1
  63. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/getResponseText.js.map +0 -1
  64. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/index.d.ts +0 -1
  65. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/index.js +0 -6
  66. package/dist/extensions/shelly/actions/summarizeForm/lib/getResponseText/index.js.map +0 -1
  67. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.d.ts +0 -2
  68. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.js +0 -43
  69. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/constants.js.map +0 -1
  70. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.js.map +0 -1
  71. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.js.map +0 -1
  72. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.js +0 -54
  73. package/dist/extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.js.map +0 -1
  74. /package/dist/extensions/shelly/actions/{summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.d.ts → summarizeFormsInStep/summarizeFormsInStepRealOpenAI.test.d.ts} +0 -0
  75. /package/dist/extensions/shelly/{actions/summarizeForm/lib → lib}/summarizeFormWithLLM/index.d.ts +0 -0
  76. /package/dist/extensions/shelly/{actions/summarizeForm/lib → lib}/summarizeFormWithLLM/index.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeFormsInStepRealOpenAI.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStepRealOpenAI.test.ts"],"names":[],"mappings":";AAAA,uDAAuD;;AAEvD,yBAAsB;AACtB,mEAA2D;AAC3D,mCAA6C;AAC7C,wBAAwC;AACxC,+GAA+G;AAC/G,iGAAwI;AACxI,+FAAmI;AACnI,mDAAyD;AAGzD,QAAQ,CAAC,IAAI,CAAC,0CAA0C,EAAE,GAAG,EAAE;IAC7D,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,GACjE,6BAAW,CAAC,UAAU,CAAC,uBAAoB,CAAC,CAAA;IAE9C,UAAU,CAAC,GAAG,EAAE;Q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;AAC1D,CAAC,CAAC,CAAA"}
@@ -1,2 +1,3 @@
1
1
  export declare const OPENAI_BASE_URL = "https://api.openai.com/v1/chat/completion";
2
- export declare const DISCLAIMER_MSG = "Important Notice: The content provided is an AI-generated summary";
2
+ export declare const DISCLAIMER_MSG = "Important Notice: The content provided is an AI-generated summary.";
3
+ export declare const DISCLAIMER_MSG_FORM = "Important Notice: The content provided is an AI-generated summary of the form responses.";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DISCLAIMER_MSG = exports.OPENAI_BASE_URL = void 0;
3
+ exports.DISCLAIMER_MSG_FORM = exports.DISCLAIMER_MSG = exports.OPENAI_BASE_URL = void 0;
4
4
  exports.OPENAI_BASE_URL = 'https://api.openai.com/v1/chat/completion';
5
- exports.DISCLAIMER_MSG = 'Important Notice: The content provided is an AI-generated summary';
5
+ exports.DISCLAIMER_MSG = 'Important Notice: The content provided is an AI-generated summary.';
6
+ exports.DISCLAIMER_MSG_FORM = 'Important Notice: The content provided is an AI-generated summary of the form responses.';
6
7
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../extensions/shelly/lib/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,2CAA2C,CAAA;AAE7D,QAAA,cAAc,GACzB,mEAAmE,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../extensions/shelly/lib/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,2CAA2C,CAAA;AAE7D,QAAA,cAAc,GACzB,oEAAoE,CAAA;AAEzD,QAAA,mBAAmB,GAC9B,0FAA0F,CAAA"}
@@ -6,10 +6,21 @@ export interface OmittedFormAnswer {
6
6
  export declare const getFormTitle: (opts: {
7
7
  formDefinition: Form;
8
8
  }) => string;
9
- export declare const getResponseText: (opts: {
9
+ export declare const getFormResponseText: (opts: {
10
10
  formDefinition: Form;
11
11
  formResponse: FormResponse;
12
12
  }) => {
13
13
  result: string;
14
14
  omittedFormAnswers: OmittedFormAnswer[];
15
15
  };
16
+ export declare const getResponsesForAllForms: (opts: {
17
+ formsData: Array<{
18
+ formActivityId: string;
19
+ formId: string;
20
+ formDefinition: Form;
21
+ formResponse: FormResponse;
22
+ }>;
23
+ }) => {
24
+ result: string;
25
+ omittedFormAnswers: OmittedFormAnswer[];
26
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getResponseText = exports.getFormTitle = void 0;
3
+ exports.getResponsesForAllForms = exports.getFormResponseText = exports.getFormTitle = void 0;
4
4
  const getBooleanAnswer = (answer) => {
5
5
  if (answer === '0')
6
6
  return 'Answer: No';
@@ -68,7 +68,7 @@ const getFormTitle = (opts) => {
68
68
  return opts.formDefinition.title;
69
69
  };
70
70
  exports.getFormTitle = getFormTitle;
71
- const getResponseText = (opts) => {
71
+ const getFormResponseText = (opts) => {
72
72
  const formAnswers = [];
73
73
  const omittedFormAnswers = [];
74
74
  opts.formResponse.answers.forEach((questionResponse) => {
@@ -98,5 +98,29 @@ const getResponseText = (opts) => {
98
98
  omittedFormAnswers,
99
99
  };
100
100
  };
101
- exports.getResponseText = getResponseText;
102
- //# sourceMappingURL=getResponseText.js.map
101
+ exports.getFormResponseText = getFormResponseText;
102
+ const getResponsesForAllForms = (opts) => {
103
+ console.log('hereeee');
104
+ console.log(opts.formsData);
105
+ const allFormResponses = opts.formsData.map((formData) => {
106
+ const formResponseText = (0, exports.getFormResponseText)({
107
+ formDefinition: formData.formDefinition,
108
+ formResponse: formData.formResponse,
109
+ });
110
+ return {
111
+ formActivityId: formData.formActivityId,
112
+ formId: formData.formId,
113
+ ...formResponseText
114
+ };
115
+ });
116
+ const concatenatedResponses = allFormResponses
117
+ .map((response) => `Form Activity ID: ${response.formActivityId}\nForm ID: ${response.formId}\n${response.result}`)
118
+ .join('\n\n==========Next Form==========\n\n');
119
+ const allOmittedAnswers = allFormResponses.flatMap((response) => response.omittedFormAnswers);
120
+ return {
121
+ result: concatenatedResponses,
122
+ omittedFormAnswers: allOmittedAnswers,
123
+ };
124
+ };
125
+ exports.getResponsesForAllForms = getResponsesForAllForms;
126
+ //# sourceMappingURL=getFormResponseText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFormResponseText.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/getFormResponseText/getFormResponseText.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,EA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G,CAAC,IAOvC,EAGC,EAAE;IACF,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACtB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC3B,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACvD,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC;YAC3C,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,YAAY,EAAE,QAAQ,CAAC,YAAY;SACpC,CAAC,CAAC;QACH,OAAO;YACL,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,GAAG,gBAAgB;SACpB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,qBAAqB,GAAG,gBAAgB;SAC3C,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,qBAAqB,QAAQ,CAAC,cAAc,cAAc,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;SAClH,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAEjD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,OAAO,CAChD,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAC1C,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,qBAAqB;QAC7B,kBAAkB,EAAE,iBAAiB;KACtC,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,uBAAuB,2BAqClC"}
@@ -0,0 +1 @@
1
+ export { getFormResponseText, getResponsesForAllForms } from './getFormResponseText';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getResponsesForAllForms = exports.getFormResponseText = void 0;
4
+ var getFormResponseText_1 = require("./getFormResponseText");
5
+ Object.defineProperty(exports, "getFormResponseText", { enumerable: true, get: function () { return getFormResponseText_1.getFormResponseText; } });
6
+ Object.defineProperty(exports, "getResponsesForAllForms", { enumerable: true, get: function () { return getFormResponseText_1.getResponsesForAllForms; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/getFormResponseText/index.ts"],"names":[],"mappings":";;;AAAA,6DAAoF;AAA3E,0HAAA,mBAAmB,OAAA;AAAE,8HAAA,uBAAuB,OAAA"}
@@ -0,0 +1,3 @@
1
+ import { ChatPromptTemplate } from '@langchain/core/prompts';
2
+ export declare const systemPromptBulletPoints: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an assistant tasked with summarizing forms completed by patients. Each form contains a title, questions, answers, possibly answer labels and answer options. Your objective is to create a concise summary of the patient's responses, tailored for a team of clinicians involved in patient care. The summary must cover all patient questions and provide an easy-to-review overview.\n\n Please follow these step-by-step instructions:\n\n 1. **Begin the summary with the form title if available.**\n - Use title as is without alteration. Format is as title. \n - Then add an empty line for separation. \n\n - *For example:*\n - **General Health Questionnaire**\n - *Empty Line*\n \n 2. **Identify all questions and their corresponding answers.**\n\n 3. **Structure the summary using bullet points in clear and correct Markdown format:**\n\n - Use the format: `- **Question** - Answer`\n - **Ensure the answer is informative:**\n - For multiple-choice questions where the raw answer may be a code (e.g., 0, 1) that lacks meaning on its own, use the associated **answer label** instead.\n - For other questions, use the raw answer if it is clear and informative.\n\n 4. **Enhance conciseness and readability:**\n\n - **Shorten lengthy questions and answers to their essential meaning for easier inspection, while preserving all essential context.**\n - *For example:*\n - **Before**: \"Can you describe the nature of your back pain?\"\n - **After**: \"Nature of back pain\"\n - **Before**: \"Please list any medications you are currently taking, including dosages and frequency.\"\n - **After**: \"Current medications (dosage and frequency)\"\n - **Before**: \"Have you experienced any side effects from your current treatment in the last 3 months?\"\n - **After**: \"Side effects from current treatment in the last 3 months\"\n - **Avoid omitting any key information** that might alter the meaning. It is critical to preserve all time frames (e.g., \"last week,\" \"yesterday\") and specific details (e.g., \"right leg,\" \"morning\").\n\n 5. **If there are multiple forms provided, add a new line and proceed with the next form.**\n\n **Important Notes:**\n\n - Absolutely refrain from making any suggestions, interpretations, or provide additional comments.\n\n **Style and Format Guidelines:**\n\n - Use **professional and informative language**, avoiding colloquialisms and overly technical terms.\n - Ensure the summary is **clear**, **concise**, and **easy to read**.\n\n **Language Preference:**\n\n - Summarize in the language provided below. If Default, use the language of the form.\n\n **Specified Language:**\n\n {language}\n\n ---\n\n **Content to Summarize:**\n\n {input}\n">, any>;
3
+ export declare const systemPromptTextParagraph: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an assistant tasked with summarizing forms completed by patients. Each form contains a title, questions, answers, answer labels, and possible answer options. Your objective is to create a concise summary of the patient's responses, tailored for a team of clinicians involved in patient care. The summary must provide an easy-to-review overview.\n\nPlease follow these step-by-step instructions:\n\n1. **Begin the summary with the form title if available.**\n- Use title as is without alteration. Format is as title. \n- Then add an empty line for separation. \n\n - *For example:*\n - **General Health Questionnaire**\n - *Empty Line*\n\n2. **Identify all questions and their corresponding answers.**\n\n3. **Compose the summary as an informative, easy-to-read paragraph:**\n\n - Cover all important aspects of the patient's responses.\n - Ensure the summary is **concise** and **to the point** while preserving all essential information.\n - **Write everything in one paragraph**, maintaining a logical flow of information.\n - For multiple-choice questions where the raw answer may be a code (e.g., 0, 1) that lacks meaning on its own, use the associated **answer label** instead. \n\n\n**Important Notes:**\n\n- Do not make any conclusions, suggestions, interpretations, or provide additional comments. Only summarize the information provided in the form.\n\n**Style and Format Guidelines:**\n\n- Use **professional and informative language**, avoiding colloquialisms and overly technical terms.\n- Ensure the summary is **clear**, **concise**, and **easy to read**.\n\n**Language Preference:**\n\n- Summarize in the language provided below. If Default, use the language of the form.\n\n**Specified Language:**\n\n{language}\n\n---\n\n**Content to Summarize:**\n\n{input}\n">, any>;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.systemPromptTextParagraph = exports.systemPromptBulletPoints = void 0;
4
+ const prompts_1 = require("@langchain/core/prompts");
5
+ exports.systemPromptBulletPoints = prompts_1.ChatPromptTemplate.fromTemplate(`
6
+ You are an assistant tasked with summarizing forms completed by patients. Each form contains a title, questions, answers, possibly answer labels and answer options. Your objective is to create a concise summary of the patient's responses, tailored for a team of clinicians involved in patient care. The summary must cover all patient questions and provide an easy-to-review overview.
7
+
8
+ Please follow these step-by-step instructions:
9
+
10
+ 1. **Begin the summary with the form title if available.**
11
+ - Use title as is without alteration. Format is as title.
12
+ - Then add an empty line for separation.
13
+
14
+ - *For example:*
15
+ - **General Health Questionnaire**
16
+ - *Empty Line*
17
+
18
+ 2. **Identify all questions and their corresponding answers.**
19
+
20
+ 3. **Structure the summary using bullet points in clear and correct Markdown format:**
21
+
22
+ - Use the format: \`- **Question** - Answer\`
23
+ - **Ensure the answer is informative:**
24
+ - For multiple-choice questions where the raw answer may be a code (e.g., 0, 1) that lacks meaning on its own, use the associated **answer label** instead.
25
+ - For other questions, use the raw answer if it is clear and informative.
26
+
27
+ 4. **Enhance conciseness and readability:**
28
+
29
+ - **Shorten lengthy questions and answers to their essential meaning for easier inspection, while preserving all essential context.**
30
+ - *For example:*
31
+ - **Before**: "Can you describe the nature of your back pain?"
32
+ - **After**: "Nature of back pain"
33
+ - **Before**: "Please list any medications you are currently taking, including dosages and frequency."
34
+ - **After**: "Current medications (dosage and frequency)"
35
+ - **Before**: "Have you experienced any side effects from your current treatment in the last 3 months?"
36
+ - **After**: "Side effects from current treatment in the last 3 months"
37
+ - **Avoid omitting any key information** that might alter the meaning. It is critical to preserve all time frames (e.g., "last week," "yesterday") and specific details (e.g., "right leg," "morning").
38
+
39
+ 5. **If there are multiple forms provided, add a new line and proceed with the next form.**
40
+
41
+ **Important Notes:**
42
+
43
+ - Absolutely refrain from making any suggestions, interpretations, or provide additional comments.
44
+
45
+ **Style and Format Guidelines:**
46
+
47
+ - Use **professional and informative language**, avoiding colloquialisms and overly technical terms.
48
+ - Ensure the summary is **clear**, **concise**, and **easy to read**.
49
+
50
+ **Language Preference:**
51
+
52
+ - Summarize in the language provided below. If Default, use the language of the form.
53
+
54
+ **Specified Language:**
55
+
56
+ {language}
57
+
58
+ ---
59
+
60
+ **Content to Summarize:**
61
+
62
+ {input}
63
+ `);
64
+ exports.systemPromptTextParagraph = prompts_1.ChatPromptTemplate.fromTemplate(`
65
+ You are an assistant tasked with summarizing forms completed by patients. Each form contains a title, questions, answers, answer labels, and possible answer options. Your objective is to create a concise summary of the patient's responses, tailored for a team of clinicians involved in patient care. The summary must provide an easy-to-review overview.
66
+
67
+ Please follow these step-by-step instructions:
68
+
69
+ 1. **Begin the summary with the form title if available.**
70
+ - Use title as is without alteration. Format is as title.
71
+ - Then add an empty line for separation.
72
+
73
+ - *For example:*
74
+ - **General Health Questionnaire**
75
+ - *Empty Line*
76
+
77
+ 2. **Identify all questions and their corresponding answers.**
78
+
79
+ 3. **Compose the summary as an informative, easy-to-read paragraph:**
80
+
81
+ - Cover all important aspects of the patient's responses.
82
+ - Ensure the summary is **concise** and **to the point** while preserving all essential information.
83
+ - **Write everything in one paragraph**, maintaining a logical flow of information.
84
+ - For multiple-choice questions where the raw answer may be a code (e.g., 0, 1) that lacks meaning on its own, use the associated **answer label** instead.
85
+
86
+
87
+ **Important Notes:**
88
+
89
+ - Do not make any conclusions, suggestions, interpretations, or provide additional comments. Only summarize the information provided in the form.
90
+
91
+ **Style and Format Guidelines:**
92
+
93
+ - Use **professional and informative language**, avoiding colloquialisms and overly technical terms.
94
+ - Ensure the summary is **clear**, **concise**, and **easy to read**.
95
+
96
+ **Language Preference:**
97
+
98
+ - Summarize in the language provided below. If Default, use the language of the form.
99
+
100
+ **Specified Language:**
101
+
102
+ {language}
103
+
104
+ ---
105
+
106
+ **Content to Summarize:**
107
+
108
+ {input}
109
+ `);
110
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/summarizeFormWithLLM/constants.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,wBAAwB,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DvE,CAAC,CAAA;AAEW,QAAA,yBAAyB,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CxE,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/summarizeFormWithLLM/index.ts"],"names":[],"mappings":";;;AAAA,+DAA6D;AAApD,4HAAA,oBAAoB,OAAA"}
@@ -1,7 +1,7 @@
1
1
  import { type ChatOpenAI } from '@langchain/openai';
2
- export declare const summarizeFormWithLLM: ({ ChatModelGPT4o, formData, stakeholder, additionalInstructions, }: {
2
+ export declare const summarizeFormWithLLM: ({ ChatModelGPT4o, formData, summaryFormat, language, }: {
3
3
  ChatModelGPT4o: ChatOpenAI;
4
4
  formData: string;
5
- stakeholder: string;
6
- additionalInstructions: string;
5
+ summaryFormat: string;
6
+ language: string;
7
7
  }) => Promise<string>;
@@ -2,19 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.summarizeFormWithLLM = void 0;
4
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,
5
+ const summarizeFormWithLLM = async ({ ChatModelGPT4o, formData, summaryFormat, language, }) => {
6
+ console.log('summaryFormat', summaryFormat);
7
+ const systemPrompt = summaryFormat === 'Bullet-points' ? constants_1.systemPromptBulletPoints :
8
+ summaryFormat === 'Text paragraph' ? constants_1.systemPromptTextParagraph :
9
+ constants_1.systemPromptBulletPoints; // Default to bullet points if unknown format
10
+ const prompt = await systemPrompt.format({
11
+ language,
10
12
  input: formData,
11
13
  });
12
14
  console.log('Prompt', prompt);
13
15
  const summaryMessage = await ChatModelGPT4o.invoke(prompt);
14
- console.log('Type', typeof summaryMessage.content);
15
16
  // TODO: for some reason compiler doesn't know that content is a string
16
17
  const summary = summaryMessage.content;
17
- console.log('Type', typeof summary);
18
18
  console.log('Summary', summary);
19
19
  return summary;
20
20
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeFormWithLLM.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.ts"],"names":[],"mappings":";;;AAAA,2CAAiF;AAE1E,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACzC,cAAc,EACd,QAAQ,EACR,aAAa,EACb,QAAQ,GAMT,EAAmB,EAAE;IACpB,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,CAAA;IAC3C,MAAM,YAAY,GAAG,aAAa,KAAK,eAAe,CAAC,CAAC,CAAC,oCAAwB,CAAC,CAAC;QAC9D,aAAa,KAAK,gBAAgB,CAAC,CAAC,CAAC,qCAAyB,CAAC,CAAC;YAChE,oCAAwB,CAAC,CAAC,6CAA6C;IAC5F,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC;QACvC,QAAQ;QACR,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,uEAAuE;IACvE,MAAM,OAAO,GAAG,cAAc,CAAC,OAAiB,CAAA;IAChD,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AA1BY,QAAA,oBAAoB,wBA0BhC"}
@@ -0,0 +1,93 @@
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 with Bullet-points format', 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 summaryFormat = 'Bullet-points';
42
+ const language = 'Default';
43
+ const summary = await (0, summarizeFormWithLLM_1.summarizeFormWithLLM)({
44
+ ChatModelGPT4o: ChatModelGPT4oMock,
45
+ formData: formData,
46
+ summaryFormat,
47
+ language,
48
+ });
49
+ console.log('Summary', summary);
50
+ expect(summary).toBe(mockedSummary);
51
+ expect(ChatModelGPT4oMock.invoke).toHaveBeenCalledTimes(1);
52
+ });
53
+ it('should return a mocked summary for the General Health Questionnaire with Text paragraph format', async () => {
54
+ const mockedSummary = 'The patient has been experiencing persistent back pain for two weeks, describing it as a sharp pain in the lower back that worsens when bending or lifting. Over-the-counter painkillers have been ineffective. While there are no recent injuries, the patient started a new job requiring heavy lifting. Additionally, the patient reports occasional numbness in the right leg.';
55
+ ChatModelGPT4oMock.invoke.mockResolvedValueOnce(new messages_1.AIMessageChunk(mockedSummary));
56
+ const formName = 'General Health Questionnaire';
57
+ const form = sampleForms[formName];
58
+ const formData = form.questions
59
+ .map((question, index) => `Question: ${question}\nAnswer: ${form.answers[index]}\n`)
60
+ .join('\n');
61
+ const summaryFormat = 'Text paragraph';
62
+ const language = 'Default';
63
+ const summary = await (0, summarizeFormWithLLM_1.summarizeFormWithLLM)({
64
+ ChatModelGPT4o: ChatModelGPT4oMock,
65
+ formData: formData,
66
+ summaryFormat,
67
+ language,
68
+ });
69
+ console.log('Summary', summary);
70
+ expect(summary).toBe(mockedSummary);
71
+ expect(ChatModelGPT4oMock.invoke).toHaveBeenCalledTimes(1);
72
+ });
73
+ it('should return a mocked summary for the General Health Questionnaire with default format when not specified', async () => {
74
+ const mockedSummary = '- **Reason for visit** - Persistent back pain for two weeks\n- **Nature of back pain** - Sharp pain in lower back, worse when bending or lifting\n- **Medications/treatments** - Over-the-counter painkillers, ineffective\n- **Recent injuries/accidents** - None, but started new job with heavy lifting\n- **Other symptoms** - Occasional numbness in right leg';
75
+ ChatModelGPT4oMock.invoke.mockResolvedValueOnce(new messages_1.AIMessageChunk(mockedSummary));
76
+ const formName = 'General Health Questionnaire';
77
+ const form = sampleForms[formName];
78
+ const formData = form.questions
79
+ .map((question, index) => `Question: ${question}\nAnswer: ${form.answers[index]}\n`)
80
+ .join('\n');
81
+ const language = 'Default';
82
+ const summary = await (0, summarizeFormWithLLM_1.summarizeFormWithLLM)({
83
+ ChatModelGPT4o: ChatModelGPT4oMock,
84
+ formData: formData,
85
+ summaryFormat: 'undefined',
86
+ language,
87
+ });
88
+ console.log('Summary', summary);
89
+ expect(summary).toBe(mockedSummary);
90
+ expect(ChatModelGPT4oMock.invoke).toHaveBeenCalledTimes(1);
91
+ });
92
+ });
93
+ //# sourceMappingURL=summarizeFormWithLLM.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeFormWithLLM.test.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,iEAA6D;AAE7D,uDAAyD;AAEzD,MAAM,WAAW,GAAG;IAClB,8BAA8B,EAAE;QAC9B,SAAS,EAAE;YACT,sCAAsC;YACtC,gDAAgD;YAChD,6DAA6D;YAC7D,gDAAgD;YAChD,oDAAoD;SACrD;QACD,OAAO,EAAE;YACP,qEAAqE;YACrE,oFAAoF;YACpF,kFAAkF;YAClF,gFAAgF;YAChF,4CAA4C;SAC7C;KACF;CACF,CAAA;AAED,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,kBAA2C,CAAA;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,yCAAyC;QACzC,kBAAkB,GAAG;YACnB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;SACoB,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,+FAA+F,EAAE,KAAK,IAAI,EAAE;QAC7G,MAAM,aAAa,GACjB,0MAA0M,CAAA;QAE5M,kDAAkD;QAClD,kBAAkB,CAAC,MAAM,CAAC,qBAAqB,CAC7C,IAAI,yBAAc,CAAC,aAAa,CAAC,CAClC,CAAA;QAED,MAAM,QAAQ,GAAG,8BAA8B,CAAA;QAC/C,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ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MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;IAC5D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/awell-extensions",
3
- "version": "2.0.38",
3
+ "version": "2.0.39",
4
4
  "packageManager": "yarn@3.4.1",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": {
@@ -1 +0,0 @@
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,CAC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;AACH,CAAC,CAAA;AA5CY,QAAA,eAAe,mBA4C3B"}
@@ -1 +0,0 @@
1
- export { getResponseText } from './getResponseText';
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getResponseText = void 0;
4
- var getResponseText_1 = require("./getResponseText");
5
- Object.defineProperty(exports, "getResponseText", { enumerable: true, get: function () { return getResponseText_1.getResponseText; } });
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/getResponseText/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA"}
@@ -1,2 +0,0 @@
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 settings. \n Stakeholder can be a patient - in which case give a clear targetter summary for them. \n Stakeholder can also be clinician, doctor, nurse or anyone else on the patient's care team - in which case format your summary to help them quickly understand the context of patient's form responses.\n\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 forms might weary - from general questions, basic contact information to more medically specific ones. Form title might sometimes reveal form context.\n Your job is to provide the summary of the context you have. Take into consideration form name.\n 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.\n - Do not include anything that is not present in form (such as the assumption that the patient visited clinic).\n - Do not add titles like Summary:, just provide the summary.\n - It is apsolutely critical to return proper markdown formatting, especially for new lines and paragraphs.\n\n\n Additional Instructions:\n {additionalInstructions}\n\n Stakeholder:\n {stakeholder}\n\n Content to summarize:\n {input}\n ">, any>;
@@ -1,43 +0,0 @@
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 settings.
8
- Stakeholder can be a patient - in which case give a clear targetter summary for them.
9
- Stakeholder can also be clinician, doctor, nurse or anyone else on the patient's care team - in which case format your summary to help them quickly understand the context of patient's form responses.
10
-
11
- You will be given forms with answers, answer labels, and possible answer options if applicable, to summarize.
12
- Take into consideration that context of forms might weary - from general questions, basic contact information to more medically specific ones. Form title might sometimes reveal form context.
13
- Your job is to provide the summary of the context you have. Take into consideration form name.
14
- Do not mention what is not present in the form. Do not make any assumtions - this is critical.
15
- Additionally, you will be given additional instructions on how to summarize the form directly from a stakeholder.
16
-
17
- Language:
18
- Your summary should be in the same language as the form unless otherwise specified in the additional instructions.
19
-
20
- Instructions for summarizing:
21
- - Focus on the specific use case and context you are summarizing.
22
- - It is extremely important to tailor the summary specifically for the stakeholder to maximize its usefulness to them.
23
- - Emphasize information that is most pertinent to the stakeholder's needs, including critical data, notable findings, and any insights particularly useful for them.
24
- - Provide a concise and clear summary that is brief yet comprehensive.
25
- - Aim for a length that conveys all key points without unnecessary details.
26
- - Do not list all questions and answers unless specified in the additional instructions.
27
- - Do not include titles or formatting like bold or italic.
28
- - Provide quick insights of key points in an easy-to-read format for the stakeholder.
29
- - Do not include anything that is not present in form (such as the assumption that the patient visited clinic).
30
- - Do not add titles like Summary:, just provide the summary.
31
- - It is apsolutely critical to return proper markdown formatting, especially for new lines and paragraphs.
32
-
33
-
34
- Additional Instructions:
35
- {additionalInstructions}
36
-
37
- Stakeholder:
38
- {stakeholder}
39
-
40
- Content to summarize:
41
- {input}
42
- `);
43
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCzD,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/index.ts"],"names":[],"mappings":";;;AAAA,+DAA6D;AAApD,4HAAA,oBAAoB,OAAA"}
@@ -1 +0,0 @@
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"}
@@ -1,54 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"summarizeFormWithLLM.test.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeForm/lib/summarizeFormWithLLM/summarizeFormWithLLM.test.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,iEAA6D;AAE7D,uDAAyD;AAEzD,MAAM,WAAW,GAAG;IAClB,8BAA8B,EAAE;QAC9B,SAAS,EAAE;YACT,sCAAsC;YACtC,gDAAgD;YAChD,6DAA6D;YAC7D,gDAAgD;YAChD,oDAAoD;SACrD;QACD,OAAO,EAAE;YACP,qEAAqE;YACrE,oFAAoF;YACpF,kFAAkF;YAClF,gFAAgF;YAChF,4CAA4C;SAC7C;KACF;CACF,CAAA;AAED,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,kBAA2C,CAAA;IAE/C,UAAU,CAAC,GAAG,EAAE;QACd,yCAAyC;QACzC,kBAAkB,GAAG;YACnB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;SACoB,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,qEAAqE,EAAE,KAAK,IAAI,EAAE;QACnF,MAAM,aAAa,GACjB,0MAA0M,CAAA;QAE5M,kDAAkD;QAClD,kBAAkB,CAAC,MAAM,CAAC,qBAAqB,CAC7C,IAAI,yBAAc,CAAC,a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