medpromptjs 0.4.2 → 0.4.4
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 +3 -2
- package/dist/medpromptjs.cjs.development.js +8 -10
- package/dist/medpromptjs.cjs.development.js.map +1 -1
- package/dist/medpromptjs.cjs.production.min.js +1 -1
- package/dist/medpromptjs.cjs.production.min.js.map +1 -1
- package/dist/medpromptjs.esm.js +8 -10
- package/dist/medpromptjs.esm.js.map +1 -1
- package/package.json +14 -16
- package/src/agent.ts +0 -144
- package/src/chain.ts +0 -127
- package/src/index.ts +0 -4
- package/src/llm_loop.ts +0 -357
- package/src/mydi.ts +0 -25
- package/src/tool.ts +0 -79
package/src/tool.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2024 Bell Eapen
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { DynamicStructuredTool } from 'langchain/tools';
|
|
18
|
-
import mydi from './mydi';
|
|
19
|
-
|
|
20
|
-
export class BaseTool extends DynamicStructuredTool {
|
|
21
|
-
/** @hidden */
|
|
22
|
-
container: any;
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
schema: any;
|
|
26
|
-
constructor(
|
|
27
|
-
container: any,
|
|
28
|
-
name: string,
|
|
29
|
-
description: string,
|
|
30
|
-
schema: any,
|
|
31
|
-
func: any = null
|
|
32
|
-
) {
|
|
33
|
-
super({
|
|
34
|
-
name: name,
|
|
35
|
-
description: description,
|
|
36
|
-
schema: schema,
|
|
37
|
-
func: func,
|
|
38
|
-
});
|
|
39
|
-
this.container = container;
|
|
40
|
-
this.name = name === '' ? this.camelize(this.constructor.name) : name;
|
|
41
|
-
this.description =
|
|
42
|
-
description === '' ? this.snake_case(this.constructor.name) : description;
|
|
43
|
-
this.schema = schema;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
func = async (args: any) => {
|
|
47
|
-
return 'override this';
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
resolve(name: string) {
|
|
51
|
-
return mydi(this.container, this.name, name);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
camelize(str: string) {
|
|
55
|
-
return str
|
|
56
|
-
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
57
|
-
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
58
|
-
})
|
|
59
|
-
.replace(/\s+/g, '');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
snake_case(str: string) {
|
|
63
|
-
return str
|
|
64
|
-
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
65
|
-
return index === 0 ? word.toLowerCase() : '_' + word.toLowerCase();
|
|
66
|
-
})
|
|
67
|
-
.replace(/\s+/g, '');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param input - The input to process in batch.
|
|
72
|
-
* @param config - The configuration for the batch.
|
|
73
|
-
* @returns A promise resolving to an array of results.
|
|
74
|
-
*/
|
|
75
|
-
async _batchWithConfig(input: any, config: any): Promise<any[]> {
|
|
76
|
-
// Call the parent implementation or provide your own
|
|
77
|
-
return super._batchWithConfig(input, config);
|
|
78
|
-
}
|
|
79
|
-
}
|