@cellaware/utils 3.0.11 → 3.0.13
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/llm/chain-store.d.ts +8 -1
- package/dist/llm/chain-store.js +11 -4
- package/dist/util.d.ts +0 -8
- package/dist/util.js +0 -63
- package/package.json +1 -1
|
@@ -35,7 +35,14 @@ export declare class ChainStore {
|
|
|
35
35
|
private initBuiltinChains;
|
|
36
36
|
private static getTokenUsage;
|
|
37
37
|
private getPrompt;
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* - `name`: Chain name
|
|
40
|
+
* - `modelName`: OpenAI model name
|
|
41
|
+
* - `temperature`: OpenAI model temperature
|
|
42
|
+
* - `verbose`: OpenAI verbose parameter
|
|
43
|
+
* - `templateName`: Template chain name to copy prompt from
|
|
44
|
+
*/
|
|
45
|
+
addChain(name: string, modelName: ModelName, temperature?: number, verbose?: boolean, templateName?: string): void;
|
|
39
46
|
addExistingChain(chain: SingleActionChain): void;
|
|
40
47
|
callChain(name: string, args: any, tokenUsages: any[]): Promise<import("langchain/dist/schema/index.js").ChainValues>;
|
|
41
48
|
translate(statement: string, language: string, tokenUsages?: any[]): Promise<string>;
|
package/dist/llm/chain-store.js
CHANGED
|
@@ -156,12 +156,12 @@ Your translation here:
|
|
|
156
156
|
cost: getLLMTransactionCost(tokenUsage, modelName)
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
getPrompt(chainName) {
|
|
159
|
+
getPrompt(chainName, templateChainName) {
|
|
160
160
|
let prompt = {
|
|
161
161
|
content: '',
|
|
162
162
|
variables: []
|
|
163
163
|
};
|
|
164
|
-
const path = `${this.promptsPath}/${chainName}.md`;
|
|
164
|
+
const path = !!templateChainName ? `${this.promptsPath}/${templateChainName}.md` : `${this.promptsPath}/${chainName}.md`;
|
|
165
165
|
if (!fs.existsSync(path)) {
|
|
166
166
|
throw new Error(`CHAIN_STORE: Prompt file '${path}' not found`);
|
|
167
167
|
}
|
|
@@ -182,8 +182,15 @@ Your translation here:
|
|
|
182
182
|
prompt.variables = Array.from(distinctMatches);
|
|
183
183
|
return prompt;
|
|
184
184
|
}
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
/**
|
|
186
|
+
* - `name`: Chain name
|
|
187
|
+
* - `modelName`: OpenAI model name
|
|
188
|
+
* - `temperature`: OpenAI model temperature
|
|
189
|
+
* - `verbose`: OpenAI verbose parameter
|
|
190
|
+
* - `templateName`: Template chain name to copy prompt from
|
|
191
|
+
*/
|
|
192
|
+
addChain(name, modelName, temperature, verbose, templateName) {
|
|
193
|
+
const prompt = this.getPrompt(name, templateName);
|
|
187
194
|
const llm = new ChatOpenAI({
|
|
188
195
|
modelName, temperature: temperature ?? 0, configuration: {
|
|
189
196
|
organization: process.env.OPENAI_ORGANIZATION,
|
package/dist/util.d.ts
CHANGED
|
@@ -7,11 +7,3 @@ export declare function getCurrentDayInMonth(): number;
|
|
|
7
7
|
export declare function getDaysInYear(): 366 | 365;
|
|
8
8
|
export declare function getCurrentMonth(): number;
|
|
9
9
|
export declare function getCurrentYear(): number;
|
|
10
|
-
export interface DataColDef {
|
|
11
|
-
name: string;
|
|
12
|
-
number: boolean;
|
|
13
|
-
date: boolean;
|
|
14
|
-
bool: boolean;
|
|
15
|
-
locked: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare function getDataSignature(rowData: any[], checkRowCnt?: number): DataColDef[];
|
package/dist/util.js
CHANGED
|
@@ -47,66 +47,3 @@ export function getCurrentYear() {
|
|
|
47
47
|
let date = new Date();
|
|
48
48
|
return date.getFullYear();
|
|
49
49
|
}
|
|
50
|
-
export function getDataSignature(rowData, checkRowCnt) {
|
|
51
|
-
let dataColDefs = [];
|
|
52
|
-
if (rowData === null || rowData.length === 0) {
|
|
53
|
-
return dataColDefs;
|
|
54
|
-
}
|
|
55
|
-
const cols = Object.keys(rowData[0]);
|
|
56
|
-
for (const col of cols) {
|
|
57
|
-
dataColDefs.push({ name: col, number: false, date: false, bool: false, locked: false });
|
|
58
|
-
}
|
|
59
|
-
let rowIdx = 0;
|
|
60
|
-
const _checkRowCnt = checkRowCnt ?? 5;
|
|
61
|
-
for (const row of rowData) {
|
|
62
|
-
if (rowIdx >= _checkRowCnt) {
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
let colIdx = 0;
|
|
66
|
-
for (const col in row) {
|
|
67
|
-
const val = row[col];
|
|
68
|
-
const valStr = new String(val);
|
|
69
|
-
const valStrLowerCase = valStr.toLowerCase();
|
|
70
|
-
if (!!dataColDefs[colIdx] && !dataColDefs[colIdx].locked) {
|
|
71
|
-
if (isNaN(val)) {
|
|
72
|
-
dataColDefs[colIdx].number = false;
|
|
73
|
-
if (val == null) {
|
|
74
|
-
// If is null, keep looking.
|
|
75
|
-
dataColDefs[colIdx].locked = false;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
dataColDefs[colIdx].locked = true;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (val instanceof Date) {
|
|
83
|
-
dataColDefs[colIdx].date = true;
|
|
84
|
-
dataColDefs[colIdx].number = false;
|
|
85
|
-
dataColDefs[colIdx].locked = true;
|
|
86
|
-
}
|
|
87
|
-
else if (valStrLowerCase == 'true' || valStrLowerCase == 'false') {
|
|
88
|
-
dataColDefs[colIdx].bool = true;
|
|
89
|
-
dataColDefs[colIdx].number = false;
|
|
90
|
-
dataColDefs[colIdx].locked = true;
|
|
91
|
-
}
|
|
92
|
-
else if (valStr.startsWith('0') && valStr.trim().length > 1 && !valStr.startsWith('0.')) {
|
|
93
|
-
dataColDefs[colIdx].number = false;
|
|
94
|
-
dataColDefs[colIdx].locked = true;
|
|
95
|
-
}
|
|
96
|
-
else if (valStr.trim().length >= 8) {
|
|
97
|
-
// I know this is a pretty small number, but generally we should not have larger numbers than 9,999,999 in this context.
|
|
98
|
-
dataColDefs[colIdx].number = false;
|
|
99
|
-
dataColDefs[colIdx].locked = true;
|
|
100
|
-
}
|
|
101
|
-
else if (val != null) {
|
|
102
|
-
dataColDefs[colIdx].number = true;
|
|
103
|
-
// Do not lock as number just yet -- keep looking.
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
colIdx++;
|
|
108
|
-
}
|
|
109
|
-
rowIdx++;
|
|
110
|
-
}
|
|
111
|
-
return dataColDefs;
|
|
112
|
-
}
|