@promptbook/core 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
@@ -11,7 +11,7 @@ import moment from 'moment';
11
11
  /**
12
12
  * The version of the Promptbook library
13
13
  */
14
- var PROMPTBOOK_VERSION = '0.69.0-11';
14
+ var PROMPTBOOK_VERSION = '0.69.0-12';
15
15
  // TODO: !!!! List here all the versions and annotate + put into script
16
16
 
17
17
  /*! *****************************************************************************
@@ -753,14 +753,12 @@ var DEFAULT_REMOTE_URL_PATH = '/promptbook/socket.io';
753
753
  *
754
754
  * @public exported from `@promptbook/core`
755
755
  */
756
- var DEFAULT_CSV_SETTINGS = {
757
- header: true,
756
+ var DEFAULT_CSV_SETTINGS = Object.freeze({
758
757
  delimiter: ',',
759
758
  quoteChar: '"',
760
759
  newline: '\n',
761
760
  skipEmptyLines: true,
762
- // encoding: 'utf8'
763
- };
761
+ });
764
762
  /**
765
763
  * @@@
766
764
  *
@@ -1832,7 +1830,7 @@ function forEachAsync(array, options, callbackfunction) {
1832
1830
  });
1833
1831
  }
1834
1832
 
1835
- 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"}];
1833
+ 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"}];
1836
1834
 
1837
1835
  var defaultDiacriticsRemovalMap = [
1838
1836
  {
@@ -2635,9 +2633,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
2635
2633
  throw new PipelineExecutionError("You have not provided any `LlmExecutionTools`");
2636
2634
  }
2637
2635
  else {
2638
- throw new PipelineExecutionError(spaceTrim(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
2639
- .map(function (tools) { return "- ".concat(tools.title, " ").concat(tools.description || ''); })
2640
- .join('\n')), "\n\n "); }));
2636
+ throw new PipelineExecutionError(spaceTrim(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 "); }));
2641
2637
  }
2642
2638
  }
2643
2639
  });
@@ -2943,6 +2939,16 @@ function TODO_USE() {
2943
2939
  }
2944
2940
  }
2945
2941
 
2942
+ /**
2943
+ * @@@
2944
+ *
2945
+ * @public exported from `@promptbook/core`
2946
+ */
2947
+ var MANDATORY_CSV_SETTINGS = Object.freeze({
2948
+ header: true,
2949
+ // encoding: 'utf8',
2950
+ });
2951
+
2946
2952
  /**
2947
2953
  * Definition for CSV spreadsheet
2948
2954
  *
@@ -2981,7 +2987,7 @@ var CsvFormatDefinition = {
2981
2987
  return __generator(this, function (_a) {
2982
2988
  switch (_a.label) {
2983
2989
  case 0:
2984
- csv = parse(value, settings);
2990
+ csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2985
2991
  if (csv.errors.length !== 0) {
2986
2992
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2987
2993
  spaceTrim(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -3006,7 +3012,7 @@ var CsvFormatDefinition = {
3006
3012
  }); }))];
3007
3013
  case 1:
3008
3014
  mappedData = _a.sent();
3009
- return [2 /*return*/, unparse(mappedData, settings)];
3015
+ return [2 /*return*/, unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
3010
3016
  }
3011
3017
  });
3012
3018
  });
@@ -3021,7 +3027,7 @@ var CsvFormatDefinition = {
3021
3027
  return __generator(this, function (_a) {
3022
3028
  switch (_a.label) {
3023
3029
  case 0:
3024
- csv = parse(value, settings);
3030
+ csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
3025
3031
  if (csv.errors.length !== 0) {
3026
3032
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
3027
3033
  spaceTrim(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -3044,7 +3050,7 @@ var CsvFormatDefinition = {
3044
3050
  }); }))];
3045
3051
  case 1:
3046
3052
  mappedData = _a.sent();
3047
- return [2 /*return*/, unparse(mappedData, settings)];
3053
+ return [2 /*return*/, unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
3048
3054
  }
3049
3055
  });
3050
3056
  });
@@ -3687,10 +3693,10 @@ function executeAttempts(options) {
3687
3693
  $scriptPipelineExecutionErrors: [],
3688
3694
  };
3689
3695
  _loop_1 = function (attempt) {
3690
- 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;
3691
- var e_1, _r, e_3, _s, e_2, _t;
3692
- return __generator(this, function (_u) {
3693
- switch (_u.label) {
3696
+ 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;
3697
+ var e_1, _q, e_3, _r, e_2, _s;
3698
+ return __generator(this, function (_t) {
3699
+ switch (_t.label) {
3694
3700
  case 0:
3695
3701
  isJokerAttempt = attempt < 0;
3696
3702
  jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
@@ -3710,21 +3716,21 @@ function executeAttempts(options) {
3710
3716
  $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
3711
3717
  }
3712
3718
  }
3713
- _u.label = 1;
3719
+ _t.label = 1;
3714
3720
  case 1:
3715
- _u.trys.push([1, 44, 45, 46]);
3716
- if (!!isJokerAttempt) return [3 /*break*/, 26];
3721
+ _t.trys.push([1, 43, 44, 45]);
3722
+ if (!!isJokerAttempt) return [3 /*break*/, 25];
3717
3723
  _b = template.templateType;
3718
3724
  switch (_b) {
3719
3725
  case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3720
3726
  case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
3721
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 12];
3722
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 23];
3727
+ case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
3728
+ case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
3723
3729
  }
3724
- return [3 /*break*/, 25];
3730
+ return [3 /*break*/, 24];
3725
3731
  case 2:
3726
3732
  $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
3727
- return [3 /*break*/, 26];
3733
+ return [3 /*break*/, 25];
3728
3734
  case 3:
3729
3735
  modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
3730
3736
  $ongoingTemplateResult.$prompt = {
@@ -3749,67 +3755,57 @@ function executeAttempts(options) {
3749
3755
  case 'COMPLETION': return [3 /*break*/, 6];
3750
3756
  case 'EMBEDDING': return [3 /*break*/, 8];
3751
3757
  }
3752
- return [3 /*break*/, 10];
3758
+ return [3 /*break*/, 9];
3753
3759
  case 4:
3754
3760
  _d = $ongoingTemplateResult;
3755
3761
  return [4 /*yield*/, llmTools.callChatModel($deepFreeze($ongoingTemplateResult.$prompt))];
3756
3762
  case 5:
3757
- _d.$chatResult = _u.sent();
3763
+ _d.$chatResult = _t.sent();
3758
3764
  // TODO: [🍬] Destroy chatThread
3759
3765
  $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
3760
3766
  $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
3761
- return [3 /*break*/, 11];
3767
+ return [3 /*break*/, 10];
3762
3768
  case 6:
3763
3769
  _e = $ongoingTemplateResult;
3764
3770
  return [4 /*yield*/, llmTools.callCompletionModel($deepFreeze($ongoingTemplateResult.$prompt))];
3765
3771
  case 7:
3766
- _e.$completionResult = _u.sent();
3772
+ _e.$completionResult = _t.sent();
3767
3773
  $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
3768
3774
  $ongoingTemplateResult.$resultString =
3769
3775
  $ongoingTemplateResult.$completionResult.content;
3770
- return [3 /*break*/, 11];
3771
- case 8:
3772
- // TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
3773
- _f = $ongoingTemplateResult;
3774
- return [4 /*yield*/, llmTools.callEmbeddingModel($deepFreeze($ongoingTemplateResult.$prompt))];
3775
- case 9:
3776
- // TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
3777
- _f.$embeddingResult = _u.sent();
3778
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$embeddingResult;
3779
- $ongoingTemplateResult.$resultString =
3780
- $ongoingTemplateResult.$embeddingResult.content.join(',');
3781
- return [3 /*break*/, 11];
3782
- case 10: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3783
- case 11: return [3 /*break*/, 26];
3784
- case 12:
3776
+ return [3 /*break*/, 10];
3777
+ case 8: throw new PipelineExecutionError(spaceTrim$1(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 "); }));
3778
+ case 9: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3779
+ case 10: return [3 /*break*/, 25];
3780
+ case 11:
3785
3781
  if (arrayableToArray(tools.script).length === 0) {
3786
3782
  throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3787
3783
  }
3788
3784
  if (!template.contentLanguage) {
3789
3785
  throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3790
3786
  }
3791
- _u.label = 13;
3787
+ _t.label = 12;
3788
+ case 12:
3789
+ _t.trys.push([12, 19, 20, 21]);
3790
+ _f = (e_1 = void 0, __values(arrayableToArray(tools.script))), _g = _f.next();
3791
+ _t.label = 13;
3792
3792
  case 13:
3793
- _u.trys.push([13, 20, 21, 22]);
3794
- _g = (e_1 = void 0, __values(arrayableToArray(tools.script))), _h = _g.next();
3795
- _u.label = 14;
3793
+ if (!!_g.done) return [3 /*break*/, 18];
3794
+ scriptTools = _g.value;
3795
+ _t.label = 14;
3796
3796
  case 14:
3797
- if (!!_h.done) return [3 /*break*/, 19];
3798
- scriptTools = _h.value;
3799
- _u.label = 15;
3800
- case 15:
3801
- _u.trys.push([15, 17, , 18]);
3802
- _j = $ongoingTemplateResult;
3797
+ _t.trys.push([14, 16, , 17]);
3798
+ _h = $ongoingTemplateResult;
3803
3799
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
3804
3800
  scriptLanguage: template.contentLanguage,
3805
3801
  script: preparedContent,
3806
3802
  parameters: parameters,
3807
3803
  }))];
3804
+ case 15:
3805
+ _h.$resultString = _t.sent();
3806
+ return [3 /*break*/, 18];
3808
3807
  case 16:
3809
- _j.$resultString = _u.sent();
3810
- return [3 /*break*/, 19];
3811
- case 17:
3812
- error_1 = _u.sent();
3808
+ error_1 = _t.sent();
3813
3809
  if (!(error_1 instanceof Error)) {
3814
3810
  throw error_1;
3815
3811
  }
@@ -3817,24 +3813,24 @@ function executeAttempts(options) {
3817
3813
  throw error_1;
3818
3814
  }
3819
3815
  $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
3820
- return [3 /*break*/, 18];
3821
- case 18:
3822
- _h = _g.next();
3823
- return [3 /*break*/, 14];
3824
- case 19: return [3 /*break*/, 22];
3825
- case 20:
3826
- e_1_1 = _u.sent();
3816
+ return [3 /*break*/, 17];
3817
+ case 17:
3818
+ _g = _f.next();
3819
+ return [3 /*break*/, 13];
3820
+ case 18: return [3 /*break*/, 21];
3821
+ case 19:
3822
+ e_1_1 = _t.sent();
3827
3823
  e_1 = { error: e_1_1 };
3828
- return [3 /*break*/, 22];
3829
- case 21:
3824
+ return [3 /*break*/, 21];
3825
+ case 20:
3830
3826
  try {
3831
- if (_h && !_h.done && (_r = _g.return)) _r.call(_g);
3827
+ if (_g && !_g.done && (_q = _f.return)) _q.call(_f);
3832
3828
  }
3833
3829
  finally { if (e_1) throw e_1.error; }
3834
3830
  return [7 /*endfinally*/];
3835
- case 22:
3831
+ case 21:
3836
3832
  if ($ongoingTemplateResult.$resultString !== null) {
3837
- return [3 /*break*/, 26];
3833
+ return [3 /*break*/, 25];
3838
3834
  }
3839
3835
  if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
3840
3836
  throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
@@ -3844,12 +3840,12 @@ function executeAttempts(options) {
3844
3840
  .map(function (error) { return '- ' + error.message; })
3845
3841
  .join('\n\n')), "\n "); }));
3846
3842
  }
3847
- case 23:
3843
+ case 22:
3848
3844
  if (tools.userInterface === undefined) {
3849
3845
  throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3850
3846
  }
3851
3847
  // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3852
- _k = $ongoingTemplateResult;
3848
+ _j = $ongoingTemplateResult;
3853
3849
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
3854
3850
  promptTitle: template.title,
3855
3851
  promptMessage: replaceParameters(template.description || '', parameters),
@@ -3858,34 +3854,34 @@ function executeAttempts(options) {
3858
3854
  placeholder: undefined,
3859
3855
  priority: priority,
3860
3856
  }))];
3861
- case 24:
3857
+ case 23:
3862
3858
  // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3863
- _k.$resultString = _u.sent();
3864
- return [3 /*break*/, 26];
3865
- case 25: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3859
+ _j.$resultString = _t.sent();
3860
+ return [3 /*break*/, 25];
3861
+ case 24: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3862
+ case 25:
3863
+ if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3864
+ _t.label = 26;
3866
3865
  case 26:
3867
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 43];
3868
- _u.label = 27;
3866
+ _t.trys.push([26, 40, 41, 42]);
3867
+ _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
3868
+ _t.label = 27;
3869
3869
  case 27:
3870
- _u.trys.push([27, 41, 42, 43]);
3871
- _l = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _m = _l.next();
3872
- _u.label = 28;
3873
- case 28:
3874
- if (!!_m.done) return [3 /*break*/, 40];
3875
- functionName = _m.value;
3870
+ if (!!_l.done) return [3 /*break*/, 39];
3871
+ functionName = _l.value;
3876
3872
  postprocessingError = null;
3877
- _u.label = 29;
3873
+ _t.label = 28;
3874
+ case 28:
3875
+ _t.trys.push([28, 35, 36, 37]);
3876
+ _m = (e_2 = void 0, __values(arrayableToArray(tools.script))), _o = _m.next();
3877
+ _t.label = 29;
3878
3878
  case 29:
3879
- _u.trys.push([29, 36, 37, 38]);
3880
- _o = (e_2 = void 0, __values(arrayableToArray(tools.script))), _p = _o.next();
3881
- _u.label = 30;
3879
+ if (!!_o.done) return [3 /*break*/, 34];
3880
+ scriptTools = _o.value;
3881
+ _t.label = 30;
3882
3882
  case 30:
3883
- if (!!_p.done) return [3 /*break*/, 35];
3884
- scriptTools = _p.value;
3885
- _u.label = 31;
3886
- case 31:
3887
- _u.trys.push([31, 33, , 34]);
3888
- _q = $ongoingTemplateResult;
3883
+ _t.trys.push([30, 32, , 33]);
3884
+ _p = $ongoingTemplateResult;
3889
3885
  return [4 /*yield*/, scriptTools.execute({
3890
3886
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
3891
3887
  script: "".concat(functionName, "(resultString)"),
@@ -3894,12 +3890,12 @@ function executeAttempts(options) {
3894
3890
  // Note: No ...parametersForTemplate, because working with result only
3895
3891
  },
3896
3892
  })];
3897
- case 32:
3898
- _q.$resultString = _u.sent();
3893
+ case 31:
3894
+ _p.$resultString = _t.sent();
3899
3895
  postprocessingError = null;
3900
- return [3 /*break*/, 35];
3901
- case 33:
3902
- error_2 = _u.sent();
3896
+ return [3 /*break*/, 34];
3897
+ case 32:
3898
+ error_2 = _t.sent();
3903
3899
  if (!(error_2 instanceof Error)) {
3904
3900
  throw error_2;
3905
3901
  }
@@ -3908,41 +3904,41 @@ function executeAttempts(options) {
3908
3904
  }
3909
3905
  postprocessingError = error_2;
3910
3906
  $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
3911
- return [3 /*break*/, 34];
3912
- case 34:
3913
- _p = _o.next();
3914
- return [3 /*break*/, 30];
3915
- case 35: return [3 /*break*/, 38];
3916
- case 36:
3917
- e_2_1 = _u.sent();
3907
+ return [3 /*break*/, 33];
3908
+ case 33:
3909
+ _o = _m.next();
3910
+ return [3 /*break*/, 29];
3911
+ case 34: return [3 /*break*/, 37];
3912
+ case 35:
3913
+ e_2_1 = _t.sent();
3918
3914
  e_2 = { error: e_2_1 };
3919
- return [3 /*break*/, 38];
3920
- case 37:
3915
+ return [3 /*break*/, 37];
3916
+ case 36:
3921
3917
  try {
3922
- if (_p && !_p.done && (_t = _o.return)) _t.call(_o);
3918
+ if (_o && !_o.done && (_s = _m.return)) _s.call(_m);
3923
3919
  }
3924
3920
  finally { if (e_2) throw e_2.error; }
3925
3921
  return [7 /*endfinally*/];
3926
- case 38:
3922
+ case 37:
3927
3923
  if (postprocessingError) {
3928
3924
  throw postprocessingError;
3929
3925
  }
3930
- _u.label = 39;
3931
- case 39:
3932
- _m = _l.next();
3933
- return [3 /*break*/, 28];
3934
- case 40: return [3 /*break*/, 43];
3935
- case 41:
3936
- e_3_1 = _u.sent();
3926
+ _t.label = 38;
3927
+ case 38:
3928
+ _l = _k.next();
3929
+ return [3 /*break*/, 27];
3930
+ case 39: return [3 /*break*/, 42];
3931
+ case 40:
3932
+ e_3_1 = _t.sent();
3937
3933
  e_3 = { error: e_3_1 };
3938
- return [3 /*break*/, 43];
3939
- case 42:
3934
+ return [3 /*break*/, 42];
3935
+ case 41:
3940
3936
  try {
3941
- if (_m && !_m.done && (_s = _l.return)) _s.call(_l);
3937
+ if (_l && !_l.done && (_r = _k.return)) _r.call(_k);
3942
3938
  }
3943
3939
  finally { if (e_3) throw e_3.error; }
3944
3940
  return [7 /*endfinally*/];
3945
- case 43:
3941
+ case 42:
3946
3942
  // TODO: [💝] Unite object for expecting amount and format
3947
3943
  if (template.format) {
3948
3944
  if (template.format === 'JSON') {
@@ -3967,14 +3963,14 @@ function executeAttempts(options) {
3967
3963
  checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
3968
3964
  }
3969
3965
  return [2 /*return*/, "break-attempts"];
3970
- case 44:
3971
- error_3 = _u.sent();
3966
+ case 43:
3967
+ error_3 = _t.sent();
3972
3968
  if (!(error_3 instanceof ExpectError)) {
3973
3969
  throw error_3;
3974
3970
  }
3975
3971
  $ongoingTemplateResult.$expectError = error_3;
3976
- return [3 /*break*/, 46];
3977
- case 45:
3972
+ return [3 /*break*/, 45];
3973
+ case 44:
3978
3974
  if (!isJokerAttempt &&
3979
3975
  template.templateType === 'PROMPT_TEMPLATE' &&
3980
3976
  $ongoingTemplateResult.$prompt
@@ -3991,7 +3987,7 @@ function executeAttempts(options) {
3991
3987
  });
3992
3988
  }
3993
3989
  return [7 /*endfinally*/];
3994
- case 46:
3990
+ case 45:
3995
3991
  if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
3996
3992
  throw new PipelineExecutionError(spaceTrim$1(function (block) {
3997
3993
  var _a, _b, _c;
@@ -4090,6 +4086,8 @@ function executeFormatCells(options) {
4090
4086
  return __generator(this, function (_a) {
4091
4087
  switch (_a.label) {
4092
4088
  case 0:
4089
+ // TODO: !!!!!!! Limit to N concurrent executions
4090
+ // TODO: !!!!!!! Report progress
4093
4091
  try {
4094
4092
  mappedParameters = mapAvailableToExpectedParameters({
4095
4093
  expectedParameters: Object.fromEntries(template.foreach.subparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
@@ -4873,8 +4871,13 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
4873
4871
  case 6: return [3 /*break*/, 8];
4874
4872
  case 7:
4875
4873
  error_1 = _c.sent();
4874
+ // Note: Here is expected error:
4875
+ // > PipelineExecutionError: You have not provided any `LlmExecutionTools` that support model variant "EMBEDDING
4876
+ if (!(error_1 instanceof PipelineExecutionError)) {
4877
+ throw error_1;
4878
+ }
4876
4879
  // TODO: [🟥] Detect browser / node and make it colorfull
4877
- console.error(error_1);
4880
+ console.error(error_1, "<- Note: This error is not critical to prepare the pipeline, just knowledge pieces won't have embeddings");
4878
4881
  return [3 /*break*/, 8];
4879
4882
  case 8: return [2 /*return*/, {
4880
4883
  name: name,
@@ -6359,6 +6362,9 @@ var modelCommandParser = {
6359
6362
  */
6360
6363
  parse: function (input) {
6361
6364
  var args = input.args, normalized = input.normalized;
6365
+ var availableVariantsMessage = spaceTrim(function (block) { return "\n Available variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) {
6366
+ return "- ".concat(variantName).concat(variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)');
6367
+ }).join('\n')), "\n "); });
6362
6368
  // TODO: Make this more elegant and dynamically
6363
6369
  if (normalized.startsWith('MODEL_VARIANT')) {
6364
6370
  if (normalized === 'MODEL_VARIANT_CHAT') {
@@ -6374,17 +6380,13 @@ var modelCommandParser = {
6374
6380
  key: 'modelVariant',
6375
6381
  value: 'COMPLETION',
6376
6382
  };
6383
+ // <- Note: [🤖]
6377
6384
  }
6378
6385
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
6379
- return {
6380
- type: 'MODEL',
6381
- key: 'modelVariant',
6382
- value: 'EMBEDDING',
6383
- };
6384
- // <- Note: [🤖]
6386
+ spaceTrim(function (block) { return "\n Embedding model can not be used in pipeline\n\n ".concat(block(availableVariantsMessage), "\n "); });
6385
6387
  }
6386
6388
  else {
6387
- throw new ParseError(spaceTrim(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 "); }));
6389
+ throw new ParseError(spaceTrim(function (block) { return "\n Unknown model variant in command:\n\n ".concat(block(availableVariantsMessage), "\n "); }));
6388
6390
  }
6389
6391
  }
6390
6392
  if (normalized.startsWith('MODEL_NAME')) {
@@ -9218,5 +9220,5 @@ function executionReportJsonToString(executionReportJson, options) {
9218
9220
  * TODO: [🧠] Should be in generated file GENERATOR_WARNING
9219
9221
  */
9220
9222
 
9221
- export { $llmToolsMetadataRegister, $llmToolsRegister, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, DEFAULT_CSV_SETTINGS, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MAX_EXECUTION_ATTEMPTS, MAX_FILENAME_LENGTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, MAX_PARALLEL_COUNT, MODEL_VARIANTS, MemoryStorage, NotFoundError, NotYetImplementedError, PIPELINE_COLLECTION_BASE_FILENAME, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _OpenAiMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
9223
+ export { $llmToolsMetadataRegister, $llmToolsRegister, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, DEFAULT_CSV_SETTINGS, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_EXECUTION_ATTEMPTS, MAX_FILENAME_LENGTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, MAX_PARALLEL_COUNT, MODEL_VARIANTS, MemoryStorage, NotFoundError, NotYetImplementedError, PIPELINE_COLLECTION_BASE_FILENAME, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _OpenAiMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
9222
9224
  //# sourceMappingURL=index.es.js.map