@awell-health/awell-extensions 2.0.152 → 2.0.153
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/findAppointmentsByPrompt.js +33 -113
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/findAppointmentsByPrompt.js.map +1 -1
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/getAppoitnmentCountByStatus.d.ts +2 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/getAppoitnmentCountByStatus.js +15 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/getAppoitnmentCountByStatus.js.map +1 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/findAppointmentsByPromptWithLLM.d.ts +14 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/findAppointmentsByPromptWithLLM.js +36 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/findAppointmentsByPromptWithLLM.js.map +1 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/parser.d.ts +17 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/parser.js +14 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/parser.js.map +1 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/prompt.d.ts +2 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/prompt.js +24 -0
- package/dist/extensions/elation/actions/findAppointmentsByPrompt/lib/findAppointmentsByPromptWithLLM/prompt.js.map +1 -0
- package/dist/extensions/elation/actions/findFutureAppointment/findFutureAppointment.d.ts +1 -1
- package/dist/extensions/elation/actions/findFutureAppointment/findFutureAppointment.js +32 -90
- package/dist/extensions/elation/actions/findFutureAppointment/findFutureAppointment.js.map +1 -1
- package/dist/extensions/elation/actions/findFutureAppointment/formatAppointments.d.ts +2 -0
- package/dist/extensions/elation/actions/findFutureAppointment/formatAppointments.js +18 -0
- package/dist/extensions/elation/actions/findFutureAppointment/formatAppointments.js.map +1 -0
- package/dist/extensions/elation/actions/findFutureAppointment/getFutureAppoitnments.d.ts +3 -0
- package/dist/extensions/elation/actions/findFutureAppointment/getFutureAppoitnments.js +15 -0
- package/dist/extensions/elation/actions/findFutureAppointment/getFutureAppoitnments.js.map +1 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/findAppointmentWithLLM.d.ts +14 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/findAppointmentWithLLM.js +29 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/findAppointmentWithLLM.js.map +1 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/parser.d.ts +17 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/parser.js +16 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/parser.js.map +1 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/prompt.d.ts +2 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/prompt.js +20 -0
- package/dist/extensions/elation/actions/findFutureAppointment/lib/findAppointmentWithLLM/prompt.js.map +1 -0
- package/dist/extensions/elation/actions/index.d.ts +0 -210
- package/dist/extensions/elation/actions/updatePatientTags/config/types.d.ts +29 -0
- package/dist/extensions/elation/actions/updatePatientTags/config/types.js +21 -0
- package/dist/extensions/elation/actions/updatePatientTags/config/types.js.map +1 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/getTagsFromLLM.d.ts +13 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/getTagsFromLLM.js +29 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/getTagsFromLLM.js.map +1 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/parser.d.ts +13 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/parser.js +7 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/parser.js.map +1 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.d.ts +2 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.js +22 -0
- package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.js.map +1 -0
- package/dist/extensions/elation/actions/updatePatientTags/updatePatientTags.d.ts +8 -0
- package/dist/extensions/elation/actions/updatePatientTags/updatePatientTags.js +35 -77
- package/dist/extensions/elation/actions/updatePatientTags/updatePatientTags.js.map +1 -1
- package/dist/extensions/elation/actions/updatePatientTags/updateTags.d.ts +2 -0
- package/dist/extensions/elation/actions/updatePatientTags/updateTags.js +18 -0
- package/dist/extensions/elation/actions/updatePatientTags/updateTags.js.map +1 -0
- package/dist/extensions/elation/settings.d.ts +1 -10
- package/dist/extensions/elation/settings.js +0 -8
- package/dist/extensions/elation/settings.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.d.ts +10 -2
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js +32 -24
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.d.ts +22 -2
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.js +22 -7
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/categorizeMessageWithLLM.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/parser.d.ts +20 -0
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/parser.js +18 -0
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/parser.js.map +1 -0
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/prompt.d.ts +13 -0
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/prompt.js +35 -0
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/prompt.js.map +1 -0
- package/dist/extensions/shelly/actions/generateMessage/generateMessage.d.ts +10 -2
- package/dist/extensions/shelly/actions/generateMessage/generateMessage.js +33 -25
- package/dist/extensions/shelly/actions/generateMessage/generateMessage.js.map +1 -1
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/generateMessageWithLLM.d.ts +18 -2
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/generateMessageWithLLM.js +23 -10
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/generateMessageWithLLM.js.map +1 -1
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/parser.d.ts +28 -0
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/parser.js +17 -0
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/parser.js.map +1 -0
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/prompt.d.ts +10 -0
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/prompt.js +121 -0
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/prompt.js.map +1 -0
- package/dist/extensions/shelly/actions/index.d.ts +7 -63
- package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.d.ts +1 -2
- package/dist/extensions/shelly/actions/medicationFromImage/medicationFromImage.js.map +1 -1
- package/dist/extensions/shelly/actions/reviewMedicationExtraction/reviewMedicationExtraction.d.ts +1 -2
- package/dist/extensions/shelly/actions/reviewMedicationExtraction/reviewMedicationExtraction.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/{constants.js → prompt.js} +1 -1
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/prompt.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.d.ts +22 -2
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.js +30 -8
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/summarizeCareFlowWithLLM.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.d.ts +1 -2
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.js +24 -21
- package/dist/extensions/shelly/actions/summarizeCareFlow/summarizeCareFlow.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.d.ts +10 -2
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js +42 -28
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.d.ts +1 -2
- package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.js +29 -26
- package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.js.map +1 -1
- package/dist/extensions/shelly/index.js +2 -3
- package/dist/extensions/shelly/index.js.map +1 -1
- package/dist/extensions/shelly/lib/summarizeFormWithLLM/{constants.js → prompt.js} +1 -1
- package/dist/extensions/shelly/lib/summarizeFormWithLLM/prompt.js.map +1 -0
- package/dist/extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.d.ts +23 -2
- package/dist/extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.js +33 -9
- package/dist/extensions/shelly/lib/summarizeFormWithLLM/summarizeFormWithLLM.js.map +1 -1
- package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.d.ts +1 -5
- package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js +5 -20
- package/dist/extensions/shelly/lib/validatePayloadAndCreateSdk.js.map +1 -1
- package/dist/src/lib/llm/openai/constants.d.ts +28 -0
- package/dist/src/lib/llm/openai/constants.js +32 -0
- package/dist/src/lib/llm/openai/constants.js.map +1 -0
- package/dist/src/lib/llm/openai/createOpenAIModel.d.ts +23 -0
- package/dist/src/lib/llm/openai/createOpenAIModel.js +89 -0
- package/dist/src/lib/llm/openai/createOpenAIModel.js.map +1 -0
- package/dist/src/lib/llm/openai/index.d.ts +3 -0
- package/dist/src/lib/llm/openai/index.js +20 -0
- package/dist/src/lib/llm/openai/index.js.map +1 -0
- package/dist/src/lib/llm/openai/types.d.ts +63 -0
- package/dist/src/lib/llm/openai/types.js +3 -0
- package/dist/src/lib/llm/openai/types.js.map +1 -0
- package/package.json +5 -4
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.d.ts +0 -24
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js +0 -33
- package/dist/extensions/shelly/actions/categorizeMessage/lib/categorizeMessageWithLLM/constants.js.map +0 -1
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/constants.d.ts +0 -24
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/constants.js +0 -123
- package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/constants.js.map +0 -1
- package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/constants.js.map +0 -1
- package/dist/extensions/shelly/lib/summarizeFormWithLLM/constants.js.map +0 -1
- package/dist/extensions/shelly/settings.d.ts +0 -17
- package/dist/extensions/shelly/settings.js +0 -17
- package/dist/extensions/shelly/settings.js.map +0 -1
- /package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/{constants.d.ts → prompt.d.ts} +0 -0
- /package/dist/extensions/shelly/lib/summarizeFormWithLLM/{constants.d.ts → prompt.d.ts} +0 -0
@@ -3,9 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateMessage = void 0;
|
4
4
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
5
|
const generateMessageWithLLM_1 = require("./lib/generateMessageWithLLM");
|
6
|
-
const lib_1 = require("../../lib");
|
7
6
|
const config_1 = require("./config");
|
8
7
|
const utils_1 = require("../../../../src/utils");
|
8
|
+
const createOpenAIModel_1 = require("../../../../src/lib/llm/openai/createOpenAIModel");
|
9
|
+
const constants_1 = require("../../../../src/lib/llm/openai/constants");
|
10
|
+
/**
|
11
|
+
* Awell Action: Message Generation
|
12
|
+
*
|
13
|
+
* Takes communication objective and personalization inputs, uses LLM to:
|
14
|
+
* 1. Generate a personalized message
|
15
|
+
* 2. Create appropriate subject line
|
16
|
+
*
|
17
|
+
* @returns subject and HTML-formatted message
|
18
|
+
*/
|
9
19
|
exports.generateMessage = {
|
10
20
|
key: 'generateMessage',
|
11
21
|
category: extensions_core_1.Category.WORKFLOW,
|
@@ -15,32 +25,30 @@ exports.generateMessage = {
|
|
15
25
|
previewable: false,
|
16
26
|
dataPoints: config_1.dataPoints,
|
17
27
|
onEvent: async ({ payload, onComplete, onError, helpers }) => {
|
18
|
-
|
19
|
-
|
28
|
+
// 1. Validate input fields
|
29
|
+
const { communicationObjective, personalizationInput, stakeholder, language } = config_1.FieldsValidationSchema.parse(payload.fields);
|
30
|
+
// 2. Initialize OpenAI model with metadata
|
31
|
+
const { model, metadata, callbacks } = await (0, createOpenAIModel_1.createOpenAIModel)({
|
32
|
+
settings: payload.settings,
|
33
|
+
helpers,
|
20
34
|
payload,
|
35
|
+
modelType: constants_1.OPENAI_MODELS.GPT4o // Using GPT4 for high-quality message generation
|
36
|
+
});
|
37
|
+
// 3. Generate message
|
38
|
+
const { subject, message } = await (0, generateMessageWithLLM_1.generateMessageWithLLM)({
|
39
|
+
model,
|
40
|
+
communicationObjective,
|
41
|
+
personalizationInput,
|
42
|
+
stakeholder,
|
43
|
+
language,
|
44
|
+
metadata,
|
45
|
+
callbacks
|
46
|
+
});
|
47
|
+
// 4. Format and return results
|
48
|
+
const htmlMessage = await (0, utils_1.markdownToHtml)(message);
|
49
|
+
await onComplete({
|
50
|
+
data_points: { subject, message: htmlMessage }
|
21
51
|
});
|
22
|
-
try {
|
23
|
-
const generated_message = await (0, generateMessageWithLLM_1.generateMessageWithLLM)({
|
24
|
-
ChatModelGPT4o,
|
25
|
-
communicationObjective,
|
26
|
-
personalizationInput,
|
27
|
-
stakeholder,
|
28
|
-
language,
|
29
|
-
});
|
30
|
-
const { subject, message } = generated_message;
|
31
|
-
const htmlMessage = await (0, utils_1.markdownToHtml)(message);
|
32
|
-
await onComplete({
|
33
|
-
data_points: {
|
34
|
-
subject,
|
35
|
-
message: htmlMessage,
|
36
|
-
},
|
37
|
-
});
|
38
|
-
}
|
39
|
-
catch (error) {
|
40
|
-
console.error('Error generating message:', error);
|
41
|
-
// Catch in extention server
|
42
|
-
throw new Error('Error generating message');
|
43
|
-
}
|
44
52
|
},
|
45
53
|
};
|
46
54
|
//# sourceMappingURL=generateMessage.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generateMessage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/generateMessage/generateMessage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,yEAAqE;AACrE,
|
1
|
+
{"version":3,"file":"generateMessage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/generateMessage/generateMessage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,yEAAqE;AACrE,qCAAqE;AACrE,iDAAsD;AACtD,wFAAoF;AACpF,wEAAwE;AAExE;;;;;;;;GAQG;AACU,QAAA,eAAe,GAIxB;IACF,GAAG,EAAE,iBAAiB;IACtB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,iCAAiC;IAC9C,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IAEV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,2BAA2B;QAC3B,MAAM,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,GAC3E,+BAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE9C,2CAA2C;QAC3C,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,qCAAiB,EAAC;YAC7D,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO;YACP,OAAO;YACP,SAAS,EAAE,yBAAa,CAAC,KAAK,CAAC,iDAAiD;SACjF,CAAC,CAAA;QAEF,sBAAsB;QACtB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,+CAAsB,EAAC;YACxD,KAAK;YACL,sBAAsB;YACtB,oBAAoB;YACpB,WAAW;YACX,QAAQ;YACR,QAAQ;YACR,SAAS;SACV,CAAC,CAAA;QAEF,+BAA+B;QAC/B,MAAM,WAAW,GAAG,MAAM,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAA;QACjD,MAAM,UAAU,CAAC;YACf,WAAW,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE;SAC/C,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
@@ -1,10 +1,26 @@
|
|
1
1
|
import { type ChatOpenAI } from '@langchain/openai';
|
2
|
-
|
3
|
-
|
2
|
+
import { type AIActionMetadata } from '../../../../../../src/lib/llm/openai/types';
|
3
|
+
import type { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
4
|
+
/**
|
5
|
+
* Generates a personalized message using LLM with retry logic
|
6
|
+
*
|
7
|
+
* @param model - OpenAI chat model
|
8
|
+
* @param communicationObjective - Purpose of the message
|
9
|
+
* @param personalizationInput - Details for message customization
|
10
|
+
* @param stakeholder - Target recipient (e.g., Patient, Clinician)
|
11
|
+
* @param language - Message language
|
12
|
+
* @param metadata - Tracking info for LangSmith
|
13
|
+
* @param callbacks - Optional callbacks for LangChain
|
14
|
+
* @returns Generated subject and message
|
15
|
+
*/
|
16
|
+
export declare const generateMessageWithLLM: ({ model, communicationObjective, personalizationInput, stakeholder, language, metadata, callbacks, }: {
|
17
|
+
model: ChatOpenAI;
|
4
18
|
communicationObjective: string;
|
5
19
|
personalizationInput: string;
|
6
20
|
stakeholder: string;
|
7
21
|
language: string;
|
22
|
+
metadata: AIActionMetadata;
|
23
|
+
callbacks?: BaseCallbackHandler[];
|
8
24
|
}) => Promise<{
|
9
25
|
subject: string;
|
10
26
|
message: string;
|
@@ -1,29 +1,43 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.generateMessageWithLLM = void 0;
|
4
|
-
const
|
5
|
-
const
|
4
|
+
const parser_1 = require("./parser");
|
5
|
+
const prompt_1 = require("./prompt");
|
6
|
+
/**
|
7
|
+
* Generates a personalized message using LLM with retry logic
|
8
|
+
*
|
9
|
+
* @param model - OpenAI chat model
|
10
|
+
* @param communicationObjective - Purpose of the message
|
11
|
+
* @param personalizationInput - Details for message customization
|
12
|
+
* @param stakeholder - Target recipient (e.g., Patient, Clinician)
|
13
|
+
* @param language - Message language
|
14
|
+
* @param metadata - Tracking info for LangSmith
|
15
|
+
* @param callbacks - Optional callbacks for LangChain
|
16
|
+
* @returns Generated subject and message
|
17
|
+
*/
|
18
|
+
const generateMessageWithLLM = async ({ model, communicationObjective, personalizationInput, stakeholder, language, metadata, callbacks, }) => {
|
6
19
|
var _a, _b;
|
7
|
-
|
20
|
+
// 1. Prepare prompt with inputs
|
21
|
+
const prompt = await prompt_1.systemPrompt.format({
|
8
22
|
communicationObjective,
|
9
23
|
personalizationInput,
|
10
24
|
stakeholder,
|
11
25
|
language,
|
12
26
|
});
|
13
|
-
|
27
|
+
// 2. Create chain with structured output
|
28
|
+
const structured_output_chain = model.pipe(parser_1.parser);
|
29
|
+
// 3. Run chain with retries
|
14
30
|
const MAX_RETRIES = 3;
|
15
31
|
let retries = 0;
|
16
32
|
let subject = '';
|
17
33
|
let message = '';
|
18
|
-
// TODO: do it with more grace eventually
|
19
34
|
while (retries < MAX_RETRIES) { // Sometimes the LLM returns a non-JSON response
|
20
35
|
try {
|
21
|
-
const generated_message = await structured_output_chain.invoke(prompt);
|
36
|
+
const generated_message = await structured_output_chain.invoke(prompt, { metadata, runName: 'ShellyGenerateMessage', callbacks });
|
22
37
|
subject = (_a = generated_message.subject) !== null && _a !== void 0 ? _a : '';
|
23
38
|
message = (_b = generated_message.message) !== null && _b !== void 0 ? _b : '';
|
24
|
-
// If subject or message are not directly available
|
39
|
+
// If subject or message are not directly available, try parsing AIMessageChunk
|
25
40
|
if (subject.trim() === '' || message.trim() === '') {
|
26
|
-
console.log('Attempting to parse AIMessageChunk...');
|
27
41
|
// Attempt to get content from AIMessageChunk
|
28
42
|
if ('content' in generated_message) {
|
29
43
|
try {
|
@@ -38,7 +52,7 @@ const generateMessageWithLLM = async ({ ChatModelGPT4o, communicationObjective,
|
|
38
52
|
}
|
39
53
|
}
|
40
54
|
catch (error) {
|
41
|
-
|
55
|
+
throw new Error('Error parsing message content');
|
42
56
|
}
|
43
57
|
}
|
44
58
|
}
|
@@ -50,7 +64,6 @@ const generateMessageWithLLM = async ({ ChatModelGPT4o, communicationObjective,
|
|
50
64
|
throw new Error('Failed to generate valid subject and message');
|
51
65
|
}
|
52
66
|
catch (error) {
|
53
|
-
console.error(`Attempt ${retries + 1} failed:`, error);
|
54
67
|
retries++;
|
55
68
|
if (retries >= MAX_RETRIES) {
|
56
69
|
throw new Error('Failed to generate the message after multiple attempts');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generateMessageWithLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/generateMessageWithLLM.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"generateMessageWithLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/generateMessageWithLLM.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,qCAAuC;AAKvC;;;;;;;;;;;GAWG;AACI,MAAM,sBAAsB,GAAG,KAAK,EAAE,EAC3C,KAAK,EACL,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,GASV,EAAiD,EAAE;;IAClD,gCAAgC;IAChC,MAAM,MAAM,GAAG,MAAM,qBAAY,CAAC,MAAM,CAAC;QACvC,sBAAsB;QACtB,oBAAoB;QACpB,WAAW;QACX,QAAQ;KACT,CAAC,CAAA;IAEF,yCAAyC;IACzC,MAAM,uBAAuB,GAAG,KAAK,CAAC,IAAI,CAAC,eAAM,CAAC,CAAA;IAElD,4BAA4B;IAC5B,MAAM,WAAW,GAAG,CAAC,CAAA;IACrB,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,IAAI,OAAO,GAAG,EAAE,CAAA;IAEhB,OAAO,OAAO,GAAG,WAAW,EAAE,CAAC,CAAC,gDAAgD;QAC9E,IAAI,CAAC;YACH,MAAM,iBAAiB,GAAG,MAAM,uBAAuB,CAAC,MAAM,CAC5D,MAAM,EACN,EAAE,QAAQ,EAAE,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,CAC1D,CAAA;YACD,OAAO,GAAG,MAAA,iBAAiB,CAAC,OAAO,mCAAI,EAAE,CAAA;YACzC,OAAO,GAAG,MAAA,iBAAiB,CAAC,OAAO,mCAAI,EAAE,CAAA;YAEzC,+EAA+E;YAC/E,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBACnD,6CAA6C;gBAC7C,IAAI,SAAS,IAAI,iBAAiB,EAAE,CAAC;oBACnC,IAAI,CAAC;wBACH,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAiB,CAAC,CAAA;wBACrE,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;4BAChE,IAAI,SAAS,IAAI,aAAa,IAAI,OAAO,aAAa,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gCAC5E,OAAO,GAAG,aAAa,CAAC,OAAO,CAAA;4BACjC,CAAC;4BACD,IAAI,SAAS,IAAI,aAAa,IAAI,OAAO,aAAa,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gCAC5E,OAAO,GAAG,aAAa,CAAC,OAAO,CAAA;4BACjC,CAAC;wBACH,CAAC;oBACH,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;oBAClD,CAAC;gBACH,CAAC;YACH,CAAC;YAED,sDAAsD;YACtD,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBACnD,MAAK;YACP,CAAC;YAED,qEAAqE;YACrE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;QACjE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,CAAA;YACT,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;YAC3E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;AAC7B,CAAC,CAAA;AA/EY,QAAA,sBAAsB,0BA+ElC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { StructuredOutputParser } from 'langchain/output_parsers';
|
2
|
+
import { z } from 'zod';
|
3
|
+
/**
|
4
|
+
* Message Generation Output Schema
|
5
|
+
* Defines the expected structure of the LLM response:
|
6
|
+
* - subject: Clear, professional subject line
|
7
|
+
* - message: Complete, markdown-formatted message body
|
8
|
+
*/
|
9
|
+
export declare const messageSchema: z.ZodObject<{
|
10
|
+
subject: z.ZodString;
|
11
|
+
message: z.ZodString;
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
13
|
+
message: string;
|
14
|
+
subject: string;
|
15
|
+
}, {
|
16
|
+
message: string;
|
17
|
+
subject: string;
|
18
|
+
}>;
|
19
|
+
export declare const parser: StructuredOutputParser<z.ZodObject<{
|
20
|
+
subject: z.ZodString;
|
21
|
+
message: z.ZodString;
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
23
|
+
message: string;
|
24
|
+
subject: string;
|
25
|
+
}, {
|
26
|
+
message: string;
|
27
|
+
subject: string;
|
28
|
+
}>>;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.parser = exports.messageSchema = void 0;
|
4
|
+
const output_parsers_1 = require("langchain/output_parsers");
|
5
|
+
const zod_1 = require("zod");
|
6
|
+
/**
|
7
|
+
* Message Generation Output Schema
|
8
|
+
* Defines the expected structure of the LLM response:
|
9
|
+
* - subject: Clear, professional subject line
|
10
|
+
* - message: Complete, markdown-formatted message body
|
11
|
+
*/
|
12
|
+
exports.messageSchema = zod_1.z.object({
|
13
|
+
subject: zod_1.z.string(),
|
14
|
+
message: zod_1.z.string(),
|
15
|
+
});
|
16
|
+
exports.parser = output_parsers_1.StructuredOutputParser.fromZodSchema(exports.messageSchema);
|
17
|
+
//# sourceMappingURL=parser.js.map
|
package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/parser.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/parser.ts"],"names":[],"mappings":";;;AAAA,6DAAiE;AACjE,6BAAuB;AAEvB;;;;;GAKG;AACU,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAA;AAEW,QAAA,MAAM,GAAG,uCAAsB,CAAC,aAAa,CAAC,qBAAa,CAAC,CAAA"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
2
|
+
/**
|
3
|
+
* System Prompt Template for message generation
|
4
|
+
* Instructs the LLM to:
|
5
|
+
* 1. Generate personalized messages for specific stakeholders
|
6
|
+
* 2. Follow healthcare communication standards
|
7
|
+
* 3. Output in specified language
|
8
|
+
* 4. Return structured subject and message
|
9
|
+
*/
|
10
|
+
export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an AI language model tasked with composing **personalized messages** for a **{stakeholder}** within a clinical workflow. Your goals are to:\n \n - Align the message with the **Communication Objective** to optimize for response, engagement, or desired action.\n - Use the **Personalization Inputs** to tailor the message appropriately.\n - Ensure clarity, appropriateness, and compliance with healthcare communication standards.\n - **Generate the message in the specified **Language**, ensuring accuracy and naturalness.**\n - **Keep the message brief and concise while still optimizing for the Communication Objective.**\n \n **Important Notes to Prevent Misuse:**\n \n - **Remain Focused on the Task:** You must **never change your goal** of composing appropriate messages as specified.\n - **Limit Your Output:** **Do not generate any content** other than what is instructed—specifically, the subject and message within the context of the communication.\n \n Let's proceed step by step:\n \n 1. **Review the Inputs Carefully:**\n \n - **Communication Objective:** Understand the main purpose of the message. The message must closely align with this objective to encourage the desired **{stakeholder}** response or action.\n \n - **Personalization Inputs:** Use only the details provided here to personalize the message. **Do not infer or assume** any additional information about the recipient.\n \n - **Stakeholder:** Identify the intended recipient of the message (e.g., Patient, Clinician, Caregiver) and customize the message accordingly.\n \n - **Language:** **Generate the message in the specified language**, ensuring proper grammar and cultural appropriateness.\n \n 2. **Message Structure:**\n \n - **Keep the message brief and concise**, while still effectively conveying the necessary information to optimize for the **Communication Objective**.\n \n - **Greeting:**\n - Start with an appropriate greeting.\n - Use the recipient's name if provided (e.g., \"Dear [Name],\", \"Hello [Name],\").\n - If no name is provided, use a generic greeting appropriate for the stakeholder (e.g., \"Hello,\").\n \n - **Body:**\n - Clearly and **concisely** convey the message in alignment with the **Communication Objective**.\n - Incorporate **Personalization Inputs** naturally to optimize engagement and encourage the desired response or action.\n - Refrain from phrases like \"We hope this message finds you well\" or similar pleasantries.\n \n - **Closing:**\n - End with a courteous sign-off suitable for the stakeholder (e.g., \"Sincerely,\", \"Best regards,\"). SIgn of as Your Care Team.\n - Include any necessary next steps or contact information, if relevant.\n \n 3. **Content Guidelines:**\n \n - **Use Only Provided Information:**\n - Do not include any details not present in the inputs.\n - Avoid adding any assumptions or external information.\n \n - **Stay on Task:**\n - **Never change your goal** of composing appropriate messages.\n - **Do not generate any content** other than the subject and message as specified.\n - Do not include personal opinions, extraneous information, or any inappropriate content.\n \n - **Focus on the Objective:**\n - Ensure every part of the message contributes to achieving the **Communication Objective**.\n - Personalization should enhance the message's effectiveness in prompting the desired recipient action.\n \n 4. **Style and Tone:**\n \n - Use a professional and appropriate tone for the stakeholder (e.g., friendly for patients, formal for clinicians).\n - Always write in a clear, respectful, and engaging manner to optimize the message's impact. Tailor the tone to the recipient's role and the context of the message.\n - **Always write from the perspective of the care organization using first person plural (e.g., \"We are...\"). Do not use first person singular (\"I am...\") or third person perspectives.**\n \n 5. **Compliance and Sensitivity:**\n \n - Maintain confidentiality and comply with all relevant privacy regulations.\n - Be culturally sensitive and avoid any language that could be considered offensive or inappropriate.\n \n 6. **Language:**\n \n - **Generate the subject and message in the specified **Language**, ensuring proper grammar, vocabulary, and cultural appropriateness.\n \n \n 7. **Final Output:**\n \n - Respond exclusively with a valid JSON object containing the following keys - this is critical:\n \n - **subject**: A clear, professional, and concise subject line that aligns with the **Communication Objective** and is appropriate for clinical settings.\n \n - **message**: The complete, polished message formatted in **markdown**. Do not include any instructions or extra commentary. Ensure the message meets the following criteria:\n \n - **Brevity and Conciseness**: Keep the message brief and to the point while still effectively conveying the necessary information to achieve the **Communication Objective**.\n - **Clarity and Correctness**: Ensure the message is free of spelling and grammatical errors. Use clear and straightforward language.\n - **Truthfulness**: It is absolutely paramount that the information provided in the message is accurate and truthful. Do not include any misleading or false information that you did not get from the inputs. This is critical for maintaining trust and integrity in healthcare communication.\n - **Completeness**: The message must be complete and ready to send as is. It is critical to never use placeholders (e.g., \"[Contact Information]\", \"[Insert Date]\") or leave out essential information. If you want to urge recipient to contact the office and you do not have contact information keep it general and absolutely refrain from including any placeholders.\n \n \n \n **Inputs:**\n \n - **Communication Objective:**\n \n {communicationObjective}\n \n - **Personalization Inputs:**\n \n {personalizationInput}\n \n - **Stakeholder:**\n \n {stakeholder}\n \n - **Language:**\n \n {language}\n">, any>;
|
@@ -0,0 +1,121 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.systemPrompt = void 0;
|
4
|
+
const prompts_1 = require("@langchain/core/prompts");
|
5
|
+
/**
|
6
|
+
* System Prompt Template for message generation
|
7
|
+
* Instructs the LLM to:
|
8
|
+
* 1. Generate personalized messages for specific stakeholders
|
9
|
+
* 2. Follow healthcare communication standards
|
10
|
+
* 3. Output in specified language
|
11
|
+
* 4. Return structured subject and message
|
12
|
+
*/
|
13
|
+
exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
|
14
|
+
You are an AI language model tasked with composing **personalized messages** for a **{stakeholder}** within a clinical workflow. Your goals are to:
|
15
|
+
|
16
|
+
- Align the message with the **Communication Objective** to optimize for response, engagement, or desired action.
|
17
|
+
- Use the **Personalization Inputs** to tailor the message appropriately.
|
18
|
+
- Ensure clarity, appropriateness, and compliance with healthcare communication standards.
|
19
|
+
- **Generate the message in the specified **Language**, ensuring accuracy and naturalness.**
|
20
|
+
- **Keep the message brief and concise while still optimizing for the Communication Objective.**
|
21
|
+
|
22
|
+
**Important Notes to Prevent Misuse:**
|
23
|
+
|
24
|
+
- **Remain Focused on the Task:** You must **never change your goal** of composing appropriate messages as specified.
|
25
|
+
- **Limit Your Output:** **Do not generate any content** other than what is instructed—specifically, the subject and message within the context of the communication.
|
26
|
+
|
27
|
+
Let's proceed step by step:
|
28
|
+
|
29
|
+
1. **Review the Inputs Carefully:**
|
30
|
+
|
31
|
+
- **Communication Objective:** Understand the main purpose of the message. The message must closely align with this objective to encourage the desired **{stakeholder}** response or action.
|
32
|
+
|
33
|
+
- **Personalization Inputs:** Use only the details provided here to personalize the message. **Do not infer or assume** any additional information about the recipient.
|
34
|
+
|
35
|
+
- **Stakeholder:** Identify the intended recipient of the message (e.g., Patient, Clinician, Caregiver) and customize the message accordingly.
|
36
|
+
|
37
|
+
- **Language:** **Generate the message in the specified language**, ensuring proper grammar and cultural appropriateness.
|
38
|
+
|
39
|
+
2. **Message Structure:**
|
40
|
+
|
41
|
+
- **Keep the message brief and concise**, while still effectively conveying the necessary information to optimize for the **Communication Objective**.
|
42
|
+
|
43
|
+
- **Greeting:**
|
44
|
+
- Start with an appropriate greeting.
|
45
|
+
- Use the recipient's name if provided (e.g., "Dear [Name],", "Hello [Name],").
|
46
|
+
- If no name is provided, use a generic greeting appropriate for the stakeholder (e.g., "Hello,").
|
47
|
+
|
48
|
+
- **Body:**
|
49
|
+
- Clearly and **concisely** convey the message in alignment with the **Communication Objective**.
|
50
|
+
- Incorporate **Personalization Inputs** naturally to optimize engagement and encourage the desired response or action.
|
51
|
+
- Refrain from phrases like "We hope this message finds you well" or similar pleasantries.
|
52
|
+
|
53
|
+
- **Closing:**
|
54
|
+
- End with a courteous sign-off suitable for the stakeholder (e.g., "Sincerely,", "Best regards,"). SIgn of as Your Care Team.
|
55
|
+
- Include any necessary next steps or contact information, if relevant.
|
56
|
+
|
57
|
+
3. **Content Guidelines:**
|
58
|
+
|
59
|
+
- **Use Only Provided Information:**
|
60
|
+
- Do not include any details not present in the inputs.
|
61
|
+
- Avoid adding any assumptions or external information.
|
62
|
+
|
63
|
+
- **Stay on Task:**
|
64
|
+
- **Never change your goal** of composing appropriate messages.
|
65
|
+
- **Do not generate any content** other than the subject and message as specified.
|
66
|
+
- Do not include personal opinions, extraneous information, or any inappropriate content.
|
67
|
+
|
68
|
+
- **Focus on the Objective:**
|
69
|
+
- Ensure every part of the message contributes to achieving the **Communication Objective**.
|
70
|
+
- Personalization should enhance the message's effectiveness in prompting the desired recipient action.
|
71
|
+
|
72
|
+
4. **Style and Tone:**
|
73
|
+
|
74
|
+
- Use a professional and appropriate tone for the stakeholder (e.g., friendly for patients, formal for clinicians).
|
75
|
+
- Always write in a clear, respectful, and engaging manner to optimize the message's impact. Tailor the tone to the recipient's role and the context of the message.
|
76
|
+
- **Always write from the perspective of the care organization using first person plural (e.g., "We are..."). Do not use first person singular ("I am...") or third person perspectives.**
|
77
|
+
|
78
|
+
5. **Compliance and Sensitivity:**
|
79
|
+
|
80
|
+
- Maintain confidentiality and comply with all relevant privacy regulations.
|
81
|
+
- Be culturally sensitive and avoid any language that could be considered offensive or inappropriate.
|
82
|
+
|
83
|
+
6. **Language:**
|
84
|
+
|
85
|
+
- **Generate the subject and message in the specified **Language**, ensuring proper grammar, vocabulary, and cultural appropriateness.
|
86
|
+
|
87
|
+
|
88
|
+
7. **Final Output:**
|
89
|
+
|
90
|
+
- Respond exclusively with a valid JSON object containing the following keys - this is critical:
|
91
|
+
|
92
|
+
- **subject**: A clear, professional, and concise subject line that aligns with the **Communication Objective** and is appropriate for clinical settings.
|
93
|
+
|
94
|
+
- **message**: The complete, polished message formatted in **markdown**. Do not include any instructions or extra commentary. Ensure the message meets the following criteria:
|
95
|
+
|
96
|
+
- **Brevity and Conciseness**: Keep the message brief and to the point while still effectively conveying the necessary information to achieve the **Communication Objective**.
|
97
|
+
- **Clarity and Correctness**: Ensure the message is free of spelling and grammatical errors. Use clear and straightforward language.
|
98
|
+
- **Truthfulness**: It is absolutely paramount that the information provided in the message is accurate and truthful. Do not include any misleading or false information that you did not get from the inputs. This is critical for maintaining trust and integrity in healthcare communication.
|
99
|
+
- **Completeness**: The message must be complete and ready to send as is. It is critical to never use placeholders (e.g., "[Contact Information]", "[Insert Date]") or leave out essential information. If you want to urge recipient to contact the office and you do not have contact information keep it general and absolutely refrain from including any placeholders.
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
**Inputs:**
|
104
|
+
|
105
|
+
- **Communication Objective:**
|
106
|
+
|
107
|
+
{communicationObjective}
|
108
|
+
|
109
|
+
- **Personalization Inputs:**
|
110
|
+
|
111
|
+
{personalizationInput}
|
112
|
+
|
113
|
+
- **Stakeholder:**
|
114
|
+
|
115
|
+
{stakeholder}
|
116
|
+
|
117
|
+
- **Language:**
|
118
|
+
|
119
|
+
{language}
|
120
|
+
`);
|
121
|
+
//# sourceMappingURL=prompt.js.map
|
package/dist/extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/prompt.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE5D;;;;;;;GAOG;AACU,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2G3D,CAAC,CAAA"}
|
@@ -20,15 +20,7 @@ declare const actions: {
|
|
20
20
|
type: import("@awell-health/extensions-core").FieldType.STRING;
|
21
21
|
required: false;
|
22
22
|
};
|
23
|
-
},
|
24
|
-
openAiApiKey: {
|
25
|
-
key: string;
|
26
|
-
label: string;
|
27
|
-
obfuscated: true;
|
28
|
-
required: true;
|
29
|
-
description: string;
|
30
|
-
};
|
31
|
-
}, "summary">;
|
23
|
+
}, Record<string, never>, "summary">;
|
32
24
|
summarizeFormsInStep: import("@awell-health/extensions-core").Action<{
|
33
25
|
summaryFormat: {
|
34
26
|
id: string;
|
@@ -44,15 +36,7 @@ declare const actions: {
|
|
44
36
|
type: import("@awell-health/extensions-core").FieldType.STRING;
|
45
37
|
required: false;
|
46
38
|
};
|
47
|
-
},
|
48
|
-
openAiApiKey: {
|
49
|
-
key: string;
|
50
|
-
label: string;
|
51
|
-
obfuscated: true;
|
52
|
-
required: true;
|
53
|
-
description: string;
|
54
|
-
};
|
55
|
-
}, "summary">;
|
39
|
+
}, Record<string, never>, "summary">;
|
56
40
|
summarizeCareFlow: import("@awell-health/extensions-core").Action<{
|
57
41
|
additionalInstructions: {
|
58
42
|
id: string;
|
@@ -68,15 +52,7 @@ declare const actions: {
|
|
68
52
|
type: import("@awell-health/extensions-core").FieldType.STRING;
|
69
53
|
required: false;
|
70
54
|
};
|
71
|
-
},
|
72
|
-
openAiApiKey: {
|
73
|
-
key: string;
|
74
|
-
label: string;
|
75
|
-
obfuscated: true;
|
76
|
-
required: true;
|
77
|
-
description: string;
|
78
|
-
};
|
79
|
-
}, "summary">;
|
55
|
+
}, Record<string, never>, "summary">;
|
80
56
|
categorizeMessage: import("@awell-health/extensions-core").Action<{
|
81
57
|
message: {
|
82
58
|
id: string;
|
@@ -92,15 +68,7 @@ declare const actions: {
|
|
92
68
|
type: import("@awell-health/extensions-core").FieldType.STRING;
|
93
69
|
required: true;
|
94
70
|
};
|
95
|
-
},
|
96
|
-
openAiApiKey: {
|
97
|
-
key: string;
|
98
|
-
label: string;
|
99
|
-
obfuscated: true;
|
100
|
-
required: true;
|
101
|
-
description: string;
|
102
|
-
};
|
103
|
-
}, "category" | "explanation">;
|
71
|
+
}, Record<string, never>, "category" | "explanation">;
|
104
72
|
generateMessage: import("@awell-health/extensions-core").Action<{
|
105
73
|
communicationObjective: {
|
106
74
|
id: string;
|
@@ -130,15 +98,7 @@ declare const actions: {
|
|
130
98
|
type: import("@awell-health/extensions-core").FieldType.STRING;
|
131
99
|
required: false;
|
132
100
|
};
|
133
|
-
},
|
134
|
-
openAiApiKey: {
|
135
|
-
key: string;
|
136
|
-
label: string;
|
137
|
-
obfuscated: true;
|
138
|
-
required: true;
|
139
|
-
description: string;
|
140
|
-
};
|
141
|
-
}, "message" | "subject">;
|
101
|
+
}, Record<string, never>, "message" | "subject">;
|
142
102
|
medicationFromImage: import("@awell-health/extensions-core").Action<{
|
143
103
|
imageUrl: {
|
144
104
|
id: string;
|
@@ -147,15 +107,7 @@ declare const actions: {
|
|
147
107
|
type: import("@awell-health/extensions-core").FieldType.STRING;
|
148
108
|
required: true;
|
149
109
|
};
|
150
|
-
},
|
151
|
-
openAiApiKey: {
|
152
|
-
key: string;
|
153
|
-
label: string;
|
154
|
-
obfuscated: true;
|
155
|
-
required: true;
|
156
|
-
description: string;
|
157
|
-
};
|
158
|
-
}, "data">;
|
110
|
+
}, Record<string, never>, "data">;
|
159
111
|
reviewMedicationExtraction: import("@awell-health/extensions-core").Action<{
|
160
112
|
imageUrl: {
|
161
113
|
id: string;
|
@@ -171,14 +123,6 @@ declare const actions: {
|
|
171
123
|
type: import("@awell-health/extensions-core").FieldType.JSON;
|
172
124
|
required: true;
|
173
125
|
};
|
174
|
-
},
|
175
|
-
openAiApiKey: {
|
176
|
-
key: string;
|
177
|
-
label: string;
|
178
|
-
obfuscated: true;
|
179
|
-
required: true;
|
180
|
-
description: string;
|
181
|
-
};
|
182
|
-
}, "validatedData">;
|
126
|
+
}, Record<string, never>, "validatedData">;
|
183
127
|
};
|
184
128
|
export default actions;
|
@@ -1,4 +1,3 @@
|
|
1
1
|
import { type Action } from '@awell-health/extensions-core';
|
2
|
-
import { type settings } from '../../settings';
|
3
2
|
import { fields, dataPoints } from './config';
|
4
|
-
export declare const medicationFromImage: Action<typeof fields,
|
3
|
+
export declare const medicationFromImage: Action<typeof fields, Record<string, never>, keyof typeof dataPoints>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"medicationFromImage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/medicationFromImage/medicationFromImage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,mCAAuD;
|
1
|
+
{"version":3,"file":"medicationFromImage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/medicationFromImage/medicationFromImage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,mCAAuD;AACvD,qCAAqE;AACrE,uCAAsD;AACtD,iFAAiE;AAEpD,QAAA,mBAAmB,GAI5B;IACF,GAAG,EAAE,qBAAqB;IAC1B,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,+BAA+B;IACtC,WAAW,EAAE,oDAAoD;IACjE,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,MAAM,EACJ,MAAM,EAAE,EAAE,QAAQ,EAAE,EACpB,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAC1B,QAAQ,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,GAC7B,GAAG,MAAM,IAAA,iCAA2B,EAAC;YACpC,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,IAAI,CAAC;YACH,MAAM,sBAAsB,GAAG,IAAI,4BAAsB,EAAE,CAAA;YAE3D,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC,0BAA0B,CAAC;gBACnE,QAAQ;gBACR,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE;aACnC,CAAC,CAAA;YAEF,MAAM,UAAU,CAAC;gBACf,WAAW,EAAE;oBACX,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,WAAW,EAAE,IAAI,CAAC,WAAW;qBAC9B,CAAC;iBACH;aACF,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,mCAAU,EAAE,CAAC;gBAChC,MAAM,OAAO,CAAC;oBACZ,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;4BAC9B,IAAI,EAAE;gCACJ,EAAE,EAAE,GAAG,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,MAAM,KAAK,CAAC,YAAY,EAAE;6BACvE;4BACD,KAAK,EAAE;gCACL,QAAQ,EAAE,cAAc;gCACxB,OAAO,EAAE,GAAG,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,MAAM,KAAK,CAAC,YAAY,EAAE;6BAC5E;yBACF;qBACF;iBACF,CAAC,CAAA;gBACF,OAAM;YACR,CAAC;YAED,gDAAgD;YAChD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF,CAAA"}
|
package/dist/extensions/shelly/actions/reviewMedicationExtraction/reviewMedicationExtraction.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
1
|
import { type Action } from '@awell-health/extensions-core';
|
2
|
-
import { type settings } from '../../settings';
|
3
2
|
import { fields, dataPoints } from './config';
|
4
|
-
export declare const reviewMedicationExtraction: Action<typeof fields,
|
3
|
+
export declare const reviewMedicationExtraction: Action<typeof fields, Record<string, never>, keyof typeof dataPoints>;
|
package/dist/extensions/shelly/actions/reviewMedicationExtraction/reviewMedicationExtraction.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"reviewMedicationExtraction.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/reviewMedicationExtraction/reviewMedicationExtraction.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,mEAAqE;AACrE,mCAAuD;
|
1
|
+
{"version":3,"file":"reviewMedicationExtraction.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/reviewMedicationExtraction/reviewMedicationExtraction.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,mEAAqE;AACrE,mCAAuD;AACvD,qCAAqE;AAExD,QAAA,0BAA0B,GAInC;IACF,GAAG,EAAE,4BAA4B;IACjC,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,8BAA8B;IACrC,WAAW,EAAE,yDAAyD;IACtE,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE;QACP,YAAY,EAAE;YACZ,KAAK,EAAE,aAAa;YACpB,IAAI,EAAE,QAAQ;SACf;KACF;IACD,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,MAAM,IAAA,iCAA2B,EAAC;YAChC,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,6BAA6B;IAC/B,CAAC;CACF,CAAA"}
|
package/dist/extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/prompt.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeCareFlow/lib/summarizeCareFlowWithLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE5D,gDAAgD;AACnC,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC3D,CAAC,CAAA"}
|
@@ -1,7 +1,27 @@
|
|
1
1
|
import { type ChatOpenAI } from '@langchain/openai';
|
2
|
-
|
3
|
-
|
2
|
+
import { type AIActionMetadata } from '../../../../../../src/lib/llm/openai/types';
|
3
|
+
import type { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
4
|
+
/**
|
5
|
+
* Uses LLM to summarize care flow activities.
|
6
|
+
* The function follows these steps:
|
7
|
+
* 1. Formats prompt with stakeholder context and instructions
|
8
|
+
* 2. Runs LLM to generate summary
|
9
|
+
* 3. Returns formatted summary
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* const summary = await summarizeCareFlowWithLLM({
|
13
|
+
* model,
|
14
|
+
* careFlowActivities: "...",
|
15
|
+
* stakeholder: "Patient",
|
16
|
+
* additionalInstructions: "Focus on medications",
|
17
|
+
* metadata: { ... }
|
18
|
+
* })
|
19
|
+
*/
|
20
|
+
export declare const summarizeCareFlowWithLLM: ({ model, careFlowActivities, stakeholder, additionalInstructions, metadata, callbacks, }: {
|
21
|
+
model: ChatOpenAI;
|
4
22
|
careFlowActivities: string;
|
5
23
|
stakeholder: string;
|
6
24
|
additionalInstructions: string;
|
25
|
+
metadata: AIActionMetadata;
|
26
|
+
callbacks?: BaseCallbackHandler[];
|
7
27
|
}) => Promise<string>;
|
@@ -1,18 +1,40 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.summarizeCareFlowWithLLM = void 0;
|
4
|
-
const
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
const prompt_1 = require("./prompt");
|
5
|
+
/**
|
6
|
+
* Uses LLM to summarize care flow activities.
|
7
|
+
* The function follows these steps:
|
8
|
+
* 1. Formats prompt with stakeholder context and instructions
|
9
|
+
* 2. Runs LLM to generate summary
|
10
|
+
* 3. Returns formatted summary
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* const summary = await summarizeCareFlowWithLLM({
|
14
|
+
* model,
|
15
|
+
* careFlowActivities: "...",
|
16
|
+
* stakeholder: "Patient",
|
17
|
+
* additionalInstructions: "Focus on medications",
|
18
|
+
* metadata: { ... }
|
19
|
+
* })
|
20
|
+
*/
|
21
|
+
const summarizeCareFlowWithLLM = async ({ model, careFlowActivities, stakeholder, additionalInstructions, metadata, callbacks, }) => {
|
22
|
+
const prompt = await prompt_1.systemPrompt.format({
|
8
23
|
stakeholder,
|
9
24
|
additionalInstructions,
|
10
25
|
input: careFlowActivities,
|
11
26
|
});
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
27
|
+
try {
|
28
|
+
const response = await model.invoke(prompt, {
|
29
|
+
metadata,
|
30
|
+
runName: 'ShellySummarizeCareFlow',
|
31
|
+
callbacks
|
32
|
+
});
|
33
|
+
return response.content;
|
34
|
+
}
|
35
|
+
catch (error) {
|
36
|
+
throw new Error('Failed to summarize the care flow due to an internal error.');
|
37
|
+
}
|
16
38
|
};
|
17
39
|
exports.summarizeCareFlowWithLLM = summarizeCareFlowWithLLM;
|
18
40
|
//# sourceMappingURL=summarizeCareFlowWithLLM.js.map
|