@promptbook/cli 0.68.0-2 → 0.68.0-4

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.
Files changed (44) hide show
  1. package/README.md +2 -2
  2. package/esm/index.es.js +188 -168
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +3 -3
  5. package/esm/typings/src/_packages/core.index.d.ts +4 -4
  6. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  7. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
  8. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
  9. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +3 -0
  10. package/esm/typings/src/commands/TEMPLATE/TemplateCommand.d.ts +11 -0
  11. package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +15 -0
  12. package/esm/typings/src/commands/TEMPLATE/templateCommandParser.d.ts +12 -0
  13. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +3 -0
  14. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +3 -0
  15. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +11 -0
  16. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +11 -0
  17. package/esm/typings/src/commands/_common/stringifyCommand.test.d.ts +1 -0
  18. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -2
  19. package/esm/typings/src/commands/index.d.ts +1 -1
  20. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
  21. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -1
  22. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
  23. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +1 -1
  24. package/esm/typings/src/conversion/validation/pipelineStringToJson-parseErrors.test.d.ts +4 -0
  25. package/esm/typings/src/conversion/validation/validatePipeline-logicErrors.test.d.ts +1 -1
  26. package/esm/typings/src/conversion/validation/validatePipeline.test.d.ts +3 -0
  27. package/esm/typings/src/errors/PipelineLogicError.d.ts +1 -1
  28. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +1 -1
  29. package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
  30. package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +1 -1
  31. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +2 -2
  32. package/esm/typings/src/types/PipelineJson/ScriptTemplateJson.d.ts +2 -2
  33. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +1 -1
  34. package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
  35. package/esm/typings/src/types/TaskProgress.d.ts +2 -2
  36. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +0 -1
  37. package/package.json +1 -1
  38. package/umd/index.umd.js +188 -168
  39. package/umd/index.umd.js.map +1 -1
  40. package/esm/typings/src/commands/BLOCK/BlockCommand.d.ts +0 -11
  41. package/esm/typings/src/commands/BLOCK/BlockTypes.d.ts +0 -15
  42. package/esm/typings/src/commands/BLOCK/blockCommandParser.d.ts +0 -9
  43. /package/esm/typings/src/commands/{BLOCK/blockCommand.test.d.ts → TEMPLATE/templateCommand.test.d.ts} +0 -0
  44. /package/esm/typings/src/{conversion/validation/pipelineStringToJson-syntaxErrors.test.d.ts → commands/_common/getParserForCommand.test.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ import OpenAI from 'openai';
20
20
  /**
21
21
  * The version of the Promptbook library
22
22
  */
23
- var PROMPTBOOK_VERSION = '0.68.0-1';
23
+ var PROMPTBOOK_VERSION = '0.68.0-3';
24
24
  // TODO: !!!! List here all the versions and annotate + put into script
25
25
 
26
26
  /*! *****************************************************************************
@@ -703,7 +703,7 @@ function pipelineJsonToString(pipelineJson) {
703
703
  /* Note: Not using:> name, */
704
704
  title_1 = template.title, description_1 = template.description,
705
705
  /* Note: dependentParameterNames, */
706
- jokers = template.jokerParameterNames, blockType = template.blockType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
706
+ jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
707
707
  pipelineString += '\n\n';
708
708
  pipelineString += "## ".concat(title_1);
709
709
  if (description_1) {
@@ -713,7 +713,7 @@ function pipelineJsonToString(pipelineJson) {
713
713
  // TODO:> const commands: Array<Command>
714
714
  var commands_1 = [];
715
715
  var contentLanguage = 'text';
716
- if (blockType === 'PROMPT_TEMPLATE') {
716
+ if (templateType === 'PROMPT_TEMPLATE') {
717
717
  var modelRequirements = template.modelRequirements;
718
718
  var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
719
719
  commands_1.push("EXECUTE PROMPT TEMPLATE");
@@ -724,12 +724,12 @@ function pipelineJsonToString(pipelineJson) {
724
724
  commands_1.push("MODEL NAME `".concat(modelName, "`"));
725
725
  }
726
726
  }
727
- else if (blockType === 'SIMPLE_TEMPLATE') {
727
+ else if (templateType === 'SIMPLE_TEMPLATE') {
728
728
  commands_1.push("SIMPLE TEMPLATE");
729
729
  // Note: Nothing special here
730
730
  }
731
- else if (blockType === 'SCRIPT_TEMPLATE') {
732
- commands_1.push("EXECUTE SCRIPT");
731
+ else if (templateType === 'SCRIPT_TEMPLATE') {
732
+ commands_1.push("SCRIPT TEMPLATE");
733
733
  if (template.contentLanguage) {
734
734
  contentLanguage = template.contentLanguage;
735
735
  }
@@ -737,8 +737,8 @@ function pipelineJsonToString(pipelineJson) {
737
737
  contentLanguage = '';
738
738
  }
739
739
  }
740
- else if (blockType === 'DIALOG_TEMPLATE') {
741
- commands_1.push("DIALOG BLOCK");
740
+ else if (templateType === 'DIALOG_TEMPLATE') {
741
+ commands_1.push("DIALOG TEMPLATE");
742
742
  // Note: Nothing special here
743
743
  } // <- }else if([🅱]
744
744
  if (jokers) {
@@ -837,7 +837,7 @@ function templateParameterJsonToString(templateParameterJson) {
837
837
  return parameterString;
838
838
  }
839
839
  /**
840
- * TODO: !!!!!! Implement new features and commands into `templateParameterJsonToString`
840
+ * TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `templateParameterJsonToString` , use `stringifyCommand`
841
841
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
842
842
  * TODO: [🏛] Maybe make some markdown builder
843
843
  * TODO: [🏛] Escape all
@@ -1040,7 +1040,7 @@ function forEachAsync(array, options, callbackfunction) {
1040
1040
  });
1041
1041
  }
1042
1042
 
1043
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-1",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{blockType:"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.68.0-1",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{blockType:"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.68.0-1",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{blockType:"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.68.0-1",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:[{blockType:"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"}];
1043
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-3",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.68.0-3",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.68.0-3",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.68.0-3",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"}];
1044
1044
 
1045
1045
  /**
1046
1046
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -1062,7 +1062,7 @@ var ParseError = /** @class */ (function (_super) {
1062
1062
  */
1063
1063
 
1064
1064
  /**
1065
- * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
1065
+ * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
1066
1066
  *
1067
1067
  * @public exported from `@promptbook/core`
1068
1068
  */
@@ -1644,7 +1644,7 @@ var SimplePipelineCollection = /** @class */ (function () {
1644
1644
  * Creates PipelineCollection from array of PipelineJson or PipelineString
1645
1645
  *
1646
1646
  * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
1647
- * Note: During the construction syntax and logic of all sources are validated
1647
+ * Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
1648
1648
  *
1649
1649
  * @param promptbookSources
1650
1650
  * @returns PipelineCollection
@@ -2227,7 +2227,7 @@ function extractVariables(script) {
2227
2227
  */
2228
2228
  function extractParameterNamesFromTemplate(template) {
2229
2229
  var e_1, _a, e_2, _b, e_3, _c;
2230
- var title = template.title, description = template.description, blockType = template.blockType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
2230
+ var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
2231
2231
  var parameterNames = new Set();
2232
2232
  try {
2233
2233
  for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
@@ -2242,7 +2242,7 @@ function extractParameterNamesFromTemplate(template) {
2242
2242
  }
2243
2243
  finally { if (e_1) throw e_1.error; }
2244
2244
  }
2245
- if (blockType === 'SCRIPT_TEMPLATE') {
2245
+ if (templateType === 'SCRIPT_TEMPLATE') {
2246
2246
  try {
2247
2247
  for (var _f = __values(extractVariables(content)), _g = _f.next(); !_g.done; _g = _f.next()) {
2248
2248
  var parameterName = _g.value;
@@ -3222,7 +3222,7 @@ function createPipelineExecutor(options) {
3222
3222
  title: title,
3223
3223
  isStarted: false,
3224
3224
  isDone: false,
3225
- blockType: currentTemplate.blockType,
3225
+ templateType: currentTemplate.templateType,
3226
3226
  parameterName: currentTemplate.resultingParameterName,
3227
3227
  parameterValue: null,
3228
3228
  // <- [3]
@@ -3287,7 +3287,7 @@ function createPipelineExecutor(options) {
3287
3287
  result = null;
3288
3288
  resultString = null;
3289
3289
  expectError = null;
3290
- maxAttempts = currentTemplate.blockType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
3290
+ maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
3291
3291
  jokerParameterNames = currentTemplate.jokerParameterNames || [];
3292
3292
  preparedContent = (currentTemplate.preparedContent || '{content}')
3293
3293
  .split('{content}')
@@ -3319,7 +3319,7 @@ function createPipelineExecutor(options) {
3319
3319
  case 1:
3320
3320
  _v.trys.push([1, 44, 45, 46]);
3321
3321
  if (!!isJokerAttempt) return [3 /*break*/, 26];
3322
- _j = currentTemplate.blockType;
3322
+ _j = currentTemplate.templateType;
3323
3323
  switch (_j) {
3324
3324
  case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3325
3325
  case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
@@ -3453,10 +3453,10 @@ function createPipelineExecutor(options) {
3453
3453
  priority: priority,
3454
3454
  }))];
3455
3455
  case 24:
3456
- // TODO: [🌹] When making next attempt for `DIALOG BLOCK`, preserve the previous user input
3456
+ // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3457
3457
  resultString = _v.sent();
3458
3458
  return [3 /*break*/, 26];
3459
- case 25: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(currentTemplate.blockType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3459
+ case 25: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(currentTemplate.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3460
3460
  case 26:
3461
3461
  if (!(!isJokerAttempt && currentTemplate.postprocessingFunctionNames)) return [3 /*break*/, 43];
3462
3462
  _v.label = 27;
@@ -3571,12 +3571,12 @@ function createPipelineExecutor(options) {
3571
3571
  return [3 /*break*/, 46];
3572
3572
  case 45:
3573
3573
  if (!isJokerAttempt &&
3574
- currentTemplate.blockType === 'PROMPT_TEMPLATE' &&
3574
+ currentTemplate.templateType === 'PROMPT_TEMPLATE' &&
3575
3575
  prompt
3576
3576
  // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
3577
3577
  // In that case we don’t want to make a report about it because it’s not a llm execution error
3578
3578
  ) {
3579
- // TODO: [🧠] Maybe put other blockTypes into report
3579
+ // TODO: [🧠] Maybe put other templateTypes into report
3580
3580
  executionReport.promptExecutions.push({
3581
3581
  prompt: __assign({}, prompt),
3582
3582
  result: result || undefined,
@@ -3627,7 +3627,7 @@ function createPipelineExecutor(options) {
3627
3627
  title: title,
3628
3628
  isStarted: true,
3629
3629
  isDone: true,
3630
- blockType: currentTemplate.blockType,
3630
+ templateType: currentTemplate.templateType,
3631
3631
  parameterName: currentTemplate.resultingParameterName,
3632
3632
  parameterValue: resultString,
3633
3633
  // <- [3]
@@ -4595,7 +4595,7 @@ var knowledgeCommandParser = {
4595
4595
  */
4596
4596
  stringify: function (command) {
4597
4597
  keepUnused(command);
4598
- return "!!!!!!";
4598
+ return "---"; // <- TODO: [🛋] Implement
4599
4599
  },
4600
4600
  /**
4601
4601
  * Reads the KNOWLEDGE command from the `PipelineJson`
@@ -4604,17 +4604,20 @@ var knowledgeCommandParser = {
4604
4604
  */
4605
4605
  takeFromPipelineJson: function (pipelineJson) {
4606
4606
  keepUnused(pipelineJson);
4607
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
4607
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
4608
4608
  },
4609
4609
  };
4610
+ /**
4611
+ * Note: [⛱] There are two types of KNOWLEDGE commands *...(read more in [⛱])*
4612
+ */
4610
4613
 
4611
4614
  /**
4612
- * Block type describes the way how the block is blockd
4615
+ * Template type describes the way how the template is templated
4613
4616
  *
4614
- * @see https://github.com/webgptorg/promptbook#block-type
4617
+ * @see https://github.com/webgptorg/promptbook#template-type
4615
4618
  * @public exported from `@promptbook/core`
4616
4619
  */
4617
- var BlockTypes = [
4620
+ var TemplateTypes = [
4618
4621
  'PROMPT_TEMPLATE',
4619
4622
  'SIMPLE_TEMPLATE',
4620
4623
  'SCRIPT_TEMPLATE',
@@ -4627,108 +4630,114 @@ var BlockTypes = [
4627
4630
  ];
4628
4631
 
4629
4632
  /**
4630
- * Parses the block command
4633
+ * Parses the template command
4631
4634
  *
4632
- * @see ./BLOCK-README.md for more details
4635
+ * @see ./TEMPLATE-README.md for more details
4633
4636
  * @private within the commands folder
4634
4637
  */
4635
- var blockCommandParser = {
4638
+ var templateCommandParser = {
4636
4639
  /**
4637
4640
  * Name of the command
4638
4641
  */
4639
- name: 'BLOCK',
4642
+ name: 'TEMPLATE',
4640
4643
  /**
4641
- * Aliases for the BLOCK command
4644
+ * Aliases for the TEMPLATE command
4642
4645
  */
4643
4646
  aliasNames: [
4644
- 'PROMPT_TEMPLATE',
4645
- 'SIMPLE_TEMPLATE',
4646
- 'SCRIPT_TEMPLATE',
4647
- 'DIALOG_TEMPLATE',
4647
+ 'PROMPT',
4648
+ 'SIMPLE',
4649
+ 'SCRIPT',
4650
+ 'DIALOG',
4648
4651
  'SAMPLE',
4649
4652
  'EXAMPLE',
4650
4653
  'KNOWLEDGE',
4651
4654
  'INSTRUMENT',
4652
- 'ACTION',
4653
- // <- [🅱]
4655
+ 'ACTION', // <- Note: [⛱]
4654
4656
  ],
4655
4657
  /**
4656
- * Aliases for the BLOCK command
4658
+ * Aliases for the TEMPLATE command
4657
4659
  */
4658
- deprecatedNames: ['EXECUTE'],
4660
+ deprecatedNames: ['BLOCK', 'EXECUTE'],
4659
4661
  /**
4660
4662
  * BOILERPLATE command can be used in:
4661
4663
  */
4662
4664
  isUsedInPipelineHead: false,
4663
4665
  isUsedInPipelineTemplate: true,
4664
4666
  /**
4665
- * Description of the BLOCK command
4667
+ * Description of the TEMPLATE command
4666
4668
  */
4667
- description: "What should the code block template do",
4669
+ description: "What should the code template template do",
4668
4670
  /**
4669
4671
  * Link to discussion
4670
4672
  */
4671
4673
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/64',
4672
4674
  /**
4673
- * Example usages of the BLOCK command
4675
+ * Example usages of the TEMPLATE command
4674
4676
  */
4675
4677
  examples: [
4676
- // Recommended form:
4677
- 'PROMPT BLOCK',
4678
- 'SIMPLE BLOCK',
4679
- 'SCRIPT BLOCK',
4680
- 'DIALOG BLOCK',
4678
+ // Short form:
4679
+ 'PROMPT',
4680
+ 'SIMPLE',
4681
+ 'SCRIPT',
4682
+ 'DIALOG',
4681
4683
  // <- [🅱]
4682
- // Long form:
4683
- 'PROMPT TEMPLATE BLOCK',
4684
- 'SIMPLE TEMPLATE BLOCK',
4685
- 'SCRIPT TEMPLATE BLOCK',
4686
- 'DIALOG TEMPLATE BLOCK',
4684
+ 'SAMPLE',
4685
+ 'KNOWLEDGE',
4686
+ 'INSTRUMENT',
4687
+ 'ACTION',
4688
+ // -----------------
4689
+ // Recommended (reversed) form:
4690
+ 'PROMPT TEMPLATE',
4691
+ 'SIMPLE TEMPLATE',
4692
+ 'SCRIPT TEMPLATE',
4693
+ 'DIALOG TEMPLATE',
4687
4694
  // <- [🅱]
4688
- // Reversed form:
4689
- 'BLOCK PROMPT TEMPLATE',
4690
- 'BLOCK SIMPLE TEMPLATE',
4691
- 'BLOCK SCRIPT TEMPLATE',
4692
- 'BLOCK DIALOG TEMPLATE',
4695
+ 'SAMPLE TEMPLATE',
4696
+ 'KNOWLEDGE TEMPLATE',
4697
+ 'INSTRUMENT TEMPLATE',
4698
+ 'ACTION TEMPLATE',
4699
+ // -----------------
4700
+ // Standard form:
4701
+ 'TEMPLATE PROMPT',
4702
+ 'TEMPLATE SIMPLE',
4703
+ 'TEMPLATE SCRIPT',
4704
+ 'TEMPLATE DIALOG',
4693
4705
  // <- [🅱]
4694
- // 'Knowledge', // <- Note: [⛱] For execution blocks which are also separate commands shortcut does not work
4695
- //---
4696
- /* Note: Not implemented block types will be in examples in future -> */
4697
- 'Instrument BLOCK',
4698
- // 'Instrument', // <- Note: [⛱]
4699
- 'Action BLOCK',
4700
- // 'Action', // <- Note: [⛱]
4701
- //---
4702
- /* <- TODO: [🧠] Maybe dynamic */
4706
+ 'SAMPLE TEMPLATE',
4707
+ 'KNOWLEDGE TEMPLATE',
4708
+ 'INSTRUMENT TEMPLATE',
4709
+ 'ACTION TEMPLATE',
4703
4710
  ],
4704
4711
  // TODO: [♓️] order: -10 /* <- Note: Putting before other commands */
4705
4712
  /**
4706
- * Parses the BLOCK command
4713
+ * Parses the TEMPLATE command
4707
4714
  */
4708
4715
  parse: function (input) {
4709
4716
  var normalized = input.normalized;
4710
4717
  normalized = normalized.split('EXAMPLE').join('SAMPLE');
4711
- var blockTypes = BlockTypes.filter(function (blockType) { return normalized.includes(blockType.split('_TEMPLATE').join('')); });
4712
- if (blockTypes.length !== 1) {
4713
- throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown block type in BLOCK command\n\n Supported block types are:\n ".concat(block(BlockTypes.join(', ')), "\n "); }));
4718
+ var templateTypes = TemplateTypes.filter(function (templateType) {
4719
+ return normalized.includes(templateType.split('_TEMPLATE').join(''));
4720
+ });
4721
+ if (templateTypes.length !== 1) {
4722
+ throw new ParseError(spaceTrim$1(function (template) { return "\n Unknown template type in TEMPLATE command\n\n Supported template types are:\n ".concat(template(TemplateTypes.join(', ')), "\n "); }));
4714
4723
  }
4715
- var blockType = blockTypes[0];
4724
+ var templateType = templateTypes[0];
4716
4725
  return {
4717
- type: 'BLOCK',
4718
- blockType: blockType,
4726
+ type: 'TEMPLATE',
4727
+ templateType: templateType,
4719
4728
  };
4720
4729
  },
4721
4730
  /**
4722
- * Apply the BLOCK command to the `pipelineJson`
4731
+ * Apply the TEMPLATE command to the `pipelineJson`
4723
4732
  *
4724
4733
  * Note: `$` is used to indicate that this function mutates given `templateJson`
4725
4734
  */
4726
4735
  $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
4727
- // TODO: !!!!!! Test multiple / no block type
4728
- if ($templateJson.isBlockTypeSet === true) {
4729
- throw new ParseError(spaceTrim$1("\n Block type is already defined in the template.\n It can be defined only once.\n "));
4736
+ // TODO: !!!!!! Test multiple / no template type
4737
+ if ($templateJson.isTemplateTypeSet === true) {
4738
+ throw new ParseError(spaceTrim$1("\n Template type is already defined in the template.\n It can be defined only once.\n "));
4730
4739
  }
4731
- $templateJson.isBlockTypeSet = true;
4740
+ $templateJson.isTemplateTypeSet = true;
4732
4741
  // TODO: !!!!!! Rearrange better - but at bottom and unwrap from function
4733
4742
  var expectResultingParameterName = function () {
4734
4743
  if ($templateJson.resultingParameterName) {
@@ -4739,7 +4748,7 @@ var blockCommandParser = {
4739
4748
  if ($templateJson.content === undefined) {
4740
4749
  throw new UnexpectedError("Content is missing in the templateJson - probbably commands are applied in wrong order");
4741
4750
  }
4742
- if (command.blockType === 'SAMPLE') {
4751
+ if (command.templateType === 'SAMPLE') {
4743
4752
  expectResultingParameterName();
4744
4753
  var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $templateJson.resultingParameterName; });
4745
4754
  if (parameter === undefined) {
@@ -4747,66 +4756,59 @@ var blockCommandParser = {
4747
4756
  }
4748
4757
  parameter.sampleValues = parameter.sampleValues || [];
4749
4758
  parameter.sampleValues.push($templateJson.content);
4750
- // TODO: !!!!!! How to implement this?
4751
- // continue templates;
4752
- $templateJson.isTemplateBlock = false;
4759
+ $templateJson.isTemplate = false;
4753
4760
  return;
4754
4761
  }
4755
- if (command.blockType === 'KNOWLEDGE') {
4762
+ if (command.templateType === 'KNOWLEDGE') {
4756
4763
  knowledgeCommandParser.$applyToPipelineJson({
4757
4764
  type: 'KNOWLEDGE',
4758
4765
  sourceContent: $templateJson.content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
4759
4766
  }, $pipelineJson);
4760
- // TODO: !!!!!! How to implement this?
4761
- // continue templates;
4762
- $templateJson.isTemplateBlock = false;
4767
+ $templateJson.isTemplate = false;
4763
4768
  return;
4764
4769
  }
4765
- if (command.blockType === 'ACTION') {
4770
+ if (command.templateType === 'ACTION') {
4766
4771
  console.error(new NotYetImplementedError('Actions are not implemented yet'));
4767
- // TODO: !!!!!! How to implement this?
4768
- // continue templates;
4769
- $templateJson.isTemplateBlock = false;
4772
+ $templateJson.isTemplate = false;
4770
4773
  return;
4771
4774
  }
4772
- if (command.blockType === 'INSTRUMENT') {
4775
+ if (command.templateType === 'INSTRUMENT') {
4773
4776
  console.error(new NotYetImplementedError('Instruments are not implemented yet'));
4774
- // TODO: !!!!!! How to implement this?
4775
- // continue templates;
4776
- $templateJson.isTemplateBlock = false;
4777
+ $templateJson.isTemplate = false;
4777
4778
  return;
4778
4779
  }
4779
4780
  expectResultingParameterName();
4780
- $templateJson.blockType = command.blockType;
4781
+ $templateJson.templateType = command.templateType;
4781
4782
  /*
4782
4783
  TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
4783
- if (command.blockType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
4784
+ if (command.templateType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
4784
4785
  templateModelRequirements.modelVariant = 'CHAT';
4785
4786
  }
4786
4787
  */
4787
- // !!!!!!
4788
- // isBlockTypeSet = true; //<- Note: [2]
4789
- $templateJson.isTemplateBlock = true;
4788
+ $templateJson.isTemplate = true;
4790
4789
  },
4791
4790
  /**
4792
- * Converts the BLOCK command back to string
4791
+ * Converts the TEMPLATE command back to string
4793
4792
  *
4794
4793
  * Note: This is used in `pipelineJsonToString` utility
4795
4794
  */
4796
4795
  stringify: function (command) {
4797
4796
  keepUnused(command);
4798
- return "!!!!!!";
4797
+ return "---"; // <- TODO: [🛋] Implement
4799
4798
  },
4800
4799
  /**
4801
- * Reads the BLOCK command from the `TemplateJson`
4800
+ * Reads the TEMPLATE command from the `TemplateJson`
4802
4801
  *
4803
4802
  * Note: This is used in `pipelineJsonToString` utility
4804
4803
  */
4805
4804
  takeFromTemplateJson: function ($templateJson) {
4806
4805
  keepUnused($templateJson);
4807
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
4806
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
4808
4807
  },
4809
4808
  };
4809
+ /**
4810
+ * Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands @@@!!!!!!
4811
+ */
4810
4812
 
4811
4813
  /**
4812
4814
  * Units of text measurement
@@ -5025,7 +5027,7 @@ var expectCommandParser = {
5025
5027
  */
5026
5028
  stringify: function (command) {
5027
5029
  keepUnused(command);
5028
- return "!!!!!!";
5030
+ return "---"; // <- TODO: [🛋] Implement
5029
5031
  },
5030
5032
  /**
5031
5033
  * Reads the FORMAT command from the `TemplateJson`
@@ -5034,7 +5036,7 @@ var expectCommandParser = {
5034
5036
  */
5035
5037
  takeFromTemplateJson: function ($templateJson) {
5036
5038
  keepUnused($templateJson);
5037
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5039
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5038
5040
  },
5039
5041
  };
5040
5042
 
@@ -5119,7 +5121,7 @@ var foreachCommandParser = {
5119
5121
  },
5120
5122
  };
5121
5123
  /**
5122
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong syntax and logic
5124
+ * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
5123
5125
  */
5124
5126
 
5125
5127
  /**
@@ -5183,7 +5185,7 @@ var formatCommandParser = {
5183
5185
  */
5184
5186
  stringify: function (command) {
5185
5187
  keepUnused(command);
5186
- return "!!!!!!";
5188
+ return "---"; // <- TODO: [🛋] Implement
5187
5189
  },
5188
5190
  /**
5189
5191
  * Reads the FORMAT command from the `TemplateJson`
@@ -5192,7 +5194,7 @@ var formatCommandParser = {
5192
5194
  */
5193
5195
  takeFromTemplateJson: function ($templateJson) {
5194
5196
  keepUnused($templateJson);
5195
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5197
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5196
5198
  },
5197
5199
  };
5198
5200
 
@@ -5255,7 +5257,7 @@ var jokerCommandParser = {
5255
5257
  */
5256
5258
  stringify: function (command) {
5257
5259
  keepUnused(command);
5258
- return "!!!!!!";
5260
+ return "---"; // <- TODO: [🛋] Implement
5259
5261
  },
5260
5262
  /**
5261
5263
  * Reads the JOKER command from the `TemplateJson`
@@ -5264,7 +5266,7 @@ var jokerCommandParser = {
5264
5266
  */
5265
5267
  takeFromTemplateJson: function ($templateJson) {
5266
5268
  keepUnused($templateJson);
5267
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5269
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5268
5270
  },
5269
5271
  };
5270
5272
 
@@ -5344,7 +5346,7 @@ var modelCommandParser = {
5344
5346
  };
5345
5347
  }
5346
5348
  else {
5347
- throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown model key in command.\n\n Supported model keys are:\n ".concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
5349
+ throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown model key in command.\n\n Supported model keys are:\n ".concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
5348
5350
  }
5349
5351
  },
5350
5352
  /**
@@ -5363,7 +5365,7 @@ var modelCommandParser = {
5363
5365
  * Note: `$` is used to indicate that this function mutates given `templateJson`
5364
5366
  */
5365
5367
  $applyToTemplateJson: function (command, $templateJson) {
5366
- if ($templateJson.blockType !== 'PROMPT_TEMPLATE') {
5368
+ if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
5367
5369
  throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
5368
5370
  }
5369
5371
  // TODO: !!!!!! Error on redefine
@@ -5378,7 +5380,7 @@ var modelCommandParser = {
5378
5380
  */
5379
5381
  stringify: function (command) {
5380
5382
  keepUnused(command);
5381
- return "!!!!!!";
5383
+ return "---"; // <- TODO: [🛋] Implement
5382
5384
  },
5383
5385
  /**
5384
5386
  * Reads the MODEL command from the `PipelineJson`
@@ -5387,7 +5389,7 @@ var modelCommandParser = {
5387
5389
  */
5388
5390
  takeFromPipelineJson: function (pipelineJson) {
5389
5391
  keepUnused(pipelineJson);
5390
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5392
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5391
5393
  },
5392
5394
  /**
5393
5395
  * Reads the MODEL command from the `TemplateJson`
@@ -5396,7 +5398,7 @@ var modelCommandParser = {
5396
5398
  */
5397
5399
  takeFromTemplateJson: function ($templateJson) {
5398
5400
  keepUnused($templateJson);
5399
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5401
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5400
5402
  },
5401
5403
  };
5402
5404
 
@@ -5487,7 +5489,7 @@ var parameterCommandParser = {
5487
5489
  */
5488
5490
  stringify: function (command) {
5489
5491
  keepUnused(command);
5490
- return "!!!!!!";
5492
+ return "---"; // <- TODO: [🛋] Implement
5491
5493
  },
5492
5494
  /**
5493
5495
  * Reads the PARAMETER command from the `PipelineJson`
@@ -5496,7 +5498,7 @@ var parameterCommandParser = {
5496
5498
  */
5497
5499
  takeFromPipelineJson: function (pipelineJson) {
5498
5500
  keepUnused(pipelineJson);
5499
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5501
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5500
5502
  },
5501
5503
  /**
5502
5504
  * Reads the PARAMETER command from the `TemplateJson`
@@ -5505,7 +5507,7 @@ var parameterCommandParser = {
5505
5507
  */
5506
5508
  takeFromTemplateJson: function ($templateJson) {
5507
5509
  keepUnused($templateJson);
5508
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5510
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5509
5511
  },
5510
5512
  };
5511
5513
 
@@ -5577,7 +5579,7 @@ var personaCommandParser = {
5577
5579
  */
5578
5580
  stringify: function (command) {
5579
5581
  keepUnused(command);
5580
- return "!!!!!!";
5582
+ return "---"; // <- TODO: [🛋] Implement
5581
5583
  },
5582
5584
  /**
5583
5585
  * Reads the PERSONA command from the `PipelineJson`
@@ -5586,7 +5588,7 @@ var personaCommandParser = {
5586
5588
  */
5587
5589
  takeFromPipelineJson: function (pipelineJson) {
5588
5590
  keepUnused(pipelineJson);
5589
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5591
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5590
5592
  },
5591
5593
  /**
5592
5594
  * Reads the PERSONA command from the `TemplateJson`
@@ -5595,7 +5597,7 @@ var personaCommandParser = {
5595
5597
  */
5596
5598
  takeFromTemplateJson: function ($templateJson) {
5597
5599
  keepUnused($templateJson);
5598
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5600
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5599
5601
  },
5600
5602
  };
5601
5603
  /**
@@ -5606,7 +5608,7 @@ var personaCommandParser = {
5606
5608
  function $applyToTemplateJson(command, $templateJson, $pipelineJson) {
5607
5609
  var personaName = command.personaName, personaDescription = command.personaDescription;
5608
5610
  if ($templateJson !== null) {
5609
- if ($templateJson.blockType !== 'PROMPT_TEMPLATE') {
5611
+ if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
5610
5612
  throw new ParseError("PERSONA command can be used only in PROMPT_TEMPLATE block");
5611
5613
  }
5612
5614
  $templateJson.personaName = personaName;
@@ -5714,7 +5716,7 @@ var postprocessCommandParser = {
5714
5716
  */
5715
5717
  stringify: function (command) {
5716
5718
  keepUnused(command);
5717
- return "!!!!!!";
5719
+ return "---"; // <- TODO: [🛋] Implement
5718
5720
  },
5719
5721
  /**
5720
5722
  * Reads the POSTPROCESS command from the `TemplateJson`
@@ -5723,7 +5725,7 @@ var postprocessCommandParser = {
5723
5725
  */
5724
5726
  takeFromTemplateJson: function ($templateJson) {
5725
5727
  keepUnused($templateJson);
5726
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5728
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5727
5729
  },
5728
5730
  };
5729
5731
 
@@ -5791,7 +5793,7 @@ var promptbookVersionCommandParser = {
5791
5793
  */
5792
5794
  stringify: function (command) {
5793
5795
  keepUnused(command);
5794
- return "!!!!!!";
5796
+ return "---"; // <- TODO: [🛋] Implement
5795
5797
  },
5796
5798
  /**
5797
5799
  * Reads the PROMPTBOOK_VERSION command from the `PipelineJson`
@@ -5800,7 +5802,7 @@ var promptbookVersionCommandParser = {
5800
5802
  */
5801
5803
  takeFromPipelineJson: function (pipelineJson) {
5802
5804
  keepUnused(pipelineJson);
5803
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5805
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5804
5806
  },
5805
5807
  };
5806
5808
 
@@ -5850,7 +5852,7 @@ var urlCommandParser = {
5850
5852
  if (pipelineUrl === undefined) {
5851
5853
  throw new ParseError("URL is required");
5852
5854
  }
5853
- // TODO: [🧠][🚲] This should be maybe tested as logic not syntax
5855
+ // TODO: [🧠][🚲] This should be maybe tested as logic not parse
5854
5856
  if (!isValidPipelineUrl(pipelineUrl)) {
5855
5857
  throw new ParseError("Invalid pipeline URL \"".concat(pipelineUrl, "\""));
5856
5858
  }
@@ -5894,7 +5896,7 @@ var urlCommandParser = {
5894
5896
  */
5895
5897
  stringify: function (command) {
5896
5898
  keepUnused(command);
5897
- return "!!!!!!";
5899
+ return "---"; // <- TODO: [🛋] Implement
5898
5900
  },
5899
5901
  /**
5900
5902
  * Reads the URL command from the `PipelineJson`
@@ -5903,7 +5905,7 @@ var urlCommandParser = {
5903
5905
  */
5904
5906
  takeFromPipelineJson: function (pipelineJson) {
5905
5907
  keepUnused(pipelineJson);
5906
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5908
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5907
5909
  },
5908
5910
  };
5909
5911
 
@@ -5952,7 +5954,7 @@ var actionCommandParser = {
5952
5954
  */
5953
5955
  $applyToPipelineJson: function (command, $pipelineJson) {
5954
5956
  keepUnused(command, $pipelineJson);
5955
- console.error(new NotYetImplementedError('Actions are not implemented yet'));
5957
+ console.error(new NotYetImplementedError('[🛠] Actions are not implemented yet'));
5956
5958
  },
5957
5959
  /**
5958
5960
  * Converts the ACTION command back to string
@@ -5961,7 +5963,7 @@ var actionCommandParser = {
5961
5963
  */
5962
5964
  stringify: function (command) {
5963
5965
  keepUnused(command);
5964
- return "!!!!!!";
5966
+ throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
5965
5967
  },
5966
5968
  /**
5967
5969
  * Reads the ACTION command from the `PipelineJson`
@@ -5970,9 +5972,12 @@ var actionCommandParser = {
5970
5972
  */
5971
5973
  takeFromPipelineJson: function (pipelineJson) {
5972
5974
  keepUnused(pipelineJson);
5973
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5975
+ throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
5974
5976
  },
5975
5977
  };
5978
+ /**
5979
+ * Note: [⛱] There are two types of ACTION commands *...(read more in [⛱])*
5980
+ */
5976
5981
 
5977
5982
  /**
5978
5983
  * Parses the instrument command
@@ -6007,6 +6012,7 @@ var instrumentCommandParser = {
6007
6012
  */
6008
6013
  parse: function (input) {
6009
6014
  var args = input.args;
6015
+ // TODO: [🛠] Implement
6010
6016
  TODO_USE(args);
6011
6017
  return {
6012
6018
  type: 'INSTRUMENT',
@@ -6019,7 +6025,7 @@ var instrumentCommandParser = {
6019
6025
  */
6020
6026
  $applyToPipelineJson: function (command, $pipelineJson) {
6021
6027
  keepUnused(command, $pipelineJson);
6022
- console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6028
+ console.error(new NotYetImplementedError('[🛠] Instruments are not implemented yet'));
6023
6029
  },
6024
6030
  /**
6025
6031
  * Converts the INSTRUMENT command back to string
@@ -6028,7 +6034,7 @@ var instrumentCommandParser = {
6028
6034
  */
6029
6035
  stringify: function (command) {
6030
6036
  keepUnused(command);
6031
- return "!!!!!!";
6037
+ throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
6032
6038
  },
6033
6039
  /**
6034
6040
  * Reads the INSTRUMENT command from the `PipelineJson`
@@ -6037,9 +6043,12 @@ var instrumentCommandParser = {
6037
6043
  */
6038
6044
  takeFromPipelineJson: function (pipelineJson) {
6039
6045
  keepUnused(pipelineJson);
6040
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
6046
+ throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
6041
6047
  },
6042
6048
  };
6049
+ /**
6050
+ * Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
6051
+ */
6043
6052
 
6044
6053
  /**
6045
6054
  * Parses the boilerplate command
@@ -6117,7 +6126,7 @@ var boilerplateCommandParser = {
6117
6126
  */
6118
6127
  stringify: function (command) {
6119
6128
  keepUnused(command);
6120
- return "!!!!!!";
6129
+ return "---"; // <- TODO: [🛋] Implement
6121
6130
  },
6122
6131
  /**
6123
6132
  * Reads the BOILERPLATE command from the `PipelineJson`
@@ -6148,7 +6157,7 @@ var boilerplateCommandParser = {
6148
6157
  * @private internal index of `parseCommand`
6149
6158
  */
6150
6159
  var COMMANDS = [
6151
- blockCommandParser,
6160
+ templateCommandParser,
6152
6161
  expectCommandParser,
6153
6162
  formatCommandParser,
6154
6163
  jokerCommandParser,
@@ -6165,6 +6174,25 @@ var COMMANDS = [
6165
6174
  boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
6166
6175
  ];
6167
6176
 
6177
+ /**
6178
+ * Gets the parser for the command
6179
+ *
6180
+ * @returns the parser for the command
6181
+ * @throws {UnexpectedError} if the parser is not found
6182
+ *
6183
+ * @private within the pipelineStringToJson
6184
+ */
6185
+ function getParserForCommand(command) {
6186
+ var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
6187
+ if (commandParser === undefined) {
6188
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found\n\n ").concat(block(JSON.stringify(command, null, 4)
6189
+ .split('\n')
6190
+ .map(function (line) { return "> ".concat(line); })
6191
+ .join('\n')), "\n "); }));
6192
+ }
6193
+ return commandParser;
6194
+ }
6195
+
6168
6196
  /**
6169
6197
  * Removes Markdown formatting tags from a string.
6170
6198
  *
@@ -6300,7 +6328,7 @@ function parseCommand(raw, usagePlace) {
6300
6328
  .map(function (item) { return item.trim(); });
6301
6329
  if (items.length === 0 || items[0] === '') {
6302
6330
  throw new ParseError(spaceTrim(function (block) {
6303
- return "\n Malformed command:\n\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6331
+ return "\n Malformed command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6304
6332
  }));
6305
6333
  }
6306
6334
  // Note: Taking command name from beginning of the line
@@ -6327,7 +6355,7 @@ function parseCommand(raw, usagePlace) {
6327
6355
  }
6328
6356
  }
6329
6357
  throw new ParseError(spaceTrim(function (block) {
6330
- return "\n Malformed or unknown command:\n\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6358
+ return "\n Malformed or unknown command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6331
6359
  }));
6332
6360
  }
6333
6361
  /**
@@ -6371,7 +6399,7 @@ function parseCommandVariant(input) {
6371
6399
  throw error;
6372
6400
  }
6373
6401
  throw new ParseError(spaceTrim(function (block) {
6374
- return "\n Invalid ".concat(commandName, " command:\n ").concat(block(error.message), "\n\n - ").concat(raw, "\n\n Usage of ").concat(commandName, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n All supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6402
+ return "\n Invalid ".concat(commandName, " command:\n\n Your command:\n - ").concat(raw, "\n\n The detailed error:\n ").concat(block(error.message), "\n\n Usage of ").concat(commandName, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n All supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6375
6403
  }));
6376
6404
  }
6377
6405
  }
@@ -6634,7 +6662,7 @@ function removeContentComments(content) {
6634
6662
  * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
6635
6663
  * - `preparePipeline` - just one step in the compilation process
6636
6664
  *
6637
- * Note: This function does not validate logic of the pipeline only the syntax
6665
+ * Note: This function does not validate logic of the pipeline only the parsing
6638
6666
  * Note: This function acts as compilation process
6639
6667
  *
6640
6668
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
@@ -6731,10 +6759,7 @@ function pipelineStringToJsonSync(pipelineString) {
6731
6759
  var _loop_1 = function (listItem) {
6732
6760
  // TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineHeadCommands`
6733
6761
  var command = parseCommand(listItem, 'PIPELINE_HEAD');
6734
- var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
6735
- if (commandParser === undefined) {
6736
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found \uD83C\uDF4E\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6737
- }
6762
+ var commandParser = getParserForCommand(command);
6738
6763
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
6739
6764
  throw new ParseError(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: [🚞]
6740
6765
  }
@@ -6783,9 +6808,9 @@ function pipelineStringToJsonSync(pipelineString) {
6783
6808
  description_1 = undefined;
6784
6809
  }
6785
6810
  var $templateJson = {
6786
- isBlockTypeSet: false,
6787
- isTemplateBlock: true,
6788
- blockType: undefined /* <- Note: [🍙] Putting here placeholder to keep `blockType` on top at final JSON */,
6811
+ isTemplateTypeSet: false,
6812
+ isTemplate: true,
6813
+ templateType: undefined /* <- Note: [🍙] Putting here placeholder to keep `templateType` on top at final JSON */,
6789
6814
  name: titleToName(section.title),
6790
6815
  title: section.title,
6791
6816
  description: description_1,
@@ -6807,15 +6832,12 @@ function pipelineStringToJsonSync(pipelineString) {
6807
6832
  // Note: If block type is not set, set it to 'PROMPT_TEMPLATE'
6808
6833
  if (commands.some(function (_a) {
6809
6834
  var command = _a.command;
6810
- return command.type === 'BLOCK';
6835
+ return command.type === 'TEMPLATE';
6811
6836
  }) === false) {
6812
- blockCommandParser.$applyToTemplateJson({ type: 'BLOCK', blockType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
6837
+ templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
6813
6838
  }
6814
6839
  var _loop_3 = function (listItem, command) {
6815
- var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
6816
- if (commandParser === undefined) {
6817
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found \uD83C\uDF4F\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6818
- }
6840
+ var commandParser = getParserForCommand(command);
6819
6841
  if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
6820
6842
  throw new ParseError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the template of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
6821
6843
  }
@@ -6830,15 +6852,14 @@ function pipelineStringToJsonSync(pipelineString) {
6830
6852
  }
6831
6853
  throw new ParseError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " failed to apply to the template\n\n The error:\n ").concat(block(error.message), "\n\n Current state of the template:\n ").concat(block(JSON.stringify($templateJson, null, 4)), "\n <- Maybe wrong order of commands?\n\n Raw command:\n - ").concat(listItem, "\n\n Usage of ").concat(command.type, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
6832
6854
  }
6833
- // TODO: !!!!!! Multiple problematic things in BLOCK command - blockCommandParser.$applyToTemplateJson
6834
6855
  if (command.type === 'PARAMETER') {
6835
6856
  defineParam(command);
6836
6857
  // <- Note: [🍣]
6837
6858
  }
6838
6859
  };
6839
6860
  try {
6840
- // TODO: !!!!!! Test error situation when `PERSONA` is used before `SIMPLE BLOCK`
6841
- // TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE BLOCK`
6861
+ // TODO: !!!!!! Test error situation when `PERSONA` is used before `SIMPLE TEMPLATE`
6862
+ // TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE TEMPLATE`
6842
6863
  // TODO [♓️] List commands and before apply order them
6843
6864
  for (var commands_1 = (e_3 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
6844
6865
  var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
@@ -6852,8 +6873,8 @@ function pipelineStringToJsonSync(pipelineString) {
6852
6873
  }
6853
6874
  finally { if (e_3) throw e_3.error; }
6854
6875
  }
6855
- // TODO: [🍧] !!!!!! Should be done in BLOCK command
6856
- if ($templateJson.blockType === 'SCRIPT_TEMPLATE') {
6876
+ // TODO: [🍧] !!!!!! Should be done in TEMPLATE command
6877
+ if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
6857
6878
  if (!language) {
6858
6879
  throw new ParseError(spaceTrim(function (block) { return "\n You must specify the language of the script in the SCRIPT TEMPLATE\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
6859
6880
  }
@@ -6868,12 +6889,12 @@ function pipelineStringToJsonSync(pipelineString) {
6868
6889
  // TODO: [🍧] !!!!!! This should be checked in `MODEL` command + better error message
6869
6890
  // TODO: [🍧] !!!!!! Write error `.ptbk.md` file for `MODEL` and `PERSONA` command used in non-prompt template
6870
6891
  // TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
6871
- if ($templateJson.blockType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
6892
+ if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
6872
6893
  throw new UnexpectedError(
6873
6894
  spaceTrim(
6874
6895
  (block) => `
6875
6896
  Model requirements are defined for the block type ${
6876
- $templateJson.blockType
6897
+ $templateJson.templateType
6877
6898
  } which is not a PROMPT TEMPLATE
6878
6899
 
6879
6900
  This should be avoided by the \`modelCommandParser\`
@@ -6884,9 +6905,9 @@ function pipelineStringToJsonSync(pipelineString) {
6884
6905
  );
6885
6906
  }
6886
6907
  */
6887
- if ($templateJson.isTemplateBlock) {
6888
- delete $templateJson.isBlockTypeSet;
6889
- delete $templateJson.isTemplateBlock;
6908
+ if ($templateJson.isTemplate) {
6909
+ delete $templateJson.isTemplateTypeSet;
6910
+ delete $templateJson.isTemplate;
6890
6911
  // TODO: [🍙] Maybe do reorder of `$templateJson` here
6891
6912
  $pipelineJson.templates.push($templateJson);
6892
6913
  }
@@ -6894,7 +6915,7 @@ function pipelineStringToJsonSync(pipelineString) {
6894
6915
  try {
6895
6916
  // =============================================================
6896
6917
  // Note: 4️⃣ Process each template of the pipeline
6897
- /* TODO: !!!!!! Remove `templates:` */ for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
6918
+ for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
6898
6919
  var section = pipelineSections_1_1.value;
6899
6920
  _loop_2(section);
6900
6921
  }
@@ -6967,7 +6988,7 @@ function pipelineStringToJsonSync(pipelineString) {
6967
6988
  * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
6968
6989
  * - `preparePipeline` - just one step in the compilation process
6969
6990
  *
6970
- * Note: This function does not validate logic of the pipeline only the syntax
6991
+ * Note: This function does not validate logic of the pipeline only the parsing
6971
6992
  * Note: This function acts as compilation process
6972
6993
  *
6973
6994
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
@@ -8326,7 +8347,6 @@ function addAutoGeneratedSection(content, options) {
8326
8347
  return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
8327
8348
  }
8328
8349
  /**
8329
- * TODO: !!!!!! Somw way how to connect this with commands
8330
8350
  * TODO: [🏛] This can be part of markdown builder
8331
8351
  */
8332
8352