@awell-health/awell-extensions 2.0.269 → 2.0.271
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js +20 -1
- package/dist/extensions/shelly/actions/categorizeMessage/categorizeMessage.js.map +1 -1
- package/dist/extensions/shelly/actions/categorizeMessage/config/fields.d.ts +16 -6
- package/dist/extensions/shelly/actions/categorizeMessage/config/fields.js +13 -5
- package/dist/extensions/shelly/actions/categorizeMessage/config/fields.js.map +1 -1
- package/dist/extensions/shelly/actions/index.d.ts +10 -3
- package/package.json +1 -1
@@ -7,6 +7,7 @@ const createOpenAIModel_1 = require("../../../../src/lib/llm/openai/createOpenAI
|
|
7
7
|
const constants_1 = require("../../../../src/lib/llm/openai/constants");
|
8
8
|
const config_1 = require("./config");
|
9
9
|
const utils_1 = require("../../../../src/utils");
|
10
|
+
const lodash_1 = require("lodash");
|
10
11
|
/**
|
11
12
|
* Awell Action: Message Categorization
|
12
13
|
*
|
@@ -26,7 +27,25 @@ exports.categorizeMessage = {
|
|
26
27
|
dataPoints: config_1.dataPoints,
|
27
28
|
onEvent: async ({ payload, onComplete, onError, helpers }) => {
|
28
29
|
// 1. Validate input fields
|
29
|
-
const { message, categories, instructions } = config_1.FieldsValidationSchema.parse(payload.fields);
|
30
|
+
const { message: messageText, messageDataPoint, categories, instructions, } = config_1.FieldsValidationSchema.parse(payload.fields);
|
31
|
+
const message = !(0, lodash_1.isNil)(messageDataPoint) && (messageDataPoint === null || messageDataPoint === void 0 ? void 0 : messageDataPoint.length) > 0
|
32
|
+
? messageDataPoint
|
33
|
+
: (messageText !== null && messageText !== void 0 ? messageText : '');
|
34
|
+
// ensure message is not empty
|
35
|
+
if (message.length === 0) {
|
36
|
+
await onError({
|
37
|
+
events: [
|
38
|
+
{
|
39
|
+
date: new Date().toISOString(),
|
40
|
+
text: { en: 'Either message or messageDataPoint is required' },
|
41
|
+
error: {
|
42
|
+
category: 'BAD_REQUEST',
|
43
|
+
message: 'Either message or messageDataPoint is required',
|
44
|
+
},
|
45
|
+
},
|
46
|
+
],
|
47
|
+
});
|
48
|
+
}
|
30
49
|
// 2. Initialize OpenAI model with metadata
|
31
50
|
const { model, metadata, callbacks } = await (0, createOpenAIModel_1.createOpenAIModel)({
|
32
51
|
settings: {}, // we use built-in API key for OpenAI
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"categorizeMessage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/categorizeMessage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,6EAAyE;AACzE,wFAAoF;AACpF,wEAAwE;AACxE,qCAAqE;AACrE,iDAAsD;
|
1
|
+
{"version":3,"file":"categorizeMessage.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/categorizeMessage/categorizeMessage.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,6EAAyE;AACzE,wFAAoF;AACpF,wEAAwE;AACxE,qCAAqE;AACrE,iDAAsD;AACtD,mCAA8B;AAE9B;;;;;;;;GAQG;AACU,QAAA,iBAAiB,GAI1B;IACF,GAAG,EAAE,mBAAmB;IACxB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,2BAA2B;IAClC,WAAW,EACT,mEAAmE;IACrE,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,EACJ,OAAO,EAAE,WAAW,EACpB,gBAAgB,EAChB,UAAU,EACV,YAAY,GACb,GAAG,+BAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAEhD,MAAM,OAAO,GACX,CAAC,IAAA,cAAK,EAAC,gBAAgB,CAAC,IAAI,C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
|
export declare const fields: {
|
4
|
-
|
4
|
+
messageDataPoint: {
|
5
5
|
id: string;
|
6
6
|
label: string;
|
7
7
|
description: string;
|
8
8
|
type: FieldType.STRING;
|
9
|
-
required:
|
9
|
+
required: false;
|
10
|
+
};
|
11
|
+
message: {
|
12
|
+
id: string;
|
13
|
+
label: string;
|
14
|
+
description: string;
|
15
|
+
type: FieldType.TEXT;
|
16
|
+
required: false;
|
10
17
|
};
|
11
18
|
categories: {
|
12
19
|
id: string;
|
@@ -19,20 +26,23 @@ export declare const fields: {
|
|
19
26
|
id: string;
|
20
27
|
label: string;
|
21
28
|
description: string;
|
22
|
-
type: FieldType.
|
29
|
+
type: FieldType.TEXT;
|
23
30
|
required: false;
|
24
31
|
};
|
25
32
|
};
|
26
33
|
export declare const FieldsValidationSchema: z.ZodObject<{
|
27
|
-
message: z.ZodString
|
34
|
+
message: z.ZodOptional<z.ZodString>;
|
35
|
+
messageDataPoint: z.ZodOptional<z.ZodString>;
|
28
36
|
categories: z.ZodEffects<z.ZodEffects<z.ZodString, string[], string>, string[], string>;
|
29
37
|
instructions: z.ZodOptional<z.ZodString>;
|
30
38
|
}, "strip", z.ZodTypeAny, {
|
31
|
-
message: string;
|
32
39
|
categories: string[];
|
40
|
+
message?: string | undefined;
|
33
41
|
instructions?: string | undefined;
|
42
|
+
messageDataPoint?: string | undefined;
|
34
43
|
}, {
|
35
|
-
message: string;
|
36
44
|
categories: string;
|
45
|
+
message?: string | undefined;
|
37
46
|
instructions?: string | undefined;
|
47
|
+
messageDataPoint?: string | undefined;
|
38
48
|
}>;
|
@@ -7,12 +7,19 @@ exports.FieldsValidationSchema = exports.fields = void 0;
|
|
7
7
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
8
8
|
const zod_1 = __importDefault(require("zod"));
|
9
9
|
exports.fields = {
|
10
|
+
messageDataPoint: {
|
11
|
+
id: 'messageDataPoint',
|
12
|
+
label: 'Message Data Point',
|
13
|
+
description: 'The message to be categorized. Use this if you want to use a data point for the message.',
|
14
|
+
type: extensions_core_1.FieldType.STRING, // Should be string, to allow selecting a data point
|
15
|
+
required: false,
|
16
|
+
},
|
10
17
|
message: {
|
11
18
|
id: 'message',
|
12
19
|
label: 'Message',
|
13
|
-
description: 'The message to be categorized',
|
14
|
-
type: extensions_core_1.FieldType.
|
15
|
-
required:
|
20
|
+
description: 'The message to be categorized. Use this if you want to use a text for the message.',
|
21
|
+
type: extensions_core_1.FieldType.TEXT, // TEXT if data point is not in use
|
22
|
+
required: false,
|
16
23
|
},
|
17
24
|
categories: {
|
18
25
|
id: 'categories',
|
@@ -25,12 +32,13 @@ exports.fields = {
|
|
25
32
|
id: 'instructions',
|
26
33
|
label: 'Instructions',
|
27
34
|
description: 'Add additional instructions prompt for the LLM',
|
28
|
-
type: extensions_core_1.FieldType.
|
35
|
+
type: extensions_core_1.FieldType.TEXT,
|
29
36
|
required: false,
|
30
37
|
},
|
31
38
|
};
|
32
39
|
exports.FieldsValidationSchema = zod_1.default.object({
|
33
|
-
message: zod_1.default.string().
|
40
|
+
message: zod_1.default.string().optional(),
|
41
|
+
messageDataPoint: zod_1.default.string().optional(),
|
34
42
|
categories: zod_1.default
|
35
43
|
.string()
|
36
44
|
.trim()
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/categorizeMessage/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,8CAAwC;
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/shelly/actions/categorizeMessage/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAqE;AACrE,8CAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,gBAAgB,EAAE;QAChB,EAAE,EAAE,kBAAkB;QACtB,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EACT,0FAA0F;QAC5F,IAAI,EAAE,2BAAS,CAAC,MAAM,EAAE,oDAAoD;QAC5E,QAAQ,E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izeMessage: import("@awell-health/extensions-core").Action<{
|
3
|
-
|
3
|
+
messageDataPoint: {
|
4
4
|
id: string;
|
5
5
|
label: string;
|
6
6
|
description: string;
|
7
7
|
type: import("@awell-health/extensions-core").FieldType.STRING;
|
8
|
-
required:
|
8
|
+
required: false;
|
9
|
+
};
|
10
|
+
message: {
|
11
|
+
id: string;
|
12
|
+
label: string;
|
13
|
+
description: string;
|
14
|
+
type: import("@awell-health/extensions-core").FieldType.TEXT;
|
15
|
+
required: false;
|
9
16
|
};
|
10
17
|
categories: {
|
11
18
|
id: string;
|
@@ -18,7 +25,7 @@ declare const actions: {
|
|
18
25
|
id: string;
|
19
26
|
label: string;
|
20
27
|
description: string;
|
21
|
-
type: import("@awell-health/extensions-core").FieldType.
|
28
|
+
type: import("@awell-health/extensions-core").FieldType.TEXT;
|
22
29
|
required: false;
|
23
30
|
};
|
24
31
|
}, Record<string, never>, "category" | "explanation">;
|