@cellaware/utils 3.0.12 → 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/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,
|