@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.
@@ -35,7 +35,14 @@ export declare class ChainStore {
35
35
  private initBuiltinChains;
36
36
  private static getTokenUsage;
37
37
  private getPrompt;
38
- addChain(name: string, modelName: ModelName, temperature?: number, verbose?: boolean): void;
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>;
@@ -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
- addChain(name, modelName, temperature, verbose) {
186
- const prompt = this.getPrompt(name);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",