@promptbook/core 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.
@@ -12,3 +12,6 @@ export type ExpectAmountCommand = {
12
12
  readonly unit: ExpectationUnit;
13
13
  readonly amount: ExpectationAmount;
14
14
  };
15
+ /**
16
+ * TODO: [🍋] Allow to `EXPECT` relative amounts like `EXPECT MAX 130% {foo} Words`
17
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.67.6",
3
+ "version": "0.67.8",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -16,7 +16,7 @@
16
16
  /**
17
17
  * The version of the Promptbook library
18
18
  */
19
- var PROMPTBOOK_VERSION = '0.67.5';
19
+ var PROMPTBOOK_VERSION = '0.67.7';
20
20
  // TODO: !!!! List here all the versions and annotate + put into script
21
21
 
22
22
  /*! *****************************************************************************
@@ -1786,7 +1786,7 @@
1786
1786
  });
1787
1787
  }
1788
1788
 
1789
- 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"}];
1789
+ 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"}];
1790
1790
 
1791
1791
  var defaultDiacriticsRemovalMap = [
1792
1792
  {
@@ -3379,7 +3379,7 @@
3379
3379
  }
3380
3380
  function executeSingleTemplate(currentTemplate) {
3381
3381
  return __awaiter(this, void 0, void 0, function () {
3382
- 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;
3382
+ 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;
3383
3383
  var e_4, _f, _g;
3384
3384
  return __generator(this, function (_h) {
3385
3385
  switch (_h.label) {
@@ -3388,16 +3388,23 @@
3388
3388
  title = currentTemplate.title;
3389
3389
  priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
3390
3390
  if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3391
- return [4 /*yield*/, onProgress({
3392
- name: name,
3393
- title: title,
3394
- isStarted: false,
3395
- isDone: false,
3396
- blockType: currentTemplate.blockType,
3397
- parameterName: currentTemplate.resultingParameterName,
3398
- parameterValue: null,
3399
- // <- [3]
3400
- })];
3391
+ progress_1 = {
3392
+ name: name,
3393
+ title: title,
3394
+ isStarted: false,
3395
+ isDone: false,
3396
+ blockType: currentTemplate.blockType,
3397
+ parameterName: currentTemplate.resultingParameterName,
3398
+ parameterValue: null,
3399
+ // <- [3]
3400
+ };
3401
+ if (isReturned) {
3402
+ throw new UnexpectedError(spaceTrim.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)
3403
+ .split('\n')
3404
+ .map(function (line) { return "> ".concat(line); })
3405
+ .join('\n')), "\n "); }));
3406
+ }
3407
+ return [4 /*yield*/, onProgress(progress_1)];
3401
3408
  case 1:
3402
3409
  _h.sent();
3403
3410
  _h.label = 2;
@@ -3783,18 +3790,28 @@
3783
3790
  if (resultString === null) {
3784
3791
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3785
3792
  }
3786
- if (onProgress /* <- [3] */) {
3787
- onProgress({
3788
- name: name,
3789
- title: title,
3790
- isStarted: true,
3791
- isDone: true,
3792
- blockType: currentTemplate.blockType,
3793
- parameterName: currentTemplate.resultingParameterName,
3794
- parameterValue: resultString,
3795
- // <- [3]
3796
- });
3793
+ if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3794
+ progress_2 = {
3795
+ name: name,
3796
+ title: title,
3797
+ isStarted: true,
3798
+ isDone: true,
3799
+ blockType: currentTemplate.blockType,
3800
+ parameterName: currentTemplate.resultingParameterName,
3801
+ parameterValue: resultString,
3802
+ // <- [3]
3803
+ };
3804
+ if (isReturned) {
3805
+ throw new UnexpectedError(spaceTrim.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)
3806
+ .split('\n')
3807
+ .map(function (line) { return "> ".concat(line); })
3808
+ .join('\n')), "\n\n "); }));
3797
3809
  }
3810
+ return [4 /*yield*/, onProgress(progress_2)];
3811
+ case 8:
3812
+ _h.sent();
3813
+ _h.label = 9;
3814
+ case 9:
3798
3815
  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)));
3799
3816
  return [2 /*return*/];
3800
3817
  }
@@ -3831,7 +3848,7 @@
3831
3848
  }
3832
3849
  return outputParameters;
3833
3850
  }
3834
- 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;
3851
+ 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;
3835
3852
  var e_1, _e, e_2, _f;
3836
3853
  return __generator(this, function (_g) {
3837
3854
  switch (_g.label) {
@@ -3856,6 +3873,7 @@
3856
3873
  description: preparedPipeline.description,
3857
3874
  promptExecutions: [],
3858
3875
  };
3876
+ isReturned = false;
3859
3877
  try {
3860
3878
  // Note: Check that all input input parameters are defined
3861
3879
  for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
@@ -3864,6 +3882,7 @@
3864
3882
  })), _b = _a.next(); !_b.done; _b = _a.next()) {
3865
3883
  parameter = _b.value;
3866
3884
  if (inputParameters[parameter.name] === undefined) {
3885
+ isReturned = true;
3867
3886
  return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3868
3887
  isSuccessful: false,
3869
3888
  errors: __spreadArray([
@@ -3894,6 +3913,7 @@
3894
3913
  warnings.push(new PipelineExecutionError(spaceTrim.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 "); })));
3895
3914
  }
3896
3915
  else if (parameter.isInput === false) {
3916
+ isReturned = true;
3897
3917
  return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3898
3918
  isSuccessful: false,
3899
3919
  errors: __spreadArray([
@@ -4006,6 +4026,7 @@
4006
4026
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
4007
4027
  })), false));
4008
4028
  outputParameters_1 = filterJustOutputParameters();
4029
+ isReturned = true;
4009
4030
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
4010
4031
  isSuccessful: false,
4011
4032
  errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
@@ -4021,6 +4042,7 @@
4021
4042
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
4022
4043
  })), false));
4023
4044
  outputParameters = filterJustOutputParameters();
4045
+ isReturned = true;
4024
4046
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
4025
4047
  isSuccessful: true,
4026
4048
  errors: errors.map(serializeError),
@@ -6068,7 +6090,7 @@
6068
6090
  personas: [],
6069
6091
  preparations: [],
6070
6092
  };
6071
- var pipelineIdentification = (function () {
6093
+ function getPipelineIdentification() {
6072
6094
  // Note: This is a 😐 implementation of [🚞]
6073
6095
  var _ = [];
6074
6096
  if (pipelineJson.sourceFile !== undefined) {
@@ -6078,7 +6100,7 @@
6078
6100
  _.push("Url: ".concat(pipelineJson.pipelineUrl));
6079
6101
  }
6080
6102
  return _.join('\n');
6081
- })();
6103
+ }
6082
6104
  // =============================================================
6083
6105
  // Note: 1️⃣ Parsing of the markdown into object
6084
6106
  pipelineString = removeContentComments(pipelineString);
@@ -6087,27 +6109,27 @@
6087
6109
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
6088
6110
  var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
6089
6111
  if (pipelineHead === undefined) {
6090
- throw new UnexpectedError(spaceTrim.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 "); }));
6112
+ throw new UnexpectedError(spaceTrim.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 "); }));
6091
6113
  }
6092
6114
  if (pipelineHead.level !== 1) {
6093
- throw new UnexpectedError(spaceTrim.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 "); }));
6115
+ throw new UnexpectedError(spaceTrim.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 "); }));
6094
6116
  }
6095
6117
  if (!pipelineSections.every(function (section) { return section.level === 2; })) {
6096
- throw new UnexpectedError(spaceTrim.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 "); }));
6118
+ throw new UnexpectedError(spaceTrim.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 "); }));
6097
6119
  }
6098
6120
  // =============================================================
6099
6121
  ///Note: 2️⃣ Function for defining parameters
6100
6122
  var defineParam = function (parameterCommand) {
6101
6123
  var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
6102
6124
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
6103
- throw new ParsingError(spaceTrim.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: [🚞] */);
6125
+ throw new ParsingError(spaceTrim.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: [🚞] */);
6104
6126
  }
6105
6127
  var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
6106
6128
  if (existingParameter &&
6107
6129
  existingParameter.description &&
6108
6130
  existingParameter.description !== parameterDescription &&
6109
6131
  parameterDescription) {
6110
- throw new ParsingError(spaceTrim.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 "); }));
6132
+ throw new ParsingError(spaceTrim.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 "); }));
6111
6133
  }
6112
6134
  if (existingParameter) {
6113
6135
  if (parameterDescription) {
@@ -6170,10 +6192,10 @@
6170
6192
  // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6171
6193
  break;
6172
6194
  case 'BOILERPLATE':
6173
- throw new ParsingError(spaceTrim.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: [🚞]
6195
+ throw new ParsingError(spaceTrim.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: [🚞]
6174
6196
  // <- [💐]
6175
6197
  default:
6176
- throw new ParsingError(spaceTrim.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: [🚞]
6198
+ throw new ParsingError(spaceTrim.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: [🚞]
6177
6199
  }
6178
6200
  };
6179
6201
  try {
@@ -6206,7 +6228,7 @@
6206
6228
  if (resultingParameterName !== null) {
6207
6229
  return resultingParameterName;
6208
6230
  }
6209
- throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(pipelineIdentification), "\n\n Invalid section:\n ").concat(block(
6231
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
6210
6232
  // TODO: Show code of invalid sections each time + DRY
6211
6233
  section.content
6212
6234
  .split('\n')
@@ -6249,13 +6271,13 @@
6249
6271
  // TODO: [🍧] Use here applyToPipelineJson and remove switch statement
6250
6272
  case 'BLOCK':
6251
6273
  if (isBlockTypeSet) {
6252
- throw new ParsingError(spaceTrim.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 "); }));
6274
+ throw new ParsingError(spaceTrim.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 "); }));
6253
6275
  }
6254
6276
  if (command.blockType === 'SAMPLE') {
6255
6277
  expectResultingParameterName();
6256
6278
  var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
6257
6279
  if (parameter === undefined) {
6258
- throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(pipelineIdentification), "\n "); }));
6280
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6259
6281
  }
6260
6282
  parameter.sampleValues = parameter.sampleValues || [];
6261
6283
  parameter.sampleValues.push(content);
@@ -6290,20 +6312,20 @@
6290
6312
  templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
6291
6313
  if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
6292
6314
  if (templateJson.expectations[unit_1].min !== undefined) {
6293
- throw new ParsingError(spaceTrim.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 "); }));
6315
+ throw new ParsingError(spaceTrim.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 "); }));
6294
6316
  }
6295
6317
  templateJson.expectations[unit_1].min = command.amount;
6296
6318
  } /* not else */
6297
6319
  if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
6298
6320
  if (templateJson.expectations[unit_1].max !== undefined) {
6299
- throw new ParsingError(spaceTrim.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 "); }));
6321
+ throw new ParsingError(spaceTrim.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 "); }));
6300
6322
  }
6301
6323
  templateJson.expectations[unit_1].max = command.amount;
6302
6324
  }
6303
6325
  break;
6304
6326
  case 'EXPECT_FORMAT':
6305
6327
  if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
6306
- throw new ParsingError(spaceTrim.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 "); }));
6328
+ throw new ParsingError(spaceTrim.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 "); }));
6307
6329
  }
6308
6330
  templateJson.expectFormat = command.format;
6309
6331
  break;
@@ -6339,11 +6361,11 @@
6339
6361
  // <- Note: Prototype of [🍧] (remove this comment after full implementation)
6340
6362
  break;
6341
6363
  case 'BOILERPLATE':
6342
- console.error(new ParsingError(spaceTrim.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 "); })));
6364
+ console.error(new ParsingError(spaceTrim.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 "); })));
6343
6365
  break;
6344
6366
  // <- [💐]
6345
6367
  default:
6346
- throw new ParsingError(spaceTrim.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 "); }));
6368
+ throw new ParsingError(spaceTrim.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 "); }));
6347
6369
  }
6348
6370
  };
6349
6371
  try {
@@ -6365,7 +6387,7 @@
6365
6387
  // TODO: [🍧] Should be done in BLOCK command
6366
6388
  if (templateJson.blockType === 'SCRIPT') {
6367
6389
  if (!language) {
6368
- throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(pipelineIdentification), "\n "); }));
6390
+ throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
6369
6391
  }
6370
6392
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
6371
6393
  throw new ParsingError(spaceTrim.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 "); }));