@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/umd/index.umd.js CHANGED
@@ -39,7 +39,7 @@
39
39
  /**
40
40
  * The version of the Promptbook library
41
41
  */
42
- var PROMPTBOOK_VERSION = '0.68.0-1';
42
+ var PROMPTBOOK_VERSION = '0.68.0-3';
43
43
  // TODO: !!!! List here all the versions and annotate + put into script
44
44
 
45
45
  /*! *****************************************************************************
@@ -722,7 +722,7 @@
722
722
  /* Note: Not using:> name, */
723
723
  title_1 = template.title, description_1 = template.description,
724
724
  /* Note: dependentParameterNames, */
725
- jokers = template.jokerParameterNames, blockType = template.blockType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
725
+ jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
726
726
  pipelineString += '\n\n';
727
727
  pipelineString += "## ".concat(title_1);
728
728
  if (description_1) {
@@ -732,7 +732,7 @@
732
732
  // TODO:> const commands: Array<Command>
733
733
  var commands_1 = [];
734
734
  var contentLanguage = 'text';
735
- if (blockType === 'PROMPT_TEMPLATE') {
735
+ if (templateType === 'PROMPT_TEMPLATE') {
736
736
  var modelRequirements = template.modelRequirements;
737
737
  var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
738
738
  commands_1.push("EXECUTE PROMPT TEMPLATE");
@@ -743,12 +743,12 @@
743
743
  commands_1.push("MODEL NAME `".concat(modelName, "`"));
744
744
  }
745
745
  }
746
- else if (blockType === 'SIMPLE_TEMPLATE') {
746
+ else if (templateType === 'SIMPLE_TEMPLATE') {
747
747
  commands_1.push("SIMPLE TEMPLATE");
748
748
  // Note: Nothing special here
749
749
  }
750
- else if (blockType === 'SCRIPT_TEMPLATE') {
751
- commands_1.push("EXECUTE SCRIPT");
750
+ else if (templateType === 'SCRIPT_TEMPLATE') {
751
+ commands_1.push("SCRIPT TEMPLATE");
752
752
  if (template.contentLanguage) {
753
753
  contentLanguage = template.contentLanguage;
754
754
  }
@@ -756,8 +756,8 @@
756
756
  contentLanguage = '';
757
757
  }
758
758
  }
759
- else if (blockType === 'DIALOG_TEMPLATE') {
760
- commands_1.push("DIALOG BLOCK");
759
+ else if (templateType === 'DIALOG_TEMPLATE') {
760
+ commands_1.push("DIALOG TEMPLATE");
761
761
  // Note: Nothing special here
762
762
  } // <- }else if([🅱]
763
763
  if (jokers) {
@@ -856,7 +856,7 @@
856
856
  return parameterString;
857
857
  }
858
858
  /**
859
- * TODO: !!!!!! Implement new features and commands into `templateParameterJsonToString`
859
+ * TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `templateParameterJsonToString` , use `stringifyCommand`
860
860
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
861
861
  * TODO: [🏛] Maybe make some markdown builder
862
862
  * TODO: [🏛] Escape all
@@ -1059,7 +1059,7 @@
1059
1059
  });
1060
1060
  }
1061
1061
 
1062
- 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"}];
1062
+ 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"}];
1063
1063
 
1064
1064
  /**
1065
1065
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -1081,7 +1081,7 @@
1081
1081
  */
1082
1082
 
1083
1083
  /**
1084
- * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
1084
+ * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
1085
1085
  *
1086
1086
  * @public exported from `@promptbook/core`
1087
1087
  */
@@ -1663,7 +1663,7 @@
1663
1663
  * Creates PipelineCollection from array of PipelineJson or PipelineString
1664
1664
  *
1665
1665
  * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
1666
- * Note: During the construction syntax and logic of all sources are validated
1666
+ * Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
1667
1667
  *
1668
1668
  * @param promptbookSources
1669
1669
  * @returns PipelineCollection
@@ -2246,7 +2246,7 @@
2246
2246
  */
2247
2247
  function extractParameterNamesFromTemplate(template) {
2248
2248
  var e_1, _a, e_2, _b, e_3, _c;
2249
- var title = template.title, description = template.description, blockType = template.blockType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
2249
+ var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
2250
2250
  var parameterNames = new Set();
2251
2251
  try {
2252
2252
  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()) {
@@ -2261,7 +2261,7 @@
2261
2261
  }
2262
2262
  finally { if (e_1) throw e_1.error; }
2263
2263
  }
2264
- if (blockType === 'SCRIPT_TEMPLATE') {
2264
+ if (templateType === 'SCRIPT_TEMPLATE') {
2265
2265
  try {
2266
2266
  for (var _f = __values(extractVariables(content)), _g = _f.next(); !_g.done; _g = _f.next()) {
2267
2267
  var parameterName = _g.value;
@@ -3241,7 +3241,7 @@
3241
3241
  title: title,
3242
3242
  isStarted: false,
3243
3243
  isDone: false,
3244
- blockType: currentTemplate.blockType,
3244
+ templateType: currentTemplate.templateType,
3245
3245
  parameterName: currentTemplate.resultingParameterName,
3246
3246
  parameterValue: null,
3247
3247
  // <- [3]
@@ -3306,7 +3306,7 @@
3306
3306
  result = null;
3307
3307
  resultString = null;
3308
3308
  expectError = null;
3309
- maxAttempts = currentTemplate.blockType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
3309
+ maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
3310
3310
  jokerParameterNames = currentTemplate.jokerParameterNames || [];
3311
3311
  preparedContent = (currentTemplate.preparedContent || '{content}')
3312
3312
  .split('{content}')
@@ -3338,7 +3338,7 @@
3338
3338
  case 1:
3339
3339
  _v.trys.push([1, 44, 45, 46]);
3340
3340
  if (!!isJokerAttempt) return [3 /*break*/, 26];
3341
- _j = currentTemplate.blockType;
3341
+ _j = currentTemplate.templateType;
3342
3342
  switch (_j) {
3343
3343
  case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3344
3344
  case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
@@ -3472,10 +3472,10 @@
3472
3472
  priority: priority,
3473
3473
  }))];
3474
3474
  case 24:
3475
- // TODO: [🌹] When making next attempt for `DIALOG BLOCK`, preserve the previous user input
3475
+ // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3476
3476
  resultString = _v.sent();
3477
3477
  return [3 /*break*/, 26];
3478
- case 25: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(currentTemplate.blockType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3478
+ case 25: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(currentTemplate.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3479
3479
  case 26:
3480
3480
  if (!(!isJokerAttempt && currentTemplate.postprocessingFunctionNames)) return [3 /*break*/, 43];
3481
3481
  _v.label = 27;
@@ -3590,12 +3590,12 @@
3590
3590
  return [3 /*break*/, 46];
3591
3591
  case 45:
3592
3592
  if (!isJokerAttempt &&
3593
- currentTemplate.blockType === 'PROMPT_TEMPLATE' &&
3593
+ currentTemplate.templateType === 'PROMPT_TEMPLATE' &&
3594
3594
  prompt
3595
3595
  // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
3596
3596
  // In that case we don’t want to make a report about it because it’s not a llm execution error
3597
3597
  ) {
3598
- // TODO: [🧠] Maybe put other blockTypes into report
3598
+ // TODO: [🧠] Maybe put other templateTypes into report
3599
3599
  executionReport.promptExecutions.push({
3600
3600
  prompt: __assign({}, prompt),
3601
3601
  result: result || undefined,
@@ -3646,7 +3646,7 @@
3646
3646
  title: title,
3647
3647
  isStarted: true,
3648
3648
  isDone: true,
3649
- blockType: currentTemplate.blockType,
3649
+ templateType: currentTemplate.templateType,
3650
3650
  parameterName: currentTemplate.resultingParameterName,
3651
3651
  parameterValue: resultString,
3652
3652
  // <- [3]
@@ -4614,7 +4614,7 @@
4614
4614
  */
4615
4615
  stringify: function (command) {
4616
4616
  keepUnused(command);
4617
- return "!!!!!!";
4617
+ return "---"; // <- TODO: [🛋] Implement
4618
4618
  },
4619
4619
  /**
4620
4620
  * Reads the KNOWLEDGE command from the `PipelineJson`
@@ -4623,17 +4623,20 @@
4623
4623
  */
4624
4624
  takeFromPipelineJson: function (pipelineJson) {
4625
4625
  keepUnused(pipelineJson);
4626
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
4626
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
4627
4627
  },
4628
4628
  };
4629
+ /**
4630
+ * Note: [⛱] There are two types of KNOWLEDGE commands *...(read more in [⛱])*
4631
+ */
4629
4632
 
4630
4633
  /**
4631
- * Block type describes the way how the block is blockd
4634
+ * Template type describes the way how the template is templated
4632
4635
  *
4633
- * @see https://github.com/webgptorg/promptbook#block-type
4636
+ * @see https://github.com/webgptorg/promptbook#template-type
4634
4637
  * @public exported from `@promptbook/core`
4635
4638
  */
4636
- var BlockTypes = [
4639
+ var TemplateTypes = [
4637
4640
  'PROMPT_TEMPLATE',
4638
4641
  'SIMPLE_TEMPLATE',
4639
4642
  'SCRIPT_TEMPLATE',
@@ -4646,108 +4649,114 @@
4646
4649
  ];
4647
4650
 
4648
4651
  /**
4649
- * Parses the block command
4652
+ * Parses the template command
4650
4653
  *
4651
- * @see ./BLOCK-README.md for more details
4654
+ * @see ./TEMPLATE-README.md for more details
4652
4655
  * @private within the commands folder
4653
4656
  */
4654
- var blockCommandParser = {
4657
+ var templateCommandParser = {
4655
4658
  /**
4656
4659
  * Name of the command
4657
4660
  */
4658
- name: 'BLOCK',
4661
+ name: 'TEMPLATE',
4659
4662
  /**
4660
- * Aliases for the BLOCK command
4663
+ * Aliases for the TEMPLATE command
4661
4664
  */
4662
4665
  aliasNames: [
4663
- 'PROMPT_TEMPLATE',
4664
- 'SIMPLE_TEMPLATE',
4665
- 'SCRIPT_TEMPLATE',
4666
- 'DIALOG_TEMPLATE',
4666
+ 'PROMPT',
4667
+ 'SIMPLE',
4668
+ 'SCRIPT',
4669
+ 'DIALOG',
4667
4670
  'SAMPLE',
4668
4671
  'EXAMPLE',
4669
4672
  'KNOWLEDGE',
4670
4673
  'INSTRUMENT',
4671
- 'ACTION',
4672
- // <- [🅱]
4674
+ 'ACTION', // <- Note: [⛱]
4673
4675
  ],
4674
4676
  /**
4675
- * Aliases for the BLOCK command
4677
+ * Aliases for the TEMPLATE command
4676
4678
  */
4677
- deprecatedNames: ['EXECUTE'],
4679
+ deprecatedNames: ['BLOCK', 'EXECUTE'],
4678
4680
  /**
4679
4681
  * BOILERPLATE command can be used in:
4680
4682
  */
4681
4683
  isUsedInPipelineHead: false,
4682
4684
  isUsedInPipelineTemplate: true,
4683
4685
  /**
4684
- * Description of the BLOCK command
4686
+ * Description of the TEMPLATE command
4685
4687
  */
4686
- description: "What should the code block template do",
4688
+ description: "What should the code template template do",
4687
4689
  /**
4688
4690
  * Link to discussion
4689
4691
  */
4690
4692
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/64',
4691
4693
  /**
4692
- * Example usages of the BLOCK command
4694
+ * Example usages of the TEMPLATE command
4693
4695
  */
4694
4696
  examples: [
4695
- // Recommended form:
4696
- 'PROMPT BLOCK',
4697
- 'SIMPLE BLOCK',
4698
- 'SCRIPT BLOCK',
4699
- 'DIALOG BLOCK',
4697
+ // Short form:
4698
+ 'PROMPT',
4699
+ 'SIMPLE',
4700
+ 'SCRIPT',
4701
+ 'DIALOG',
4700
4702
  // <- [🅱]
4701
- // Long form:
4702
- 'PROMPT TEMPLATE BLOCK',
4703
- 'SIMPLE TEMPLATE BLOCK',
4704
- 'SCRIPT TEMPLATE BLOCK',
4705
- 'DIALOG TEMPLATE BLOCK',
4703
+ 'SAMPLE',
4704
+ 'KNOWLEDGE',
4705
+ 'INSTRUMENT',
4706
+ 'ACTION',
4707
+ // -----------------
4708
+ // Recommended (reversed) form:
4709
+ 'PROMPT TEMPLATE',
4710
+ 'SIMPLE TEMPLATE',
4711
+ 'SCRIPT TEMPLATE',
4712
+ 'DIALOG TEMPLATE',
4706
4713
  // <- [🅱]
4707
- // Reversed form:
4708
- 'BLOCK PROMPT TEMPLATE',
4709
- 'BLOCK SIMPLE TEMPLATE',
4710
- 'BLOCK SCRIPT TEMPLATE',
4711
- 'BLOCK DIALOG TEMPLATE',
4714
+ 'SAMPLE TEMPLATE',
4715
+ 'KNOWLEDGE TEMPLATE',
4716
+ 'INSTRUMENT TEMPLATE',
4717
+ 'ACTION TEMPLATE',
4718
+ // -----------------
4719
+ // Standard form:
4720
+ 'TEMPLATE PROMPT',
4721
+ 'TEMPLATE SIMPLE',
4722
+ 'TEMPLATE SCRIPT',
4723
+ 'TEMPLATE DIALOG',
4712
4724
  // <- [🅱]
4713
- // 'Knowledge', // <- Note: [⛱] For execution blocks which are also separate commands shortcut does not work
4714
- //---
4715
- /* Note: Not implemented block types will be in examples in future -> */
4716
- 'Instrument BLOCK',
4717
- // 'Instrument', // <- Note: [⛱]
4718
- 'Action BLOCK',
4719
- // 'Action', // <- Note: [⛱]
4720
- //---
4721
- /* <- TODO: [🧠] Maybe dynamic */
4725
+ 'SAMPLE TEMPLATE',
4726
+ 'KNOWLEDGE TEMPLATE',
4727
+ 'INSTRUMENT TEMPLATE',
4728
+ 'ACTION TEMPLATE',
4722
4729
  ],
4723
4730
  // TODO: [♓️] order: -10 /* <- Note: Putting before other commands */
4724
4731
  /**
4725
- * Parses the BLOCK command
4732
+ * Parses the TEMPLATE command
4726
4733
  */
4727
4734
  parse: function (input) {
4728
4735
  var normalized = input.normalized;
4729
4736
  normalized = normalized.split('EXAMPLE').join('SAMPLE');
4730
- var blockTypes = BlockTypes.filter(function (blockType) { return normalized.includes(blockType.split('_TEMPLATE').join('')); });
4731
- if (blockTypes.length !== 1) {
4732
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown block type in BLOCK command\n\n Supported block types are:\n ".concat(block(BlockTypes.join(', ')), "\n "); }));
4737
+ var templateTypes = TemplateTypes.filter(function (templateType) {
4738
+ return normalized.includes(templateType.split('_TEMPLATE').join(''));
4739
+ });
4740
+ if (templateTypes.length !== 1) {
4741
+ throw new ParseError(spaceTrim__default["default"](function (template) { return "\n Unknown template type in TEMPLATE command\n\n Supported template types are:\n ".concat(template(TemplateTypes.join(', ')), "\n "); }));
4733
4742
  }
4734
- var blockType = blockTypes[0];
4743
+ var templateType = templateTypes[0];
4735
4744
  return {
4736
- type: 'BLOCK',
4737
- blockType: blockType,
4745
+ type: 'TEMPLATE',
4746
+ templateType: templateType,
4738
4747
  };
4739
4748
  },
4740
4749
  /**
4741
- * Apply the BLOCK command to the `pipelineJson`
4750
+ * Apply the TEMPLATE command to the `pipelineJson`
4742
4751
  *
4743
4752
  * Note: `$` is used to indicate that this function mutates given `templateJson`
4744
4753
  */
4745
4754
  $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
4746
- // TODO: !!!!!! Test multiple / no block type
4747
- if ($templateJson.isBlockTypeSet === true) {
4748
- throw new ParseError(spaceTrim__default["default"]("\n Block type is already defined in the template.\n It can be defined only once.\n "));
4755
+ // TODO: !!!!!! Test multiple / no template type
4756
+ if ($templateJson.isTemplateTypeSet === true) {
4757
+ throw new ParseError(spaceTrim__default["default"]("\n Template type is already defined in the template.\n It can be defined only once.\n "));
4749
4758
  }
4750
- $templateJson.isBlockTypeSet = true;
4759
+ $templateJson.isTemplateTypeSet = true;
4751
4760
  // TODO: !!!!!! Rearrange better - but at bottom and unwrap from function
4752
4761
  var expectResultingParameterName = function () {
4753
4762
  if ($templateJson.resultingParameterName) {
@@ -4758,7 +4767,7 @@
4758
4767
  if ($templateJson.content === undefined) {
4759
4768
  throw new UnexpectedError("Content is missing in the templateJson - probbably commands are applied in wrong order");
4760
4769
  }
4761
- if (command.blockType === 'SAMPLE') {
4770
+ if (command.templateType === 'SAMPLE') {
4762
4771
  expectResultingParameterName();
4763
4772
  var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $templateJson.resultingParameterName; });
4764
4773
  if (parameter === undefined) {
@@ -4766,66 +4775,59 @@
4766
4775
  }
4767
4776
  parameter.sampleValues = parameter.sampleValues || [];
4768
4777
  parameter.sampleValues.push($templateJson.content);
4769
- // TODO: !!!!!! How to implement this?
4770
- // continue templates;
4771
- $templateJson.isTemplateBlock = false;
4778
+ $templateJson.isTemplate = false;
4772
4779
  return;
4773
4780
  }
4774
- if (command.blockType === 'KNOWLEDGE') {
4781
+ if (command.templateType === 'KNOWLEDGE') {
4775
4782
  knowledgeCommandParser.$applyToPipelineJson({
4776
4783
  type: 'KNOWLEDGE',
4777
4784
  sourceContent: $templateJson.content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
4778
4785
  }, $pipelineJson);
4779
- // TODO: !!!!!! How to implement this?
4780
- // continue templates;
4781
- $templateJson.isTemplateBlock = false;
4786
+ $templateJson.isTemplate = false;
4782
4787
  return;
4783
4788
  }
4784
- if (command.blockType === 'ACTION') {
4789
+ if (command.templateType === 'ACTION') {
4785
4790
  console.error(new NotYetImplementedError('Actions are not implemented yet'));
4786
- // TODO: !!!!!! How to implement this?
4787
- // continue templates;
4788
- $templateJson.isTemplateBlock = false;
4791
+ $templateJson.isTemplate = false;
4789
4792
  return;
4790
4793
  }
4791
- if (command.blockType === 'INSTRUMENT') {
4794
+ if (command.templateType === 'INSTRUMENT') {
4792
4795
  console.error(new NotYetImplementedError('Instruments are not implemented yet'));
4793
- // TODO: !!!!!! How to implement this?
4794
- // continue templates;
4795
- $templateJson.isTemplateBlock = false;
4796
+ $templateJson.isTemplate = false;
4796
4797
  return;
4797
4798
  }
4798
4799
  expectResultingParameterName();
4799
- $templateJson.blockType = command.blockType;
4800
+ $templateJson.templateType = command.templateType;
4800
4801
  /*
4801
4802
  TODO: !!!!!! Chat model variant should be applied in `createPipelineExecutor`
4802
- if (command.blockType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
4803
+ if (command.templateType ==='PROMPT_TEMPLATE' && templateModelRequirements.modelVariant === undefined) {
4803
4804
  templateModelRequirements.modelVariant = 'CHAT';
4804
4805
  }
4805
4806
  */
4806
- // !!!!!!
4807
- // isBlockTypeSet = true; //<- Note: [2]
4808
- $templateJson.isTemplateBlock = true;
4807
+ $templateJson.isTemplate = true;
4809
4808
  },
4810
4809
  /**
4811
- * Converts the BLOCK command back to string
4810
+ * Converts the TEMPLATE command back to string
4812
4811
  *
4813
4812
  * Note: This is used in `pipelineJsonToString` utility
4814
4813
  */
4815
4814
  stringify: function (command) {
4816
4815
  keepUnused(command);
4817
- return "!!!!!!";
4816
+ return "---"; // <- TODO: [🛋] Implement
4818
4817
  },
4819
4818
  /**
4820
- * Reads the BLOCK command from the `TemplateJson`
4819
+ * Reads the TEMPLATE command from the `TemplateJson`
4821
4820
  *
4822
4821
  * Note: This is used in `pipelineJsonToString` utility
4823
4822
  */
4824
4823
  takeFromTemplateJson: function ($templateJson) {
4825
4824
  keepUnused($templateJson);
4826
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
4825
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
4827
4826
  },
4828
4827
  };
4828
+ /**
4829
+ * Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands @@@!!!!!!
4830
+ */
4829
4831
 
4830
4832
  /**
4831
4833
  * Units of text measurement
@@ -5044,7 +5046,7 @@
5044
5046
  */
5045
5047
  stringify: function (command) {
5046
5048
  keepUnused(command);
5047
- return "!!!!!!";
5049
+ return "---"; // <- TODO: [🛋] Implement
5048
5050
  },
5049
5051
  /**
5050
5052
  * Reads the FORMAT command from the `TemplateJson`
@@ -5053,7 +5055,7 @@
5053
5055
  */
5054
5056
  takeFromTemplateJson: function ($templateJson) {
5055
5057
  keepUnused($templateJson);
5056
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5058
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5057
5059
  },
5058
5060
  };
5059
5061
 
@@ -5138,7 +5140,7 @@
5138
5140
  },
5139
5141
  };
5140
5142
  /**
5141
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong syntax and logic
5143
+ * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
5142
5144
  */
5143
5145
 
5144
5146
  /**
@@ -5202,7 +5204,7 @@
5202
5204
  */
5203
5205
  stringify: function (command) {
5204
5206
  keepUnused(command);
5205
- return "!!!!!!";
5207
+ return "---"; // <- TODO: [🛋] Implement
5206
5208
  },
5207
5209
  /**
5208
5210
  * Reads the FORMAT command from the `TemplateJson`
@@ -5211,7 +5213,7 @@
5211
5213
  */
5212
5214
  takeFromTemplateJson: function ($templateJson) {
5213
5215
  keepUnused($templateJson);
5214
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5216
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5215
5217
  },
5216
5218
  };
5217
5219
 
@@ -5274,7 +5276,7 @@
5274
5276
  */
5275
5277
  stringify: function (command) {
5276
5278
  keepUnused(command);
5277
- return "!!!!!!";
5279
+ return "---"; // <- TODO: [🛋] Implement
5278
5280
  },
5279
5281
  /**
5280
5282
  * Reads the JOKER command from the `TemplateJson`
@@ -5283,7 +5285,7 @@
5283
5285
  */
5284
5286
  takeFromTemplateJson: function ($templateJson) {
5285
5287
  keepUnused($templateJson);
5286
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5288
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5287
5289
  },
5288
5290
  };
5289
5291
 
@@ -5363,7 +5365,7 @@
5363
5365
  };
5364
5366
  }
5365
5367
  else {
5366
- throw new ParseError(spaceTrim__default["default"](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 "); }));
5368
+ throw new ParseError(spaceTrim__default["default"](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 "); }));
5367
5369
  }
5368
5370
  },
5369
5371
  /**
@@ -5382,7 +5384,7 @@
5382
5384
  * Note: `$` is used to indicate that this function mutates given `templateJson`
5383
5385
  */
5384
5386
  $applyToTemplateJson: function (command, $templateJson) {
5385
- if ($templateJson.blockType !== 'PROMPT_TEMPLATE') {
5387
+ if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
5386
5388
  throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
5387
5389
  }
5388
5390
  // TODO: !!!!!! Error on redefine
@@ -5397,7 +5399,7 @@
5397
5399
  */
5398
5400
  stringify: function (command) {
5399
5401
  keepUnused(command);
5400
- return "!!!!!!";
5402
+ return "---"; // <- TODO: [🛋] Implement
5401
5403
  },
5402
5404
  /**
5403
5405
  * Reads the MODEL command from the `PipelineJson`
@@ -5406,7 +5408,7 @@
5406
5408
  */
5407
5409
  takeFromPipelineJson: function (pipelineJson) {
5408
5410
  keepUnused(pipelineJson);
5409
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5411
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5410
5412
  },
5411
5413
  /**
5412
5414
  * Reads the MODEL command from the `TemplateJson`
@@ -5415,7 +5417,7 @@
5415
5417
  */
5416
5418
  takeFromTemplateJson: function ($templateJson) {
5417
5419
  keepUnused($templateJson);
5418
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5420
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5419
5421
  },
5420
5422
  };
5421
5423
 
@@ -5506,7 +5508,7 @@
5506
5508
  */
5507
5509
  stringify: function (command) {
5508
5510
  keepUnused(command);
5509
- return "!!!!!!";
5511
+ return "---"; // <- TODO: [🛋] Implement
5510
5512
  },
5511
5513
  /**
5512
5514
  * Reads the PARAMETER command from the `PipelineJson`
@@ -5515,7 +5517,7 @@
5515
5517
  */
5516
5518
  takeFromPipelineJson: function (pipelineJson) {
5517
5519
  keepUnused(pipelineJson);
5518
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5520
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5519
5521
  },
5520
5522
  /**
5521
5523
  * Reads the PARAMETER command from the `TemplateJson`
@@ -5524,7 +5526,7 @@
5524
5526
  */
5525
5527
  takeFromTemplateJson: function ($templateJson) {
5526
5528
  keepUnused($templateJson);
5527
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5529
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5528
5530
  },
5529
5531
  };
5530
5532
 
@@ -5596,7 +5598,7 @@
5596
5598
  */
5597
5599
  stringify: function (command) {
5598
5600
  keepUnused(command);
5599
- return "!!!!!!";
5601
+ return "---"; // <- TODO: [🛋] Implement
5600
5602
  },
5601
5603
  /**
5602
5604
  * Reads the PERSONA command from the `PipelineJson`
@@ -5605,7 +5607,7 @@
5605
5607
  */
5606
5608
  takeFromPipelineJson: function (pipelineJson) {
5607
5609
  keepUnused(pipelineJson);
5608
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5610
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5609
5611
  },
5610
5612
  /**
5611
5613
  * Reads the PERSONA command from the `TemplateJson`
@@ -5614,7 +5616,7 @@
5614
5616
  */
5615
5617
  takeFromTemplateJson: function ($templateJson) {
5616
5618
  keepUnused($templateJson);
5617
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5619
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5618
5620
  },
5619
5621
  };
5620
5622
  /**
@@ -5625,7 +5627,7 @@
5625
5627
  function $applyToTemplateJson(command, $templateJson, $pipelineJson) {
5626
5628
  var personaName = command.personaName, personaDescription = command.personaDescription;
5627
5629
  if ($templateJson !== null) {
5628
- if ($templateJson.blockType !== 'PROMPT_TEMPLATE') {
5630
+ if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
5629
5631
  throw new ParseError("PERSONA command can be used only in PROMPT_TEMPLATE block");
5630
5632
  }
5631
5633
  $templateJson.personaName = personaName;
@@ -5733,7 +5735,7 @@
5733
5735
  */
5734
5736
  stringify: function (command) {
5735
5737
  keepUnused(command);
5736
- return "!!!!!!";
5738
+ return "---"; // <- TODO: [🛋] Implement
5737
5739
  },
5738
5740
  /**
5739
5741
  * Reads the POSTPROCESS command from the `TemplateJson`
@@ -5742,7 +5744,7 @@
5742
5744
  */
5743
5745
  takeFromTemplateJson: function ($templateJson) {
5744
5746
  keepUnused($templateJson);
5745
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5747
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5746
5748
  },
5747
5749
  };
5748
5750
 
@@ -5810,7 +5812,7 @@
5810
5812
  */
5811
5813
  stringify: function (command) {
5812
5814
  keepUnused(command);
5813
- return "!!!!!!";
5815
+ return "---"; // <- TODO: [🛋] Implement
5814
5816
  },
5815
5817
  /**
5816
5818
  * Reads the PROMPTBOOK_VERSION command from the `PipelineJson`
@@ -5819,7 +5821,7 @@
5819
5821
  */
5820
5822
  takeFromPipelineJson: function (pipelineJson) {
5821
5823
  keepUnused(pipelineJson);
5822
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5824
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5823
5825
  },
5824
5826
  };
5825
5827
 
@@ -5869,7 +5871,7 @@
5869
5871
  if (pipelineUrl === undefined) {
5870
5872
  throw new ParseError("URL is required");
5871
5873
  }
5872
- // TODO: [🧠][🚲] This should be maybe tested as logic not syntax
5874
+ // TODO: [🧠][🚲] This should be maybe tested as logic not parse
5873
5875
  if (!isValidPipelineUrl(pipelineUrl)) {
5874
5876
  throw new ParseError("Invalid pipeline URL \"".concat(pipelineUrl, "\""));
5875
5877
  }
@@ -5913,7 +5915,7 @@
5913
5915
  */
5914
5916
  stringify: function (command) {
5915
5917
  keepUnused(command);
5916
- return "!!!!!!";
5918
+ return "---"; // <- TODO: [🛋] Implement
5917
5919
  },
5918
5920
  /**
5919
5921
  * Reads the URL command from the `PipelineJson`
@@ -5922,7 +5924,7 @@
5922
5924
  */
5923
5925
  takeFromPipelineJson: function (pipelineJson) {
5924
5926
  keepUnused(pipelineJson);
5925
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5927
+ throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5926
5928
  },
5927
5929
  };
5928
5930
 
@@ -5971,7 +5973,7 @@
5971
5973
  */
5972
5974
  $applyToPipelineJson: function (command, $pipelineJson) {
5973
5975
  keepUnused(command, $pipelineJson);
5974
- console.error(new NotYetImplementedError('Actions are not implemented yet'));
5976
+ console.error(new NotYetImplementedError('[🛠] Actions are not implemented yet'));
5975
5977
  },
5976
5978
  /**
5977
5979
  * Converts the ACTION command back to string
@@ -5980,7 +5982,7 @@
5980
5982
  */
5981
5983
  stringify: function (command) {
5982
5984
  keepUnused(command);
5983
- return "!!!!!!";
5985
+ throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
5984
5986
  },
5985
5987
  /**
5986
5988
  * Reads the ACTION command from the `PipelineJson`
@@ -5989,9 +5991,12 @@
5989
5991
  */
5990
5992
  takeFromPipelineJson: function (pipelineJson) {
5991
5993
  keepUnused(pipelineJson);
5992
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
5994
+ throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
5993
5995
  },
5994
5996
  };
5997
+ /**
5998
+ * Note: [⛱] There are two types of ACTION commands *...(read more in [⛱])*
5999
+ */
5995
6000
 
5996
6001
  /**
5997
6002
  * Parses the instrument command
@@ -6026,6 +6031,7 @@
6026
6031
  */
6027
6032
  parse: function (input) {
6028
6033
  var args = input.args;
6034
+ // TODO: [🛠] Implement
6029
6035
  TODO_USE(args);
6030
6036
  return {
6031
6037
  type: 'INSTRUMENT',
@@ -6038,7 +6044,7 @@
6038
6044
  */
6039
6045
  $applyToPipelineJson: function (command, $pipelineJson) {
6040
6046
  keepUnused(command, $pipelineJson);
6041
- console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6047
+ console.error(new NotYetImplementedError('[🛠] Instruments are not implemented yet'));
6042
6048
  },
6043
6049
  /**
6044
6050
  * Converts the INSTRUMENT command back to string
@@ -6047,7 +6053,7 @@
6047
6053
  */
6048
6054
  stringify: function (command) {
6049
6055
  keepUnused(command);
6050
- return "!!!!!!";
6056
+ throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
6051
6057
  },
6052
6058
  /**
6053
6059
  * Reads the INSTRUMENT command from the `PipelineJson`
@@ -6056,9 +6062,12 @@
6056
6062
  */
6057
6063
  takeFromPipelineJson: function (pipelineJson) {
6058
6064
  keepUnused(pipelineJson);
6059
- throw new NotYetImplementedError("Not implemented yet !!!!!!");
6065
+ throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
6060
6066
  },
6061
6067
  };
6068
+ /**
6069
+ * Note: [⛱] There are two types of INSTRUMENT commands *...(read more in [⛱])*
6070
+ */
6062
6071
 
6063
6072
  /**
6064
6073
  * Parses the boilerplate command
@@ -6136,7 +6145,7 @@
6136
6145
  */
6137
6146
  stringify: function (command) {
6138
6147
  keepUnused(command);
6139
- return "!!!!!!";
6148
+ return "---"; // <- TODO: [🛋] Implement
6140
6149
  },
6141
6150
  /**
6142
6151
  * Reads the BOILERPLATE command from the `PipelineJson`
@@ -6167,7 +6176,7 @@
6167
6176
  * @private internal index of `parseCommand`
6168
6177
  */
6169
6178
  var COMMANDS = [
6170
- blockCommandParser,
6179
+ templateCommandParser,
6171
6180
  expectCommandParser,
6172
6181
  formatCommandParser,
6173
6182
  jokerCommandParser,
@@ -6184,6 +6193,25 @@
6184
6193
  boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
6185
6194
  ];
6186
6195
 
6196
+ /**
6197
+ * Gets the parser for the command
6198
+ *
6199
+ * @returns the parser for the command
6200
+ * @throws {UnexpectedError} if the parser is not found
6201
+ *
6202
+ * @private within the pipelineStringToJson
6203
+ */
6204
+ function getParserForCommand(command) {
6205
+ var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
6206
+ if (commandParser === undefined) {
6207
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found\n\n ").concat(block(JSON.stringify(command, null, 4)
6208
+ .split('\n')
6209
+ .map(function (line) { return "> ".concat(line); })
6210
+ .join('\n')), "\n "); }));
6211
+ }
6212
+ return commandParser;
6213
+ }
6214
+
6187
6215
  /**
6188
6216
  * Removes Markdown formatting tags from a string.
6189
6217
  *
@@ -6319,7 +6347,7 @@
6319
6347
  .map(function (item) { return item.trim(); });
6320
6348
  if (items.length === 0 || items[0] === '') {
6321
6349
  throw new ParseError(spaceTrim.spaceTrim(function (block) {
6322
- return "\n Malformed command:\n\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6350
+ return "\n Malformed command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6323
6351
  }));
6324
6352
  }
6325
6353
  // Note: Taking command name from beginning of the line
@@ -6346,7 +6374,7 @@
6346
6374
  }
6347
6375
  }
6348
6376
  throw new ParseError(spaceTrim.spaceTrim(function (block) {
6349
- return "\n Malformed or unknown command:\n\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6377
+ return "\n Malformed or unknown command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
6350
6378
  }));
6351
6379
  }
6352
6380
  /**
@@ -6390,7 +6418,7 @@
6390
6418
  throw error;
6391
6419
  }
6392
6420
  throw new ParseError(spaceTrim.spaceTrim(function (block) {
6393
- 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 ");
6421
+ 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 ");
6394
6422
  }));
6395
6423
  }
6396
6424
  }
@@ -6653,7 +6681,7 @@
6653
6681
  * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
6654
6682
  * - `preparePipeline` - just one step in the compilation process
6655
6683
  *
6656
- * Note: This function does not validate logic of the pipeline only the syntax
6684
+ * Note: This function does not validate logic of the pipeline only the parsing
6657
6685
  * Note: This function acts as compilation process
6658
6686
  *
6659
6687
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
@@ -6750,10 +6778,7 @@
6750
6778
  var _loop_1 = function (listItem) {
6751
6779
  // TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineHeadCommands`
6752
6780
  var command = parseCommand(listItem, 'PIPELINE_HEAD');
6753
- var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
6754
- if (commandParser === undefined) {
6755
- throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found \uD83C\uDF4E\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6756
- }
6781
+ var commandParser = getParserForCommand(command);
6757
6782
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
6758
6783
  throw new ParseError(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: [🚞]
6759
6784
  }
@@ -6802,9 +6827,9 @@
6802
6827
  description_1 = undefined;
6803
6828
  }
6804
6829
  var $templateJson = {
6805
- isBlockTypeSet: false,
6806
- isTemplateBlock: true,
6807
- blockType: undefined /* <- Note: [🍙] Putting here placeholder to keep `blockType` on top at final JSON */,
6830
+ isTemplateTypeSet: false,
6831
+ isTemplate: true,
6832
+ templateType: undefined /* <- Note: [🍙] Putting here placeholder to keep `templateType` on top at final JSON */,
6808
6833
  name: titleToName(section.title),
6809
6834
  title: section.title,
6810
6835
  description: description_1,
@@ -6826,15 +6851,12 @@
6826
6851
  // Note: If block type is not set, set it to 'PROMPT_TEMPLATE'
6827
6852
  if (commands.some(function (_a) {
6828
6853
  var command = _a.command;
6829
- return command.type === 'BLOCK';
6854
+ return command.type === 'TEMPLATE';
6830
6855
  }) === false) {
6831
- blockCommandParser.$applyToTemplateJson({ type: 'BLOCK', blockType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
6856
+ templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
6832
6857
  }
6833
6858
  var _loop_3 = function (listItem, command) {
6834
- var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
6835
- if (commandParser === undefined) {
6836
- throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found \uD83C\uDF4F\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
6837
- }
6859
+ var commandParser = getParserForCommand(command);
6838
6860
  if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
6839
6861
  throw new ParseError(spaceTrim.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: [🚞]
6840
6862
  }
@@ -6849,15 +6871,14 @@
6849
6871
  }
6850
6872
  throw new ParseError(spaceTrim.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: [🚞]
6851
6873
  }
6852
- // TODO: !!!!!! Multiple problematic things in BLOCK command - blockCommandParser.$applyToTemplateJson
6853
6874
  if (command.type === 'PARAMETER') {
6854
6875
  defineParam(command);
6855
6876
  // <- Note: [🍣]
6856
6877
  }
6857
6878
  };
6858
6879
  try {
6859
- // TODO: !!!!!! Test error situation when `PERSONA` is used before `SIMPLE BLOCK`
6860
- // TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE BLOCK`
6880
+ // TODO: !!!!!! Test error situation when `PERSONA` is used before `SIMPLE TEMPLATE`
6881
+ // TODO: !!!!!! Test error situation when `MODEL` is used before `SIMPLE TEMPLATE`
6861
6882
  // TODO [♓️] List commands and before apply order them
6862
6883
  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()) {
6863
6884
  var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
@@ -6871,8 +6892,8 @@
6871
6892
  }
6872
6893
  finally { if (e_3) throw e_3.error; }
6873
6894
  }
6874
- // TODO: [🍧] !!!!!! Should be done in BLOCK command
6875
- if ($templateJson.blockType === 'SCRIPT_TEMPLATE') {
6895
+ // TODO: [🍧] !!!!!! Should be done in TEMPLATE command
6896
+ if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
6876
6897
  if (!language) {
6877
6898
  throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the SCRIPT TEMPLATE\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
6878
6899
  }
@@ -6887,12 +6908,12 @@
6887
6908
  // TODO: [🍧] !!!!!! This should be checked in `MODEL` command + better error message
6888
6909
  // TODO: [🍧] !!!!!! Write error `.ptbk.md` file for `MODEL` and `PERSONA` command used in non-prompt template
6889
6910
  // TODO: [🍧] !!!!!! `PERSONA` command should behave same as `MODEL` command - only usable in prompt template
6890
- if ($templateJson.blockType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
6911
+ if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
6891
6912
  throw new UnexpectedError(
6892
6913
  spaceTrim(
6893
6914
  (block) => `
6894
6915
  Model requirements are defined for the block type ${
6895
- $templateJson.blockType
6916
+ $templateJson.templateType
6896
6917
  } which is not a PROMPT TEMPLATE
6897
6918
 
6898
6919
  This should be avoided by the \`modelCommandParser\`
@@ -6903,9 +6924,9 @@
6903
6924
  );
6904
6925
  }
6905
6926
  */
6906
- if ($templateJson.isTemplateBlock) {
6907
- delete $templateJson.isBlockTypeSet;
6908
- delete $templateJson.isTemplateBlock;
6927
+ if ($templateJson.isTemplate) {
6928
+ delete $templateJson.isTemplateTypeSet;
6929
+ delete $templateJson.isTemplate;
6909
6930
  // TODO: [🍙] Maybe do reorder of `$templateJson` here
6910
6931
  $pipelineJson.templates.push($templateJson);
6911
6932
  }
@@ -6913,7 +6934,7 @@
6913
6934
  try {
6914
6935
  // =============================================================
6915
6936
  // Note: 4️⃣ Process each template of the pipeline
6916
- /* 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()) {
6937
+ for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
6917
6938
  var section = pipelineSections_1_1.value;
6918
6939
  _loop_2(section);
6919
6940
  }
@@ -6986,7 +7007,7 @@
6986
7007
  * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
6987
7008
  * - `preparePipeline` - just one step in the compilation process
6988
7009
  *
6989
- * Note: This function does not validate logic of the pipeline only the syntax
7010
+ * Note: This function does not validate logic of the pipeline only the parsing
6990
7011
  * Note: This function acts as compilation process
6991
7012
  *
6992
7013
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
@@ -8345,7 +8366,6 @@
8345
8366
  return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
8346
8367
  }
8347
8368
  /**
8348
- * TODO: !!!!!! Somw way how to connect this with commands
8349
8369
  * TODO: [🏛] This can be part of markdown builder
8350
8370
  */
8351
8371