medpromptjs 0.5.5 → 0.6.1
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/README.md +7 -5
- package/dist/agent.d.ts +2 -1
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +51 -0
- package/dist/agent.js.map +1 -0
- package/dist/chain.d.ts +1 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +120 -0
- package/dist/chain.js.map +1 -0
- package/dist/embedding.d.ts +1 -0
- package/dist/embedding.d.ts.map +1 -0
- package/dist/embedding.js +82 -0
- package/dist/embedding.js.map +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -0
- package/dist/llm.d.ts +1 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +147 -0
- package/dist/llm.js.map +1 -0
- package/dist/llm_loop.d.ts +1 -0
- package/dist/llm_loop.d.ts.map +1 -0
- package/dist/llm_loop.js +352 -0
- package/dist/llm_loop.js.map +1 -0
- package/dist/mydi.d.ts +1 -0
- package/dist/mydi.d.ts.map +1 -0
- package/dist/mydi.js +34 -0
- package/dist/mydi.js.map +1 -0
- package/dist/tool.d.ts +2 -1
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +69 -0
- package/dist/tool.js.map +1 -0
- package/package.json +43 -55
- package/dist/medpromptjs.cjs.development.js +0 -764
- package/dist/medpromptjs.cjs.development.js.map +0 -1
- package/dist/medpromptjs.cjs.production.min.js +0 -2
- package/dist/medpromptjs.cjs.production.min.js.map +0 -1
- package/dist/medpromptjs.esm.js +0 -755
- package/dist/medpromptjs.esm.js.map +0 -1
package/dist/llm_loop.js
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.LLMLoop = void 0;
|
|
37
|
+
const chain_1 = require("./chain");
|
|
38
|
+
const textsplitters_1 = require("@langchain/textsplitters");
|
|
39
|
+
const tslog_1 = require("tslog");
|
|
40
|
+
const log = new tslog_1.Logger();
|
|
41
|
+
class LLMLoop extends chain_1.BaseChain {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
// Implement the LLM loop logic here
|
|
45
|
+
this.stringExpression = '';
|
|
46
|
+
this._mapQueryTemplate = `
|
|
47
|
+
You are an assistant that can convert statements to a natural language query as in the example below.\n
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Statements: Visual foot exam in the last month. Visual foot exam showed active infection.
|
|
51
|
+
query: Did the patient have a visual foot exam in the last month? Is there any evidence of active infection?
|
|
52
|
+
Statements: {expression}
|
|
53
|
+
query: `;
|
|
54
|
+
this._mapDocTemplate = `
|
|
55
|
+
You will be given a document and few statements.\n
|
|
56
|
+
Extract facts from the document that are relevant to the statements.\n
|
|
57
|
+
Do not include any irrelevant information or context.\n
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
Example:\n
|
|
61
|
+
document: The patient is a 45-year-old male with a history of hypertension. He presented with chest pain and was diagnosed with myocardial infarction. He was treated with aspirin and beta-blockers.\n
|
|
62
|
+
statements: diagnosis of myocardial infarction. currently on beta-blockers.\n
|
|
63
|
+
facts: The patient was diagnosed with myocardial infarction and is currently on beta-blockers.\n
|
|
64
|
+
document: {document} \n
|
|
65
|
+
statements: {statements}\n
|
|
66
|
+
facts: `;
|
|
67
|
+
this._reduceChainTemplate = `
|
|
68
|
+
Say yes if the facts mentions all aspects of the query, else say no.\n
|
|
69
|
+
|
|
70
|
+
Example:
|
|
71
|
+
facts: Patient had a laproscopy 27 days back. The findings were normal. \n
|
|
72
|
+
query: Did the patient have a laproscopy this month?\n
|
|
73
|
+
answer: YES. The patient had a laproscopy 27 days back.\n
|
|
74
|
+
facts: The patient is a diabetic and hypertensive. He is on metformin and amlodipine. \n
|
|
75
|
+
query: Is the patient on heparin and metformin?\n
|
|
76
|
+
answer: NO. The patient is on heparin but not on metformin.\n
|
|
77
|
+
facts: A visual foot examination was performed 26 days ago to assess skin integrity, circulation, and structural abnormalities. The exam revealed normal skin condition, nail health, circulation, and absence of edema and deformities. However, there were signs of an active infection with erythema and swelling. \n
|
|
78
|
+
query: Did the patient have a visual foot exam in the last month? Is there any evidence of active infection?\n
|
|
79
|
+
answer: YES. The patient had a visual foot exam in the last month and there is evidence of active infection.\n
|
|
80
|
+
facts: A visual foot examination was performed 126 days ago to assess skin integrity, circulation, and structural abnormalities. The exam revealed normal skin condition, nail health, circulation, and absence of edema and deformities. However, there were signs of an active infection with erythema and swelling. \n
|
|
81
|
+
query: Did the patient have a visual foot exam in the last month? Is there any evidence of active infection?\n
|
|
82
|
+
answer: NO. The patient did not have a visual foot exam in the last month but there is evidence of active infection.\n
|
|
83
|
+
facts: {facts} \n
|
|
84
|
+
query: {query}\n
|
|
85
|
+
answer: `;
|
|
86
|
+
}
|
|
87
|
+
// Add getters and setters for the templates if needed
|
|
88
|
+
get mapQueryTemplate() {
|
|
89
|
+
return this._mapQueryTemplate;
|
|
90
|
+
}
|
|
91
|
+
set mapQueryTemplate(template) {
|
|
92
|
+
this._mapQueryTemplate = template;
|
|
93
|
+
}
|
|
94
|
+
get mapDocTemplate() {
|
|
95
|
+
return this._mapDocTemplate;
|
|
96
|
+
}
|
|
97
|
+
set mapDocTemplate(template) {
|
|
98
|
+
this._mapDocTemplate = template;
|
|
99
|
+
}
|
|
100
|
+
get reduceChainTemplate() {
|
|
101
|
+
return this._reduceChainTemplate;
|
|
102
|
+
}
|
|
103
|
+
set reduceChainTemplate(template) {
|
|
104
|
+
this._reduceChainTemplate = template;
|
|
105
|
+
}
|
|
106
|
+
async checkAssertion(expression, context) {
|
|
107
|
+
let _expression = '';
|
|
108
|
+
try {
|
|
109
|
+
// Check if expression is a valid JSON string
|
|
110
|
+
_expression = this.printValues(JSON.parse(expression));
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
_expression = expression; // If not, use the expression as is
|
|
114
|
+
}
|
|
115
|
+
log.info(`Checking assertion with expression: ${_expression}`);
|
|
116
|
+
// Initialize context and content
|
|
117
|
+
let _context = undefined;
|
|
118
|
+
let _content = '';
|
|
119
|
+
try {
|
|
120
|
+
_context = JSON.parse(context);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
_context = context; // If not, use the context as is
|
|
124
|
+
log.warn(`Context is not a valid JSON string: ${context}`);
|
|
125
|
+
log.warn(`Using context as a string: ${_context}`);
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
// Check if context is a valid JSON string
|
|
129
|
+
_context = JSON.parse(context);
|
|
130
|
+
_context.forEach((element) => {
|
|
131
|
+
element.content.forEach((contentItem) => {
|
|
132
|
+
_content += atob(contentItem.attachment.data.value);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
_content = context; // If not, use the context as is
|
|
138
|
+
log.warn(`Context is not a valid JSON : ${context}`);
|
|
139
|
+
log.warn(`Using context as a string: ${_content}`);
|
|
140
|
+
}
|
|
141
|
+
_content = this.findDatesAndConvertToTimeElapsed(_content.replace(/(\r\n|\n|\r)/gm, ' '));
|
|
142
|
+
log.info(`Checking assertion with context: ${_content}`);
|
|
143
|
+
const _input = {
|
|
144
|
+
input: {
|
|
145
|
+
expression: _expression,
|
|
146
|
+
context: _content,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
const result = await this.chain(_input);
|
|
150
|
+
log.info(`Assertion check result: ${result}`);
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
async checkMention(expression, context) {
|
|
154
|
+
if (expression && context)
|
|
155
|
+
return true; // Placeholder for assertion check logic
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
async checkNegation(expression, context) {
|
|
159
|
+
if (expression && context)
|
|
160
|
+
return true; // Placeholder for assertion check logic
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
findDatesAndConvertToTimeElapsed(text) {
|
|
164
|
+
// Regular expression to match dates in format of 'mm/dd/yyyy' or 'mm-dd-yyyy'
|
|
165
|
+
const dateRegex = /(\d{1,2}[-/]\d{1,2}[-/]\d{4})/g;
|
|
166
|
+
let matches;
|
|
167
|
+
const currentDate = new Date();
|
|
168
|
+
while ((matches = dateRegex.exec(text)) !== null) {
|
|
169
|
+
const date = new Date(matches[0]);
|
|
170
|
+
const timeElapsed = (currentDate.getTime() - date.getTime()) / (1000 * 60 * 60 * 24);
|
|
171
|
+
text = text.replace(matches[0], Math.floor(timeElapsed).toString() + ' days ago.');
|
|
172
|
+
}
|
|
173
|
+
return text;
|
|
174
|
+
}
|
|
175
|
+
camelToString(camelCase) {
|
|
176
|
+
return camelCase.replace(/([A-Z])/g, ' $1').replace(/^./, function (str) {
|
|
177
|
+
return str.toUpperCase();
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
stringToBoolean(str) {
|
|
181
|
+
log.info(`Converting string to boolean: ${str}`);
|
|
182
|
+
const positiveKeywords = [
|
|
183
|
+
'true',
|
|
184
|
+
'contains',
|
|
185
|
+
'confirms',
|
|
186
|
+
'yes',
|
|
187
|
+
'affirmative',
|
|
188
|
+
'matches',
|
|
189
|
+
'exists',
|
|
190
|
+
'present',
|
|
191
|
+
'absolutely',
|
|
192
|
+
'certainly',
|
|
193
|
+
'definitely',
|
|
194
|
+
'indeed',
|
|
195
|
+
'did have',
|
|
196
|
+
'showed',
|
|
197
|
+
'revealed',
|
|
198
|
+
];
|
|
199
|
+
const lowerStr = str.toLowerCase();
|
|
200
|
+
return positiveKeywords.some((keyword) => lowerStr.includes(keyword));
|
|
201
|
+
}
|
|
202
|
+
async textSplitter(text, chunkSize = 3900, chunkOverlap = 0) {
|
|
203
|
+
const textSplitter = new textsplitters_1.CharacterTextSplitter({
|
|
204
|
+
chunkSize: chunkSize,
|
|
205
|
+
chunkOverlap: chunkOverlap,
|
|
206
|
+
});
|
|
207
|
+
const texts = await textSplitter.splitText(text);
|
|
208
|
+
// Log the number of chunks created
|
|
209
|
+
if (texts.length === 0) {
|
|
210
|
+
log.warn('No text chunks created. Please check the input text.');
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
if (texts.length > 100) {
|
|
214
|
+
log.warn(`Warning: More than 100 text chunks created (${texts.length}). This may affect performance.`);
|
|
215
|
+
}
|
|
216
|
+
if (chunkSize < 1000) {
|
|
217
|
+
log.warn(`Warning: Chunk size is less than 1000 characters (${chunkSize}). This may lead to very small chunks.`);
|
|
218
|
+
}
|
|
219
|
+
log.info(`Text split into ${texts.length} chunks with size ${chunkSize} and overlap ${chunkOverlap}`);
|
|
220
|
+
return texts;
|
|
221
|
+
}
|
|
222
|
+
printValues(obj) {
|
|
223
|
+
log.info(`Processing Rule: ${obj.name} for ${obj.context}`);
|
|
224
|
+
// For each obj.expression:arg:where
|
|
225
|
+
if (obj.expression && obj.expression.arg && obj.expression.arg.where) {
|
|
226
|
+
// for each args in obj.expression.arg.where, extract the nested key called "value"
|
|
227
|
+
const statements = this.extractObjectsByKey(obj.expression.arg.where, 'value');
|
|
228
|
+
return statements.join(' ').replace(/,/g, ' ');
|
|
229
|
+
}
|
|
230
|
+
// return statements array as a string seperated by space
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
extractObjectsByKey(obj, key) {
|
|
234
|
+
const results = [];
|
|
235
|
+
function traverse(obj) {
|
|
236
|
+
for (const currentKey in obj) {
|
|
237
|
+
if (obj.hasOwnProperty(currentKey)) {
|
|
238
|
+
if (currentKey === key) {
|
|
239
|
+
results.push(obj[currentKey]);
|
|
240
|
+
}
|
|
241
|
+
if (typeof obj[currentKey] === 'object' && obj[currentKey] !== null) {
|
|
242
|
+
traverse(obj[currentKey]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
traverse(obj);
|
|
248
|
+
return results;
|
|
249
|
+
}
|
|
250
|
+
_printValues(obj) {
|
|
251
|
+
for (const key in obj) {
|
|
252
|
+
if (typeof obj[key] === 'object') {
|
|
253
|
+
this._printValues(obj[key]);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
this.stringExpression += obj[key] + ' ';
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const _eliminate = [
|
|
260
|
+
'true',
|
|
261
|
+
'false',
|
|
262
|
+
'null',
|
|
263
|
+
'undefined',
|
|
264
|
+
'String',
|
|
265
|
+
'Number',
|
|
266
|
+
'Object',
|
|
267
|
+
'Array',
|
|
268
|
+
'Boolean',
|
|
269
|
+
'value',
|
|
270
|
+
'Type',
|
|
271
|
+
'Specifier',
|
|
272
|
+
'Named',
|
|
273
|
+
];
|
|
274
|
+
_eliminate.forEach((element) => {
|
|
275
|
+
const regex = new RegExp(element, 'g');
|
|
276
|
+
this.stringExpression = this.stringExpression.replace(regex, '');
|
|
277
|
+
});
|
|
278
|
+
this.stringExpression = this.stringExpression.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '');
|
|
279
|
+
return this.camelToString(this.stringExpression);
|
|
280
|
+
}
|
|
281
|
+
async chain(input) {
|
|
282
|
+
// Create a chain using RunnableSequence, RunnablePassthrough and RunnableParallel
|
|
283
|
+
// input has two properties: expression and context
|
|
284
|
+
// expression goes through mapQuery and parallely
|
|
285
|
+
// context goes through textSplitter and mapDoc
|
|
286
|
+
// Finally reduceChain is called with the results of mapQuery and mapDoc
|
|
287
|
+
// LCEL-based implementation using RunnableSequence, RunnableParallel, and RunnablePassthrough
|
|
288
|
+
const { RunnableSequence, RunnableParallel, RunnablePassthrough } = await Promise.resolve().then(() => __importStar(require('@langchain/core/runnables')));
|
|
289
|
+
const mapQuery = new chain_1.BaseChain(this.container);
|
|
290
|
+
const mapDoc = new chain_1.BaseChain(this.container);
|
|
291
|
+
const reduceChain = new chain_1.BaseChain(this.container);
|
|
292
|
+
mapQuery.name = 'MapQuery';
|
|
293
|
+
mapQuery.description = 'Map the expression to a natural language query.';
|
|
294
|
+
mapQuery.template = this.resolve('litl_mapquery_template', this._mapQueryTemplate);
|
|
295
|
+
mapDoc.name = 'MapDoc';
|
|
296
|
+
mapDoc.description = 'Map the document to a set of facts.';
|
|
297
|
+
mapDoc.template = this.resolve('litl_mapdoc_template', this._mapDocTemplate);
|
|
298
|
+
reduceChain.name = 'ReduceChain';
|
|
299
|
+
reduceChain.description = 'Reduce a set of documents to binary answer.';
|
|
300
|
+
reduceChain.template = this.resolve('litl_reduce_chain_template', this._reduceChainTemplate);
|
|
301
|
+
const mapQueryChain = RunnablePassthrough.assign({
|
|
302
|
+
query: async (input) => mapQuery.chain({ expression: input.input.expression }),
|
|
303
|
+
});
|
|
304
|
+
const mapDocChain = RunnablePassthrough.assign({
|
|
305
|
+
documents: async (input) => {
|
|
306
|
+
const textChunks = await this.textSplitter(input.input.context);
|
|
307
|
+
return Promise.all(textChunks.map((chunk) => mapDoc.chain({
|
|
308
|
+
document: chunk,
|
|
309
|
+
statements: input.input.expression,
|
|
310
|
+
})));
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
const parallelChain = RunnableParallel.from([mapQueryChain, mapDocChain]);
|
|
314
|
+
const sequence = RunnableSequence.from([
|
|
315
|
+
parallelChain,
|
|
316
|
+
async (results) => {
|
|
317
|
+
/* results is an array: [{ query: ... }, { documents: [...] }]
|
|
318
|
+
{
|
|
319
|
+
"0": {
|
|
320
|
+
"input": {
|
|
321
|
+
"expression": "0 Visual foot exam showed active infection?",
|
|
322
|
+
"context": "Procedure: The patient underwent a visual foot examination on 26 days ago. to assess skin integrity, circulation, and structural abnormalities. Findings: - Skin Condition: No signs of dryness, cracking, or ulceration were observed. No abnormal lesions or discoloration present. - Nail Health: Toenails appeared intact with no evidence of fungal infection or ingrown nails. - Circulation: Normal coloration, with no signs of cyanosis or pallor. Capillary refill time within normal limits. - Edema: No visible swelling in the feet or ankles. - Deformities: No structural abnormalities such as bunions, hammertoes, or Charcot foot deformities noted. - Infections: Showed signs of active infection with erythema and swelling. - Sensation: No visible signs of neuropathy, though further testing may be required to assess sensory deficits. "
|
|
323
|
+
},
|
|
324
|
+
"query": "The text indicates a question about whether a visual foot exam revealed an active infection.\n"
|
|
325
|
+
},
|
|
326
|
+
"1": {
|
|
327
|
+
"input": {
|
|
328
|
+
"expression": "0 Visual foot exam showed active infection?",
|
|
329
|
+
"context": "Procedure: The patient underwent a visual foot examination on 26 days ago. to assess skin integrity, circulation, and structural abnormalities. Findings: - Skin Condition: No signs of dryness, cracking, or ulceration were observed. No abnormal lesions or discoloration present. - Nail Health: Toenails appeared intact with no evidence of fungal infection or ingrown nails. - Circulation: Normal coloration, with no signs of cyanosis or pallor. Capillary refill time within normal limits. - Edema: No visible swelling in the feet or ankles. - Deformities: No structural abnormalities such as bunions, hammertoes, or Charcot foot deformities noted. - Infections: Showed signs of active infection with erythema and swelling. - Sensation: No visible signs of neuropathy, though further testing may be required to assess sensory deficits. "
|
|
330
|
+
},
|
|
331
|
+
"documents": [
|
|
332
|
+
"26 days ago, a visual foot examination revealed no dryness, cracking, ulceration, lesions, discoloration, fungal infection, ingrown nails, cyanosis, pallor, edema, bunions, hammertoes, or Charcot foot deformities. Circulation and capillary refill were normal. However, the exam showed signs"
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
*/
|
|
337
|
+
log.info(`Results from parallel chain: ${JSON.stringify(results)}`);
|
|
338
|
+
const expression = results[0].input.expression;
|
|
339
|
+
const query = results[0].query;
|
|
340
|
+
const documents = results[1].documents;
|
|
341
|
+
return reduceChain.chain({
|
|
342
|
+
facts: documents,
|
|
343
|
+
query: query + ' ' + expression,
|
|
344
|
+
});
|
|
345
|
+
},
|
|
346
|
+
(result) => this.stringToBoolean(result),
|
|
347
|
+
]);
|
|
348
|
+
return sequence.invoke(input);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
exports.LLMLoop = LLMLoop;
|
|
352
|
+
//# sourceMappingURL=llm_loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm_loop.js","sourceRoot":"","sources":["../src/llm_loop.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAoC;AACpC,4DAAiE;AACjE,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;;;;;;;;;;;;GAcG;AAEH,QAAA,MAAM,IAAI,GAAI,GAAG,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,QAWzC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/mydi.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2024 Bell Eapen
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const mydi = (c, m, b) => {
|
|
19
|
+
try {
|
|
20
|
+
return c.resolve(m + '_' + b);
|
|
21
|
+
}
|
|
22
|
+
catch (e) { }
|
|
23
|
+
try {
|
|
24
|
+
return c.resolve(m + '-' + b);
|
|
25
|
+
}
|
|
26
|
+
catch (e) { }
|
|
27
|
+
try {
|
|
28
|
+
return c.resolve(b);
|
|
29
|
+
}
|
|
30
|
+
catch (e) { }
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
exports.default = mydi;
|
|
34
|
+
//# sourceMappingURL=mydi.js.map
|
package/dist/mydi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mydi.js","sourceRoot":"","sources":["../src/mydi.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,MAAM,IAAI,GAAG,CAAC,CAAM,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IAC5C,IAAI,CAAC;QACH,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACf,IAAI,CAAC;QACH,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;IACd,IAAI,CAAC;QACH,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;IACd,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
package/dist/tool.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { DynamicStructuredTool } from 'langchain/tools';
|
|
16
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
17
17
|
export declare class BaseTool extends DynamicStructuredTool {
|
|
18
18
|
/** @hidden */
|
|
19
19
|
container: any;
|
|
@@ -32,3 +32,4 @@ export declare class BaseTool extends DynamicStructuredTool {
|
|
|
32
32
|
*/
|
|
33
33
|
_batchWithConfig(input: any, config: any): Promise<any[]>;
|
|
34
34
|
}
|
|
35
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,qBAAa,QAAS,SAAQ,qBAAqB;IACjD,cAAc;IACd,SAAS,EAAE,GAAG,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,GAAG,CAAC;gBAEV,SAAS,EAAE,GAAG,EACd,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,GAAG,EACX,IAAI,GAAE,GAAU;IAelB,IAAI,GAAU,MAAM,GAAG,qBAErB;IAEF,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,QAAQ,CAAC,GAAG,EAAE,MAAM;IAQpB,UAAU,CAAC,GAAG,EAAE,MAAM;IAQtB;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;CAIhE"}
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2024 Bell Eapen
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.BaseTool = void 0;
|
|
22
|
+
const tools_1 = require("@langchain/core/tools");
|
|
23
|
+
const mydi_1 = __importDefault(require("./mydi"));
|
|
24
|
+
class BaseTool extends tools_1.DynamicStructuredTool {
|
|
25
|
+
constructor(container, name, description, schema, func = null) {
|
|
26
|
+
super({
|
|
27
|
+
name: name,
|
|
28
|
+
description: description,
|
|
29
|
+
schema: schema,
|
|
30
|
+
func: func,
|
|
31
|
+
});
|
|
32
|
+
this.func = async (args) => {
|
|
33
|
+
return 'override this';
|
|
34
|
+
};
|
|
35
|
+
this.container = container;
|
|
36
|
+
this.name = name === '' ? this.camelize(this.constructor.name) : name;
|
|
37
|
+
this.description =
|
|
38
|
+
description === '' ? this.snake_case(this.constructor.name) : description;
|
|
39
|
+
this.schema = schema;
|
|
40
|
+
}
|
|
41
|
+
resolve(name) {
|
|
42
|
+
return (0, mydi_1.default)(this.container, this.name, name);
|
|
43
|
+
}
|
|
44
|
+
camelize(str) {
|
|
45
|
+
return str
|
|
46
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
47
|
+
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
48
|
+
})
|
|
49
|
+
.replace(/\s+/g, '');
|
|
50
|
+
}
|
|
51
|
+
snake_case(str) {
|
|
52
|
+
return str
|
|
53
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
54
|
+
return index === 0 ? word.toLowerCase() : '_' + word.toLowerCase();
|
|
55
|
+
})
|
|
56
|
+
.replace(/\s+/g, '');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @param input - The input to process in batch.
|
|
60
|
+
* @param config - The configuration for the batch.
|
|
61
|
+
* @returns A promise resolving to an array of results.
|
|
62
|
+
*/
|
|
63
|
+
async _batchWithConfig(input, config) {
|
|
64
|
+
// Call the parent implementation or provide your own
|
|
65
|
+
return super._batchWithConfig(input, config);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.BaseTool = BaseTool;
|
|
69
|
+
//# sourceMappingURL=tool.js.map
|
package/dist/tool.js.map
ADDED
|
@@ -0,0 +1 @@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,CAAC,CAAC;aACD,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzB,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,OAAO,GAAG;aACP,OAAO,CAAC,qBAAqB,EAAE,UAAU,IAAI,EAAE,KAAK;YACnD,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACrE,CAAC,CAAC;aACD,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,KAAU,EAAE,MAAW;QAC5C,qDAAqD;QACrD,OAAO,KAAK,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF;AA3DD,4BA2DC"}
|
package/package.json
CHANGED
|
@@ -1,37 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "medpromptjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "A library of langchain base classes for building medical applications.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/dermatologist/medpromptjs.git"
|
|
8
|
+
},
|
|
5
9
|
"license": "Apache-2.0",
|
|
6
10
|
"author": "Bell Eapen",
|
|
7
11
|
"main": "dist/index.js",
|
|
8
|
-
"module": "dist/medpromptjs.mjs",
|
|
9
12
|
"typings": "dist/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/medpromptjs.esm.js",
|
|
14
|
-
"require": "./dist/index.js",
|
|
15
|
-
"default": "./dist/index.js"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
13
|
"files": [
|
|
19
14
|
"dist"
|
|
20
15
|
],
|
|
21
16
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"test": "dts test --coverage --verbose --testPathIgnorePatterns=./test/e2e/*",
|
|
29
|
-
"e2e": "dts test --verbose ./test/e2e --detectOpenHandles",
|
|
30
|
-
"docs": "typedoc --exclude src/tool.ts --html docs src"
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"lint": "eslint src --fix",
|
|
19
|
+
"prepare": "npm run build",
|
|
20
|
+
"test": "jest --coverage --verbose --testPathIgnorePatterns=./test/e2e/*",
|
|
21
|
+
"e2e": "jest --verbose ./test/e2e --detectOpenHandles",
|
|
22
|
+
"docs": "typedoc --exclude src/tool.ts --out docs src"
|
|
31
23
|
},
|
|
32
24
|
"husky": {
|
|
33
25
|
"hooks": {
|
|
34
|
-
"pre-commit": "
|
|
26
|
+
"pre-commit": "npm run lint"
|
|
35
27
|
}
|
|
36
28
|
},
|
|
37
29
|
"prettier": {
|
|
@@ -40,47 +32,43 @@
|
|
|
40
32
|
"singleQuote": true,
|
|
41
33
|
"trailingComma": "es5"
|
|
42
34
|
},
|
|
43
|
-
"jest": {
|
|
44
|
-
"testEnvironment": "node"
|
|
45
|
-
},
|
|
46
35
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
36
|
+
"node": ">=24"
|
|
48
37
|
},
|
|
49
|
-
"size-limit": [
|
|
50
|
-
{
|
|
51
|
-
"path": "dist/medpromptjs.cjs.production.min.js",
|
|
52
|
-
"limit": "10 KB"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"path": "dist/medpromptjs.esm.js",
|
|
56
|
-
"limit": "10 KB"
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
38
|
"devDependencies": {
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@types/
|
|
65
|
-
"
|
|
66
|
-
"
|
|
39
|
+
"@babel/core": "^7.29.13",
|
|
40
|
+
"@babel/preset-env": "^7.29.14",
|
|
41
|
+
"@babel/preset-typescript": "^7.29.7",
|
|
42
|
+
"@tsconfig/recommended": "^1.0.14",
|
|
43
|
+
"@types/cors": "^2.8.19",
|
|
44
|
+
"@types/express": "^5.0.6",
|
|
45
|
+
"@types/jest": "^29.5.14",
|
|
46
|
+
"@types/supertest": "^7.2.1",
|
|
47
|
+
"babel-jest": "^30.5.2",
|
|
48
|
+
"eslint": "^10.15.0",
|
|
49
|
+
"globals": "^17.14.0",
|
|
50
|
+
"google-auth-library": "^11.3.4",
|
|
67
51
|
"husky": "^9.1.7",
|
|
68
|
-
"
|
|
69
|
-
"supertest": "^7.
|
|
52
|
+
"jest": "^29.7.0",
|
|
53
|
+
"supertest": "^7.3.2",
|
|
54
|
+
"ts-jest": "^29.2.6",
|
|
70
55
|
"ts-mockito": "^2.6.1",
|
|
71
|
-
"tslib": "^2.
|
|
72
|
-
"typedoc": "^0.28.
|
|
73
|
-
"typescript": "^5.
|
|
56
|
+
"tslib": "^2.9.1",
|
|
57
|
+
"typedoc": "^0.28.20",
|
|
58
|
+
"typescript": "^5.9.3",
|
|
59
|
+
"typescript-eslint": "^8.73.0"
|
|
74
60
|
},
|
|
75
61
|
"dependencies": {
|
|
76
|
-
"@langchain/
|
|
77
|
-
"@langchain/
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
62
|
+
"@langchain/classic": "^1.0.62",
|
|
63
|
+
"@langchain/community": "^1.1.29",
|
|
64
|
+
"@langchain/core": "^1.5.0",
|
|
65
|
+
"@langchain/textsplitters": "^1.0.2",
|
|
66
|
+
"cors": "^2.8.6",
|
|
67
|
+
"dotenv": "^16.6.1",
|
|
68
|
+
"express": "^5.3.0",
|
|
69
|
+
"langchain": "^1.6.7",
|
|
70
|
+
"reflect-metadata": "^0.2.2",
|
|
71
|
+
"tslog": "^5.5.0",
|
|
72
|
+
"tsyringe": "^4.10.0"
|
|
85
73
|
}
|
|
86
74
|
}
|