@awell-health/awell-extensions 2.0.156 → 2.0.157

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. package/dist/extensions/elation/actions/index.d.ts +2 -2
  2. package/dist/extensions/elation/actions/updatePatientTags/config/dataPoints.d.ts +4 -0
  3. package/dist/extensions/elation/actions/updatePatientTags/config/dataPoints.js +4 -0
  4. package/dist/extensions/elation/actions/updatePatientTags/config/dataPoints.js.map +1 -1
  5. package/dist/extensions/elation/actions/updatePatientTags/config/fields.d.ts +4 -4
  6. package/dist/extensions/elation/actions/updatePatientTags/config/fields.js +5 -5
  7. package/dist/extensions/elation/actions/updatePatientTags/config/fields.js.map +1 -1
  8. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/evaluateTags.d.ts +24 -0
  9. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/evaluateTags.js +148 -0
  10. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/evaluateTags.js.map +1 -0
  11. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/getTagsFromLLM.d.ts +1 -1
  12. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/getTagsFromLLM.js +2 -2
  13. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/getTagsFromLLM.js.map +1 -1
  14. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/parser.d.ts +22 -6
  15. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/parser.js +13 -3
  16. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/parser.js.map +1 -1
  17. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.d.ts +1 -1
  18. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.js +32 -11
  19. package/dist/extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.js.map +1 -1
  20. package/dist/extensions/elation/actions/updatePatientTags/updatePatientTags.js +4 -3
  21. package/dist/extensions/elation/actions/updatePatientTags/updatePatientTags.js.map +1 -1
  22. package/dist/extensions/elation/actions/updatePatientTags/updateTags.js +3 -2
  23. package/dist/extensions/elation/actions/updatePatientTags/updateTags.js.map +1 -1
  24. package/package.json +1 -1
  25. package/dist/extensions/elation/actions/updatePatientTags/config/types.d.ts +0 -29
  26. package/dist/extensions/elation/actions/updatePatientTags/config/types.js +0 -21
  27. package/dist/extensions/elation/actions/updatePatientTags/config/types.js.map +0 -1
@@ -2266,7 +2266,7 @@ export declare const actions: {
2266
2266
  required: true;
2267
2267
  description: string;
2268
2268
  };
2269
- prompt: {
2269
+ instructions: {
2270
2270
  id: string;
2271
2271
  label: string;
2272
2272
  type: import("@awell-health/extensions-core").FieldType.TEXT;
@@ -2316,7 +2316,7 @@ export declare const actions: {
2316
2316
  description: string;
2317
2317
  required: false;
2318
2318
  };
2319
- }, "updatedTags">;
2319
+ }, "updatedTags" | "explanation">;
2320
2320
  getReferralOrder: import("@awell-health/extensions-core").Action<{
2321
2321
  referralOrderId: {
2322
2322
  id: string;
@@ -3,4 +3,8 @@ export declare const dataPoints: {
3
3
  key: string;
4
4
  valueType: "string";
5
5
  };
6
+ explanation: {
7
+ key: string;
8
+ valueType: "string";
9
+ };
6
10
  };
@@ -6,5 +6,9 @@ exports.dataPoints = {
6
6
  key: 'updatedTags',
7
7
  valueType: 'string',
8
8
  },
9
+ explanation: {
10
+ key: 'explanation',
11
+ valueType: 'string',
12
+ }
9
13
  };
10
14
  //# sourceMappingURL=dataPoints.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataPoints.js","sourceRoot":"","sources":["../../../../../../extensions/elation/actions/updatePatientTags/config/dataPoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,WAAW,EAAE;QACX,GAAG,EAAE,aAAa;QAClB,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA"}
1
+ {"version":3,"file":"dataPoints.js","sourceRoot":"","sources":["../../../../../../extensions/elation/actions/updatePatientTags/config/dataPoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,WAAW,EAAE;QACX,GAAG,EAAE,aAAa;QAClB,SAAS,EAAE,QAAQ;KACpB;IACD,WAAW,EAAE;QACX,GAAG,EAAE,aAAa;QAClB,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA"}
@@ -8,7 +8,7 @@ export declare const fields: {
8
8
  required: true;
9
9
  description: string;
10
10
  };
11
- prompt: {
11
+ instructions: {
12
12
  id: string;
13
13
  label: string;
14
14
  type: FieldType.TEXT;
@@ -18,11 +18,11 @@ export declare const fields: {
18
18
  };
19
19
  export declare const FieldsValidationSchema: z.ZodObject<{
20
20
  patientId: z.ZodNumber;
21
- prompt: z.ZodString;
21
+ instructions: z.ZodString;
22
22
  }, "strip", z.ZodTypeAny, {
23
23
  patientId: number;
24
- prompt: string;
24
+ instructions: string;
25
25
  }, {
26
26
  patientId: number;
27
- prompt: string;
27
+ instructions: string;
28
28
  }>;
@@ -11,16 +11,16 @@ exports.fields = {
11
11
  required: true,
12
12
  description: '',
13
13
  },
14
- prompt: {
15
- id: 'prompt',
16
- label: 'Describe what tags you would like to add, update, or remove',
14
+ instructions: {
15
+ id: 'instructions',
16
+ label: 'Specify tags to add, remove, or modify',
17
17
  type: extensions_core_1.FieldType.TEXT,
18
18
  required: true,
19
- description: '',
19
+ description: 'Provide clear instructions for tag changes and relevant context, especially for uncommon tags. Specify new tags in single quotes (e.g., \'Patient-Tag\').'
20
20
  },
21
21
  };
22
22
  exports.FieldsValidationSchema = zod_1.z.object({
23
23
  patientId: extensions_core_1.NumericIdSchema,
24
- prompt: zod_1.z.string().min(1),
24
+ instructions: zod_1.z.string().min(1),
25
25
  });
26
26
  //# sourceMappingURL=fields.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/elation/actions/updatePatientTags/config/fields.ts"],"names":[],"mappings":";;;AAAA,6BAAwC;AACxC,mEAIsC;AAEzB,QAAA,MAAM,GAAG;IACpB,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,2BAAS,CAAC,OAAO;QACvB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,EAAE;KAChB;IACD,MAAM,EAAE;QACN,EAAE,EAAE,QAAQ;QACZ,KAAK,EAAE,6DAA6D;QACpE,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,EAAE;KAChB;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,SAAS,EAAE,iCAAe;IAC1B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACwB,CAAC,CAAA"}
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/elation/actions/updatePatientTags/config/fields.ts"],"names":[],"mappings":";;;AAAA,6BAAwC;AACxC,mEAIsC;AAEzB,QAAA,MAAM,GAAG;IACpB,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,2BAAS,CAAC,OAAO;QACvB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,EAAE;KAChB;IACD,YAAY,EAAE;QACZ,EAAE,EAAE,cAAc;QAClB,KAAK,EAAE,wCAAwC;QAC/C,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,2JAA2J;KACzK;CAC8B,CAAA;AAEpB,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,SAAS,EAAE,iCAAe;IAC1B,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACkB,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * LangSmith Evaluation Script for getTagsFromLLM
3
+ *
4
+ * Evaluates the getTagsFromLLM function by:
5
+ * - Running test cases from LangSmith dataset
6
+ * - Comparing generated tags against expected tags
7
+ * - Generating evaluation reports
8
+ *
9
+ * Requirements:
10
+ * - Set environment variables in .env:
11
+ * - OPENAI_API_KEY
12
+ * - LANGSMITH_API_KEY
13
+ * - LANGSMITH_TRACING=true
14
+ * - LANGSMITH_PROJECT=ai-actions-local
15
+ *
16
+ * Usage:
17
+ * node getTagsFromLLM/evaluateTags.ts
18
+ *
19
+ * Results can be viewed in LangSmith dashboard:
20
+ * https://smith.langchain.com/o/3fffae83-70ff-4574-81ba-aaaedf0b4dc5/datasets/745cea13-3379-463f-9a8a-c6b10e29b8f6
21
+ *
22
+ * * ⚠️ **Note:** This script does NOT run in CI/CD. It is meant for **manual evaluation** before merging PRs (for now)
23
+ */
24
+ export {};
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * LangSmith Evaluation Script for getTagsFromLLM
4
+ *
5
+ * Evaluates the getTagsFromLLM function by:
6
+ * - Running test cases from LangSmith dataset
7
+ * - Comparing generated tags against expected tags
8
+ * - Generating evaluation reports
9
+ *
10
+ * Requirements:
11
+ * - Set environment variables in .env:
12
+ * - OPENAI_API_KEY
13
+ * - LANGSMITH_API_KEY
14
+ * - LANGSMITH_TRACING=true
15
+ * - LANGSMITH_PROJECT=ai-actions-local
16
+ *
17
+ * Usage:
18
+ * node getTagsFromLLM/evaluateTags.ts
19
+ *
20
+ * Results can be viewed in LangSmith dashboard:
21
+ * https://smith.langchain.com/o/3fffae83-70ff-4574-81ba-aaaedf0b4dc5/datasets/745cea13-3379-463f-9a8a-c6b10e29b8f6
22
+ *
23
+ * * ⚠️ **Note:** This script does NOT run in CI/CD. It is meant for **manual evaluation** before merging PRs (for now)
24
+ */
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const langsmith_1 = require("langsmith");
30
+ const evaluation_1 = require("langsmith/evaluation");
31
+ const createOpenAIModel_1 = require("../../../../../../src/lib/llm/openai/createOpenAIModel");
32
+ const getTagsFromLLM_1 = require("./getTagsFromLLM");
33
+ const constants_1 = require("../../../../../../src/lib/llm/openai/constants");
34
+ const lodash_1 = require("lodash");
35
+ const dotenv_1 = __importDefault(require("dotenv"));
36
+ dotenv_1.default.config();
37
+ const langsmith = new langsmith_1.Client({
38
+ apiKey: process.env.LANGSMITH_API_KEY,
39
+ apiUrl: process.env.LANGSMITH_ENDPOINT,
40
+ });
41
+ // Define the dataset name
42
+ const datasetName = 'ai-actions-update-patient-tags-elation';
43
+ // Fetch the 'test' split examples from the dataset
44
+ const fetchTestExamples = async () => {
45
+ try {
46
+ const testExamples = langsmith.listExamples({
47
+ datasetName,
48
+ splits: ['test'],
49
+ });
50
+ const examples = [];
51
+ for await (const example of testExamples) {
52
+ if (!(0, lodash_1.isNil)(example.inputs) && !(0, lodash_1.isNil)(example.outputs)) { // Explicit null check
53
+ examples.push(example);
54
+ }
55
+ }
56
+ return examples;
57
+ }
58
+ catch (error) {
59
+ console.error('❌ Error fetching test examples:', error);
60
+ throw error;
61
+ }
62
+ };
63
+ // Custom evaluator to compare generated tags with expected tags
64
+ const tagsMatchEvaluator = async ({ outputs, referenceOutputs, }) => {
65
+ console.log('Evaluator received:', { outputs, referenceOutputs }); // Debug log
66
+ const generatedTags = outputs === null || outputs === void 0 ? void 0 : outputs.validatedTags;
67
+ const expectedTags = referenceOutputs === null || referenceOutputs === void 0 ? void 0 : referenceOutputs.expected_updated_tags;
68
+ // console.log('Comparing tags:', { generatedTags, expectedTags }); // Debug log
69
+ const isEqual = Array.isArray(generatedTags) &&
70
+ Array.isArray(expectedTags) &&
71
+ generatedTags.length === expectedTags.length &&
72
+ generatedTags.every((tag, index) => tag === expectedTags[index]);
73
+ return { key: 'tags_match', score: isEqual ? 1 : 0 };
74
+ };
75
+ // Wrapper function to adapt getTagsFromLLM for evaluation
76
+ const getTagsFromLLMWrapper = async (input) => {
77
+ const payload = {
78
+ activity: {
79
+ id: 'test-activity-id'
80
+ },
81
+ pathway: {
82
+ tenant_id: 'test-tenant',
83
+ definition_id: 'test-definition',
84
+ id: 'test-pathway',
85
+ org_slug: 'test-org',
86
+ org_id: 'test-org-id'
87
+ },
88
+ fields: {
89
+ instructions: input.instruction,
90
+ patientId: 'test-patient'
91
+ },
92
+ settings: {
93
+ openAiApiKey: process.env.OPENAI_API_KEY
94
+ }
95
+ };
96
+ const helpers = {
97
+ getOpenAIConfig: () => {
98
+ const apiKey = process.env.OPENAI_API_KEY;
99
+ if ((0, lodash_1.isNil)(apiKey) || apiKey.trim() === '') {
100
+ throw new Error('OPENAI_API_KEY is required but not set');
101
+ }
102
+ return { apiKey };
103
+ }
104
+ };
105
+ const { model, metadata, callbacks } = await (0, createOpenAIModel_1.createOpenAIModel)({
106
+ settings: payload.settings,
107
+ helpers,
108
+ payload,
109
+ modelType: constants_1.OPENAI_MODELS.GPT4o,
110
+ });
111
+ return await (0, getTagsFromLLM_1.getTagsFromLLM)({
112
+ model,
113
+ existingTags: input.input_patient_tags,
114
+ instructions: input.instruction,
115
+ metadata,
116
+ callbacks,
117
+ });
118
+ };
119
+ // Main function to run the evaluation and print results
120
+ const runEvaluation = async () => {
121
+ var _a, _b;
122
+ try {
123
+ console.log('📡 Fetching test dataset from LangSmith...');
124
+ const testExamples = await fetchTestExamples();
125
+ console.log(`✅ Loaded ${testExamples.length} test examples\n`);
126
+ console.log('🚀 Running evaluation...\n');
127
+ const results = await (0, evaluation_1.evaluate)(getTagsFromLLMWrapper, {
128
+ data: testExamples,
129
+ evaluators: [tagsMatchEvaluator],
130
+ experimentPrefix: 'GetTagsFromLLM Evaluation',
131
+ maxConcurrency: 4,
132
+ });
133
+ const resultsArray = Array.isArray(results) ? results : [results];
134
+ const experimentId = (_b = (_a = resultsArray[0]) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.run_id;
135
+ if (!(0, lodash_1.isNil)(experimentId) && experimentId.trim() !== '') {
136
+ console.log('\n✨ Evaluation Complete!');
137
+ console.log('View detailed results in LangSmith:');
138
+ console.log(`https://smith.langchain.com/runs/${experimentId}`);
139
+ }
140
+ }
141
+ catch (error) {
142
+ console.error('❌ Error during evaluation:', error);
143
+ throw error;
144
+ }
145
+ };
146
+ // Execute the evaluation
147
+ void runEvaluation();
148
+ //# sourceMappingURL=evaluateTags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluateTags.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/evaluateTags.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;AAEH,yCAAiD;AACjD,qDAAgD;AAChD,8FAA2F;AAC3F,qDAAkD;AAClD,8EAA+E;AAE/E,mCAA+B;AAE/B,oDAA4B;AAC5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAGhB,MAAM,SAAS,GAAG,IAAI,kBAAM,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;IACrC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;CACvC,CAAC,CAAC;AAEH,0BAA0B;AAC1B,MAAM,WAAW,GAAG,wCAAwC,CAAC;AAiB7D,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,KAAK,IAAwB,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;YAC1C,WAAW;YACX,MAAM,EAAE,CAAC,MAAM,CAAC;SACjB,CAAC,CAAC;QACH,MAAM,QAAQ,GAAc,EAAE,CAAC;QAC/B,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;YACzC,IAAI,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAA,cAAK,EAAC,OAAO,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CAAC,GAAG,CAAC,YAAY,YAAY,CAAC,MAAM,kBAAkB,CAAC,CAAC;QAE/D,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAQ,EAAC,qBAAqB,EAAE;YACpD,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,CAAC,kBAAkB,CAAC;YAChC,gBAAgB,EAAE,2BAA2B;YAC7C,cAAc,EAAE,CAAC;SAClB,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,YAAY,GAAG,MAAA,MAAA,YAAY,CAAC,CAAC,CAAC,0CAAE,GAAG,0CAAE,MAAgB,CAAC;QAE5D,IAAI,CAAC,IAAA,cAAK,EAAC,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;YACxC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,oCAAoC,YAAY,EAAE,CAAC,CAAC;QAClE,CAAC;IAEH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF,yBAAyB;AACzB,KAAK,aAAa,EAAE,CAAC"}
@@ -5,7 +5,7 @@ import type { BaseCallbackHandler } from "@langchain/core/callbacks/base";
5
5
  interface GetTagsFromLLMProps {
6
6
  model: ChatOpenAI;
7
7
  existingTags: string[];
8
- prompt: string;
8
+ instructions: string;
9
9
  metadata: AIActionMetadata;
10
10
  callbacks?: BaseCallbackHandler[];
11
11
  }
@@ -4,12 +4,12 @@ exports.getTagsFromLLM = void 0;
4
4
  const prompt_1 = require("./prompt");
5
5
  const parser_1 = require("./parser");
6
6
  const getTagsFromLLM = async (props) => {
7
- const { model, existingTags, prompt, metadata, callbacks } = props;
7
+ const { model, existingTags, instructions, metadata, callbacks } = props;
8
8
  try {
9
9
  const chain = model.pipe(parser_1.parser);
10
10
  const formattedPrompt = await prompt_1.systemPrompt.format({
11
11
  existingTags: JSON.stringify(existingTags),
12
- prompt
12
+ instructions
13
13
  });
14
14
  const result = await chain.invoke(formattedPrompt, {
15
15
  metadata,
@@ -1 +1 @@
1
- {"version":3,"file":"getTagsFromLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/getTagsFromLLM.ts"],"names":[],"mappings":";;;AAEA,qCAAuC;AACvC,qCAAkD;AAW3C,MAAM,cAAc,GAAG,KAAK,EAAE,KAA0B,EAAuB,EAAE;IACtF,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;IAElE,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,eAAM,CAAC,CAAA;QAChC,MAAM,eAAe,GAAG,MAAM,qBAAY,CAAC,MAAM,CAAC;YAChD,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;YAC1C,MAAM;SACP,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAC/B,eAAe,EACf;YACE,QAAQ;YACR,OAAO,EAAE,0BAA0B;YACnC,SAAS;SACV,CACF,CAAA;QAED,OAAO;YACL,aAAa,EAAE,MAAM,CAAC,WAAW;YACjC,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACnD,CAAC;AACH,CAAC,CAAA;AAzBY,QAAA,cAAc,kBAyB1B"}
1
+ {"version":3,"file":"getTagsFromLLM.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/getTagsFromLLM.ts"],"names":[],"mappings":";;;AAEA,qCAAuC;AACvC,qCAAkD;AAW3C,MAAM,cAAc,GAAG,KAAK,EAAE,KAA0B,EAAuB,EAAE;IACtF,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;IAExE,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,eAAM,CAAC,CAAA;QAChC,MAAM,eAAe,GAAG,MAAM,qBAAY,CAAC,MAAM,CAAC;YAChD,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;YAC1C,YAAY;SACb,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAC/B,eAAe,EACf;YACE,QAAQ;YACR,OAAO,EAAE,0BAA0B;YACnC,SAAS;SACV,CACF,CAAA;QAED,OAAO;YACL,aAAa,EAAE,MAAM,CAAC,WAAW;YACjC,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACnD,CAAC;AACH,CAAC,CAAA;AAzBY,QAAA,cAAc,kBAyB1B"}
@@ -1,13 +1,29 @@
1
+ import { z } from 'zod';
1
2
  import { StructuredOutputParser } from '@langchain/core/output_parsers';
2
- import { type TagsFromAI } from '../../config/types';
3
- export declare const parser: StructuredOutputParser<import("zod").ZodObject<{
4
- updatedTags: import("zod").ZodEffects<import("zod").ZodArray<import("zod").ZodString, "many">, string[], string[]>;
5
- explanation: import("zod").ZodString;
6
- }, "strip", import("zod").ZodTypeAny, {
3
+ export declare const SingleTagSchema: z.ZodString;
4
+ export declare const TagsSchema: z.ZodArray<z.ZodString, "many">;
5
+ export declare const TagsOutputSchema: z.ZodObject<{
6
+ updatedTags: z.ZodArray<z.ZodString, "many">;
7
+ explanation: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ updatedTags: string[];
10
+ explanation: string;
11
+ }, {
12
+ updatedTags: string[];
13
+ explanation: string;
14
+ }>;
15
+ export declare const parser: StructuredOutputParser<z.ZodObject<{
16
+ updatedTags: z.ZodArray<z.ZodString, "many">;
17
+ explanation: z.ZodString;
18
+ }, "strip", z.ZodTypeAny, {
7
19
  updatedTags: string[];
8
20
  explanation: string;
9
21
  }, {
10
22
  updatedTags: string[];
11
23
  explanation: string;
12
24
  }>>;
13
- export type { TagsFromAI };
25
+ export type TagsOutput = z.infer<typeof TagsOutputSchema>;
26
+ export interface TagsFromAI {
27
+ validatedTags: string[];
28
+ explanation: string;
29
+ }
@@ -1,7 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parser = void 0;
3
+ exports.parser = exports.TagsOutputSchema = exports.TagsSchema = exports.SingleTagSchema = void 0;
4
+ const zod_1 = require("zod");
4
5
  const output_parsers_1 = require("@langchain/core/output_parsers");
5
- const types_1 = require("../../config/types");
6
- exports.parser = output_parsers_1.StructuredOutputParser.fromZodSchema(types_1.TagsOutputSchema);
6
+ exports.SingleTagSchema = zod_1.z.string();
7
+ exports.TagsSchema = zod_1.z
8
+ .array(exports.SingleTagSchema)
9
+ .describe('The updated array of tags');
10
+ exports.TagsOutputSchema = zod_1.z.object({
11
+ updatedTags: exports.TagsSchema,
12
+ explanation: zod_1.z
13
+ .string()
14
+ .describe('A single, concise sentence summarizing all tag modifications, including the reasoning behind the changes or lack thereof.'),
15
+ });
16
+ exports.parser = output_parsers_1.StructuredOutputParser.fromZodSchema(exports.TagsOutputSchema);
7
17
  //# sourceMappingURL=parser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/parser.ts"],"names":[],"mappings":";;;AAAA,mEAAuE;AACvE,8CAAsE;AAEzD,QAAA,MAAM,GAAG,uCAAsB,CAAC,aAAa,CAAC,wBAAgB,CAAC,CAAA"}
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/parser.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,mEAAuE;AAE1D,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,EAAE,CAAA;AAE5B,QAAA,UAAU,GAAG,OAAC;KACxB,KAAK,CAAC,uBAAe,CAAC;KACtB,QAAQ,CAAC,2BAA2B,CAAC,CAAA;AAE3B,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,WAAW,EAAE,kBAAU;IACvB,WAAW,EAAE,OAAC;SACX,MAAM,EAAE;SACR,QAAQ,CAAC,2HAA2H,CAAC;CACzI,CAAC,CAAA;AAEW,QAAA,MAAM,GAAG,uCAAsB,CAAC,aAAa,CAAC,wBAAgB,CAAC,CAAA"}
@@ -1,2 +1,2 @@
1
1
  import { ChatPromptTemplate } from '@langchain/core/prompts';
2
- export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\nYou are a clinical data manager. You will receive a list (array) of patient tags for a single patient and instructions about which tags to add, update, or remove. These tags are used to assign particular attributes to patients which can help with patient care, like grouping of patients, categorizing patients for reporting, or identifying patients for care.\n \n Important instructions:\n - The maximum number of tags is 10.\n - The max length of a single tag is 100 characters.\n - Ensure tags are unique.\n\n\n Input array: {existingTags}\n Instruction: {prompt}\n\n\nOutput a JSON object with two keys:\n1. updatedTags: The updated array of tags. If the input array is empty, the output should be an empty array.\n2. explanation: A readable explanation of the changes made to the tags and why\n">, any>;
2
+ export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are a clinical data manager with expert knowledge of Elation Patient Tags, which help care teams organize patient care (e.g., grouping, reporting, or identifying patients for care).\n\n Your task is to manage a single patient's tags based on the provided instructions.\n\n You will receive:\n - existing_tags: An array of the patient's current tags.\n - instruction: A directive specifying which tags to add, update, or remove. Ensure to follow them diligently.\n\n ### Step-by-Step Approach:\n 1. **Review the Instruction**\n - Identify the required tag modifications: additions, updates, or removals.\n\n 2. **Apply Modifications**\n - **Removing Tags:**\n - Only remove tags if explicitly stated in the instruction.\n - Match existing tags for removal, allowing minor variations (e.g., capitalization, spacing).\n - If unsure, do not remove the tag.\n\n - **Adding Tags:**\n - Use the exact wording and formatting provided in the instruction for new tags. Do not modify, reformat, or adjust them in any way. This is critical.\n - Ensure that the final list does not exceed **10 tags**. If adding a tag would exceed this limit, do not add it and clarify this in the \"explanation\".\n - If a tag exceeds **100 characters**, do not add it and state this in the \"explanation\".\n - Ensure all tags remain **unique** (no duplicates).\n - The updated list should first retain all unchanged tags, followed by any new additions.\n\n - **Unaffected Tags:**\n - Tags that are not affected by the modification instructions must remain unchanged, including spacing and formatting.\n\n 3. **Generate Output**\n - Return a JSON object containing:\n - \"updatedTags\": The final array of tags after modifications.\n - \"explanation\": A single, concise sentence summarizing all tag modifications, including the reasoning behind changes or lack thereof. Do not include statements about the total number of tags.\n\n ### Input\n existingTags: {existingTags}\n instructions: {instructions}\n">, any>;
@@ -3,20 +3,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.systemPrompt = void 0;
4
4
  const prompts_1 = require("@langchain/core/prompts");
5
5
  exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
6
- You are a clinical data manager. You will receive a list (array) of patient tags for a single patient and instructions about which tags to add, update, or remove. These tags are used to assign particular attributes to patients which can help with patient care, like grouping of patients, categorizing patients for reporting, or identifying patients for care.
7
-
8
- Important instructions:
9
- - The maximum number of tags is 10.
10
- - The max length of a single tag is 100 characters.
11
- - Ensure tags are unique.
6
+ You are a clinical data manager with expert knowledge of Elation Patient Tags, which help care teams organize patient care (e.g., grouping, reporting, or identifying patients for care).
12
7
 
8
+ Your task is to manage a single patient's tags based on the provided instructions.
13
9
 
14
- Input array: {existingTags}
15
- Instruction: {prompt}
10
+ You will receive:
11
+ - existing_tags: An array of the patient's current tags.
12
+ - instruction: A directive specifying which tags to add, update, or remove. Ensure to follow them diligently.
16
13
 
14
+ ### Step-by-Step Approach:
15
+ 1. **Review the Instruction**
16
+ - Identify the required tag modifications: additions, updates, or removals.
17
17
 
18
- Output a JSON object with two keys:
19
- 1. updatedTags: The updated array of tags. If the input array is empty, the output should be an empty array.
20
- 2. explanation: A readable explanation of the changes made to the tags and why
18
+ 2. **Apply Modifications**
19
+ - **Removing Tags:**
20
+ - Only remove tags if explicitly stated in the instruction.
21
+ - Match existing tags for removal, allowing minor variations (e.g., capitalization, spacing).
22
+ - If unsure, do not remove the tag.
23
+
24
+ - **Adding Tags:**
25
+ - Use the exact wording and formatting provided in the instruction for new tags. Do not modify, reformat, or adjust them in any way. This is critical.
26
+ - Ensure that the final list does not exceed **10 tags**. If adding a tag would exceed this limit, do not add it and clarify this in the "explanation".
27
+ - If a tag exceeds **100 characters**, do not add it and state this in the "explanation".
28
+ - Ensure all tags remain **unique** (no duplicates).
29
+ - The updated list should first retain all unchanged tags, followed by any new additions.
30
+
31
+ - **Unaffected Tags:**
32
+ - Tags that are not affected by the modification instructions must remain unchanged, including spacing and formatting.
33
+
34
+ 3. **Generate Output**
35
+ - Return a JSON object containing:
36
+ - "updatedTags": The final array of tags after modifications.
37
+ - "explanation": A single, concise sentence summarizing all tag modifications, including the reasoning behind changes or lack thereof. Do not include statements about the total number of tags.
38
+
39
+ ### Input
40
+ existingTags: {existingTags}
41
+ instructions: {instructions}
21
42
  `);
22
43
  //# sourceMappingURL=prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;CAgB3D,CAAC,CAAA"}
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqC3D,CAAC,CAAA"}
@@ -20,14 +20,14 @@ const constants_1 = require("../../../../src/lib/llm/openai/constants");
20
20
  exports.updatePatientTags = {
21
21
  key: 'updatePatientTags',
22
22
  category: extensions_core_1.Category.EHR_INTEGRATIONS,
23
- title: '🪄 Update patient tags (Beta)',
23
+ title: '🪄 Update patient tags',
24
24
  description: 'Update patient tags in Elation.',
25
25
  fields: config_1.fields,
26
26
  previewable: false,
27
27
  dataPoints: config_1.dataPoints,
28
28
  onEvent: async ({ payload, onComplete, onError, helpers }) => {
29
29
  // 1. Validate input and initialize API client
30
- const { prompt, patientId } = config_1.FieldsValidationSchema.parse(payload.fields);
30
+ const { instructions, patientId } = config_1.FieldsValidationSchema.parse(payload.fields);
31
31
  const api = (0, client_1.makeAPIClient)(payload.settings);
32
32
  // 2. Get existing tags
33
33
  const { tags } = await api.getPatient(patientId);
@@ -43,7 +43,7 @@ exports.updatePatientTags = {
43
43
  const { validatedTags, explanation } = await (0, getTagsFromLLM_1.getTagsFromLLM)({
44
44
  model,
45
45
  existingTags,
46
- prompt,
46
+ instructions,
47
47
  metadata,
48
48
  callbacks
49
49
  });
@@ -53,6 +53,7 @@ exports.updatePatientTags = {
53
53
  await onComplete({
54
54
  data_points: {
55
55
  updatedTags: validatedTags.join(', '),
56
+ explanation,
56
57
  },
57
58
  events: [
58
59
  (0, addEventLog_1.addActivityEventLog)({
@@ -1 +1 @@
1
- {"version":3,"file":"updatePatientTags.js","sour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YACZ,MAAM;YACN,QAAQ;YACR,SAAS;SACV,CAAC,CAAA;QAEF,4BAA4B;QAC5B,MAAM,IAAA,8BAAiB,EAAC,GAAG,EAAE,SAAS,EAAE,aAAa,CAAC,CAAA;QAEtD,kCAAkC;QAClC,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;aACtC;YACD,MAAM,EAAE;gBACN,IAAA,iCAAmB,EAAC;oBAClB,OAAO,EAAE,0BAA0B,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,IAAG,CAAC,CAAC,CAAC,CAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,2BAA2B,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,WAAW,EAAE;iBACrL,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"updatePatientTags.js","sourceRoot":"","sources":["../../../../../extensions/elation/actions/updatePatientTags/updatePatientTags.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,uEAA2E;AAE3E,yCAA4C;AAC5C,qCAAqE;AACrE,6CAAgD;AAChD,wEAAoE;AACpE,wFAAoF;AACpF,wEAAwE;AAExE;;;;;;;GAOG;AACU,QAAA,iBAAiB,GAI1B;IACF,GAAG,EAAE,mBAAmB;IACxB,QAAQ,EAAE,0BAAQ,CAAC,gBAAgB;IACnC,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EAAE,iCAAiC;IAC9C,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,8CAA8C;QAC9C,MAAM,EAAE,YAAY,EAAE,SAA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E;iBACrL,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -4,8 +4,9 @@ exports.updateElationTags = void 0;
4
4
  const updateElationTags = async (api, patientId, tags) => {
5
5
  if (tags.length === 0) {
6
6
  await api.updatePatient(patientId, {
7
- // @ts-expect-error - elation api does not clear tags on an empty array
8
- tags: ' ',
7
+ // Note: Empty array doesn't clear tags, but [''] does by setting '' as a tag and clearing the rest (so it is not actually removing all tags but setting '' as a tag)
8
+ // This is also recommended workaround Elation team for clearing tags via API
9
+ tags: [''],
9
10
  });
10
11
  }
11
12
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"updateTags.js","sourceRoot":"","sources":["../../../../../extensions/elation/actions/updatePatientTags/updateTags.ts"],"names":[],"mappings":";;;AAEO,MAAM,iBAAiB,GAAG,KAAK,EAAE,GAAqB,EAAE,SAAiB,EAAE,IAAc,EAAiB,EAAE;IAC/G,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE;YACjC,uEAAuE;YACvE,IAAI,EAAE,GAAG;SACV,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE;YACjC,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAA;AAXU,QAAA,iBAAiB,qBAW3B"}
1
+ {"version":3,"file":"updateTags.js","sourceRoot":"","sources":["../../../../../extensions/elation/actions/updatePatientTags/updateTags.ts"],"names":[],"mappings":";;;AAEO,MAAM,iBAAiB,GAAG,KAAK,EAAE,GAAqB,EAAE,SAAiB,EAAE,IAAc,EAAiB,EAAE;IAC/G,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE;YACjC,qKAAqK;YACrK,6EAA6E;YAC7E,IAAI,EAAE,CAAC,EAAE,CAAC;SACX,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE;YACjC,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAA;AAZU,QAAA,iBAAiB,qBAY3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/awell-extensions",
3
- "version": "2.0.156",
3
+ "version": "2.0.157",
4
4
  "packageManager": "yarn@4.5.3",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": {
@@ -1,29 +0,0 @@
1
- import { z } from 'zod';
2
- import { StructuredOutputParser } from '@langchain/core/output_parsers';
3
- export declare const SingleTagSchema: z.ZodString;
4
- export declare const TagsSchema: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
5
- export declare const TagsOutputSchema: z.ZodObject<{
6
- updatedTags: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
7
- explanation: z.ZodString;
8
- }, "strip", z.ZodTypeAny, {
9
- updatedTags: string[];
10
- explanation: string;
11
- }, {
12
- updatedTags: string[];
13
- explanation: string;
14
- }>;
15
- export declare const parser: StructuredOutputParser<z.ZodObject<{
16
- updatedTags: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
17
- explanation: z.ZodString;
18
- }, "strip", z.ZodTypeAny, {
19
- updatedTags: string[];
20
- explanation: string;
21
- }, {
22
- updatedTags: string[];
23
- explanation: string;
24
- }>>;
25
- export type TagsOutput = z.infer<typeof TagsOutputSchema>;
26
- export interface TagsFromAI {
27
- validatedTags: string[];
28
- explanation: string;
29
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parser = exports.TagsOutputSchema = exports.TagsSchema = exports.SingleTagSchema = void 0;
4
- const zod_1 = require("zod");
5
- const output_parsers_1 = require("@langchain/core/output_parsers");
6
- exports.SingleTagSchema = zod_1.z.string().max(100).describe('A single tag');
7
- exports.TagsSchema = zod_1.z
8
- .array(exports.SingleTagSchema)
9
- .max(10)
10
- .refine((items) => new Set(items).size === items.length, {
11
- message: 'All items must be unique, no duplicate values allowed',
12
- })
13
- .describe('The updated array of tags');
14
- exports.TagsOutputSchema = zod_1.z.object({
15
- updatedTags: exports.TagsSchema,
16
- explanation: zod_1.z
17
- .string()
18
- .describe('A readable explanation of the changes made to the tags and why'),
19
- });
20
- exports.parser = output_parsers_1.StructuredOutputParser.fromZodSchema(exports.TagsOutputSchema);
21
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../extensions/elation/actions/updatePatientTags/config/types.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,mEAAuE;AAE1D,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;AAE9D,QAAA,UAAU,GAAG,OAAC;KACxB,KAAK,CAAC,uBAAe,CAAC;KACtB,GAAG,CAAC,EAAE,CAAC;KACP,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE;IACvD,OAAO,EAAE,uDAAuD;CACjE,CAAC;KACD,QAAQ,CAAC,2BAA2B,CAAC,CAAA;AAE3B,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,WAAW,EAAE,kBAAU;IACvB,WAAW,EAAE,OAAC;SACX,MAAM,EAAE;SACR,QAAQ,CAAC,gEAAgE,CAAC;CAChF,CAAC,CAAA;AAEW,QAAA,MAAM,GAAG,uCAAsB,CAAC,aAAa,CAAC,wBAAgB,CAAC,CAAA"}