@promptbook/node 0.69.0-12 → 0.69.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.
@@ -47,6 +47,7 @@ import { isPassingExpectations } from '../execution/utils/checkExpectations';
47
47
  import { usageToHuman } from '../execution/utils/usageToHuman';
48
48
  import { usageToWorktime } from '../execution/utils/usageToWorktime';
49
49
  import { CsvFormatDefinition } from '../formats/csv/CsvFormatDefinition';
50
+ import { MANDATORY_CSV_SETTINGS } from '../formats/csv/CsvSettings';
50
51
  import { TextFormatDefinition } from '../formats/text/TextFormatDefinition';
51
52
  import { CallbackInterfaceTools } from '../knowledge/dialogs/callback/CallbackInterfaceTools';
52
53
  import type { CallbackInterfaceToolsOptions } from '../knowledge/dialogs/callback/CallbackInterfaceToolsOptions';
@@ -123,6 +124,7 @@ export { isPassingExpectations };
123
124
  export { usageToHuman };
124
125
  export { usageToWorktime };
125
126
  export { CsvFormatDefinition };
127
+ export { MANDATORY_CSV_SETTINGS };
126
128
  export { TextFormatDefinition };
127
129
  export { CallbackInterfaceTools };
128
130
  export type { CallbackInterfaceToolsOptions };
@@ -1,5 +1,13 @@
1
- import type { ParseConfig, UnparseConfig } from "papaparse";
1
+ import type { ParseConfig, UnparseConfig } from 'papaparse';
2
2
  /**
3
3
  * @@@
4
4
  */
5
- export type CsvSettings = ParseConfig & UnparseConfig;
5
+ export type CsvSettings = Pick<ParseConfig & UnparseConfig, 'delimiter' | 'quoteChar' | 'newline' | 'skipEmptyLines'>;
6
+ /**
7
+ * @@@
8
+ *
9
+ * @public exported from `@promptbook/core`
10
+ */
11
+ export declare const MANDATORY_CSV_SETTINGS: Readonly<{
12
+ readonly header: true;
13
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.69.0-12",
3
+ "version": "0.69.0-13",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,7 +47,7 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.69.0-12"
50
+ "@promptbook/core": "0.69.0-13"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * The version of the Promptbook library
37
37
  */
38
- var PROMPTBOOK_VERSION = '0.69.0-11';
38
+ var PROMPTBOOK_VERSION = '0.69.0-12';
39
39
  // TODO: !!!! List here all the versions and annotate + put into script
40
40
 
41
41
  /*! *****************************************************************************
@@ -447,14 +447,12 @@
447
447
  *
448
448
  * @public exported from `@promptbook/core`
449
449
  */
450
- var DEFAULT_CSV_SETTINGS = {
451
- header: true,
450
+ var DEFAULT_CSV_SETTINGS = Object.freeze({
452
451
  delimiter: ',',
453
452
  quoteChar: '"',
454
453
  newline: '\n',
455
454
  skipEmptyLines: true,
456
- // encoding: 'utf8'
457
- };
455
+ });
458
456
  /**
459
457
  * @@@
460
458
  *
@@ -918,7 +916,7 @@
918
916
  });
919
917
  }
920
918
 
921
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
919
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-12",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.69.0-12",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.69.0-12",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.69.0-12",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
922
920
 
923
921
  /**
924
922
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -2357,9 +2355,7 @@
2357
2355
  throw new PipelineExecutionError("You have not provided any `LlmExecutionTools`");
2358
2356
  }
2359
2357
  else {
2360
- throw new PipelineExecutionError(spaceTrim__default["default"](function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools
2361
- .map(function (tools) { return "- ".concat(tools.title, " ").concat(tools.description || ''); })
2362
- .join('\n')), "\n\n "); }));
2358
+ throw new PipelineExecutionError(spaceTrim__default["default"](function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools.map(function (tools) { return "- ".concat(tools.title); }).join('\n')), "\n\n "); }));
2363
2359
  }
2364
2360
  }
2365
2361
  });
@@ -2665,6 +2661,16 @@
2665
2661
  }
2666
2662
  }
2667
2663
 
2664
+ /**
2665
+ * @@@
2666
+ *
2667
+ * @public exported from `@promptbook/core`
2668
+ */
2669
+ var MANDATORY_CSV_SETTINGS = Object.freeze({
2670
+ header: true,
2671
+ // encoding: 'utf8',
2672
+ });
2673
+
2668
2674
  /**
2669
2675
  * Definition for CSV spreadsheet
2670
2676
  *
@@ -2703,7 +2709,7 @@
2703
2709
  return __generator(this, function (_a) {
2704
2710
  switch (_a.label) {
2705
2711
  case 0:
2706
- csv = papaparse.parse(value, settings);
2712
+ csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2707
2713
  if (csv.errors.length !== 0) {
2708
2714
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2709
2715
  spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -2728,7 +2734,7 @@
2728
2734
  }); }))];
2729
2735
  case 1:
2730
2736
  mappedData = _a.sent();
2731
- return [2 /*return*/, papaparse.unparse(mappedData, settings)];
2737
+ return [2 /*return*/, papaparse.unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
2732
2738
  }
2733
2739
  });
2734
2740
  });
@@ -2743,7 +2749,7 @@
2743
2749
  return __generator(this, function (_a) {
2744
2750
  switch (_a.label) {
2745
2751
  case 0:
2746
- csv = papaparse.parse(value, settings);
2752
+ csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2747
2753
  if (csv.errors.length !== 0) {
2748
2754
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2749
2755
  spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -2766,7 +2772,7 @@
2766
2772
  }); }))];
2767
2773
  case 1:
2768
2774
  mappedData = _a.sent();
2769
- return [2 /*return*/, papaparse.unparse(mappedData, settings)];
2775
+ return [2 /*return*/, papaparse.unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
2770
2776
  }
2771
2777
  });
2772
2778
  });
@@ -3387,10 +3393,10 @@
3387
3393
  $scriptPipelineExecutionErrors: [],
3388
3394
  };
3389
3395
  _loop_1 = function (attempt) {
3390
- var isJokerAttempt, jokerParameterName, _b, modelRequirements, _c, _d, _e, _f, _g, _h, scriptTools, _j, error_1, e_1_1, _k, _l, _m, functionName, postprocessingError, _o, _p, scriptTools, _q, error_2, e_2_1, e_3_1, error_3;
3391
- var e_1, _r, e_3, _s, e_2, _t;
3392
- return __generator(this, function (_u) {
3393
- switch (_u.label) {
3396
+ var isJokerAttempt, jokerParameterName, _b, modelRequirements, _c, _d, _e, _f, _g, scriptTools, _h, error_1, e_1_1, _j, _k, _l, functionName, postprocessingError, _m, _o, scriptTools, _p, error_2, e_2_1, e_3_1, error_3;
3397
+ var e_1, _q, e_3, _r, e_2, _s;
3398
+ return __generator(this, function (_t) {
3399
+ switch (_t.label) {
3394
3400
  case 0:
3395
3401
  isJokerAttempt = attempt < 0;
3396
3402
  jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
@@ -3410,21 +3416,21 @@
3410
3416
  $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
3411
3417
  }
3412
3418
  }
3413
- _u.label = 1;
3419
+ _t.label = 1;
3414
3420
  case 1:
3415
- _u.trys.push([1, 44, 45, 46]);
3416
- if (!!isJokerAttempt) return [3 /*break*/, 26];
3421
+ _t.trys.push([1, 43, 44, 45]);
3422
+ if (!!isJokerAttempt) return [3 /*break*/, 25];
3417
3423
  _b = template.templateType;
3418
3424
  switch (_b) {
3419
3425
  case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3420
3426
  case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
3421
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 12];
3422
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 23];
3427
+ case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
3428
+ case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
3423
3429
  }
3424
- return [3 /*break*/, 25];
3430
+ return [3 /*break*/, 24];
3425
3431
  case 2:
3426
3432
  $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
3427
- return [3 /*break*/, 26];
3433
+ return [3 /*break*/, 25];
3428
3434
  case 3:
3429
3435
  modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
3430
3436
  $ongoingTemplateResult.$prompt = {
@@ -3449,67 +3455,57 @@
3449
3455
  case 'COMPLETION': return [3 /*break*/, 6];
3450
3456
  case 'EMBEDDING': return [3 /*break*/, 8];
3451
3457
  }
3452
- return [3 /*break*/, 10];
3458
+ return [3 /*break*/, 9];
3453
3459
  case 4:
3454
3460
  _d = $ongoingTemplateResult;
3455
3461
  return [4 /*yield*/, llmTools.callChatModel($deepFreeze($ongoingTemplateResult.$prompt))];
3456
3462
  case 5:
3457
- _d.$chatResult = _u.sent();
3463
+ _d.$chatResult = _t.sent();
3458
3464
  // TODO: [🍬] Destroy chatThread
3459
3465
  $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
3460
3466
  $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
3461
- return [3 /*break*/, 11];
3467
+ return [3 /*break*/, 10];
3462
3468
  case 6:
3463
3469
  _e = $ongoingTemplateResult;
3464
3470
  return [4 /*yield*/, llmTools.callCompletionModel($deepFreeze($ongoingTemplateResult.$prompt))];
3465
3471
  case 7:
3466
- _e.$completionResult = _u.sent();
3472
+ _e.$completionResult = _t.sent();
3467
3473
  $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
3468
3474
  $ongoingTemplateResult.$resultString =
3469
3475
  $ongoingTemplateResult.$completionResult.content;
3470
- return [3 /*break*/, 11];
3471
- case 8:
3472
- // TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
3473
- _f = $ongoingTemplateResult;
3474
- return [4 /*yield*/, llmTools.callEmbeddingModel($deepFreeze($ongoingTemplateResult.$prompt))];
3475
- case 9:
3476
- // TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
3477
- _f.$embeddingResult = _u.sent();
3478
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$embeddingResult;
3479
- $ongoingTemplateResult.$resultString =
3480
- $ongoingTemplateResult.$embeddingResult.content.join(',');
3481
- return [3 /*break*/, 11];
3482
- case 10: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3483
- case 11: return [3 /*break*/, 26];
3484
- case 12:
3476
+ return [3 /*break*/, 10];
3477
+ case 8: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Embedding model can not be used in pipeline\n\n This should be catched during parsing\n\n ".concat(block(pipelineIdentification), "\n\n "); }));
3478
+ case 9: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3479
+ case 10: return [3 /*break*/, 25];
3480
+ case 11:
3485
3481
  if (arrayableToArray(tools.script).length === 0) {
3486
3482
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3487
3483
  }
3488
3484
  if (!template.contentLanguage) {
3489
3485
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3490
3486
  }
3491
- _u.label = 13;
3487
+ _t.label = 12;
3488
+ case 12:
3489
+ _t.trys.push([12, 19, 20, 21]);
3490
+ _f = (e_1 = void 0, __values(arrayableToArray(tools.script))), _g = _f.next();
3491
+ _t.label = 13;
3492
3492
  case 13:
3493
- _u.trys.push([13, 20, 21, 22]);
3494
- _g = (e_1 = void 0, __values(arrayableToArray(tools.script))), _h = _g.next();
3495
- _u.label = 14;
3493
+ if (!!_g.done) return [3 /*break*/, 18];
3494
+ scriptTools = _g.value;
3495
+ _t.label = 14;
3496
3496
  case 14:
3497
- if (!!_h.done) return [3 /*break*/, 19];
3498
- scriptTools = _h.value;
3499
- _u.label = 15;
3500
- case 15:
3501
- _u.trys.push([15, 17, , 18]);
3502
- _j = $ongoingTemplateResult;
3497
+ _t.trys.push([14, 16, , 17]);
3498
+ _h = $ongoingTemplateResult;
3503
3499
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
3504
3500
  scriptLanguage: template.contentLanguage,
3505
3501
  script: preparedContent,
3506
3502
  parameters: parameters,
3507
3503
  }))];
3504
+ case 15:
3505
+ _h.$resultString = _t.sent();
3506
+ return [3 /*break*/, 18];
3508
3507
  case 16:
3509
- _j.$resultString = _u.sent();
3510
- return [3 /*break*/, 19];
3511
- case 17:
3512
- error_1 = _u.sent();
3508
+ error_1 = _t.sent();
3513
3509
  if (!(error_1 instanceof Error)) {
3514
3510
  throw error_1;
3515
3511
  }
@@ -3517,24 +3513,24 @@
3517
3513
  throw error_1;
3518
3514
  }
3519
3515
  $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
3520
- return [3 /*break*/, 18];
3521
- case 18:
3522
- _h = _g.next();
3523
- return [3 /*break*/, 14];
3524
- case 19: return [3 /*break*/, 22];
3525
- case 20:
3526
- e_1_1 = _u.sent();
3516
+ return [3 /*break*/, 17];
3517
+ case 17:
3518
+ _g = _f.next();
3519
+ return [3 /*break*/, 13];
3520
+ case 18: return [3 /*break*/, 21];
3521
+ case 19:
3522
+ e_1_1 = _t.sent();
3527
3523
  e_1 = { error: e_1_1 };
3528
- return [3 /*break*/, 22];
3529
- case 21:
3524
+ return [3 /*break*/, 21];
3525
+ case 20:
3530
3526
  try {
3531
- if (_h && !_h.done && (_r = _g.return)) _r.call(_g);
3527
+ if (_g && !_g.done && (_q = _f.return)) _q.call(_f);
3532
3528
  }
3533
3529
  finally { if (e_1) throw e_1.error; }
3534
3530
  return [7 /*endfinally*/];
3535
- case 22:
3531
+ case 21:
3536
3532
  if ($ongoingTemplateResult.$resultString !== null) {
3537
- return [3 /*break*/, 26];
3533
+ return [3 /*break*/, 25];
3538
3534
  }
3539
3535
  if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
3540
3536
  throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
@@ -3544,12 +3540,12 @@
3544
3540
  .map(function (error) { return '- ' + error.message; })
3545
3541
  .join('\n\n')), "\n "); }));
3546
3542
  }
3547
- case 23:
3543
+ case 22:
3548
3544
  if (tools.userInterface === undefined) {
3549
3545
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3550
3546
  }
3551
3547
  // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3552
- _k = $ongoingTemplateResult;
3548
+ _j = $ongoingTemplateResult;
3553
3549
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
3554
3550
  promptTitle: template.title,
3555
3551
  promptMessage: replaceParameters(template.description || '', parameters),
@@ -3558,34 +3554,34 @@
3558
3554
  placeholder: undefined,
3559
3555
  priority: priority,
3560
3556
  }))];
3561
- case 24:
3557
+ case 23:
3562
3558
  // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3563
- _k.$resultString = _u.sent();
3564
- return [3 /*break*/, 26];
3565
- case 25: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3559
+ _j.$resultString = _t.sent();
3560
+ return [3 /*break*/, 25];
3561
+ case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3562
+ case 25:
3563
+ if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3564
+ _t.label = 26;
3566
3565
  case 26:
3567
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 43];
3568
- _u.label = 27;
3566
+ _t.trys.push([26, 40, 41, 42]);
3567
+ _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
3568
+ _t.label = 27;
3569
3569
  case 27:
3570
- _u.trys.push([27, 41, 42, 43]);
3571
- _l = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _m = _l.next();
3572
- _u.label = 28;
3573
- case 28:
3574
- if (!!_m.done) return [3 /*break*/, 40];
3575
- functionName = _m.value;
3570
+ if (!!_l.done) return [3 /*break*/, 39];
3571
+ functionName = _l.value;
3576
3572
  postprocessingError = null;
3577
- _u.label = 29;
3573
+ _t.label = 28;
3574
+ case 28:
3575
+ _t.trys.push([28, 35, 36, 37]);
3576
+ _m = (e_2 = void 0, __values(arrayableToArray(tools.script))), _o = _m.next();
3577
+ _t.label = 29;
3578
3578
  case 29:
3579
- _u.trys.push([29, 36, 37, 38]);
3580
- _o = (e_2 = void 0, __values(arrayableToArray(tools.script))), _p = _o.next();
3581
- _u.label = 30;
3579
+ if (!!_o.done) return [3 /*break*/, 34];
3580
+ scriptTools = _o.value;
3581
+ _t.label = 30;
3582
3582
  case 30:
3583
- if (!!_p.done) return [3 /*break*/, 35];
3584
- scriptTools = _p.value;
3585
- _u.label = 31;
3586
- case 31:
3587
- _u.trys.push([31, 33, , 34]);
3588
- _q = $ongoingTemplateResult;
3583
+ _t.trys.push([30, 32, , 33]);
3584
+ _p = $ongoingTemplateResult;
3589
3585
  return [4 /*yield*/, scriptTools.execute({
3590
3586
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
3591
3587
  script: "".concat(functionName, "(resultString)"),
@@ -3594,12 +3590,12 @@
3594
3590
  // Note: No ...parametersForTemplate, because working with result only
3595
3591
  },
3596
3592
  })];
3597
- case 32:
3598
- _q.$resultString = _u.sent();
3593
+ case 31:
3594
+ _p.$resultString = _t.sent();
3599
3595
  postprocessingError = null;
3600
- return [3 /*break*/, 35];
3601
- case 33:
3602
- error_2 = _u.sent();
3596
+ return [3 /*break*/, 34];
3597
+ case 32:
3598
+ error_2 = _t.sent();
3603
3599
  if (!(error_2 instanceof Error)) {
3604
3600
  throw error_2;
3605
3601
  }
@@ -3608,41 +3604,41 @@
3608
3604
  }
3609
3605
  postprocessingError = error_2;
3610
3606
  $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
3611
- return [3 /*break*/, 34];
3612
- case 34:
3613
- _p = _o.next();
3614
- return [3 /*break*/, 30];
3615
- case 35: return [3 /*break*/, 38];
3616
- case 36:
3617
- e_2_1 = _u.sent();
3607
+ return [3 /*break*/, 33];
3608
+ case 33:
3609
+ _o = _m.next();
3610
+ return [3 /*break*/, 29];
3611
+ case 34: return [3 /*break*/, 37];
3612
+ case 35:
3613
+ e_2_1 = _t.sent();
3618
3614
  e_2 = { error: e_2_1 };
3619
- return [3 /*break*/, 38];
3620
- case 37:
3615
+ return [3 /*break*/, 37];
3616
+ case 36:
3621
3617
  try {
3622
- if (_p && !_p.done && (_t = _o.return)) _t.call(_o);
3618
+ if (_o && !_o.done && (_s = _m.return)) _s.call(_m);
3623
3619
  }
3624
3620
  finally { if (e_2) throw e_2.error; }
3625
3621
  return [7 /*endfinally*/];
3626
- case 38:
3622
+ case 37:
3627
3623
  if (postprocessingError) {
3628
3624
  throw postprocessingError;
3629
3625
  }
3630
- _u.label = 39;
3631
- case 39:
3632
- _m = _l.next();
3633
- return [3 /*break*/, 28];
3634
- case 40: return [3 /*break*/, 43];
3635
- case 41:
3636
- e_3_1 = _u.sent();
3626
+ _t.label = 38;
3627
+ case 38:
3628
+ _l = _k.next();
3629
+ return [3 /*break*/, 27];
3630
+ case 39: return [3 /*break*/, 42];
3631
+ case 40:
3632
+ e_3_1 = _t.sent();
3637
3633
  e_3 = { error: e_3_1 };
3638
- return [3 /*break*/, 43];
3639
- case 42:
3634
+ return [3 /*break*/, 42];
3635
+ case 41:
3640
3636
  try {
3641
- if (_m && !_m.done && (_s = _l.return)) _s.call(_l);
3637
+ if (_l && !_l.done && (_r = _k.return)) _r.call(_k);
3642
3638
  }
3643
3639
  finally { if (e_3) throw e_3.error; }
3644
3640
  return [7 /*endfinally*/];
3645
- case 43:
3641
+ case 42:
3646
3642
  // TODO: [💝] Unite object for expecting amount and format
3647
3643
  if (template.format) {
3648
3644
  if (template.format === 'JSON') {
@@ -3667,14 +3663,14 @@
3667
3663
  checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
3668
3664
  }
3669
3665
  return [2 /*return*/, "break-attempts"];
3670
- case 44:
3671
- error_3 = _u.sent();
3666
+ case 43:
3667
+ error_3 = _t.sent();
3672
3668
  if (!(error_3 instanceof ExpectError)) {
3673
3669
  throw error_3;
3674
3670
  }
3675
3671
  $ongoingTemplateResult.$expectError = error_3;
3676
- return [3 /*break*/, 46];
3677
- case 45:
3672
+ return [3 /*break*/, 45];
3673
+ case 44:
3678
3674
  if (!isJokerAttempt &&
3679
3675
  template.templateType === 'PROMPT_TEMPLATE' &&
3680
3676
  $ongoingTemplateResult.$prompt
@@ -3691,7 +3687,7 @@
3691
3687
  });
3692
3688
  }
3693
3689
  return [7 /*endfinally*/];
3694
- case 46:
3690
+ case 45:
3695
3691
  if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
3696
3692
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) {
3697
3693
  var _a, _b, _c;
@@ -3790,6 +3786,8 @@
3790
3786
  return __generator(this, function (_a) {
3791
3787
  switch (_a.label) {
3792
3788
  case 0:
3789
+ // TODO: !!!!!!! Limit to N concurrent executions
3790
+ // TODO: !!!!!!! Report progress
3793
3791
  try {
3794
3792
  mappedParameters = mapAvailableToExpectedParameters({
3795
3793
  expectedParameters: Object.fromEntries(template.foreach.subparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
@@ -4573,8 +4571,13 @@
4573
4571
  case 6: return [3 /*break*/, 8];
4574
4572
  case 7:
4575
4573
  error_1 = _c.sent();
4574
+ // Note: Here is expected error:
4575
+ // > PipelineExecutionError: You have not provided any `LlmExecutionTools` that support model variant "EMBEDDING
4576
+ if (!(error_1 instanceof PipelineExecutionError)) {
4577
+ throw error_1;
4578
+ }
4576
4579
  // TODO: [🟥] Detect browser / node and make it colorfull
4577
- console.error(error_1);
4580
+ console.error(error_1, "<- Note: This error is not critical to prepare the pipeline, just knowledge pieces won't have embeddings");
4578
4581
  return [3 /*break*/, 8];
4579
4582
  case 8: return [2 /*return*/, {
4580
4583
  name: name,
@@ -6077,6 +6080,9 @@
6077
6080
  */
6078
6081
  parse: function (input) {
6079
6082
  var args = input.args, normalized = input.normalized;
6083
+ var availableVariantsMessage = spaceTrim__default["default"](function (block) { return "\n Available variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) {
6084
+ return "- ".concat(variantName).concat(variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)');
6085
+ }).join('\n')), "\n "); });
6080
6086
  // TODO: Make this more elegant and dynamically
6081
6087
  if (normalized.startsWith('MODEL_VARIANT')) {
6082
6088
  if (normalized === 'MODEL_VARIANT_CHAT') {
@@ -6092,17 +6098,13 @@
6092
6098
  key: 'modelVariant',
6093
6099
  value: 'COMPLETION',
6094
6100
  };
6101
+ // <- Note: [🤖]
6095
6102
  }
6096
6103
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
6097
- return {
6098
- type: 'MODEL',
6099
- key: 'modelVariant',
6100
- value: 'EMBEDDING',
6101
- };
6102
- // <- Note: [🤖]
6104
+ spaceTrim__default["default"](function (block) { return "\n Embedding model can not be used in pipeline\n\n ".concat(block(availableVariantsMessage), "\n "); });
6103
6105
  }
6104
6106
  else {
6105
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown model variant in command:\n\n Supported variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) { return "- ".concat(variantName); }).join('\n')), "\n "); }));
6107
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown model variant in command:\n\n ".concat(block(availableVariantsMessage), "\n "); }));
6106
6108
  }
6107
6109
  }
6108
6110
  if (normalized.startsWith('MODEL_NAME')) {