@promptbook/node 0.67.6 → 0.67.8

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
@@ -13,7 +13,7 @@ import * as dotenv from 'dotenv';
13
13
  /**
14
14
  * The version of the Promptbook library
15
15
  */
16
- var PROMPTBOOK_VERSION = '0.67.5';
16
+ var PROMPTBOOK_VERSION = '0.67.7';
17
17
  // TODO: !!!! List here all the versions and annotate + put into script
18
18
 
19
19
  /*! *****************************************************************************
@@ -867,7 +867,7 @@ function forEachAsync(array, options, callbackfunction) {
867
867
  });
868
868
  }
869
869
 
870
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.5",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],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.67.5",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],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.67.5",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],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.67.5",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT"},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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
870
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.7",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],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.67.7",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],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.67.7",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],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.67.7",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT"},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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
871
871
 
872
872
  /**
873
873
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -3052,7 +3052,7 @@ function createPipelineExecutor(options) {
3052
3052
  }
3053
3053
  function executeSingleTemplate(currentTemplate) {
3054
3054
  return __awaiter(this, void 0, void 0, function () {
3055
- var name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2;
3055
+ var name, title, priority, progress_1, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2, progress_2;
3056
3056
  var e_4, _f, _g;
3057
3057
  return __generator(this, function (_h) {
3058
3058
  switch (_h.label) {
@@ -3061,16 +3061,23 @@ function createPipelineExecutor(options) {
3061
3061
  title = currentTemplate.title;
3062
3062
  priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
3063
3063
  if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3064
- return [4 /*yield*/, onProgress({
3065
- name: name,
3066
- title: title,
3067
- isStarted: false,
3068
- isDone: false,
3069
- blockType: currentTemplate.blockType,
3070
- parameterName: currentTemplate.resultingParameterName,
3071
- parameterValue: null,
3072
- // <- [3]
3073
- })];
3064
+ progress_1 = {
3065
+ name: name,
3066
+ title: title,
3067
+ isStarted: false,
3068
+ isDone: false,
3069
+ blockType: currentTemplate.blockType,
3070
+ parameterName: currentTemplate.resultingParameterName,
3071
+ parameterValue: null,
3072
+ // <- [3]
3073
+ };
3074
+ if (isReturned) {
3075
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4F\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_1, null, 4)
3076
+ .split('\n')
3077
+ .map(function (line) { return "> ".concat(line); })
3078
+ .join('\n')), "\n "); }));
3079
+ }
3080
+ return [4 /*yield*/, onProgress(progress_1)];
3074
3081
  case 1:
3075
3082
  _h.sent();
3076
3083
  _h.label = 2;
@@ -3456,18 +3463,28 @@ function createPipelineExecutor(options) {
3456
3463
  if (resultString === null) {
3457
3464
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3458
3465
  }
3459
- if (onProgress /* <- [3] */) {
3460
- onProgress({
3461
- name: name,
3462
- title: title,
3463
- isStarted: true,
3464
- isDone: true,
3465
- blockType: currentTemplate.blockType,
3466
- parameterName: currentTemplate.resultingParameterName,
3467
- parameterValue: resultString,
3468
- // <- [3]
3469
- });
3466
+ if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3467
+ progress_2 = {
3468
+ name: name,
3469
+ title: title,
3470
+ isStarted: true,
3471
+ isDone: true,
3472
+ blockType: currentTemplate.blockType,
3473
+ parameterName: currentTemplate.resultingParameterName,
3474
+ parameterValue: resultString,
3475
+ // <- [3]
3476
+ };
3477
+ if (isReturned) {
3478
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4E\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_2, null, 4)
3479
+ .split('\n')
3480
+ .map(function (line) { return "> ".concat(line); })
3481
+ .join('\n')), "\n\n "); }));
3470
3482
  }
3483
+ return [4 /*yield*/, onProgress(progress_2)];
3484
+ case 8:
3485
+ _h.sent();
3486
+ _h.label = 9;
3487
+ case 9:
3471
3488
  parametersToPass = Object.freeze(__assign(__assign({}, parametersToPass), (_g = {}, _g[currentTemplate.resultingParameterName] = resultString /* <- Note: Not need to detect parameter collision here because pipeline checks logic consistency during construction */, _g)));
3472
3489
  return [2 /*return*/];
3473
3490
  }
@@ -3504,7 +3521,7 @@ function createPipelineExecutor(options) {
3504
3521
  }
3505
3522
  return outputParameters;
3506
3523
  }
3507
- var errors, warnings, executionReport, _a, _b, parameter, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
3524
+ var errors, warnings, executionReport, isReturned, _a, _b, parameter, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
3508
3525
  var e_1, _e, e_2, _f;
3509
3526
  return __generator(this, function (_g) {
3510
3527
  switch (_g.label) {
@@ -3529,6 +3546,7 @@ function createPipelineExecutor(options) {
3529
3546
  description: preparedPipeline.description,
3530
3547
  promptExecutions: [],
3531
3548
  };
3549
+ isReturned = false;
3532
3550
  try {
3533
3551
  // Note: Check that all input input parameters are defined
3534
3552
  for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
@@ -3537,6 +3555,7 @@ function createPipelineExecutor(options) {
3537
3555
  })), _b = _a.next(); !_b.done; _b = _a.next()) {
3538
3556
  parameter = _b.value;
3539
3557
  if (inputParameters[parameter.name] === undefined) {
3558
+ isReturned = true;
3540
3559
  return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3541
3560
  isSuccessful: false,
3542
3561
  errors: __spreadArray([
@@ -3567,6 +3586,7 @@ function createPipelineExecutor(options) {
3567
3586
  warnings.push(new PipelineExecutionError(spaceTrim(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
3568
3587
  }
3569
3588
  else if (parameter.isInput === false) {
3589
+ isReturned = true;
3570
3590
  return { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3571
3591
  isSuccessful: false,
3572
3592
  errors: __spreadArray([
@@ -3679,6 +3699,7 @@ function createPipelineExecutor(options) {
3679
3699
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
3680
3700
  })), false));
3681
3701
  outputParameters_1 = filterJustOutputParameters();
3702
+ isReturned = true;
3682
3703
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
3683
3704
  isSuccessful: false,
3684
3705
  errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
@@ -3694,6 +3715,7 @@ function createPipelineExecutor(options) {
3694
3715
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
3695
3716
  })), false));
3696
3717
  outputParameters = filterJustOutputParameters();
3718
+ isReturned = true;
3697
3719
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
3698
3720
  isSuccessful: true,
3699
3721
  errors: errors.map(serializeError),
@@ -5759,7 +5781,7 @@ function pipelineStringToJsonSync(pipelineString) {
5759
5781
  personas: [],
5760
5782
  preparations: [],
5761
5783
  };
5762
- var pipelineIdentification = (function () {
5784
+ function getPipelineIdentification() {
5763
5785
  // Note: This is a 😐 implementation of [🚞]
5764
5786
  var _ = [];
5765
5787
  if (pipelineJson.sourceFile !== undefined) {
@@ -5769,7 +5791,7 @@ function pipelineStringToJsonSync(pipelineString) {
5769
5791
  _.push("Url: ".concat(pipelineJson.pipelineUrl));
5770
5792
  }
5771
5793
  return _.join('\n');
5772
- })();
5794
+ }
5773
5795
  // =============================================================
5774
5796
  // Note: 1️⃣ Parsing of the markdown into object
5775
5797
  pipelineString = removeContentComments(pipelineString);
@@ -5778,27 +5800,27 @@ function pipelineStringToJsonSync(pipelineString) {
5778
5800
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
5779
5801
  var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
5780
5802
  if (pipelineHead === undefined) {
5781
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(pipelineIdentification), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5803
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5782
5804
  }
5783
5805
  if (pipelineHead.level !== 1) {
5784
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(pipelineIdentification), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5806
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5785
5807
  }
5786
5808
  if (!pipelineSections.every(function (section) { return section.level === 2; })) {
5787
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(pipelineIdentification), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5809
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
5788
5810
  }
5789
5811
  // =============================================================
5790
5812
  ///Note: 2️⃣ Function for defining parameters
5791
5813
  var defineParam = function (parameterCommand) {
5792
5814
  var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
5793
5815
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
5794
- throw new ParsingError(spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(pipelineIdentification), "\n "); }) /* <- TODO: [🚞] */);
5816
+ throw new ParsingError(spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(getPipelineIdentification()), "\n "); }) /* <- TODO: [🚞] */);
5795
5817
  }
5796
5818
  var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
5797
5819
  if (existingParameter &&
5798
5820
  existingParameter.description &&
5799
5821
  existingParameter.description !== parameterDescription &&
5800
5822
  parameterDescription) {
5801
- throw new ParsingError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(pipelineIdentification), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
5823
+ throw new ParsingError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
5802
5824
  }
5803
5825
  if (existingParameter) {
5804
5826
  if (parameterDescription) {
@@ -5861,10 +5883,10 @@ function pipelineStringToJsonSync(pipelineString) {
5861
5883
  // <- Note: Prototype of [🍧] (remove this comment after full implementation)
5862
5884
  break;
5863
5885
  case 'BOILERPLATE':
5864
- throw new ParsingError(spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(pipelineIdentification), "\n "); })); // <- TODO: [🚞]
5886
+ throw new ParsingError(spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
5865
5887
  // <- [💐]
5866
5888
  default:
5867
- throw new ParsingError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(pipelineIdentification), "\n "); })); // <- TODO: [🚞]
5889
+ throw new ParsingError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
5868
5890
  }
5869
5891
  };
5870
5892
  try {
@@ -5897,7 +5919,7 @@ function pipelineStringToJsonSync(pipelineString) {
5897
5919
  if (resultingParameterName !== null) {
5898
5920
  return resultingParameterName;
5899
5921
  }
5900
- throw new ParsingError(spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(pipelineIdentification), "\n\n Invalid section:\n ").concat(block(
5922
+ throw new ParsingError(spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
5901
5923
  // TODO: Show code of invalid sections each time + DRY
5902
5924
  section.content
5903
5925
  .split('\n')
@@ -5940,13 +5962,13 @@ function pipelineStringToJsonSync(pipelineString) {
5940
5962
  // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
5941
5963
  case 'BLOCK':
5942
5964
  if (isBlockTypeSet) {
5943
- throw new ParsingError(spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(pipelineIdentification), "\n "); }));
5965
+ throw new ParsingError(spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
5944
5966
  }
5945
5967
  if (command.blockType === 'SAMPLE') {
5946
5968
  expectResultingParameterName();
5947
5969
  var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
5948
5970
  if (parameter === undefined) {
5949
- throw new ParsingError(spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(pipelineIdentification), "\n "); }));
5971
+ throw new ParsingError(spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
5950
5972
  }
5951
5973
  parameter.sampleValues = parameter.sampleValues || [];
5952
5974
  parameter.sampleValues.push(content);
@@ -5981,20 +6003,20 @@ function pipelineStringToJsonSync(pipelineString) {
5981
6003
  templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
5982
6004
  if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
5983
6005
  if (templateJson.expectations[unit_1].min !== undefined) {
5984
- throw new ParsingError(spaceTrim(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
6006
+ throw new ParsingError(spaceTrim(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
5985
6007
  }
5986
6008
  templateJson.expectations[unit_1].min = command.amount;
5987
6009
  } /* not else */
5988
6010
  if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
5989
6011
  if (templateJson.expectations[unit_1].max !== undefined) {
5990
- throw new ParsingError(spaceTrim(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
6012
+ throw new ParsingError(spaceTrim(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
5991
6013
  }
5992
6014
  templateJson.expectations[unit_1].max = command.amount;
5993
6015
  }
5994
6016
  break;
5995
6017
  case 'EXPECT_FORMAT':
5996
6018
  if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
5997
- throw new ParsingError(spaceTrim(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(pipelineIdentification), "\n "); }));
6019
+ throw new ParsingError(spaceTrim(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
5998
6020
  }
5999
6021
  templateJson.expectFormat = command.format;
6000
6022
  break;
@@ -6030,11 +6052,11 @@ function pipelineStringToJsonSync(pipelineString) {
6030
6052
  // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6031
6053
  break;
6032
6054
  case 'BOILERPLATE':
6033
- console.error(new ParsingError(spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(pipelineIdentification), "\n "); })));
6055
+ console.error(new ParsingError(spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })));
6034
6056
  break;
6035
6057
  // <- [💐]
6036
6058
  default:
6037
- throw new ParsingError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
6059
+ throw new ParsingError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(getPipelineIdentification()), "\n\n "); }));
6038
6060
  }
6039
6061
  };
6040
6062
  try {
@@ -6056,7 +6078,7 @@ function pipelineStringToJsonSync(pipelineString) {
6056
6078
  // TODO: [🍧] Should be done in BLOCK command
6057
6079
  if (templateJson.blockType === 'SCRIPT') {
6058
6080
  if (!language) {
6059
- throw new ParsingError(spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(pipelineIdentification), "\n "); }));
6081
+ throw new ParsingError(spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
6060
6082
  }
6061
6083
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
6062
6084
  throw new ParsingError(spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));