@promptbook/cli 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.
package/esm/index.es.js CHANGED
@@ -21,7 +21,7 @@ import OpenAI from 'openai';
21
21
  /**
22
22
  * The version of the Promptbook library
23
23
  */
24
- var PROMPTBOOK_VERSION = '0.69.0-11';
24
+ var PROMPTBOOK_VERSION = '0.69.0-12';
25
25
  // TODO: !!!! List here all the versions and annotate + put into script
26
26
 
27
27
  /*! *****************************************************************************
@@ -508,14 +508,12 @@ var DEFAULT_REMOTE_URL_PATH = '/promptbook/socket.io';
508
508
  *
509
509
  * @public exported from `@promptbook/core`
510
510
  */
511
- var DEFAULT_CSV_SETTINGS = {
512
- header: true,
511
+ var DEFAULT_CSV_SETTINGS = Object.freeze({
513
512
  delimiter: ',',
514
513
  quoteChar: '"',
515
514
  newline: '\n',
516
515
  skipEmptyLines: true,
517
- // encoding: 'utf8'
518
- };
516
+ });
519
517
  /**
520
518
  * @@@
521
519
  *
@@ -1064,7 +1062,7 @@ function forEachAsync(array, options, callbackfunction) {
1064
1062
  });
1065
1063
  }
1066
1064
 
1067
- 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"}];
1065
+ 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"}];
1068
1066
 
1069
1067
  /**
1070
1068
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -2487,9 +2485,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
2487
2485
  throw new PipelineExecutionError("You have not provided any `LlmExecutionTools`");
2488
2486
  }
2489
2487
  else {
2490
- throw new PipelineExecutionError(spaceTrim$1(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
2491
- .map(function (tools) { return "- ".concat(tools.title, " ").concat(tools.description || ''); })
2492
- .join('\n')), "\n\n "); }));
2488
+ throw new PipelineExecutionError(spaceTrim$1(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 "); }));
2493
2489
  }
2494
2490
  }
2495
2491
  });
@@ -2795,6 +2791,16 @@ function TODO_USE() {
2795
2791
  }
2796
2792
  }
2797
2793
 
2794
+ /**
2795
+ * @@@
2796
+ *
2797
+ * @public exported from `@promptbook/core`
2798
+ */
2799
+ var MANDATORY_CSV_SETTINGS = Object.freeze({
2800
+ header: true,
2801
+ // encoding: 'utf8',
2802
+ });
2803
+
2798
2804
  /**
2799
2805
  * Definition for CSV spreadsheet
2800
2806
  *
@@ -2833,7 +2839,7 @@ var CsvFormatDefinition = {
2833
2839
  return __generator(this, function (_a) {
2834
2840
  switch (_a.label) {
2835
2841
  case 0:
2836
- csv = parse(value, settings);
2842
+ csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2837
2843
  if (csv.errors.length !== 0) {
2838
2844
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2839
2845
  spaceTrim$1(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -2858,7 +2864,7 @@ var CsvFormatDefinition = {
2858
2864
  }); }))];
2859
2865
  case 1:
2860
2866
  mappedData = _a.sent();
2861
- return [2 /*return*/, unparse(mappedData, settings)];
2867
+ return [2 /*return*/, unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
2862
2868
  }
2863
2869
  });
2864
2870
  });
@@ -2873,7 +2879,7 @@ var CsvFormatDefinition = {
2873
2879
  return __generator(this, function (_a) {
2874
2880
  switch (_a.label) {
2875
2881
  case 0:
2876
- csv = parse(value, settings);
2882
+ csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2877
2883
  if (csv.errors.length !== 0) {
2878
2884
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2879
2885
  spaceTrim$1(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -2896,7 +2902,7 @@ var CsvFormatDefinition = {
2896
2902
  }); }))];
2897
2903
  case 1:
2898
2904
  mappedData = _a.sent();
2899
- return [2 /*return*/, unparse(mappedData, settings)];
2905
+ return [2 /*return*/, unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
2900
2906
  }
2901
2907
  });
2902
2908
  });
@@ -3517,10 +3523,10 @@ function executeAttempts(options) {
3517
3523
  $scriptPipelineExecutionErrors: [],
3518
3524
  };
3519
3525
  _loop_1 = function (attempt) {
3520
- 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;
3521
- var e_1, _r, e_3, _s, e_2, _t;
3522
- return __generator(this, function (_u) {
3523
- switch (_u.label) {
3526
+ 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;
3527
+ var e_1, _q, e_3, _r, e_2, _s;
3528
+ return __generator(this, function (_t) {
3529
+ switch (_t.label) {
3524
3530
  case 0:
3525
3531
  isJokerAttempt = attempt < 0;
3526
3532
  jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
@@ -3540,21 +3546,21 @@ function executeAttempts(options) {
3540
3546
  $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
3541
3547
  }
3542
3548
  }
3543
- _u.label = 1;
3549
+ _t.label = 1;
3544
3550
  case 1:
3545
- _u.trys.push([1, 44, 45, 46]);
3546
- if (!!isJokerAttempt) return [3 /*break*/, 26];
3551
+ _t.trys.push([1, 43, 44, 45]);
3552
+ if (!!isJokerAttempt) return [3 /*break*/, 25];
3547
3553
  _b = template.templateType;
3548
3554
  switch (_b) {
3549
3555
  case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3550
3556
  case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
3551
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 12];
3552
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 23];
3557
+ case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
3558
+ case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
3553
3559
  }
3554
- return [3 /*break*/, 25];
3560
+ return [3 /*break*/, 24];
3555
3561
  case 2:
3556
3562
  $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
3557
- return [3 /*break*/, 26];
3563
+ return [3 /*break*/, 25];
3558
3564
  case 3:
3559
3565
  modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
3560
3566
  $ongoingTemplateResult.$prompt = {
@@ -3579,67 +3585,57 @@ function executeAttempts(options) {
3579
3585
  case 'COMPLETION': return [3 /*break*/, 6];
3580
3586
  case 'EMBEDDING': return [3 /*break*/, 8];
3581
3587
  }
3582
- return [3 /*break*/, 10];
3588
+ return [3 /*break*/, 9];
3583
3589
  case 4:
3584
3590
  _d = $ongoingTemplateResult;
3585
3591
  return [4 /*yield*/, llmTools.callChatModel($deepFreeze($ongoingTemplateResult.$prompt))];
3586
3592
  case 5:
3587
- _d.$chatResult = _u.sent();
3593
+ _d.$chatResult = _t.sent();
3588
3594
  // TODO: [🍬] Destroy chatThread
3589
3595
  $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
3590
3596
  $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
3591
- return [3 /*break*/, 11];
3597
+ return [3 /*break*/, 10];
3592
3598
  case 6:
3593
3599
  _e = $ongoingTemplateResult;
3594
3600
  return [4 /*yield*/, llmTools.callCompletionModel($deepFreeze($ongoingTemplateResult.$prompt))];
3595
3601
  case 7:
3596
- _e.$completionResult = _u.sent();
3602
+ _e.$completionResult = _t.sent();
3597
3603
  $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
3598
3604
  $ongoingTemplateResult.$resultString =
3599
3605
  $ongoingTemplateResult.$completionResult.content;
3600
- return [3 /*break*/, 11];
3601
- case 8:
3602
- // TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
3603
- _f = $ongoingTemplateResult;
3604
- return [4 /*yield*/, llmTools.callEmbeddingModel($deepFreeze($ongoingTemplateResult.$prompt))];
3605
- case 9:
3606
- // TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
3607
- _f.$embeddingResult = _u.sent();
3608
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$embeddingResult;
3609
- $ongoingTemplateResult.$resultString =
3610
- $ongoingTemplateResult.$embeddingResult.content.join(',');
3611
- return [3 /*break*/, 11];
3612
- case 10: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3613
- case 11: return [3 /*break*/, 26];
3614
- case 12:
3606
+ return [3 /*break*/, 10];
3607
+ case 8: throw new PipelineExecutionError(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 "); }));
3608
+ case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3609
+ case 10: return [3 /*break*/, 25];
3610
+ case 11:
3615
3611
  if (arrayableToArray(tools.script).length === 0) {
3616
3612
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3617
3613
  }
3618
3614
  if (!template.contentLanguage) {
3619
3615
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3620
3616
  }
3621
- _u.label = 13;
3617
+ _t.label = 12;
3618
+ case 12:
3619
+ _t.trys.push([12, 19, 20, 21]);
3620
+ _f = (e_1 = void 0, __values(arrayableToArray(tools.script))), _g = _f.next();
3621
+ _t.label = 13;
3622
3622
  case 13:
3623
- _u.trys.push([13, 20, 21, 22]);
3624
- _g = (e_1 = void 0, __values(arrayableToArray(tools.script))), _h = _g.next();
3625
- _u.label = 14;
3623
+ if (!!_g.done) return [3 /*break*/, 18];
3624
+ scriptTools = _g.value;
3625
+ _t.label = 14;
3626
3626
  case 14:
3627
- if (!!_h.done) return [3 /*break*/, 19];
3628
- scriptTools = _h.value;
3629
- _u.label = 15;
3630
- case 15:
3631
- _u.trys.push([15, 17, , 18]);
3632
- _j = $ongoingTemplateResult;
3627
+ _t.trys.push([14, 16, , 17]);
3628
+ _h = $ongoingTemplateResult;
3633
3629
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
3634
3630
  scriptLanguage: template.contentLanguage,
3635
3631
  script: preparedContent,
3636
3632
  parameters: parameters,
3637
3633
  }))];
3634
+ case 15:
3635
+ _h.$resultString = _t.sent();
3636
+ return [3 /*break*/, 18];
3638
3637
  case 16:
3639
- _j.$resultString = _u.sent();
3640
- return [3 /*break*/, 19];
3641
- case 17:
3642
- error_1 = _u.sent();
3638
+ error_1 = _t.sent();
3643
3639
  if (!(error_1 instanceof Error)) {
3644
3640
  throw error_1;
3645
3641
  }
@@ -3647,24 +3643,24 @@ function executeAttempts(options) {
3647
3643
  throw error_1;
3648
3644
  }
3649
3645
  $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
3650
- return [3 /*break*/, 18];
3651
- case 18:
3652
- _h = _g.next();
3653
- return [3 /*break*/, 14];
3654
- case 19: return [3 /*break*/, 22];
3655
- case 20:
3656
- e_1_1 = _u.sent();
3646
+ return [3 /*break*/, 17];
3647
+ case 17:
3648
+ _g = _f.next();
3649
+ return [3 /*break*/, 13];
3650
+ case 18: return [3 /*break*/, 21];
3651
+ case 19:
3652
+ e_1_1 = _t.sent();
3657
3653
  e_1 = { error: e_1_1 };
3658
- return [3 /*break*/, 22];
3659
- case 21:
3654
+ return [3 /*break*/, 21];
3655
+ case 20:
3660
3656
  try {
3661
- if (_h && !_h.done && (_r = _g.return)) _r.call(_g);
3657
+ if (_g && !_g.done && (_q = _f.return)) _q.call(_f);
3662
3658
  }
3663
3659
  finally { if (e_1) throw e_1.error; }
3664
3660
  return [7 /*endfinally*/];
3665
- case 22:
3661
+ case 21:
3666
3662
  if ($ongoingTemplateResult.$resultString !== null) {
3667
- return [3 /*break*/, 26];
3663
+ return [3 /*break*/, 25];
3668
3664
  }
3669
3665
  if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
3670
3666
  throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
@@ -3674,12 +3670,12 @@ function executeAttempts(options) {
3674
3670
  .map(function (error) { return '- ' + error.message; })
3675
3671
  .join('\n\n')), "\n "); }));
3676
3672
  }
3677
- case 23:
3673
+ case 22:
3678
3674
  if (tools.userInterface === undefined) {
3679
3675
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3680
3676
  }
3681
3677
  // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3682
- _k = $ongoingTemplateResult;
3678
+ _j = $ongoingTemplateResult;
3683
3679
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
3684
3680
  promptTitle: template.title,
3685
3681
  promptMessage: replaceParameters(template.description || '', parameters),
@@ -3688,34 +3684,34 @@ function executeAttempts(options) {
3688
3684
  placeholder: undefined,
3689
3685
  priority: priority,
3690
3686
  }))];
3691
- case 24:
3687
+ case 23:
3692
3688
  // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3693
- _k.$resultString = _u.sent();
3694
- return [3 /*break*/, 26];
3695
- case 25: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3689
+ _j.$resultString = _t.sent();
3690
+ return [3 /*break*/, 25];
3691
+ case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3692
+ case 25:
3693
+ if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3694
+ _t.label = 26;
3696
3695
  case 26:
3697
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 43];
3698
- _u.label = 27;
3696
+ _t.trys.push([26, 40, 41, 42]);
3697
+ _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
3698
+ _t.label = 27;
3699
3699
  case 27:
3700
- _u.trys.push([27, 41, 42, 43]);
3701
- _l = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _m = _l.next();
3702
- _u.label = 28;
3703
- case 28:
3704
- if (!!_m.done) return [3 /*break*/, 40];
3705
- functionName = _m.value;
3700
+ if (!!_l.done) return [3 /*break*/, 39];
3701
+ functionName = _l.value;
3706
3702
  postprocessingError = null;
3707
- _u.label = 29;
3703
+ _t.label = 28;
3704
+ case 28:
3705
+ _t.trys.push([28, 35, 36, 37]);
3706
+ _m = (e_2 = void 0, __values(arrayableToArray(tools.script))), _o = _m.next();
3707
+ _t.label = 29;
3708
3708
  case 29:
3709
- _u.trys.push([29, 36, 37, 38]);
3710
- _o = (e_2 = void 0, __values(arrayableToArray(tools.script))), _p = _o.next();
3711
- _u.label = 30;
3709
+ if (!!_o.done) return [3 /*break*/, 34];
3710
+ scriptTools = _o.value;
3711
+ _t.label = 30;
3712
3712
  case 30:
3713
- if (!!_p.done) return [3 /*break*/, 35];
3714
- scriptTools = _p.value;
3715
- _u.label = 31;
3716
- case 31:
3717
- _u.trys.push([31, 33, , 34]);
3718
- _q = $ongoingTemplateResult;
3713
+ _t.trys.push([30, 32, , 33]);
3714
+ _p = $ongoingTemplateResult;
3719
3715
  return [4 /*yield*/, scriptTools.execute({
3720
3716
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
3721
3717
  script: "".concat(functionName, "(resultString)"),
@@ -3724,12 +3720,12 @@ function executeAttempts(options) {
3724
3720
  // Note: No ...parametersForTemplate, because working with result only
3725
3721
  },
3726
3722
  })];
3727
- case 32:
3728
- _q.$resultString = _u.sent();
3723
+ case 31:
3724
+ _p.$resultString = _t.sent();
3729
3725
  postprocessingError = null;
3730
- return [3 /*break*/, 35];
3731
- case 33:
3732
- error_2 = _u.sent();
3726
+ return [3 /*break*/, 34];
3727
+ case 32:
3728
+ error_2 = _t.sent();
3733
3729
  if (!(error_2 instanceof Error)) {
3734
3730
  throw error_2;
3735
3731
  }
@@ -3738,41 +3734,41 @@ function executeAttempts(options) {
3738
3734
  }
3739
3735
  postprocessingError = error_2;
3740
3736
  $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
3741
- return [3 /*break*/, 34];
3742
- case 34:
3743
- _p = _o.next();
3744
- return [3 /*break*/, 30];
3745
- case 35: return [3 /*break*/, 38];
3746
- case 36:
3747
- e_2_1 = _u.sent();
3737
+ return [3 /*break*/, 33];
3738
+ case 33:
3739
+ _o = _m.next();
3740
+ return [3 /*break*/, 29];
3741
+ case 34: return [3 /*break*/, 37];
3742
+ case 35:
3743
+ e_2_1 = _t.sent();
3748
3744
  e_2 = { error: e_2_1 };
3749
- return [3 /*break*/, 38];
3750
- case 37:
3745
+ return [3 /*break*/, 37];
3746
+ case 36:
3751
3747
  try {
3752
- if (_p && !_p.done && (_t = _o.return)) _t.call(_o);
3748
+ if (_o && !_o.done && (_s = _m.return)) _s.call(_m);
3753
3749
  }
3754
3750
  finally { if (e_2) throw e_2.error; }
3755
3751
  return [7 /*endfinally*/];
3756
- case 38:
3752
+ case 37:
3757
3753
  if (postprocessingError) {
3758
3754
  throw postprocessingError;
3759
3755
  }
3760
- _u.label = 39;
3761
- case 39:
3762
- _m = _l.next();
3763
- return [3 /*break*/, 28];
3764
- case 40: return [3 /*break*/, 43];
3765
- case 41:
3766
- e_3_1 = _u.sent();
3756
+ _t.label = 38;
3757
+ case 38:
3758
+ _l = _k.next();
3759
+ return [3 /*break*/, 27];
3760
+ case 39: return [3 /*break*/, 42];
3761
+ case 40:
3762
+ e_3_1 = _t.sent();
3767
3763
  e_3 = { error: e_3_1 };
3768
- return [3 /*break*/, 43];
3769
- case 42:
3764
+ return [3 /*break*/, 42];
3765
+ case 41:
3770
3766
  try {
3771
- if (_m && !_m.done && (_s = _l.return)) _s.call(_l);
3767
+ if (_l && !_l.done && (_r = _k.return)) _r.call(_k);
3772
3768
  }
3773
3769
  finally { if (e_3) throw e_3.error; }
3774
3770
  return [7 /*endfinally*/];
3775
- case 43:
3771
+ case 42:
3776
3772
  // TODO: [💝] Unite object for expecting amount and format
3777
3773
  if (template.format) {
3778
3774
  if (template.format === 'JSON') {
@@ -3797,14 +3793,14 @@ function executeAttempts(options) {
3797
3793
  checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
3798
3794
  }
3799
3795
  return [2 /*return*/, "break-attempts"];
3800
- case 44:
3801
- error_3 = _u.sent();
3796
+ case 43:
3797
+ error_3 = _t.sent();
3802
3798
  if (!(error_3 instanceof ExpectError)) {
3803
3799
  throw error_3;
3804
3800
  }
3805
3801
  $ongoingTemplateResult.$expectError = error_3;
3806
- return [3 /*break*/, 46];
3807
- case 45:
3802
+ return [3 /*break*/, 45];
3803
+ case 44:
3808
3804
  if (!isJokerAttempt &&
3809
3805
  template.templateType === 'PROMPT_TEMPLATE' &&
3810
3806
  $ongoingTemplateResult.$prompt
@@ -3821,7 +3817,7 @@ function executeAttempts(options) {
3821
3817
  });
3822
3818
  }
3823
3819
  return [7 /*endfinally*/];
3824
- case 46:
3820
+ case 45:
3825
3821
  if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
3826
3822
  throw new PipelineExecutionError(spaceTrim(function (block) {
3827
3823
  var _a, _b, _c;
@@ -3920,6 +3916,8 @@ function executeFormatCells(options) {
3920
3916
  return __generator(this, function (_a) {
3921
3917
  switch (_a.label) {
3922
3918
  case 0:
3919
+ // TODO: !!!!!!! Limit to N concurrent executions
3920
+ // TODO: !!!!!!! Report progress
3923
3921
  try {
3924
3922
  mappedParameters = mapAvailableToExpectedParameters({
3925
3923
  expectedParameters: Object.fromEntries(template.foreach.subparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
@@ -4703,8 +4701,13 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
4703
4701
  case 6: return [3 /*break*/, 8];
4704
4702
  case 7:
4705
4703
  error_1 = _c.sent();
4704
+ // Note: Here is expected error:
4705
+ // > PipelineExecutionError: You have not provided any `LlmExecutionTools` that support model variant "EMBEDDING
4706
+ if (!(error_1 instanceof PipelineExecutionError)) {
4707
+ throw error_1;
4708
+ }
4706
4709
  // TODO: [🟥] Detect browser / node and make it colorfull
4707
- console.error(error_1);
4710
+ console.error(error_1, "<- Note: This error is not critical to prepare the pipeline, just knowledge pieces won't have embeddings");
4708
4711
  return [3 /*break*/, 8];
4709
4712
  case 8: return [2 /*return*/, {
4710
4713
  name: name,
@@ -6207,6 +6210,9 @@ var modelCommandParser = {
6207
6210
  */
6208
6211
  parse: function (input) {
6209
6212
  var args = input.args, normalized = input.normalized;
6213
+ var availableVariantsMessage = spaceTrim$1(function (block) { return "\n Available variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) {
6214
+ return "- ".concat(variantName).concat(variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)');
6215
+ }).join('\n')), "\n "); });
6210
6216
  // TODO: Make this more elegant and dynamically
6211
6217
  if (normalized.startsWith('MODEL_VARIANT')) {
6212
6218
  if (normalized === 'MODEL_VARIANT_CHAT') {
@@ -6222,17 +6228,13 @@ var modelCommandParser = {
6222
6228
  key: 'modelVariant',
6223
6229
  value: 'COMPLETION',
6224
6230
  };
6231
+ // <- Note: [🤖]
6225
6232
  }
6226
6233
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
6227
- return {
6228
- type: 'MODEL',
6229
- key: 'modelVariant',
6230
- value: 'EMBEDDING',
6231
- };
6232
- // <- Note: [🤖]
6234
+ spaceTrim$1(function (block) { return "\n Embedding model can not be used in pipeline\n\n ".concat(block(availableVariantsMessage), "\n "); });
6233
6235
  }
6234
6236
  else {
6235
- throw new ParseError(spaceTrim$1(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 "); }));
6237
+ throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown model variant in command:\n\n ".concat(block(availableVariantsMessage), "\n "); }));
6236
6238
  }
6237
6239
  }
6238
6240
  if (normalized.startsWith('MODEL_NAME')) {