@awell-health/awell-extensions 2.0.250 → 2.0.251
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/summarizeForm/summarizeForm.js +17 -1
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.js +19 -1
- package/dist/extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.js.map +1 -1
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.d.ts +16 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.evaluate.d.ts +1 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.evaluate.js +148 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.evaluate.js.map +1 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.js +29 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.js.map +1 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/index.d.ts +1 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/index.js +6 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/index.js.map +1 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/prompt.d.ts +2 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/prompt.js +22 -0
- package/dist/extensions/shelly/lib/detectLanguageWithLLM/prompt.js.map +1 -0
- package/dist/extensions/shelly/lib/summarizeFormWithLLM/prompt.d.ts +2 -2
- package/dist/extensions/shelly/lib/summarizeFormWithLLM/prompt.js +7 -7
- package/package.json +1 -1
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.summarizeForm = void 0;
|
4
4
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
5
|
const summarizeFormWithLLM_1 = require("../../lib/summarizeFormWithLLM");
|
6
|
+
const detectLanguageWithLLM_1 = require("../../lib/detectLanguageWithLLM");
|
6
7
|
const createOpenAIModel_1 = require("../../../../src/lib/llm/openai/createOpenAIModel");
|
7
8
|
const constants_1 = require("../../../../src/lib/llm/openai/constants");
|
8
9
|
const config_1 = require("./config");
|
@@ -60,12 +61,27 @@ exports.summarizeForm = {
|
|
60
61
|
else {
|
61
62
|
disclaimerMessage = `**Important Notice:** The content provided is an AI-generated summary of form responses of Care Flow "${careFlowDetails.title}" (ID: ${payload.pathway.id}).`;
|
62
63
|
}
|
64
|
+
let summaryLanguage = language;
|
65
|
+
if (language === 'Default') {
|
66
|
+
try {
|
67
|
+
summaryLanguage = await (0, detectLanguageWithLLM_1.detectLanguageWithLLM)({
|
68
|
+
model,
|
69
|
+
text: formData,
|
70
|
+
metadata,
|
71
|
+
callbacks,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
catch (error) {
|
75
|
+
// If language detection fails, keep using 'Default'
|
76
|
+
summaryLanguage = 'Default';
|
77
|
+
}
|
78
|
+
}
|
63
79
|
// 4. Generate summary
|
64
80
|
const summary = await (0, summarizeFormWithLLM_1.summarizeFormWithLLM)({
|
65
81
|
model,
|
66
82
|
formData,
|
67
83
|
summaryFormat,
|
68
|
-
language,
|
84
|
+
language: summaryLanguage,
|
69
85
|
disclaimerMessage,
|
70
86
|
additionalInstructions,
|
71
87
|
metadata,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"summarizeForm.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,yEAAqE;AACrE,wFAAoF;AACpF,wEAAwE;AACxE,qCAAqE;AACrE,uEAAmE;AACnE,qDAAsE;AACtE,iDAAsD;AACtD,qEAAiE;AACjE,mCAA8B;AAE9B;;;;;;;;GAQG;AACU,QAAA,aAAa,GAItB;IACF,GAAG,EAAE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,CAAC;QAC3B,IAAI,CAAC,IAAA,cAAK,EAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,iBAAiB,GAAG,sGAAsG,eAAe,CAAC,OAAO,kBAAkB,eAAe,CAAC,KAAK,UAAU,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;QAC3N,CAAC;aAAM,CAAC;YACN,iBAAiB,GAAG,yGAAyG,eAAe,CAAC,KAAK,UAAU,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;QACrL,CAAC;QAED,sBAAsB;QACtB,MAAM,OAAO,GAAG,MAAM,IAAA,2CAAoB,EAAC;YACzC,KAAK;YACL,QAAQ;YACR,aAAa;YACb,QAAQ;
|
1
|
+
{"version":3,"file":"summarizeForm.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,yEAAqE;AACrE,2EAAuE;AACvE,wFAAoF;AACpF,wEAAwE;AACxE,qCAAqE;AACrE,uEAAmE;AACnE,qDAAsE;AACtE,iDAAsD;AACtD,qEAAiE;AACjE,mCAA8B;AAE9B;;;;;;;;GAQG;AACU,QAAA,aAAa,GAItB;IACF,GAAG,EAAE,eAAe;IACpB,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,0DAA0D;IACvE,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,aAAa,EAAE,QAAQ,EAAE,sBAAsB,EAAE,GAAG,+BAAsB,CAAC,KAAK,CACtF,OAAO,CAAC,MAAM,CACf,CAAA;QAED,2CAA2C;QAC3C,MAAM,EAAE,KAAK,EAAE,QAAQ,EAA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6CAAqB,EAAC;oBAC5C,KAAK;oBACL,IAAI,EAAE,QAAQ;oBACd,QAAQ;oBACR,SAAS;iBACV,CAAC,CAAA;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,oDAAoD;gBACpD,eAAe,GAAG,SAAS,CAAA;YAC7B,CAAC;QACH,CAAC;QAED,sBAAsB;QACtB,MAAM,OAAO,GAAG,MAAM,IAAA,2CAAoB,EAAC;YACzC,KAAK;YACL,QAAQ;YACR,aAAa;YACb,QAAQ,EAAE,eAAe;YACzB,iBAAiB;YACjB,sBAAsB;YACtB,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;gBACX,OAAO,EAAE,WAAW;aACrB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
@@ -5,6 +5,7 @@ const extensions_core_1 = require("@awell-health/extensions-core");
|
|
5
5
|
const config_1 = require("./config");
|
6
6
|
const getFormResponseText_1 = require("../../lib/getFormResponseText");
|
7
7
|
const summarizeFormWithLLM_1 = require("../../lib/summarizeFormWithLLM");
|
8
|
+
const detectLanguageWithLLM_1 = require("../../lib/detectLanguageWithLLM");
|
8
9
|
const constants_1 = require("../../lib/constants");
|
9
10
|
const awell_1 = require("../../../../src/lib/awell");
|
10
11
|
const utils_1 = require("../../../../src/utils");
|
@@ -40,12 +41,29 @@ exports.summarizeFormsInStep = {
|
|
40
41
|
const { result: allFormsResponseText } = (0, getFormResponseText_1.getResponsesForAllForms)({
|
41
42
|
formsData,
|
42
43
|
});
|
44
|
+
// Determine which language to use for summarization
|
45
|
+
let summaryLanguage = language;
|
46
|
+
// If language is set to 'Default', detect the language
|
47
|
+
if (language === 'Default') {
|
48
|
+
try {
|
49
|
+
summaryLanguage = await (0, detectLanguageWithLLM_1.detectLanguageWithLLM)({
|
50
|
+
model,
|
51
|
+
text: allFormsResponseText,
|
52
|
+
metadata,
|
53
|
+
callbacks,
|
54
|
+
});
|
55
|
+
}
|
56
|
+
catch (error) {
|
57
|
+
// If language detection fails, fall back to 'Default'
|
58
|
+
summaryLanguage = 'Default';
|
59
|
+
}
|
60
|
+
}
|
43
61
|
// Summarize all forms' responses
|
44
62
|
const summary = await (0, summarizeFormWithLLM_1.summarizeFormWithLLM)({
|
45
63
|
model,
|
46
64
|
formData: allFormsResponseText,
|
47
65
|
summaryFormat,
|
48
|
-
language,
|
66
|
+
language: summaryLanguage,
|
49
67
|
disclaimerMessage: constants_1.DISCLAIMER_MSG_FORM,
|
50
68
|
metadata,
|
51
69
|
callbacks, // Add callbacks here
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"summarizeFormsInStep.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,qCAAqE;AACrE,uEAAuE;AACvE,yEAAqE;AACrE,mDAAyD;AACzD,qDAAoE;AACpE,iDAAsD;AACtD,2DAAkE;AAClE,wEAAwE;AAE3D,QAAA,oBAAoB,GAI7B;IACF,GAAG,EAAE,sBAAsB;IAC3B,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,2DAA2D;IACxE,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,2BAA2B;QAC3B,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,+BAAsB,CAAC,KAAK,CAC9D,OAAO,CAAC,MAAM,CACf,CAAA;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAE/B,6DAA6D;QAC7D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,0BAAiB,EAAC;YAC7D,QAAQ,EAAE,EAAE,EAAE,qCAAqC;YACnD,OAAO;YACP,OAAO;YACP,SAAS,EAAE,yBAAa,CAAC,KAAK;YAC9B,kBAAkB,EAAE,IAAI,EAAE,0CAA0C;SACrE,CAAC,CAAA;QAEF,sCAAsC;QACtC,MAAM,SAAS,GAAG,MAAM,IAAA,gCAAwB,EAAC;YAC/C,QAAQ,EAAE,MAAM,OAAO,CAAC,QAAQ,EAAE;YAClC,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;SAChC,CAAC,CAAA;QAEF,8BAA8B;QAC9B,MAAM,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,IAAA,6CAAuB,EAAC;YAC/D,SAAS;SACV,CAAC,CAAA;QAEF,iCAAiC;QACjC,MAAM,OAAO,GAAG,MAAM,IAAA,2CAAoB,EAAC;YACzC,KAAK;YACL,QAAQ,EAAE,oBAAoB;YAC9B,aAAa;YACb,QAAQ;
|
1
|
+
{"version":3,"file":"summarizeFormsInStep.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeFormsInStep/summarizeFormsInStep.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,qCAAqE;AACrE,uEAAuE;AACvE,yEAAqE;AACrE,2EAAuE;AACvE,mDAAyD;AACzD,qDAAoE;AACpE,iDAAsD;AACtD,2DAAkE;AAClE,wEAAwE;AAE3D,QAAA,oBAAoB,GAI7B;IACF,GAAG,EAAE,sBAAsB;IAC3B,QAAQ,EAAE,0BAAQ,CAAC,QAAQ;IAC3B,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,2DAA2D;IACxE,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,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AAG,MAAM,IAAA,2CAAoB,EAAC;YACzC,KAAK;YACL,QAAQ,EAAE,oBAAoB;YAC9B,aAAa;YACb,QAAQ,EAAE,eAAe;YACzB,iBAAiB,EAAE,+BAAmB;YACtC,QAAQ;YACR,SAAS,EAAE,qBAAqB;SACjC,CAAC,CAAA;QAEF,wDAAwD;QACxD,MAAM,WAAW,GAAG,MAAM,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAA;QAEjD,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,OAAO,EAAE,WAAW;aACrB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { type ChatOpenAI } from '@langchain/openai';
|
2
|
+
import { type AIActionMetadata } from '../../../../src/lib/llm/openai/types';
|
3
|
+
import type { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
4
|
+
/**
|
5
|
+
* Uses LLM to detect the language of a given text.
|
6
|
+
* The function follows these steps:
|
7
|
+
* 1. Formats prompt with the input text
|
8
|
+
* 2. Runs LLM to identify the language
|
9
|
+
* 3. Returns the full language name (e.g., "English", "Croatian")
|
10
|
+
*/
|
11
|
+
export declare const detectLanguageWithLLM: ({ model, text, metadata, callbacks, }: {
|
12
|
+
model: ChatOpenAI;
|
13
|
+
text: string;
|
14
|
+
metadata: AIActionMetadata;
|
15
|
+
callbacks?: BaseCallbackHandler[];
|
16
|
+
}) => Promise<string>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,148 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
/**
|
7
|
+
* LangSmith Evaluation Script for detectLanguageWithLLM
|
8
|
+
*
|
9
|
+
* Evaluates the function by:
|
10
|
+
* - Running test cases from LangSmith dataset
|
11
|
+
* - Checking if a language is detected
|
12
|
+
* - Generating evaluation reports
|
13
|
+
*
|
14
|
+
* Requirements:
|
15
|
+
* - Set environment variables in .env:
|
16
|
+
* - OPENAI_API_KEY
|
17
|
+
* - LANGSMITH_API_KEY
|
18
|
+
* - LANGSMITH_TRACING=true
|
19
|
+
* - LANGSMITH_PROJECT=ai-actions-local
|
20
|
+
*
|
21
|
+
* Usage:
|
22
|
+
* yarn ts-node extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.evaluate.ts
|
23
|
+
*
|
24
|
+
* Results can be viewed in LangSmith dashboard
|
25
|
+
*
|
26
|
+
* ⚠️ **Note:** This script does NOT run in CI/CD. It is meant for **manual evaluation** before merging PRs (for now)
|
27
|
+
*/
|
28
|
+
const langsmith_1 = require("langsmith");
|
29
|
+
const evaluation_1 = require("langsmith/evaluation");
|
30
|
+
const createOpenAIModel_1 = require("../../../../src/lib/llm/openai/createOpenAIModel");
|
31
|
+
const detectLanguageWithLLM_1 = require("./detectLanguageWithLLM");
|
32
|
+
const constants_1 = require("../../../../src/lib/llm/openai/constants");
|
33
|
+
const lodash_1 = require("lodash");
|
34
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
35
|
+
dotenv_1.default.config();
|
36
|
+
const langsmith = new langsmith_1.Client({
|
37
|
+
apiKey: process.env.LANGSMITH_API_KEY,
|
38
|
+
apiUrl: process.env.LANGSMITH_ENDPOINT,
|
39
|
+
});
|
40
|
+
// Define the dataset name
|
41
|
+
const datasetName = 'ai-actions-detect-language-shelly';
|
42
|
+
// Fetch the 'test' split examples from the dataset
|
43
|
+
const fetchTestExamples = async () => {
|
44
|
+
try {
|
45
|
+
const testExamples = langsmith.listExamples({
|
46
|
+
datasetName,
|
47
|
+
splits: ['test'],
|
48
|
+
});
|
49
|
+
const examples = [];
|
50
|
+
for await (const example of testExamples) {
|
51
|
+
if (!(0, lodash_1.isNil)(example.inputs)) {
|
52
|
+
// 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 check if language detection is accurate
|
64
|
+
const languageDetectionEvaluator = async ({ outputs, }) => {
|
65
|
+
const detectedLanguage = outputs === null || outputs === void 0 ? void 0 : outputs.detectedLanguage;
|
66
|
+
// Check if language is detected and not empty
|
67
|
+
const isDetected = typeof detectedLanguage === 'string' && detectedLanguage.trim().length > 0;
|
68
|
+
return {
|
69
|
+
key: 'language_detected',
|
70
|
+
score: isDetected ? 1 : 0,
|
71
|
+
metadata: {
|
72
|
+
detectedLanguage,
|
73
|
+
isDetected
|
74
|
+
}
|
75
|
+
};
|
76
|
+
};
|
77
|
+
// Wrapper function to adapt detectLanguageWithLLM for evaluation
|
78
|
+
const detectLanguageWithLLMWrapper = async (input) => {
|
79
|
+
const payload = {
|
80
|
+
activity: {
|
81
|
+
id: 'test-activity-id',
|
82
|
+
},
|
83
|
+
pathway: {
|
84
|
+
tenant_id: 'test-tenant',
|
85
|
+
definition_id: 'test-definition',
|
86
|
+
id: 'test-pathway',
|
87
|
+
org_slug: 'test-org',
|
88
|
+
org_id: 'test-org-id',
|
89
|
+
},
|
90
|
+
fields: {
|
91
|
+
text: input.text,
|
92
|
+
},
|
93
|
+
settings: {
|
94
|
+
openAiApiKey: process.env.OPENAI_API_KEY,
|
95
|
+
},
|
96
|
+
};
|
97
|
+
const helpers = {
|
98
|
+
getOpenAIConfig: () => {
|
99
|
+
const apiKey = process.env.OPENAI_API_KEY;
|
100
|
+
if ((0, lodash_1.isNil)(apiKey) || apiKey.trim() === '') {
|
101
|
+
throw new Error('OPENAI_API_KEY is required but not set');
|
102
|
+
}
|
103
|
+
return { apiKey };
|
104
|
+
},
|
105
|
+
};
|
106
|
+
const { model, metadata, callbacks } = await (0, createOpenAIModel_1.createOpenAIModel)({
|
107
|
+
settings: payload.settings,
|
108
|
+
helpers,
|
109
|
+
payload,
|
110
|
+
modelType: constants_1.OPENAI_MODELS.GPT4o,
|
111
|
+
});
|
112
|
+
const detectedLanguage = await (0, detectLanguageWithLLM_1.detectLanguageWithLLM)({
|
113
|
+
model,
|
114
|
+
text: input.text,
|
115
|
+
metadata,
|
116
|
+
callbacks,
|
117
|
+
});
|
118
|
+
return { detectedLanguage };
|
119
|
+
};
|
120
|
+
// Main function to run the evaluation and print results
|
121
|
+
const runEvaluation = async () => {
|
122
|
+
var _a, _b;
|
123
|
+
try {
|
124
|
+
console.log('📡 Fetching test dataset from LangSmith...');
|
125
|
+
const testExamples = await fetchTestExamples();
|
126
|
+
console.log(`✅ Loaded ${testExamples.length} test examples\n`);
|
127
|
+
console.log('🚀 Running evaluation...\n');
|
128
|
+
const results = await (0, evaluation_1.evaluate)(detectLanguageWithLLMWrapper, {
|
129
|
+
data: testExamples,
|
130
|
+
evaluators: [languageDetectionEvaluator],
|
131
|
+
experimentPrefix: 'DetectLanguageWithLLM Evaluation',
|
132
|
+
maxConcurrency: 8,
|
133
|
+
numRepetitions: 1,
|
134
|
+
});
|
135
|
+
const resultsArray = Array.isArray(results) ? results : [results];
|
136
|
+
const experimentId = (_b = (_a = resultsArray[0]) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.run_id;
|
137
|
+
console.log('\n✨ Experiment Run Complete! Actual evaluation is running in LangSmith via custom evaluator.');
|
138
|
+
console.log('View detailed results in LangSmith:');
|
139
|
+
console.log(`https://smith.langchain.com/runs/${experimentId}`);
|
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=detectLanguageWithLLM.evaluate.js.map
|
package/dist/extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.evaluate.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"detectLanguageWithLLM.evaluate.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.evaluate.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,yCAAgD;AAChD,qDAA+C;AAC/C,wFAAoF;AACpF,mEAA+D;AAC/D,wEAAwE;AACxE,mCAA8B;AAE9B,oDAA2B;AAC3B,gBAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,SAAS,GAAG,IAAI,kBAAM,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;IACrC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;CACvC,CAAC,CAAA;AAEF,0BAA0B;AAC1B,MAAM,WAAW,GAAG,mCAAmC,CAAA;AAiBvD,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,CAAA;QACF,MAAM,QAAQ,GAAc,EAAE,CAAA;QAC9B,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;YACzC,IAAI,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,sBAAsB;gBACtB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAA;QACvD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED,8DAA8D;AAC9D,MAAM,0BAA0B,GAAG,KAA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AO,CAAC,GAAG,CAAC,oCAAoC,YAAY,EAAE,CAAC,CAAA;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAA;QAClD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED,yBAAyB;AACzB,KAAK,aAAa,EAAE,CAAA"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.detectLanguageWithLLM = void 0;
|
4
|
+
const prompt_1 = require("./prompt");
|
5
|
+
/**
|
6
|
+
* Uses LLM to detect the language of a given text.
|
7
|
+
* The function follows these steps:
|
8
|
+
* 1. Formats prompt with the input text
|
9
|
+
* 2. Runs LLM to identify the language
|
10
|
+
* 3. Returns the full language name (e.g., "English", "Croatian")
|
11
|
+
*/
|
12
|
+
const detectLanguageWithLLM = async ({ model, text, metadata, callbacks, }) => {
|
13
|
+
const prompt = await prompt_1.systemPrompt.format({
|
14
|
+
input: text,
|
15
|
+
});
|
16
|
+
try {
|
17
|
+
const result = await model.invoke(prompt, {
|
18
|
+
metadata,
|
19
|
+
runName: 'ShellyDetectLanguage',
|
20
|
+
callbacks
|
21
|
+
});
|
22
|
+
return result.content;
|
23
|
+
}
|
24
|
+
catch (error) {
|
25
|
+
throw new Error('Failed to detect language');
|
26
|
+
}
|
27
|
+
};
|
28
|
+
exports.detectLanguageWithLLM = detectLanguageWithLLM;
|
29
|
+
//# sourceMappingURL=detectLanguageWithLLM.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"detectLanguageWithLLM.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/detectLanguageWithLLM/detectLanguageWithLLM.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAKvC;;;;;;GAMG;AACI,MAAM,qBAAqB,GAAG,KAAK,EAAE,EAC1C,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,GAMV,EAAmB,EAAE;IACpB,MAAM,MAAM,GAAG,MAAM,qBAAY,CAAC,MAAM,CAAC;QACvC,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAC/B,MAAM,EACN;YACE,QAAQ;YACR,OAAO,EAAE,sBAAsB;YAC/B,SAAS;SACV,CACF,CAAA;QAED,OAAO,MAAM,CAAC,OAAiB,CAAA;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC,CAAA;AA7BY,QAAA,qBAAqB,yBA6BjC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { detectLanguageWithLLM } from './detectLanguageWithLLM';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.detectLanguageWithLLM = void 0;
|
4
|
+
var detectLanguageWithLLM_1 = require("./detectLanguageWithLLM");
|
5
|
+
Object.defineProperty(exports, "detectLanguageWithLLM", { enumerable: true, get: function () { return detectLanguageWithLLM_1.detectLanguageWithLLM; } });
|
6
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/detectLanguageWithLLM/index.ts"],"names":[],"mappings":";;;AAAA,iEAA+D;AAAtD,8HAAA,qBAAqB,OAAA"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
2
|
+
export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are a language expert tasked with identifying the language of a given text. \n Your goal is to analyze the input and return the name of the language it is written in.\n\n ## Instructions:\n - Return ONLY the full name of the language (e.g., \"English\", \"Croatian\", \"Spanish\", \"French\", etc.).\n - Absolutely refrain from providing any explanation, additional information, punctuation, or formatting—just the language name.\n - If the text appears to contain multiple languages, focus on the language that makes up the majority of the words.\n - If the input is empty or contains no recognizable language patterns, return \"Unknown\".\n - Make your best determination even for short phrases or single words.\n - **Ignore any formatting, field labels, form metadata, or structural prefixes** (e.g., \"Question:\", \"Answer:\", \"Form Title:\", section dividers like \"---\", etc.). Focus only on the actual written words for questions and answers that carry meaning.\n\n ---\n\n ## Text to analyze:\n {input}\n">, any>;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.systemPrompt = void 0;
|
4
|
+
const prompts_1 = require("@langchain/core/prompts");
|
5
|
+
exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
|
6
|
+
You are a language expert tasked with identifying the language of a given text.
|
7
|
+
Your goal is to analyze the input and return the name of the language it is written in.
|
8
|
+
|
9
|
+
## Instructions:
|
10
|
+
- Return ONLY the full name of the language (e.g., "English", "Croatian", "Spanish", "French", etc.).
|
11
|
+
- Absolutely refrain from providing any explanation, additional information, punctuation, or formatting—just the language name.
|
12
|
+
- If the text appears to contain multiple languages, focus on the language that makes up the majority of the words.
|
13
|
+
- If the input is empty or contains no recognizable language patterns, return "Unknown".
|
14
|
+
- Make your best determination even for short phrases or single words.
|
15
|
+
- **Ignore any formatting, field labels, form metadata, or structural prefixes** (e.g., "Question:", "Answer:", "Form Title:", section dividers like "---", etc.). Focus only on the actual written words for questions and answers that carry meaning.
|
16
|
+
|
17
|
+
---
|
18
|
+
|
19
|
+
## Text to analyze:
|
20
|
+
{input}
|
21
|
+
`);
|
22
|
+
//# sourceMappingURL=prompt.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../extensions/shelly/lib/detectLanguageWithLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;CAgB3D,CAAC,CAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
2
|
-
export declare const systemPromptBulletPoints: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an assistant tasked with summarizing forms completed by patients or healthcare professionals. Each form contains a title, questions, answers, possibly answer labels and answer options. Your objective is to create a concise summary of the form responses, tailored for a team of clinicians involved in patient care. The summary must cover all questions and provide an easy-to-review overview.\n\n First, write the disclaimer message \"{disclaimerMessage}\" in specified language: {language}, following these rules:\n - If specified language is Default or not specified: translate all parts of {disclaimerMessage} into the language of the form. If you cannot determine language use English.\n - If specified language is other than Default (French, Spanish, bosnian, ...): translate
|
3
|
-
export declare const systemPromptTextParagraph: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an assistant tasked with summarizing forms completed by patients or healthcare professionals. Each form contains a title, questions, answers, answer labels, and possible answer options. Your objective is to create a concise summary of the form responses, tailored for a team of clinicians involved in patient care. The summary must provide an easy-to-review overview.\n\n First, write the disclaimer message \"{disclaimerMessage}\" in specified language: {language}, following these rules:\n - If specified language is Default or not specified: translate all parts of {disclaimerMessage} into the language of the form. If you cannot determine language use English.\n - If specified language is other than Default (French, Spanish, bosnian, ...): translate
|
2
|
+
export declare const systemPromptBulletPoints: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an assistant tasked with summarizing forms completed by patients or healthcare professionals. Each form contains a title, questions, answers, possibly answer labels and answer options. Your objective is to create a concise summary of the form responses, tailored for a team of clinicians involved in patient care. The summary must cover all questions and provide an easy-to-review overview.\n\n First, write the disclaimer message \"{disclaimerMessage}\" in specified language: {language}, following these rules:\n - If specified language is Default or not specified: translate all parts of {disclaimerMessage} into the language of the form. If you cannot determine language use English.\n - If specified language is other than Default (French, Spanish, bosnian, ...): translate ALL parts of {disclaimerMessage} into specified language: {language}, including ANY heading text such as \"Important Notice\" which MUST be translated too. It is critical that the entire disclaimer message is written in the same language as specified language: {language} without any English words remaining.\n For example if the disclaimer message is \"**Important Notice:** The content provided is an AI-generated summary.\" and specified language is Spanish, the disclaimer message in Spanish would be \"**Aviso Importante:** El contenido proporcionado es un resumen generado por IA de las respuestas del formulario\".\n If the specified language is French than the same disclaimer message should be: \"**Avis Important :** Le contenu fourni est un résumé généré par IA des réponses du formulario\".\n Then add two new lines after the disclaimer message.\n\n Then adhere strictly to these step-by-step instructions:\n 1. **Begin the summary with the form title if available.**\n - Use title as is without alteration. Format is as title. \n - Then add an empty line for separation. \n\n - *For example:*\n - **General Health Questionnaire**\n - *Empty Line*\n \n 2. **Identify all questions and their corresponding answers.**\n\n 3. **Structure the summary using bullet points in clear and correct Markdown format:**\n\n - Use the format: `• **Question** - Answer`\n - **Ensure the answer is informative:**\n - For multiple-choice questions where the raw answer may be a code (e.g., 0, 1) that lacks meaning on its own, use the associated **answer label** instead.\n - For other questions, use the raw answer if it is clear and informative.\n\n 4. **Enhance conciseness and readability:**\n\n - **Shorten lengthy questions and answers to their essential meaning for easier inspection, while preserving all essential context.**\n - *For example:*\n - **Before**: \"Can you describe the nature of your back pain?\"\n - **After**: \"Nature of back pain\"\n - **Before**: \"Please list any medications you are currently taking, including dosages and frequency.\"\n - **After**: \"Current medications (dosage and frequency)\"\n - **Before**: \"Have you experienced any side effects from your current treatment in the last 3 months?\"\n - **After**: \"Side effects from current treatment in the last 3 months\"\n - **Avoid omitting any key information** that might alter the meaning. It is critical to preserve all time frames (e.g., \"last week,\" \"yesterday\") and specific details (e.g., \"right leg,\" \"morning\").\n\n 5. **If there are multiple forms provided, add a new line and proceed with the next form.**\n\n **Important Notes:**\n\n - Absolutely refrain from making any suggestions, interpretations, or provide additional comments.\n\n **Style and Format Guidelines:**\n\n - Use **professional and informative language**, avoiding colloquialisms and overly technical terms.\n - Ensure the summary is **clear**, **concise**, and **easy to read**.\n\n **Language:**\n\n - It is critical to summarize in the language specified below. If Default or not specified, use the language of the form.\n\n **Specified Language:**\n\n {language}\n\n **Additional Instructions:**\n {additionalInstructions}\n\n ---\n\n **Content to Summarize:**\n\n {input}\n">, any>;
|
3
|
+
export declare const systemPromptTextParagraph: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are an assistant tasked with summarizing forms completed by patients or healthcare professionals. Each form contains a title, questions, answers, answer labels, and possible answer options. Your objective is to create a concise summary of the form responses, tailored for a team of clinicians involved in patient care. The summary must provide an easy-to-review overview.\n\n First, write the disclaimer message \"{disclaimerMessage}\" in specified language: {language}, following these rules:\n - If specified language is Default or not specified: translate all parts of {disclaimerMessage} into the language of the form. If you cannot determine language use English.\n - If specified language is other than Default (French, Spanish, bosnian, ...): translate ALL parts of {disclaimerMessage} into specified language: {language}, including ANY heading text such as \"Important Notice\" which MUST be translated too. It is critical that the entire disclaimer message is written in the same language as specified language: {language} without any English words remaining.\n For example if the disclaimer message is \"**Important Notice:** The content provided is an AI-generated summary.\" and specified language is Spanish, the disclaimer message in Spanish would be \"**Aviso Importante:** El contenido proporcionado es un resumen generado por IA de las respuestas del formulario\".\n If the specified language is French than the same disclaimer message should be: \"**Avis Important :** Le contenu fourni est un résumé généré par IA des réponses du formulario\".\n Then add two new lines after the disclaimer message.\n \n Then adhere strictly to these step-by-step instructions:\n\n 1. **Begin the summary with the form title if available.**\n - Use title as is without alteration. Format is as title. \n - Then add an empty line for separation. \n\n - *For example:*\n - **General Health Questionnaire**\n - *Empty Line*\n\n 2. **Identify all questions and their corresponding answers.**\n\n 3. **Compose the summary as an informative, easy-to-read paragraph:**\n\n - Cover all important aspects of the responses.\n - Ensure the summary is **concise** and **to the point** while preserving all essential information.\n - **Write everything in one paragraph**, maintaining a logical flow of information.\n - For multiple-choice questions where the raw answer may be a code (e.g., 0, 1) that lacks meaning on its own, use the associated **answer label** instead. \n\n\n **Important Notes:**\n\n - Do not make any conclusions, suggestions, interpretations, or provide additional comments. Only summarize the information provided in the form.\n\n **Style and Format Guidelines:**\n\n - Use **professional and informative language**, avoiding colloquialisms and overly technical terms.\n - Ensure the summary is **clear**, **concise**, and **easy to read**.\n\n **Language:**\n\n - It is critical to summarize in the language specified below. If Default or not specified, use the language of the form.\n\n **Specified Language:**\n\n {language}\n\n **Additional Instructions:**\n {additionalInstructions}\n\n ---\n\n **Content to Summarize:**\n\n {input}\n">, any>;
|
@@ -7,9 +7,9 @@ exports.systemPromptBulletPoints = prompts_1.ChatPromptTemplate.fromTemplate(`
|
|
7
7
|
|
8
8
|
First, write the disclaimer message "{disclaimerMessage}" in specified language: {language}, following these rules:
|
9
9
|
- If specified language is Default or not specified: translate all parts of {disclaimerMessage} into the language of the form. If you cannot determine language use English.
|
10
|
-
- If specified language is other than Default (French, Spanish, bosnian, ...): translate
|
11
|
-
For example if the disclaimer message is "Important Notice
|
12
|
-
If the specified language is French than the same disclaimer message should be: "Avis Important
|
10
|
+
- If specified language is other than Default (French, Spanish, bosnian, ...): translate ALL parts of {disclaimerMessage} into specified language: {language}, including ANY heading text such as "Important Notice" which MUST be translated too. It is critical that the entire disclaimer message is written in the same language as specified language: {language} without any English words remaining.
|
11
|
+
For example if the disclaimer message is "**Important Notice:** The content provided is an AI-generated summary." and specified language is Spanish, the disclaimer message in Spanish would be "**Aviso Importante:** El contenido proporcionado es un resumen generado por IA de las respuestas del formulario".
|
12
|
+
If the specified language is French than the same disclaimer message should be: "**Avis Important :** Le contenu fourni est un résumé généré par IA des réponses du formulario".
|
13
13
|
Then add two new lines after the disclaimer message.
|
14
14
|
|
15
15
|
Then adhere strictly to these step-by-step instructions:
|
@@ -75,9 +75,9 @@ exports.systemPromptTextParagraph = prompts_1.ChatPromptTemplate.fromTemplate(`
|
|
75
75
|
|
76
76
|
First, write the disclaimer message "{disclaimerMessage}" in specified language: {language}, following these rules:
|
77
77
|
- If specified language is Default or not specified: translate all parts of {disclaimerMessage} into the language of the form. If you cannot determine language use English.
|
78
|
-
- If specified language is other than Default (French, Spanish, bosnian, ...): translate
|
79
|
-
For example if the disclaimer message is "Important Notice
|
80
|
-
If the specified language is French than the same disclaimer message should be: "Avis Important
|
78
|
+
- If specified language is other than Default (French, Spanish, bosnian, ...): translate ALL parts of {disclaimerMessage} into specified language: {language}, including ANY heading text such as "Important Notice" which MUST be translated too. It is critical that the entire disclaimer message is written in the same language as specified language: {language} without any English words remaining.
|
79
|
+
For example if the disclaimer message is "**Important Notice:** The content provided is an AI-generated summary." and specified language is Spanish, the disclaimer message in Spanish would be "**Aviso Importante:** El contenido proporcionado es un resumen generado por IA de las respuestas del formulario".
|
80
|
+
If the specified language is French than the same disclaimer message should be: "**Avis Important :** Le contenu fourni est un résumé généré par IA des réponses du formulario".
|
81
81
|
Then add two new lines after the disclaimer message.
|
82
82
|
|
83
83
|
Then adhere strictly to these step-by-step instructions:
|
@@ -111,7 +111,7 @@ exports.systemPromptTextParagraph = prompts_1.ChatPromptTemplate.fromTemplate(`
|
|
111
111
|
|
112
112
|
**Language:**
|
113
113
|
|
114
|
-
|
114
|
+
- It is critical to summarize in the language specified below. If Default or not specified, use the language of the form.
|
115
115
|
|
116
116
|
**Specified Language:**
|
117
117
|
|