@promptbook/node 0.75.0-1 → 0.75.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 (167) hide show
  1. package/README.md +28 -17
  2. package/esm/index.es.js +605 -489
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/{promptbook-collection → books}/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +28 -20
  6. package/esm/typings/src/_packages/types.index.d.ts +62 -52
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  8. package/esm/typings/src/cli/cli-commands/about.d.ts +1 -0
  9. package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -0
  10. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -0
  11. package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -0
  12. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -0
  13. package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -0
  14. package/esm/typings/src/cli/main.d.ts +1 -0
  15. package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
  16. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
  17. package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
  18. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
  19. package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
  20. package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +3 -3
  21. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -2
  22. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
  23. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +2 -2
  24. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +2 -2
  25. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +2 -2
  26. package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +11 -0
  27. package/esm/typings/src/commands/{TEMPLATE/templateCommandParser.d.ts → SECTION/sectionCommandParser.d.ts} +6 -6
  28. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  29. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +17 -19
  30. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +1 -1
  31. package/esm/typings/src/commands/index.d.ts +4 -1
  32. package/esm/typings/src/config.d.ts +11 -3
  33. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
  34. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
  35. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +3 -3
  36. package/esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts +1 -1
  37. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +4 -4
  38. package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +15 -0
  39. package/esm/typings/src/conversion/utils/renameParameter.d.ts +3 -3
  40. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +3 -2
  41. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
  42. package/esm/typings/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
  43. package/esm/typings/src/errors/index.d.ts +3 -0
  44. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  45. package/esm/typings/src/execution/PromptResultUsage.d.ts +1 -1
  46. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +1 -1
  47. package/esm/typings/src/execution/createPipelineExecutor/{$OngoingTemplateResult.d.ts → $OngoingTaskResult.d.ts} +1 -1
  48. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +1 -1
  49. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +1 -1
  50. package/esm/typings/src/execution/createPipelineExecutor/{20-executeTemplate.d.ts → 20-executeTask.d.ts} +7 -7
  51. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -5
  52. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +1 -1
  53. package/esm/typings/src/execution/createPipelineExecutor/{getContextForTemplate.d.ts → getContextForTask.d.ts} +2 -2
  54. package/esm/typings/src/execution/createPipelineExecutor/{getExamplesForTemplate.d.ts → getExamplesForTask.d.ts} +2 -2
  55. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +27 -0
  56. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +30 -0
  57. package/esm/typings/src/{types → execution}/execution-report/ExecutionPromptReportJson.d.ts +2 -2
  58. package/esm/typings/src/{types → execution}/execution-report/ExecutionReportJson.d.ts +4 -4
  59. package/esm/typings/src/{types → execution}/execution-report/ExecutionReportStringOptions.d.ts +1 -1
  60. package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  61. package/esm/typings/src/execution/utils/usage-constants.d.ts +3 -0
  62. package/esm/typings/src/formats/index.d.ts +3 -0
  63. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +2 -2
  64. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +7 -1
  65. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +3 -0
  66. package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +45 -0
  67. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +14 -0
  68. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +3 -3
  69. package/esm/typings/src/formfactors/index.d.ts +85 -12
  70. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +14 -0
  71. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +13 -3
  72. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +13 -3
  73. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
  74. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +3 -0
  75. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +1 -0
  76. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +3 -0
  77. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
  78. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  79. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  80. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +3 -0
  81. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +1 -0
  82. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  83. package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +26 -0
  84. package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +14 -0
  85. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/getPipelineInterface.d.ts +3 -1
  86. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineImplementingInterface.d.ts +5 -1
  87. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineInterfacesEqual.d.ts +2 -0
  88. package/esm/typings/src/{types/PipelineJson/TemplateJsonCommon.d.ts → pipeline/PipelineJson/CommonTaskJson.d.ts} +24 -24
  89. package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +13 -0
  90. package/esm/typings/src/{types → pipeline}/PipelineJson/Expectations.d.ts +2 -2
  91. package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgePieceJson.d.ts +7 -6
  92. package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgeSourceJson.d.ts +3 -3
  93. package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +98 -0
  94. package/esm/typings/src/{types → pipeline}/PipelineJson/PersonaJson.d.ts +5 -5
  95. package/esm/typings/src/{types → pipeline}/PipelineJson/PipelineJson.d.ts +11 -11
  96. package/esm/typings/src/{types → pipeline}/PipelineJson/PreparationJson.d.ts +1 -1
  97. package/esm/typings/src/{types/PipelineJson/PromptTemplateJson.d.ts → pipeline/PipelineJson/PromptTaskJson.d.ts} +8 -8
  98. package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +20 -0
  99. package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +13 -0
  100. package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +11 -0
  101. package/esm/typings/src/{types → pipeline}/PipelineString.d.ts +1 -1
  102. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +3 -3
  103. package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
  104. package/esm/typings/src/prepare/prepareTasks.d.ts +32 -0
  105. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -1
  106. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -1
  107. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +2 -2
  108. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  109. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +1 -1
  110. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
  111. package/esm/typings/src/scrapers/document/register-metadata.d.ts +3 -0
  112. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
  113. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
  114. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +3 -0
  115. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  116. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
  117. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +3 -0
  118. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -1
  119. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
  120. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +3 -0
  121. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +1 -1
  122. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
  123. package/esm/typings/src/scrapers/website/register-metadata.d.ts +3 -0
  124. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +1 -0
  125. package/esm/typings/src/types/Prompt.d.ts +4 -4
  126. package/esm/typings/src/types/SectionType.d.ts +21 -0
  127. package/esm/typings/src/types/TaskProgress.d.ts +2 -2
  128. package/esm/typings/src/types/TaskType.d.ts +15 -0
  129. package/esm/typings/src/types/typeAliasEmoji.d.ts +3 -0
  130. package/esm/typings/src/types/typeAliases.d.ts +2 -1
  131. package/esm/typings/src/utils/emojis.d.ts +1 -0
  132. package/esm/typings/src/utils/expectation-counters/constants.d.ts +1 -0
  133. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
  134. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
  135. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
  136. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
  137. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  138. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
  139. package/esm/typings/src/utils/expectation-counters/index.d.ts +3 -2
  140. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -0
  141. package/esm/typings/src/utils/organization/TODO_remove_as.d.ts +6 -0
  142. package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +2 -2
  143. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +1 -1
  144. package/esm/typings/src/version.d.ts +2 -1
  145. package/package.json +5 -4
  146. package/umd/index.umd.js +605 -489
  147. package/umd/index.umd.js.map +1 -1
  148. package/esm/typings/src/commands/TEMPLATE/TemplateCommand.d.ts +0 -11
  149. package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +0 -15
  150. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +0 -15
  151. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +0 -27
  152. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +0 -30
  153. package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +0 -15
  154. package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +0 -22
  155. package/esm/typings/src/pipeline/pipeline-interface/constants.d.ts +0 -9
  156. package/esm/typings/src/prepare/prepareTemplates.d.ts +0 -32
  157. package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +0 -13
  158. package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +0 -39
  159. package/esm/typings/src/types/PipelineJson/ScriptTemplateJson.d.ts +0 -20
  160. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +0 -13
  161. package/esm/typings/src/types/PipelineJson/TemplateJson.d.ts +0 -11
  162. /package/esm/typings/src/commands/{TEMPLATE/templateCommand.test.d.ts → SECTION/sectionCommand.test.d.ts} +0 -0
  163. /package/esm/typings/src/conversion/utils/{extractParameterNamesFromTemplate.test.d.ts → extractParameterNamesFromTask.test.d.ts} +0 -0
  164. /package/esm/typings/src/{types → execution}/execution-report/ExecutionReportString.d.ts +0 -0
  165. /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.d.ts +0 -0
  166. /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.test.d.ts +0 -0
  167. /package/esm/typings/src/{types → execution}/execution-report/executionReportJsonToString.d.ts +0 -0
package/umd/index.umd.js CHANGED
@@ -43,9 +43,10 @@
43
43
  *
44
44
  * @see https://github.com/webgptorg/promptbook
45
45
  */
46
- var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
46
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-3';
47
47
  /**
48
48
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
49
+ * Note: [💞] Ignore a discrepancy between file name and entity name
49
50
  */
50
51
 
51
52
  /*! *****************************************************************************
@@ -488,6 +489,7 @@
488
489
  true);
489
490
  /**
490
491
  * TODO: Extract `constants.ts` from `config.ts`
492
+ * Note: [💞] Ignore a discrepancy between file name and entity name
491
493
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
492
494
  */
493
495
 
@@ -543,7 +545,7 @@
543
545
  */
544
546
  function pipelineJsonToString(pipelineJson) {
545
547
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
546
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
548
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, tasks = pipelineJson.tasks;
547
549
  var pipelineString = "# ".concat(title);
548
550
  if (description) {
549
551
  pipelineString += '\n\n';
@@ -564,7 +566,7 @@
564
566
  return isInput;
565
567
  })), _h = _g.next(); !_h.done; _h = _g.next()) {
566
568
  var parameter = _h.value;
567
- commands.push("INPUT PARAMETER ".concat(templateParameterJsonToString(parameter)));
569
+ commands.push("INPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
568
570
  }
569
571
  }
570
572
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -580,7 +582,7 @@
580
582
  return isOutput;
581
583
  })), _k = _j.next(); !_k.done; _k = _j.next()) {
582
584
  var parameter = _k.value;
583
- commands.push("OUTPUT PARAMETER ".concat(templateParameterJsonToString(parameter)));
585
+ commands.push("OUTPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
584
586
  }
585
587
  }
586
588
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -593,13 +595,13 @@
593
595
  pipelineString += '\n\n';
594
596
  pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
595
597
  try {
596
- for (var templates_1 = __values(templates), templates_1_1 = templates_1.next(); !templates_1_1.done; templates_1_1 = templates_1.next()) {
597
- var template = templates_1_1.value;
598
+ for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
599
+ var task = tasks_1_1.value;
598
600
  var
599
601
  /* Note: Not using:> name, */
600
- title_1 = template.title, description_1 = template.description,
602
+ title_1 = task.title, description_1 = task.description,
601
603
  /* Note: dependentParameterNames, */
602
- jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
604
+ jokers = task.jokerParameterNames, taskType = task.taskType, content = task.content, postprocessing = task.postprocessingFunctionNames, expectations = task.expectations, format = task.format, resultingParameterName = task.resultingParameterName;
603
605
  pipelineString += '\n\n';
604
606
  pipelineString += "## ".concat(title_1);
605
607
  if (description_1) {
@@ -608,10 +610,11 @@
608
610
  }
609
611
  var commands_1 = [];
610
612
  var contentLanguage = 'text';
611
- if (templateType === 'PROMPT_TEMPLATE') {
612
- var modelRequirements = template.modelRequirements;
613
+ if (taskType === 'PROMPT_TASK') {
614
+ var modelRequirements = task.modelRequirements;
613
615
  var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
614
- commands_1.push("EXECUTE PROMPT TEMPLATE");
616
+ // Note: Do nothing, it is default
617
+ // commands.push(`PROMPT`);
615
618
  if (modelVariant) {
616
619
  commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
617
620
  }
@@ -619,21 +622,21 @@
619
622
  commands_1.push("MODEL NAME `".concat(modelName, "`"));
620
623
  }
621
624
  }
622
- else if (templateType === 'SIMPLE_TEMPLATE') {
625
+ else if (taskType === 'SIMPLE_TASK') {
623
626
  commands_1.push("SIMPLE TEMPLATE");
624
627
  // Note: Nothing special here
625
628
  }
626
- else if (templateType === 'SCRIPT_TEMPLATE') {
627
- commands_1.push("SCRIPT TEMPLATE");
628
- if (template.contentLanguage) {
629
- contentLanguage = template.contentLanguage;
629
+ else if (taskType === 'SCRIPT_TASK') {
630
+ commands_1.push("SCRIPT");
631
+ if (task.contentLanguage) {
632
+ contentLanguage = task.contentLanguage;
630
633
  }
631
634
  else {
632
635
  contentLanguage = '';
633
636
  }
634
637
  }
635
- else if (templateType === 'DIALOG_TEMPLATE') {
636
- commands_1.push("DIALOG TEMPLATE");
638
+ else if (taskType === 'DIALOG_TASK') {
639
+ commands_1.push("DIALOG");
637
640
  // Note: Nothing special here
638
641
  } // <- }else if([🅱]
639
642
  if (jokers) {
@@ -708,13 +711,13 @@
708
711
  pipelineString += '\n';
709
712
  pipelineString += '```';
710
713
  pipelineString += '\n\n';
711
- pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use templateParameterJsonToString
714
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
712
715
  }
713
716
  }
714
717
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
715
718
  finally {
716
719
  try {
717
- if (templates_1_1 && !templates_1_1.done && (_c = templates_1.return)) _c.call(templates_1);
720
+ if (tasks_1_1 && !tasks_1_1.done && (_c = tasks_1.return)) _c.call(tasks_1);
718
721
  }
719
722
  finally { if (e_3) throw e_3.error; }
720
723
  }
@@ -723,8 +726,8 @@
723
726
  /**
724
727
  * @private internal utility of `pipelineJsonToString`
725
728
  */
726
- function templateParameterJsonToString(templateParameterJson) {
727
- var name = templateParameterJson.name, description = templateParameterJson.description;
729
+ function taskParameterJsonToString(taskParameterJson) {
730
+ var name = taskParameterJson.name, description = taskParameterJson.description;
728
731
  var parameterString = "{".concat(name, "}");
729
732
  if (description) {
730
733
  parameterString = "".concat(parameterString, " ").concat(description);
@@ -732,7 +735,7 @@
732
735
  return parameterString;
733
736
  }
734
737
  /**
735
- * TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `templateParameterJsonToString` , use `stringifyCommand`
738
+ * TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `taskParameterJsonToString` , use `stringifyCommand`
736
739
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
737
740
  * TODO: [🏛] Maybe make some markdown builder
738
741
  * TODO: [🏛] Escape all
@@ -883,6 +886,9 @@
883
886
  pagesCount: { value: 0, isUncertain: true },
884
887
  },
885
888
  });
889
+ /**
890
+ * Note: [💞] Ignore a discrepancy between file name and entity name
891
+ */
886
892
 
887
893
  /**
888
894
  * @@@
@@ -1374,7 +1380,7 @@
1374
1380
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
1375
1381
  */
1376
1382
 
1377
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",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.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",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.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",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.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",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## Example\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.book.md"}];
1383
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",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:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",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:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",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:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",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}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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:"./books/prepare-persona.book.md"}];
1378
1384
 
1379
1385
  /**
1380
1386
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -1628,9 +1634,9 @@
1628
1634
  throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.parameters` expected to be an array, but got ".concat(typeof pipeline.parameters, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1629
1635
  }
1630
1636
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1631
- if (!Array.isArray(pipeline.templates)) {
1637
+ if (!Array.isArray(pipeline.tasks)) {
1632
1638
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
1633
- throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.templates` expected to be an array, but got ".concat(typeof pipeline.templates, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1639
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.tasks` expected to be an array, but got ".concat(typeof pipeline.tasks, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1634
1640
  }
1635
1641
  var _loop_1 = function (parameter) {
1636
1642
  if (parameter.isInput && parameter.isOutput) {
@@ -1639,13 +1645,12 @@
1639
1645
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
1640
1646
  if (!parameter.isInput &&
1641
1647
  !parameter.isOutput &&
1642
- !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
1648
+ !pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
1643
1649
  throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
1644
1650
  }
1645
- // Note: Testing that parameter is either input or result of some template
1646
- if (!parameter.isInput &&
1647
- !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
1648
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add template that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1651
+ // Note: Testing that parameter is either input or result of some task
1652
+ if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
1653
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add task that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1649
1654
  }
1650
1655
  };
1651
1656
  try {
@@ -1662,7 +1667,7 @@
1662
1667
  }
1663
1668
  finally { if (e_1) throw e_1.error; }
1664
1669
  }
1665
- // Note: All input parameters are defined - so that they can be used as result of some template
1670
+ // Note: All input parameters are defined - so that they can be used as result of some task
1666
1671
  var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
1667
1672
  var isInput = _a.isInput;
1668
1673
  return isInput;
@@ -1670,27 +1675,27 @@
1670
1675
  var name = _a.name;
1671
1676
  return name;
1672
1677
  }));
1673
- var _loop_2 = function (template) {
1678
+ var _loop_2 = function (task) {
1674
1679
  var e_4, _h, e_5, _j;
1675
- if (definedParameters.has(template.resultingParameterName)) {
1676
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1680
+ if (definedParameters.has(task.resultingParameterName)) {
1681
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1677
1682
  }
1678
- if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1679
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
1683
+ if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
1684
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(task.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
1680
1685
  }
1681
- definedParameters.add(template.resultingParameterName);
1682
- if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
1683
- if (!template.format &&
1684
- !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1685
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
1686
+ definedParameters.add(task.resultingParameterName);
1687
+ if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
1688
+ if (!task.format &&
1689
+ !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1690
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Joker parameters are used for {".concat(task.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
1686
1691
  }
1687
1692
  var _loop_4 = function (joker) {
1688
- if (!template.dependentParameterNames.includes(joker)) {
1689
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1693
+ if (!task.dependentParameterNames.includes(joker)) {
1694
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(task.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1690
1695
  }
1691
1696
  };
1692
1697
  try {
1693
- for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1698
+ for (var _k = (e_4 = void 0, __values(task.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1694
1699
  var joker = _l.value;
1695
1700
  _loop_4(joker);
1696
1701
  }
@@ -1703,7 +1708,7 @@
1703
1708
  finally { if (e_4) throw e_4.error; }
1704
1709
  }
1705
1710
  }
1706
- if (template.expectations) {
1711
+ if (task.expectations) {
1707
1712
  var _loop_5 = function (unit, min, max) {
1708
1713
  if (min !== undefined && max !== undefined && min > max) {
1709
1714
  throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -1716,7 +1721,7 @@
1716
1721
  }
1717
1722
  };
1718
1723
  try {
1719
- for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1724
+ for (var _m = (e_5 = void 0, __values(Object.entries(task.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1720
1725
  var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
1721
1726
  _loop_5(unit, min, max);
1722
1727
  }
@@ -1731,10 +1736,10 @@
1731
1736
  }
1732
1737
  };
1733
1738
  try {
1734
- // Note: Checking each template individually
1735
- for (var _f = __values(pipeline.templates), _g = _f.next(); !_g.done; _g = _f.next()) {
1736
- var template = _g.value;
1737
- _loop_2(template);
1739
+ // Note: Checking each task individually
1740
+ for (var _f = __values(pipeline.tasks), _g = _f.next(); !_g.done; _g = _f.next()) {
1741
+ var task = _g.value;
1742
+ _loop_2(task);
1738
1743
  }
1739
1744
  }
1740
1745
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1768,20 +1773,20 @@
1768
1773
  }
1769
1774
  finally { if (e_3) throw e_3.error; }
1770
1775
  }
1771
- var unresovedTemplates = __spreadArray([], __read(pipeline.templates), false);
1776
+ var unresovedTasks = __spreadArray([], __read(pipeline.tasks), false);
1772
1777
  var loopLimit = LOOP_LIMIT;
1773
1778
  var _loop_3 = function () {
1774
1779
  if (loopLimit-- < 0) {
1775
1780
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1776
1781
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
1777
1782
  }
1778
- var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1779
- return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1783
+ var currentlyResovedTasks = unresovedTasks.filter(function (task) {
1784
+ return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1780
1785
  });
1781
- if (currentlyResovedTemplates.length === 0) {
1786
+ if (currentlyResovedTasks.length === 0) {
1782
1787
  throw new PipelineLogicError(
1783
1788
  // TODO: [🐎] DRY
1784
- spaceTrim.spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates
1789
+ spaceTrim.spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks
1785
1790
  .map(function (_a) {
1786
1791
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
1787
1792
  return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
@@ -1800,13 +1805,13 @@
1800
1805
  .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1801
1806
  .join('\n')), "\n\n\n "); }));
1802
1807
  }
1803
- resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1808
+ resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTasks.map(function (_a) {
1804
1809
  var resultingParameterName = _a.resultingParameterName;
1805
1810
  return resultingParameterName;
1806
1811
  })), false);
1807
- unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
1812
+ unresovedTasks = unresovedTasks.filter(function (task) { return !currentlyResovedTasks.includes(task); });
1808
1813
  };
1809
- while (unresovedTemplates.length > 0) {
1814
+ while (unresovedTasks.length > 0) {
1810
1815
  _loop_3();
1811
1816
  }
1812
1817
  // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
@@ -1866,9 +1871,9 @@
1866
1871
  }(Error));
1867
1872
 
1868
1873
  /**
1869
- * Parses the template and returns the list of all parameter names
1874
+ * Parses the task and returns the list of all parameter names
1870
1875
  *
1871
- * @param template the template with parameters in {curly} braces
1876
+ * @param template the string template with parameters in {curly} braces
1872
1877
  * @returns the list of parameter names
1873
1878
  * @public exported from `@promptbook/utils`
1874
1879
  */
@@ -1899,18 +1904,18 @@
1899
1904
  * @public exported from `@promptbook/core`
1900
1905
  */
1901
1906
  function unpreparePipeline(pipeline) {
1902
- var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, templates = pipeline.templates;
1907
+ var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
1903
1908
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
1904
1909
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
1905
- templates = templates.map(function (template) {
1906
- var dependentParameterNames = template.dependentParameterNames;
1907
- var parameterNames = extractParameterNames(template.preparedContent || '');
1910
+ tasks = tasks.map(function (task) {
1911
+ var dependentParameterNames = task.dependentParameterNames;
1912
+ var parameterNames = extractParameterNames(task.preparedContent || '');
1908
1913
  dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
1909
- var templateUnprepared = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames });
1910
- delete templateUnprepared.preparedContent;
1911
- return templateUnprepared;
1914
+ var taskUnprepared = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames });
1915
+ delete taskUnprepared.preparedContent;
1916
+ return taskUnprepared;
1912
1917
  });
1913
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { templates: templates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1918
+ return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1914
1919
  }
1915
1920
  /**
1916
1921
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -2125,6 +2130,9 @@
2125
2130
  UnexpectedError: UnexpectedError,
2126
2131
  // TODO: [🪑]> VersionMismatchError,
2127
2132
  };
2133
+ /**
2134
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2135
+ */
2128
2136
 
2129
2137
  /**
2130
2138
  * Deserializes the error object
@@ -2186,8 +2194,8 @@
2186
2194
  return false;
2187
2195
  }
2188
2196
  /*
2189
- TODO: [🧠][🍫] `templates` can not be determined if they are fully prepared SO ignoring them
2190
- > if (!pipeline.templates.every(({ preparedContent }) => preparedContent === undefined)) {
2197
+ TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
2198
+ > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
2191
2199
  > return false;
2192
2200
  > }
2193
2201
  */
@@ -2198,9 +2206,9 @@
2198
2206
  * TODO: [🐠] Maybe base this on `makeValidator`
2199
2207
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2200
2208
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2201
- * - [🏍] ? Is context in each template
2209
+ * - [🏍] ? Is context in each task
2202
2210
  * - [♨] Are examples prepared
2203
- * - [♨] Are templates prepared
2211
+ * - [♨] Are tasks prepared
2204
2212
  */
2205
2213
 
2206
2214
  /**
@@ -2270,16 +2278,16 @@
2270
2278
  */
2271
2279
 
2272
2280
  /**
2273
- * Parses the template and returns the set of all used parameters
2281
+ * Parses the task and returns the set of all used parameters
2274
2282
  *
2275
- * @param template the template with used parameters
2283
+ * @param task the task with used parameters
2276
2284
  * @returns the set of parameter names
2277
2285
  * @throws {ParseError} if the script is invalid
2278
2286
  * @public exported from `@promptbook/utils`
2279
2287
  */
2280
- function extractParameterNamesFromTemplate(template) {
2288
+ function extractParameterNamesFromTask(task) {
2281
2289
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
2282
- var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
2290
+ var title = task.title, description = task.description, taskType = task.taskType, content = task.content, preparedContent = task.preparedContent, jokerParameterNames = task.jokerParameterNames, foreach = task.foreach;
2283
2291
  var parameterNames = new Set();
2284
2292
  try {
2285
2293
  for (var _e = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _f = _e.next(); !_f.done; _f = _e.next()) {
@@ -2294,7 +2302,7 @@
2294
2302
  }
2295
2303
  finally { if (e_1) throw e_1.error; }
2296
2304
  }
2297
- if (templateType === 'SCRIPT_TEMPLATE') {
2305
+ if (taskType === 'SCRIPT_TASK') {
2298
2306
  try {
2299
2307
  for (var _g = __values(extractVariables(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
2300
2308
  var parameterName = _h.value;
@@ -2725,6 +2733,9 @@
2725
2733
  TextFormatDefinition,
2726
2734
  CsvFormatDefinition,
2727
2735
  ];
2736
+ /**
2737
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2738
+ */
2728
2739
 
2729
2740
  /**
2730
2741
  * Maps available parameters to expected parameters
@@ -2960,7 +2971,7 @@
2960
2971
  }
2961
2972
  finally { if (e_1) throw e_1.error; }
2962
2973
  }
2963
- var replacedTemplate = template;
2974
+ var replacedTemplates = template;
2964
2975
  var match;
2965
2976
  var loopLimit = LOOP_LIMIT;
2966
2977
  var _loop_1 = function () {
@@ -2989,24 +3000,24 @@
2989
3000
  .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
2990
3001
  .join('\n');
2991
3002
  }
2992
- replacedTemplate =
2993
- replacedTemplate.substring(0, match.index + precol.length) +
3003
+ replacedTemplates =
3004
+ replacedTemplates.substring(0, match.index + precol.length) +
2994
3005
  parameterValue +
2995
- replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
3006
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
2996
3007
  };
2997
3008
  while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
2998
- .exec(replacedTemplate))) {
3009
+ .exec(replacedTemplates))) {
2999
3010
  _loop_1();
3000
3011
  }
3001
3012
  // [💫] Check if there are parameters that are not closed properly
3002
- if (/{\w+$/.test(replacedTemplate)) {
3013
+ if (/{\w+$/.test(replacedTemplates)) {
3003
3014
  throw new PipelineExecutionError('Parameter is not closed');
3004
3015
  }
3005
3016
  // [💫] Check if there are parameters that are not opened properly
3006
- if (/^\w+}/.test(replacedTemplate)) {
3017
+ if (/^\w+}/.test(replacedTemplates)) {
3007
3018
  throw new PipelineExecutionError('Parameter is not opened');
3008
3019
  }
3009
- return replacedTemplate;
3020
+ return replacedTemplates;
3010
3021
  }
3011
3022
 
3012
3023
  /**
@@ -3038,6 +3049,7 @@
3038
3049
  var LINES_PER_STANDARD_PAGE = 44;
3039
3050
  /**
3040
3051
  * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
3052
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3041
3053
  */
3042
3054
 
3043
3055
  /**
@@ -3378,6 +3390,7 @@
3378
3390
  };
3379
3391
  /**
3380
3392
  * TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
3393
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3381
3394
  */
3382
3395
 
3383
3396
  /**
@@ -3426,12 +3439,12 @@
3426
3439
  */
3427
3440
  function executeAttempts(options) {
3428
3441
  return __awaiter(this, void 0, void 0, function () {
3429
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3442
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTaskResult, _llms, llmTools, _loop_1, attempt, state_1;
3430
3443
  return __generator(this, function (_a) {
3431
3444
  switch (_a.label) {
3432
3445
  case 0:
3433
- jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts;
3434
- $ongoingTemplateResult = {
3446
+ jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, task = options.task, preparedPipeline = options.preparedPipeline, tools = options.tools, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts;
3447
+ $ongoingTaskResult = {
3435
3448
  $result: null,
3436
3449
  $resultString: null,
3437
3450
  $expectError: null,
@@ -3451,52 +3464,51 @@
3451
3464
  if (isJokerAttempt && !jokerParameterName) {
3452
3465
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
3453
3466
  }
3454
- $ongoingTemplateResult.$result = null;
3455
- $ongoingTemplateResult.$resultString = null;
3456
- $ongoingTemplateResult.$expectError = null;
3467
+ $ongoingTaskResult.$result = null;
3468
+ $ongoingTaskResult.$resultString = null;
3469
+ $ongoingTaskResult.$expectError = null;
3457
3470
  if (isJokerAttempt) {
3458
3471
  if (parameters[jokerParameterName] === undefined) {
3459
3472
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
3460
3473
  // <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
3461
3474
  }
3462
3475
  else {
3463
- $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
3476
+ $ongoingTaskResult.$resultString = parameters[jokerParameterName];
3464
3477
  }
3465
3478
  }
3466
3479
  _t.label = 1;
3467
3480
  case 1:
3468
3481
  _t.trys.push([1, 43, 44, 45]);
3469
3482
  if (!!isJokerAttempt) return [3 /*break*/, 25];
3470
- _b = template.templateType;
3483
+ _b = task.taskType;
3471
3484
  switch (_b) {
3472
- case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3473
- case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
3474
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
3475
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
3485
+ case 'SIMPLE_TASK': return [3 /*break*/, 2];
3486
+ case 'PROMPT_TASK': return [3 /*break*/, 3];
3487
+ case 'SCRIPT_TASK': return [3 /*break*/, 11];
3488
+ case 'DIALOG_TASK': return [3 /*break*/, 22];
3476
3489
  }
3477
3490
  return [3 /*break*/, 24];
3478
3491
  case 2:
3479
- $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
3492
+ $ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
3480
3493
  return [3 /*break*/, 25];
3481
3494
  case 3:
3482
- modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
3483
- $ongoingTemplateResult.$prompt = {
3484
- title: template.title,
3495
+ modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
3496
+ $ongoingTaskResult.$prompt = {
3497
+ title: task.title,
3485
3498
  pipelineUrl: "".concat(preparedPipeline.pipelineUrl
3486
3499
  ? preparedPipeline.pipelineUrl
3487
- : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
3488
- // <- TODO: Here should be maybe also subformat index to distinguish between same template with different subformat values
3500
+ : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(task.name
3501
+ // <- TODO: Here should be maybe also subformat index to distinguish between same task with different subformat values
3489
3502
  ),
3490
3503
  parameters: parameters,
3491
3504
  content: preparedContent,
3492
3505
  modelRequirements: modelRequirements,
3493
3506
  expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
3494
3507
  var name = _a.name;
3495
- return name === template.personaName;
3496
- }) ||
3497
- {})), template.expectations),
3498
- format: template.format,
3499
- postprocessingFunctionNames: template.postprocessingFunctionNames,
3508
+ return name === task.personaName;
3509
+ }) || {})), task.expectations),
3510
+ format: task.format,
3511
+ postprocessingFunctionNames: task.postprocessingFunctionNames,
3500
3512
  }; // <- TODO: Not very good type guard
3501
3513
  _c = modelRequirements.modelVariant;
3502
3514
  switch (_c) {
@@ -3506,36 +3518,35 @@
3506
3518
  }
3507
3519
  return [3 /*break*/, 9];
3508
3520
  case 4:
3509
- _d = $ongoingTemplateResult;
3521
+ _d = $ongoingTaskResult;
3510
3522
  return [4 /*yield*/, llmTools.callChatModel(
3511
3523
  // <- TODO: [🧁] Check that `callChatModel` is defined
3512
- $deepFreeze($ongoingTemplateResult.$prompt))];
3524
+ $deepFreeze($ongoingTaskResult.$prompt))];
3513
3525
  case 5:
3514
3526
  _d.$chatResult = _t.sent();
3515
3527
  // TODO: [🍬] Destroy chatThread
3516
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
3517
- $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
3528
+ $ongoingTaskResult.$result = $ongoingTaskResult.$chatResult;
3529
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$chatResult.content;
3518
3530
  return [3 /*break*/, 10];
3519
3531
  case 6:
3520
- _e = $ongoingTemplateResult;
3532
+ _e = $ongoingTaskResult;
3521
3533
  return [4 /*yield*/, llmTools.callCompletionModel(
3522
3534
  // <- TODO: [🧁] Check that `callCompletionModel` is defined
3523
- $deepFreeze($ongoingTemplateResult.$prompt))];
3535
+ $deepFreeze($ongoingTaskResult.$prompt))];
3524
3536
  case 7:
3525
3537
  _e.$completionResult = _t.sent();
3526
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
3527
- $ongoingTemplateResult.$resultString =
3528
- $ongoingTemplateResult.$completionResult.content;
3538
+ $ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
3539
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
3529
3540
  return [3 /*break*/, 10];
3530
3541
  case 8: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Embedding model can not be used in pipeline\n\n This should be catched during parsing\n\n ".concat(block(pipelineIdentification), "\n\n "); }));
3531
- case 9: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3542
+ case 9: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant \"".concat(task.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3532
3543
  case 10: return [3 /*break*/, 25];
3533
3544
  case 11:
3534
3545
  if (arrayableToArray(tools.script).length === 0) {
3535
3546
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3536
3547
  }
3537
- if (!template.contentLanguage) {
3538
- throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3548
+ if (!task.contentLanguage) {
3549
+ throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TASK \"".concat(task.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3539
3550
  }
3540
3551
  _t.label = 12;
3541
3552
  case 12:
@@ -3548,9 +3559,9 @@
3548
3559
  _t.label = 14;
3549
3560
  case 14:
3550
3561
  _t.trys.push([14, 16, , 17]);
3551
- _h = $ongoingTemplateResult;
3562
+ _h = $ongoingTaskResult;
3552
3563
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
3553
- scriptLanguage: template.contentLanguage,
3564
+ scriptLanguage: task.contentLanguage,
3554
3565
  script: preparedContent,
3555
3566
  parameters: parameters,
3556
3567
  }))];
@@ -3565,7 +3576,7 @@
3565
3576
  if (error_1 instanceof UnexpectedError) {
3566
3577
  throw error_1;
3567
3578
  }
3568
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
3579
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_1);
3569
3580
  return [3 /*break*/, 17];
3570
3581
  case 17:
3571
3582
  _g = _f.next();
@@ -3582,14 +3593,14 @@
3582
3593
  finally { if (e_1) throw e_1.error; }
3583
3594
  return [7 /*endfinally*/];
3584
3595
  case 21:
3585
- if ($ongoingTemplateResult.$resultString !== null) {
3596
+ if ($ongoingTaskResult.$resultString !== null) {
3586
3597
  return [3 /*break*/, 25];
3587
3598
  }
3588
- if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
3589
- throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
3599
+ if ($ongoingTaskResult.$scriptPipelineExecutionErrors.length === 1) {
3600
+ throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
3590
3601
  }
3591
3602
  else {
3592
- throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
3603
+ throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTaskResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTaskResult.$scriptPipelineExecutionErrors
3593
3604
  .map(function (error) { return '- ' + error.message; })
3594
3605
  .join('\n\n')), "\n "); }));
3595
3606
  }
@@ -3597,27 +3608,27 @@
3597
3608
  if (tools.userInterface === undefined) {
3598
3609
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3599
3610
  }
3600
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3601
- _j = $ongoingTemplateResult;
3611
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
3612
+ _j = $ongoingTaskResult;
3602
3613
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
3603
- promptTitle: template.title,
3604
- promptMessage: replaceParameters(template.description || '', parameters),
3614
+ promptTitle: task.title,
3615
+ promptMessage: replaceParameters(task.description || '', parameters),
3605
3616
  defaultValue: replaceParameters(preparedContent, parameters),
3606
3617
  // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
3607
3618
  placeholder: undefined,
3608
3619
  priority: priority,
3609
3620
  }))];
3610
3621
  case 23:
3611
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3622
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
3612
3623
  _j.$resultString = _t.sent();
3613
3624
  return [3 /*break*/, 25];
3614
- case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3625
+ case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3615
3626
  case 25:
3616
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3627
+ if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
3617
3628
  _t.label = 26;
3618
3629
  case 26:
3619
3630
  _t.trys.push([26, 40, 41, 42]);
3620
- _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
3631
+ _k = (e_3 = void 0, __values(task.postprocessingFunctionNames)), _l = _k.next();
3621
3632
  _t.label = 27;
3622
3633
  case 27:
3623
3634
  if (!!_l.done) return [3 /*break*/, 39];
@@ -3634,13 +3645,13 @@
3634
3645
  _t.label = 30;
3635
3646
  case 30:
3636
3647
  _t.trys.push([30, 32, , 33]);
3637
- _p = $ongoingTemplateResult;
3648
+ _p = $ongoingTaskResult;
3638
3649
  return [4 /*yield*/, scriptTools.execute({
3639
3650
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
3640
3651
  script: "".concat(functionName, "(resultString)"),
3641
3652
  parameters: {
3642
- resultString: $ongoingTemplateResult.$resultString || '',
3643
- // Note: No ...parametersForTemplate, because working with result only
3653
+ resultString: $ongoingTaskResult.$resultString || '',
3654
+ // Note: No ...parametersForTask, because working with result only
3644
3655
  },
3645
3656
  })];
3646
3657
  case 31:
@@ -3656,7 +3667,7 @@
3656
3667
  throw error_2;
3657
3668
  }
3658
3669
  postprocessingError = error_2;
3659
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
3670
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_2);
3660
3671
  return [3 /*break*/, 33];
3661
3672
  case 33:
3662
3673
  _o = _m.next();
@@ -3693,12 +3704,12 @@
3693
3704
  return [7 /*endfinally*/];
3694
3705
  case 42:
3695
3706
  // TODO: [💝] Unite object for expecting amount and format
3696
- if (template.format) {
3697
- if (template.format === 'JSON') {
3698
- if (!isValidJsonString($ongoingTemplateResult.$resultString || '')) {
3707
+ if (task.format) {
3708
+ if (task.format === 'JSON') {
3709
+ if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
3699
3710
  // TODO: [🏢] Do more universally via `FormatDefinition`
3700
3711
  try {
3701
- $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
3712
+ $ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
3702
3713
  }
3703
3714
  catch (error) {
3704
3715
  throw new ExpectError(spaceTrim.spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
@@ -3707,12 +3718,12 @@
3707
3718
  }
3708
3719
  }
3709
3720
  else {
3710
- throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3721
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3711
3722
  }
3712
3723
  }
3713
3724
  // TODO: [💝] Unite object for expecting amount and format
3714
- if (template.expectations) {
3715
- checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
3725
+ if (task.expectations) {
3726
+ checkExpectations(task.expectations, $ongoingTaskResult.$resultString || '');
3716
3727
  }
3717
3728
  return [2 /*return*/, "break-attempts"];
3718
3729
  case 43:
@@ -3720,38 +3731,38 @@
3720
3731
  if (!(error_3 instanceof ExpectError)) {
3721
3732
  throw error_3;
3722
3733
  }
3723
- $ongoingTemplateResult.$expectError = error_3;
3734
+ $ongoingTaskResult.$expectError = error_3;
3724
3735
  return [3 /*break*/, 45];
3725
3736
  case 44:
3726
3737
  if (!isJokerAttempt &&
3727
- template.templateType === 'PROMPT_TEMPLATE' &&
3728
- $ongoingTemplateResult.$prompt
3738
+ task.taskType === 'PROMPT_TASK' &&
3739
+ $ongoingTaskResult.$prompt
3729
3740
  // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
3730
3741
  // In that case we don’t want to make a report about it because it’s not a llm execution error
3731
3742
  ) {
3732
- // TODO: [🧠] Maybe put other templateTypes into report
3743
+ // TODO: [🧠] Maybe put other taskTypes into report
3733
3744
  $executionReport.promptExecutions.push({
3734
- prompt: __assign({}, $ongoingTemplateResult.$prompt),
3735
- result: $ongoingTemplateResult.$result || undefined,
3736
- error: $ongoingTemplateResult.$expectError === null
3745
+ prompt: __assign({}, $ongoingTaskResult.$prompt),
3746
+ result: $ongoingTaskResult.$result || undefined,
3747
+ error: $ongoingTaskResult.$expectError === null
3737
3748
  ? undefined
3738
- : serializeError($ongoingTemplateResult.$expectError),
3749
+ : serializeError($ongoingTaskResult.$expectError),
3739
3750
  });
3740
3751
  }
3741
3752
  return [7 /*endfinally*/];
3742
3753
  case 45:
3743
- if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
3754
+ if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
3744
3755
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) {
3745
3756
  var _a, _b, _c;
3746
- return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $ongoingTemplateResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
3757
+ return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
3747
3758
  .split('\n')
3748
3759
  .map(function (line) { return "> ".concat(line); })
3749
- .join('\n')), "\n\n Last error ").concat(((_b = $ongoingTemplateResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || '', ":\n ").concat(block((((_c = $ongoingTemplateResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
3760
+ .join('\n')), "\n\n Last error ").concat(((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || '', ":\n ").concat(block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
3750
3761
  .split('\n')
3751
3762
  .map(function (line) { return "> ".concat(line); })
3752
- .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
3763
+ .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTaskResult.$resultString === null
3753
3764
  ? 'null'
3754
- : $ongoingTemplateResult.$resultString
3765
+ : $ongoingTaskResult.$resultString
3755
3766
  .split('\n')
3756
3767
  .map(function (line) { return "> ".concat(line); })
3757
3768
  .join('\n')), "\n ---\n ");
@@ -3776,10 +3787,10 @@
3776
3787
  attempt++;
3777
3788
  return [3 /*break*/, 1];
3778
3789
  case 4:
3779
- if ($ongoingTemplateResult.$resultString === null) {
3790
+ if ($ongoingTaskResult.$resultString === null) {
3780
3791
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3781
3792
  }
3782
- return [2 /*return*/, $ongoingTemplateResult.$resultString];
3793
+ return [2 /*return*/, $ongoingTaskResult.$resultString];
3783
3794
  }
3784
3795
  });
3785
3796
  });
@@ -3795,36 +3806,36 @@
3795
3806
  */
3796
3807
  function executeFormatSubvalues(options) {
3797
3808
  return __awaiter(this, void 0, void 0, function () {
3798
- var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3809
+ var task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3799
3810
  var _this = this;
3800
3811
  return __generator(this, function (_a) {
3801
3812
  switch (_a.label) {
3802
3813
  case 0:
3803
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
3804
- if (template.foreach === undefined) {
3814
+ task = options.task, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
3815
+ if (task.foreach === undefined) {
3805
3816
  return [2 /*return*/, /* not await */ executeAttempts(options)];
3806
3817
  }
3807
3818
  if (jokerParameterNames.length !== 0) {
3808
3819
  throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n JOKER parameters are not supported together with FOREACH command\n\n [\uD83E\uDDDE\u200D\u2640\uFE0F] This should be prevented in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
3809
3820
  }
3810
- parameterValue = parameters[template.foreach.parameterName] || '';
3821
+ parameterValue = parameters[task.foreach.parameterName] || '';
3811
3822
  formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
3812
- return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(template.foreach.formatName);
3823
+ return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(task.foreach.formatName);
3813
3824
  });
3814
3825
  if (formatDefinition === undefined) {
3815
3826
  throw new UnexpectedError(
3816
3827
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
3817
- spaceTrim__default["default"](function (block) { return "\n Unsupported format \"".concat(template.foreach.formatName, "\"\n\n Available formats:\n ").concat(block(FORMAT_DEFINITIONS.map(function (formatDefinition) { return formatDefinition.formatName; })
3828
+ spaceTrim__default["default"](function (block) { return "\n Unsupported format \"".concat(task.foreach.formatName, "\"\n\n Available formats:\n ").concat(block(FORMAT_DEFINITIONS.map(function (formatDefinition) { return formatDefinition.formatName; })
3818
3829
  .map(function (formatName) { return "- ".concat(formatName); })
3819
3830
  .join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
3820
3831
  }
3821
3832
  subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
3822
- return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(template.foreach.subformatName);
3833
+ return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(task.foreach.subformatName);
3823
3834
  });
3824
3835
  if (subvalueDefinition === undefined) {
3825
3836
  throw new UnexpectedError(
3826
3837
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
3827
- spaceTrim__default["default"](function (block) { return "\n Unsupported subformat name \"".concat(template.foreach.subformatName, "\" for format \"").concat(template.foreach.formatName, "\"\n\n Available subformat names for format \"").concat(formatDefinition.formatName, "\":\n ").concat(block(formatDefinition.subvalueDefinitions
3838
+ spaceTrim__default["default"](function (block) { return "\n Unsupported subformat name \"".concat(task.foreach.subformatName, "\" for format \"").concat(task.foreach.formatName, "\"\n\n Available subformat names for format \"").concat(formatDefinition.formatName, "\":\n ").concat(block(formatDefinition.subvalueDefinitions
3828
3839
  .map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
3829
3840
  .map(function (subvalueName) { return "- ".concat(subvalueName); })
3830
3841
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -3833,7 +3844,7 @@
3833
3844
  formatSettings = csvSettings;
3834
3845
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
3835
3846
  }
3836
- return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
3847
+ return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
3837
3848
  var mappedParameters, allSubparameters, subresultString;
3838
3849
  return __generator(this, function (_a) {
3839
3850
  switch (_a.label) {
@@ -3842,7 +3853,7 @@
3842
3853
  // TODO: When done [🐚] Report progress also for each subvalue here
3843
3854
  try {
3844
3855
  mappedParameters = mapAvailableToExpectedParameters({
3845
- expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
3856
+ expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
3846
3857
  availableParameters: subparameters,
3847
3858
  });
3848
3859
  }
@@ -3875,7 +3886,7 @@
3875
3886
  *
3876
3887
  * @private internal utility of `createPipelineExecutor`
3877
3888
  */
3878
- function getContextForTemplate(template) {
3889
+ function getContextForTask(task) {
3879
3890
  return __awaiter(this, void 0, void 0, function () {
3880
3891
  return __generator(this, function (_a) {
3881
3892
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
@@ -3888,15 +3899,10 @@
3888
3899
  *
3889
3900
  * @private internal utility of `createPipelineExecutor`
3890
3901
  */
3891
- function getKnowledgeForTemplate(options) {
3902
+ function getExamplesForTask(task) {
3892
3903
  return __awaiter(this, void 0, void 0, function () {
3893
- var preparedPipeline;
3894
3904
  return __generator(this, function (_a) {
3895
- preparedPipeline = options.preparedPipeline, options.template;
3896
- return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
3897
- var content = _a.content;
3898
- return "- ".concat(content);
3899
- }).join('\n')];
3905
+ return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
3900
3906
  });
3901
3907
  });
3902
3908
  }
@@ -3906,10 +3912,15 @@
3906
3912
  *
3907
3913
  * @private internal utility of `createPipelineExecutor`
3908
3914
  */
3909
- function getExamplesForTemplate(template) {
3915
+ function getKnowledgeForTask(options) {
3910
3916
  return __awaiter(this, void 0, void 0, function () {
3917
+ var preparedPipeline;
3911
3918
  return __generator(this, function (_a) {
3912
- return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
3919
+ preparedPipeline = options.preparedPipeline, options.task;
3920
+ return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
3921
+ var content = _a.content;
3922
+ return "- ".concat(content);
3923
+ }).join('\n')];
3913
3924
  });
3914
3925
  });
3915
3926
  }
@@ -3919,21 +3930,21 @@
3919
3930
  *
3920
3931
  * @private internal utility of `createPipelineExecutor`
3921
3932
  */
3922
- function getReservedParametersForTemplate(options) {
3933
+ function getReservedParametersForTask(options) {
3923
3934
  return __awaiter(this, void 0, void 0, function () {
3924
- var preparedPipeline, template, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
3935
+ var preparedPipeline, task, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
3925
3936
  var e_1, _a;
3926
3937
  return __generator(this, function (_b) {
3927
3938
  switch (_b.label) {
3928
3939
  case 0:
3929
- preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
3930
- return [4 /*yield*/, getContextForTemplate()];
3940
+ preparedPipeline = options.preparedPipeline, task = options.task, pipelineIdentification = options.pipelineIdentification;
3941
+ return [4 /*yield*/, getContextForTask()];
3931
3942
  case 1:
3932
3943
  context = _b.sent();
3933
- return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
3944
+ return [4 /*yield*/, getKnowledgeForTask({ preparedPipeline: preparedPipeline, task: task })];
3934
3945
  case 2:
3935
3946
  knowledge = _b.sent();
3936
- return [4 /*yield*/, getExamplesForTemplate()];
3947
+ return [4 /*yield*/, getExamplesForTask()];
3937
3948
  case 3:
3938
3949
  examples = _b.sent();
3939
3950
  currentDate = new Date().toISOString();
@@ -3976,31 +3987,31 @@
3976
3987
  *
3977
3988
  * @private internal utility of `createPipelineExecutor`
3978
3989
  */
3979
- function executeTemplate(options) {
3990
+ function executeTask(options) {
3980
3991
  return __awaiter(this, void 0, void 0, function () {
3981
- var currentTemplate, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, _a, maxExecutionAttempts, name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _b, _c, _d, definedParameterNames, parameters, _loop_1, _e, _f, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
3992
+ var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, _a, maxExecutionAttempts, name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _b, _c, _d, definedParameterNames, parameters, _loop_1, _e, _f, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
3982
3993
  var e_1, _g, _h;
3983
3994
  return __generator(this, function (_j) {
3984
3995
  switch (_j.label) {
3985
3996
  case 0:
3986
- currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a;
3987
- name = "pipeline-executor-frame-".concat(currentTemplate.name);
3988
- title = currentTemplate.title;
3989
- priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
3997
+ currentTask = options.currentTask, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a;
3998
+ name = "pipeline-executor-frame-".concat(currentTask.name);
3999
+ title = currentTask.title;
4000
+ priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
3990
4001
  return [4 /*yield*/, onProgress({
3991
4002
  name: name,
3992
4003
  title: title,
3993
4004
  isStarted: false,
3994
4005
  isDone: false,
3995
- templateType: currentTemplate.templateType,
3996
- parameterName: currentTemplate.resultingParameterName,
4006
+ taskType: currentTask.taskType,
4007
+ parameterName: currentTask.resultingParameterName,
3997
4008
  parameterValue: null,
3998
4009
  // <- [🍸]
3999
4010
  })];
4000
4011
  case 1:
4001
4012
  _j.sent();
4002
- usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
4003
- dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
4013
+ usedParameterNames = extractParameterNamesFromTask(currentTask);
4014
+ dependentParameterNames = new Set(currentTask.dependentParameterNames);
4004
4015
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4005
4016
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
4006
4017
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Dependent parameters are not consistent with used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames)
@@ -4011,9 +4022,9 @@
4011
4022
  }
4012
4023
  _c = (_b = Object).freeze;
4013
4024
  _d = [{}];
4014
- return [4 /*yield*/, getReservedParametersForTemplate({
4025
+ return [4 /*yield*/, getReservedParametersForTask({
4015
4026
  preparedPipeline: preparedPipeline,
4016
- template: currentTemplate,
4027
+ task: currentTask,
4017
4028
  pipelineIdentification: pipelineIdentification,
4018
4029
  })];
4019
4030
  case 2:
@@ -4031,11 +4042,11 @@
4031
4042
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4032
4043
  // Houston, we have a problem
4033
4044
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
4034
- throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4045
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in task \"").concat(currentTask.title || currentTask.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4035
4046
  }
4036
4047
  };
4037
4048
  try {
4038
- // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
4049
+ // Note: [2] Check that all used parameters are defined and removing unused parameters for this task
4039
4050
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4040
4051
  for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4041
4052
  parameterName = _f.value;
@@ -4051,18 +4062,16 @@
4051
4062
  }
4052
4063
  // Note: [👨‍👨‍👧] Now we can freeze `parameters` because we are sure that all and only used parameters are defined and are not going to be changed
4053
4064
  Object.freeze(parameters);
4054
- maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
4055
- jokerParameterNames = currentTemplate.jokerParameterNames || [];
4056
- preparedContent = (currentTemplate.preparedContent || '{content}')
4057
- .split('{content}')
4058
- .join(currentTemplate.content);
4065
+ maxAttempts = currentTask.taskType === 'DIALOG_TASK' ? Infinity : maxExecutionAttempts;
4066
+ jokerParameterNames = currentTask.jokerParameterNames || [];
4067
+ preparedContent = (currentTask.preparedContent || '{content}').split('{content}').join(currentTask.content);
4059
4068
  return [4 /*yield*/, executeFormatSubvalues({
4060
4069
  jokerParameterNames: jokerParameterNames,
4061
4070
  priority: priority,
4062
4071
  maxAttempts: maxAttempts,
4063
4072
  preparedContent: preparedContent,
4064
4073
  parameters: parameters,
4065
- template: currentTemplate,
4074
+ task: currentTask,
4066
4075
  preparedPipeline: preparedPipeline,
4067
4076
  tools: tools,
4068
4077
  $executionReport: $executionReport,
@@ -4075,15 +4084,15 @@
4075
4084
  title: title,
4076
4085
  isStarted: true,
4077
4086
  isDone: true,
4078
- templateType: currentTemplate.templateType,
4079
- parameterName: currentTemplate.resultingParameterName,
4087
+ taskType: currentTask.taskType,
4088
+ parameterName: currentTask.resultingParameterName,
4080
4089
  parameterValue: resultString,
4081
4090
  // <- [🍸]
4082
4091
  })];
4083
4092
  case 4:
4084
4093
  _j.sent();
4085
4094
  return [2 /*return*/, Object.freeze((_h = {},
4086
- _h[currentTemplate.resultingParameterName] =
4095
+ _h[currentTask.resultingParameterName] =
4087
4096
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
4088
4097
  resultString,
4089
4098
  _h))];
@@ -4145,7 +4154,7 @@
4145
4154
  */
4146
4155
  function executePipeline(options) {
4147
4156
  return __awaiter(this, void 0, void 0, function () {
4148
- var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, _a, isVerbose, preparedPipeline, errors, warnings, executionReport, isReturned, _b, _c, parameter, e_1_1, _loop_1, _d, _e, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
4157
+ var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, _a, isVerbose, preparedPipeline, errors, warnings, executionReport, isReturned, _b, _c, parameter, e_1_1, _loop_1, _d, _e, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1, unresovedTasks_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
4149
4158
  var e_1, _f, e_2, _g;
4150
4159
  return __generator(this, function (_h) {
4151
4160
  switch (_h.label) {
@@ -4299,11 +4308,11 @@
4299
4308
  var name = _a.name;
4300
4309
  return name;
4301
4310
  });
4302
- unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.templates), false);
4311
+ unresovedTasks_1 = __spreadArray([], __read(preparedPipeline.tasks), false);
4303
4312
  resolving_1 = [];
4304
4313
  loopLimit = LOOP_LIMIT;
4305
4314
  _loop_2 = function () {
4306
- var currentTemplate, work_1;
4315
+ var currentTask, work_1;
4307
4316
  return __generator(this, function (_k) {
4308
4317
  switch (_k.label) {
4309
4318
  case 0:
@@ -4311,15 +4320,15 @@
4311
4320
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
4312
4321
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
4313
4322
  }
4314
- currentTemplate = unresovedTemplates_1.find(function (template) {
4315
- return template.dependentParameterNames.every(function (name) {
4323
+ currentTask = unresovedTasks_1.find(function (task) {
4324
+ return task.dependentParameterNames.every(function (name) {
4316
4325
  return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
4317
4326
  });
4318
4327
  });
4319
- if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
4328
+ if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
4320
4329
  throw new UnexpectedError(
4321
4330
  // TODO: [🐎] DRY
4322
- spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates_1
4331
+ spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks_1
4323
4332
  .map(function (_a) {
4324
4333
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
4325
4334
  return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
@@ -4338,14 +4347,14 @@
4338
4347
  .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
4339
4348
  .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
4340
4349
  case 1:
4341
- if (!!currentTemplate) return [3 /*break*/, 3];
4350
+ if (!!currentTask) return [3 /*break*/, 3];
4342
4351
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
4343
4352
  case 2:
4344
4353
  /* [🤹‍♂️] */ _k.sent();
4345
4354
  return [3 /*break*/, 4];
4346
4355
  case 3:
4347
- unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
4348
- work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4356
+ unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
4357
+ work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4349
4358
  if (isReturned) {
4350
4359
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
4351
4360
  .split('\n')
@@ -4355,16 +4364,16 @@
4355
4364
  if (onProgress) {
4356
4365
  onProgress(progress);
4357
4366
  }
4358
- }, $executionReport: executionReport, pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
4367
+ }, $executionReport: executionReport, pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
4359
4368
  .then(function (newParametersToPass) {
4360
4369
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
4361
- resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
4370
+ resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
4362
4371
  })
4363
4372
  .then(function () {
4364
4373
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
4365
4374
  });
4366
4375
  // <- Note: Errors are catched here [3]
4367
- // TODO: BUT if in multiple templates are errors, only the first one is catched so maybe we should catch errors here and save them to errors array here
4376
+ // TODO: BUT if in multiple tasks are errors, only the first one is catched so maybe we should catch errors here and save them to errors array here
4368
4377
  resolving_1.push(work_1);
4369
4378
  _k.label = 4;
4370
4379
  case 4: return [2 /*return*/];
@@ -4373,7 +4382,7 @@
4373
4382
  };
4374
4383
  _h.label = 21;
4375
4384
  case 21:
4376
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
4385
+ if (!(unresovedTasks_1.length > 0)) return [3 /*break*/, 23];
4377
4386
  return [5 /*yield**/, _loop_2()];
4378
4387
  case 22:
4379
4388
  _h.sent();
@@ -4914,6 +4923,9 @@
4914
4923
  normalizedName = normalizedName.replace(/-$/, '');
4915
4924
  return normalizedName;
4916
4925
  }
4926
+ /**
4927
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4928
+ */
4917
4929
 
4918
4930
  /**
4919
4931
  * Creates unique name for the source
@@ -5285,7 +5297,7 @@
5285
5297
  */
5286
5298
  function clonePipeline(pipeline) {
5287
5299
  // Note: Not using spread operator (...) because @@@
5288
- var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
5300
+ var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
5289
5301
  return {
5290
5302
  pipelineUrl: pipelineUrl,
5291
5303
  sourceFile: sourceFile,
@@ -5294,7 +5306,7 @@
5294
5306
  description: description,
5295
5307
  formfactorName: formfactorName,
5296
5308
  parameters: parameters,
5297
- templates: templates,
5309
+ tasks: tasks,
5298
5310
  knowledgeSources: knowledgeSources,
5299
5311
  knowledgePieces: knowledgePieces,
5300
5312
  personas: personas,
@@ -5310,20 +5322,20 @@
5310
5322
  *
5311
5323
  * @public exported from `@promptbook/core`
5312
5324
  */
5313
- function prepareTemplates(pipeline, tools, options) {
5325
+ function prepareTasks(pipeline, tools, options) {
5314
5326
  return __awaiter(this, void 0, void 0, function () {
5315
- var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
5327
+ var _a, maxParallelCount, tasks, knowledgePiecesCount, tasksPrepared;
5316
5328
  var _this = this;
5317
5329
  return __generator(this, function (_b) {
5318
5330
  switch (_b.label) {
5319
5331
  case 0:
5320
5332
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
5321
- templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5322
- templatesPrepared = new Array(templates.length);
5323
- return [4 /*yield*/, forEachAsync(templates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
5324
- var dependentParameterNames, preparedContent, preparedTemplate;
5333
+ tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5334
+ tasksPrepared = new Array(tasks.length);
5335
+ return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (task, index) { return __awaiter(_this, void 0, void 0, function () {
5336
+ var dependentParameterNames, preparedContent, preparedTask;
5325
5337
  return __generator(this, function (_a) {
5326
- dependentParameterNames = template.dependentParameterNames;
5338
+ dependentParameterNames = task.dependentParameterNames;
5327
5339
  preparedContent = undefined;
5328
5340
  if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
5329
5341
  preparedContent = spaceTrim.spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
@@ -5332,22 +5344,22 @@
5332
5344
  'knowledge',
5333
5345
  ], false);
5334
5346
  }
5335
- preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
5336
- templatesPrepared[index] = preparedTemplate;
5347
+ preparedTask = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
5348
+ tasksPrepared[index] = preparedTask;
5337
5349
  return [2 /*return*/];
5338
5350
  });
5339
5351
  }); })];
5340
5352
  case 1:
5341
5353
  _b.sent();
5342
- return [2 /*return*/, { templatesPrepared: templatesPrepared }];
5354
+ return [2 /*return*/, { tasksPrepared: tasksPrepared }];
5343
5355
  }
5344
5356
  });
5345
5357
  });
5346
5358
  }
5347
5359
  /**
5348
- * TODO: [🧠] Add context to each template (if missing)
5349
- * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
5350
- * TODO: [♨][main] !!! Prepare index the examples and maybe templates
5360
+ * TODO: [🧠] Add context to each task (if missing)
5361
+ * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
5362
+ * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
5351
5363
  * TODO: Write tests for `preparePipeline`
5352
5364
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
5353
5365
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -5364,12 +5376,12 @@
5364
5376
  */
5365
5377
  function preparePipeline(pipeline, tools, options) {
5366
5378
  return __awaiter(this, void 0, void 0, function () {
5367
- var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, templates,
5379
+ var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, tasks,
5368
5380
  /*
5369
5381
  <- TODO: [🧠][🪑] `promptbookVersion` */
5370
5382
  knowledgeSources /*
5371
5383
  <- TODO: [🧊] `knowledgePieces` */, personas /*
5372
- <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, templatesPrepared /* TODO: parameters: parametersPrepared*/;
5384
+ <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
5373
5385
  var _this = this;
5374
5386
  return __generator(this, function (_c) {
5375
5387
  switch (_c.label) {
@@ -5378,7 +5390,7 @@
5378
5390
  return [2 /*return*/, pipeline];
5379
5391
  }
5380
5392
  rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
5381
- parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5393
+ parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5382
5394
  if (tools === undefined || tools.llm === undefined) {
5383
5395
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
5384
5396
  }
@@ -5421,9 +5433,9 @@
5421
5433
  case 2:
5422
5434
  partialknowledgePiecesPrepared = _c.sent();
5423
5435
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
5424
- return [4 /*yield*/, prepareTemplates({
5436
+ return [4 /*yield*/, prepareTasks({
5425
5437
  parameters: parameters,
5426
- templates: templates,
5438
+ tasks: tasks,
5427
5439
  knowledgePiecesCount: knowledgePiecesPrepared.length,
5428
5440
  }, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), {
5429
5441
  rootDirname: rootDirname,
@@ -5431,12 +5443,12 @@
5431
5443
  isVerbose: isVerbose,
5432
5444
  })];
5433
5445
  case 3:
5434
- templatesPrepared = (_c.sent()).templatesPrepared;
5435
- // ----- /Templates preparation -----
5446
+ tasksPrepared = (_c.sent()).tasksPrepared;
5447
+ // ----- /Tasks preparation -----
5436
5448
  // Note: Count total usage
5437
5449
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
5438
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
5439
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
5450
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
5451
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
5440
5452
  knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
5441
5453
  }
5442
5454
  });
@@ -5451,6 +5463,40 @@
5451
5463
  * @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
5452
5464
  */
5453
5465
 
5466
+ /**
5467
+ * All available task types
5468
+ *
5469
+ * There is is distinction between task types and section types
5470
+ * - Every section in markdown has its SectionType
5471
+ * - Some sections are tasks but other can be non-task sections
5472
+ *
5473
+ * @public exported from `@promptbook/core`
5474
+ */
5475
+ var TaskTypes = [
5476
+ 'PROMPT',
5477
+ 'SIMPLE',
5478
+ 'SCRIPT',
5479
+ 'DIALOG',
5480
+ // <- [🅱]
5481
+ ];
5482
+
5483
+ /**
5484
+ * All available sections which are not tasks
5485
+ *
5486
+ * @public exported from `@promptbook/core`
5487
+ */
5488
+ var NonTaskSectionTypes = ['EXAMPLE', 'KNOWLEDGE', 'INSTRUMENT', 'ACTION'];
5489
+ /**
5490
+ * All available section types
5491
+ *
5492
+ * There is is distinction between task types and section types
5493
+ * - Every section in markdown has its SectionType
5494
+ * - Some sections are tasks but other can be non-task sections
5495
+ *
5496
+ * @public exported from `@promptbook/core`
5497
+ */
5498
+ var SectionTypes = __spreadArray(__spreadArray([], __read(TaskTypes.map(function (TaskType) { return "".concat(TaskType, "_TASK"); })), false), __read(NonTaskSectionTypes), false);
5499
+
5454
5500
  /**
5455
5501
  * Parses the knowledge command
5456
5502
  *
@@ -5466,7 +5512,7 @@
5466
5512
  * BOILERPLATE command can be used in:
5467
5513
  */
5468
5514
  isUsedInPipelineHead: true,
5469
- isUsedInPipelineTemplate: false,
5515
+ isUsedInPipelineTask: false,
5470
5516
  /**
5471
5517
  * Description of the KNOWLEDGE command
5472
5518
  */
@@ -5544,36 +5590,18 @@
5544
5590
  */
5545
5591
 
5546
5592
  /**
5547
- * Template type describes the way how the template is templated
5548
- *
5549
- * @see https://github.com/webgptorg/promptbook#template-type
5550
- * @public exported from `@promptbook/core`
5551
- */
5552
- var TemplateTypes = [
5553
- 'PROMPT_TEMPLATE',
5554
- 'SIMPLE_TEMPLATE',
5555
- 'SCRIPT_TEMPLATE',
5556
- 'DIALOG_TEMPLATE',
5557
- 'EXAMPLE',
5558
- 'KNOWLEDGE',
5559
- 'INSTRUMENT',
5560
- 'ACTION',
5561
- // <- [🅱]
5562
- ];
5563
-
5564
- /**
5565
- * Parses the template command
5593
+ * Parses the section command
5566
5594
  *
5567
5595
  * @see `documentationUrl` for more details
5568
5596
  * @private within the commands folder
5569
5597
  */
5570
- var templateCommandParser = {
5598
+ var sectionCommandParser = {
5571
5599
  /**
5572
5600
  * Name of the command
5573
5601
  */
5574
- name: 'TEMPLATE',
5602
+ name: 'SECTION',
5575
5603
  /**
5576
- * Aliases for the TEMPLATE command
5604
+ * Aliases for the SECTION command
5577
5605
  */
5578
5606
  aliasNames: [
5579
5607
  'PROMPT',
@@ -5587,24 +5615,24 @@
5587
5615
  'ACTION', // <- Note: [⛱]
5588
5616
  ],
5589
5617
  /**
5590
- * Aliases for the TEMPLATE command
5618
+ * Aliases for the SECTION command
5591
5619
  */
5592
- deprecatedNames: ['BLOCK', 'EXECUTE'],
5620
+ deprecatedNames: ['TEMPLATE', 'BLOCK', 'EXECUTE'],
5593
5621
  /**
5594
5622
  * BOILERPLATE command can be used in:
5595
5623
  */
5596
5624
  isUsedInPipelineHead: false,
5597
- isUsedInPipelineTemplate: true,
5625
+ isUsedInPipelineTask: true,
5598
5626
  /**
5599
- * Description of the TEMPLATE command
5627
+ * Description of the SECTION command
5600
5628
  */
5601
- description: "What should the code template template do",
5629
+ description: "Defines the purpose of the markdown section - if its a task and which type or something else",
5602
5630
  /**
5603
5631
  * Link to documentation
5604
5632
  */
5605
5633
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/64',
5606
5634
  /**
5607
- * Example usages of the TEMPLATE command
5635
+ * Example usages of the SECTION command
5608
5636
  */
5609
5637
  examples: [
5610
5638
  // Short form:
@@ -5619,101 +5647,103 @@
5619
5647
  'ACTION',
5620
5648
  // -----------------
5621
5649
  // Recommended (reversed) form:
5622
- 'PROMPT TEMPLATE',
5623
- 'SIMPLE TEMPLATE',
5624
- 'SCRIPT TEMPLATE',
5625
- 'DIALOG TEMPLATE',
5650
+ 'PROMPT SECTION',
5651
+ 'SIMPLE SECTION',
5652
+ 'SCRIPT SECTION',
5653
+ 'DIALOG SECTION',
5626
5654
  // <- [🅱]
5627
- 'SAMPLE TEMPLATE',
5628
- 'KNOWLEDGE TEMPLATE',
5629
- 'INSTRUMENT TEMPLATE',
5630
- 'ACTION TEMPLATE',
5655
+ 'EXAMPLE SECTION',
5656
+ 'KNOWLEDGE SECTION',
5657
+ 'INSTRUMENT SECTION',
5658
+ 'ACTION SECTION',
5631
5659
  // -----------------
5632
5660
  // Standard form:
5633
- 'TEMPLATE PROMPT',
5634
- 'TEMPLATE SIMPLE',
5635
- 'TEMPLATE SCRIPT',
5636
- 'TEMPLATE DIALOG',
5661
+ 'SECTION PROMPT',
5662
+ 'SECTION SIMPLE',
5663
+ 'SECTION SCRIPT',
5664
+ 'SECTION DIALOG',
5637
5665
  // <- [🅱]
5638
- 'SAMPLE TEMPLATE',
5639
- 'KNOWLEDGE TEMPLATE',
5640
- 'INSTRUMENT TEMPLATE',
5641
- 'ACTION TEMPLATE',
5666
+ 'SECTION EXAMPLE',
5667
+ 'SECTION KNOWLEDGE',
5668
+ 'SECTION INSTRUMENT',
5669
+ 'SECTION ACTION',
5642
5670
  ],
5643
5671
  // TODO: [♓️] order: -10 /* <- Note: Putting before other commands */
5644
5672
  /**
5645
- * Parses the TEMPLATE command
5673
+ * Parses the SECTION command
5646
5674
  */
5647
5675
  parse: function (input) {
5648
5676
  var normalized = input.normalized;
5649
5677
  normalized = normalized.split('SAMPLE').join('EXAMPLE');
5650
- var templateTypes = TemplateTypes.filter(function (templateType) {
5651
- return normalized.includes(templateType.split('_TEMPLATE').join(''));
5678
+ normalized = normalized.split('EXECUTE_').join('');
5679
+ normalized = normalized.split('DIALOGUE').join('DIALOG');
5680
+ var taskTypes = SectionTypes.filter(function (sectionType) {
5681
+ return normalized.includes(sectionType.split('_TASK').join(''));
5652
5682
  });
5653
- if (templateTypes.length !== 1) {
5654
- 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 "); }));
5683
+ if (taskTypes.length !== 1) {
5684
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown section type \"".concat(normalized, "\"\n\n Supported section types are:\n ").concat(block(SectionTypes.join(', ')), "\n "); }));
5655
5685
  }
5656
- var templateType = templateTypes[0];
5686
+ var taskType = taskTypes[0];
5657
5687
  return {
5658
- type: 'TEMPLATE',
5659
- templateType: templateType,
5688
+ type: 'SECTION',
5689
+ taskType: taskType,
5660
5690
  };
5661
5691
  },
5662
5692
  /**
5663
- * Apply the TEMPLATE command to the `pipelineJson`
5693
+ * Apply the SECTION command to the `pipelineJson`
5664
5694
  *
5665
- * Note: `$` is used to indicate that this function mutates given `templateJson`
5695
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
5666
5696
  */
5667
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
5668
- if ($templateJson.isTemplateTypeSet === true) {
5669
- throw new ParseError(spaceTrim__default["default"]("\n Template type is already defined in the template.\n It can be defined only once.\n "));
5697
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
5698
+ if ($taskJson.isSectionTypeSet === true) {
5699
+ throw new ParseError(spaceTrim__default["default"]("\n Section type is already defined in the section.\n It can be defined only once.\n "));
5670
5700
  }
5671
- $templateJson.isTemplateTypeSet = true;
5701
+ $taskJson.isSectionTypeSet = true;
5672
5702
  // TODO: [🍧] Rearrange better - but at bottom and unwrap from function
5673
5703
  var expectResultingParameterName = function () {
5674
- if ($templateJson.resultingParameterName) {
5704
+ if ($taskJson.resultingParameterName) {
5675
5705
  return;
5676
5706
  }
5677
- throw new ParseError(" Template section must end with -> {parameterName}");
5707
+ throw new ParseError("Task section and example section must end with return statement -> {parameterName}");
5678
5708
  };
5679
- if ($templateJson.content === undefined) {
5680
- throw new UnexpectedError("Content is missing in the templateJson - probbably commands are applied in wrong order");
5709
+ if ($taskJson.content === undefined) {
5710
+ throw new UnexpectedError("Content is missing in the taskJson - probbably commands are applied in wrong order");
5681
5711
  }
5682
- if (command.templateType === 'EXAMPLE') {
5712
+ if (command.taskType === 'EXAMPLE') {
5683
5713
  expectResultingParameterName();
5684
- var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $templateJson.resultingParameterName; });
5714
+ var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $taskJson.resultingParameterName; });
5685
5715
  if (parameter === undefined) {
5686
- throw new ParseError("Can not find parameter {".concat($templateJson.resultingParameterName, "} to assign example value on it"));
5716
+ throw new ParseError("Can not find parameter {".concat($taskJson.resultingParameterName, "} to assign example value on it"));
5687
5717
  }
5688
5718
  parameter.exampleValues = parameter.exampleValues || [];
5689
- parameter.exampleValues.push($templateJson.content);
5690
- $templateJson.isTemplate = false;
5719
+ parameter.exampleValues.push($taskJson.content);
5720
+ $taskJson.isTask = false;
5691
5721
  return;
5692
5722
  }
5693
- if (command.templateType === 'KNOWLEDGE') {
5723
+ if (command.taskType === 'KNOWLEDGE') {
5694
5724
  knowledgeCommandParser.$applyToPipelineJson({
5695
5725
  type: 'KNOWLEDGE',
5696
- sourceContent: $templateJson.content, // <- TODO: [🐝][main] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5726
+ sourceContent: $taskJson.content, // <- TODO: [🐝][main] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5697
5727
  }, $pipelineJson);
5698
- $templateJson.isTemplate = false;
5728
+ $taskJson.isTask = false;
5699
5729
  return;
5700
5730
  }
5701
- if (command.templateType === 'ACTION') {
5731
+ if (command.taskType === 'ACTION') {
5702
5732
  console.error(new NotYetImplementedError('Actions are not implemented yet'));
5703
- $templateJson.isTemplate = false;
5733
+ $taskJson.isTask = false;
5704
5734
  return;
5705
5735
  }
5706
- if (command.templateType === 'INSTRUMENT') {
5736
+ if (command.taskType === 'INSTRUMENT') {
5707
5737
  console.error(new NotYetImplementedError('Instruments are not implemented yet'));
5708
- $templateJson.isTemplate = false;
5738
+ $taskJson.isTask = false;
5709
5739
  return;
5710
5740
  }
5711
5741
  expectResultingParameterName();
5712
- $templateJson.templateType = command.templateType;
5713
- $templateJson.isTemplate = true;
5742
+ $taskJson.taskType = command.taskType;
5743
+ $taskJson.isTask = true;
5714
5744
  },
5715
5745
  /**
5716
- * Converts the TEMPLATE command back to string
5746
+ * Converts the SECTION command back to string
5717
5747
  *
5718
5748
  * Note: This is used in `pipelineJsonToString` utility
5719
5749
  */
@@ -5721,11 +5751,11 @@
5721
5751
  return "---"; // <- TODO: [🛋] Implement
5722
5752
  },
5723
5753
  /**
5724
- * Reads the TEMPLATE command from the `TemplateJson`
5754
+ * Reads the SECTION command from the `TaskJson`
5725
5755
  *
5726
5756
  * Note: This is used in `pipelineJsonToString` utility
5727
5757
  */
5728
- takeFromTemplateJson: function ($templateJson) {
5758
+ takeFromTaskJson: function ($taskJson) {
5729
5759
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5730
5760
  },
5731
5761
  };
@@ -5733,8 +5763,8 @@
5733
5763
  * Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
5734
5764
  * 1) There are commands `KNOWLEDGE`, `ACTION` and `INSTRUMENT` used in the pipeline head, they just define the knowledge, action or instrument as single line after the command
5735
5765
  * - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
5736
- * 2) `KNOWLEDGE TEMPLATE` which has short form `KNOWLEDGE` is used in the template, does not refer the line itself, but the content of the template
5737
- * - KNOWLEDGE TEMPLATE
5766
+ * 2) `KNOWLEDGE SECTION` which has short form `KNOWLEDGE` is used in the sectiom, does not refer the line itself, but the content of the section block
5767
+ * - KNOWLEDGE SECTION
5738
5768
  *
5739
5769
  * ```
5740
5770
  * Look at https://en.wikipedia.org/wiki/Artificial_intelligence
@@ -5762,7 +5792,7 @@
5762
5792
  * BOILERPLATE command can be used in:
5763
5793
  */
5764
5794
  isUsedInPipelineHead: true,
5765
- isUsedInPipelineTemplate: true,
5795
+ isUsedInPipelineTask: true,
5766
5796
  /**
5767
5797
  * Description of the BOILERPLATE command
5768
5798
  */
@@ -5803,9 +5833,9 @@
5803
5833
  /**
5804
5834
  * Apply the BOILERPLATE command to the `pipelineJson`
5805
5835
  *
5806
- * Note: `$` is used to indicate that this function mutates given `templateJson`
5836
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
5807
5837
  */
5808
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
5838
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
5809
5839
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
5810
5840
  },
5811
5841
  /**
@@ -5825,11 +5855,11 @@
5825
5855
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
5826
5856
  },
5827
5857
  /**
5828
- * Reads the BOILERPLATE command from the `TemplateJson`
5858
+ * Reads the BOILERPLATE command from the `TaskJson`
5829
5859
  *
5830
5860
  * Note: This is used in `pipelineJsonToString` utility
5831
5861
  */
5832
- takeFromTemplateJson: function ($templateJson) {
5862
+ takeFromTaskJson: function ($taskJson) {
5833
5863
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
5834
5864
  },
5835
5865
  };
@@ -5850,7 +5880,7 @@
5850
5880
  * BOILERPLATE command can be used in:
5851
5881
  */
5852
5882
  isUsedInPipelineHead: true,
5853
- isUsedInPipelineTemplate: false,
5883
+ isUsedInPipelineTask: false,
5854
5884
  /**
5855
5885
  * Description of the BOOK_VERSION command
5856
5886
  */
@@ -6004,11 +6034,11 @@
6004
6034
  * BOILERPLATE command can be used in:
6005
6035
  */
6006
6036
  isUsedInPipelineHead: false,
6007
- isUsedInPipelineTemplate: true,
6037
+ isUsedInPipelineTask: true,
6008
6038
  /**
6009
6039
  * Description of the FORMAT command
6010
6040
  */
6011
- description: spaceTrim__default["default"]("\n Expect command describes the desired output of the template (after post-processing)\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
6041
+ description: spaceTrim__default["default"]("\n Expect command describes the desired output of the task *(after post-processing)*\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
6012
6042
  /**
6013
6043
  * Link to documentation
6014
6044
  */
@@ -6100,24 +6130,24 @@
6100
6130
  /**
6101
6131
  * Apply the FORMAT command to the `pipelineJson`
6102
6132
  *
6103
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6133
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6104
6134
  */
6105
- $applyToTemplateJson: function (command, $templateJson) {
6135
+ $applyToTaskJson: function (command, $taskJson) {
6106
6136
  // eslint-disable-next-line no-case-declarations
6107
6137
  var unit = command.unit.toLowerCase();
6108
- $templateJson.expectations = $templateJson.expectations || {};
6109
- $templateJson.expectations[unit] = $templateJson.expectations[unit] || {};
6138
+ $taskJson.expectations = $taskJson.expectations || {};
6139
+ $taskJson.expectations[unit] = $taskJson.expectations[unit] || {};
6110
6140
  if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
6111
- if ($templateJson.expectations[unit].min !== undefined) {
6112
- throw new ParseError("Already defined minumum ".concat($templateJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6141
+ if ($taskJson.expectations[unit].min !== undefined) {
6142
+ throw new ParseError("Already defined minumum ".concat($taskJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6113
6143
  }
6114
- $templateJson.expectations[unit].min = command.amount;
6144
+ $taskJson.expectations[unit].min = command.amount;
6115
6145
  } /* not else */
6116
6146
  if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
6117
- if ($templateJson.expectations[unit].max !== undefined) {
6118
- throw new ParseError("Already defined maximum ".concat($templateJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6147
+ if ($taskJson.expectations[unit].max !== undefined) {
6148
+ throw new ParseError("Already defined maximum ".concat($taskJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6119
6149
  }
6120
- $templateJson.expectations[unit].max = command.amount;
6150
+ $taskJson.expectations[unit].max = command.amount;
6121
6151
  }
6122
6152
  },
6123
6153
  /**
@@ -6129,11 +6159,11 @@
6129
6159
  return "---"; // <- TODO: [🛋] Implement
6130
6160
  },
6131
6161
  /**
6132
- * Reads the FORMAT command from the `TemplateJson`
6162
+ * Reads the FORMAT command from the `TaskJson`
6133
6163
  *
6134
6164
  * Note: This is used in `pipelineJsonToString` utility
6135
6165
  */
6136
- takeFromTemplateJson: function ($templateJson) {
6166
+ takeFromTaskJson: function ($taskJson) {
6137
6167
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6138
6168
  },
6139
6169
  };
@@ -6340,7 +6370,7 @@
6340
6370
  * FOREACH command can be used in:
6341
6371
  */
6342
6372
  isUsedInPipelineHead: false,
6343
- isUsedInPipelineTemplate: true,
6373
+ isUsedInPipelineTask: true,
6344
6374
  /**
6345
6375
  * Description of the FOREACH command
6346
6376
  */
@@ -6439,13 +6469,13 @@
6439
6469
  /**
6440
6470
  * Apply the FOREACH command to the `pipelineJson`
6441
6471
  *
6442
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6472
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6443
6473
  */
6444
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6474
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
6445
6475
  var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName, inputSubparameterNames = command.inputSubparameterNames, outputSubparameterName = command.outputSubparameterName;
6446
6476
  // TODO: [🍭] Detect double use
6447
6477
  // TODO: [🍭] Detect usage with JOKER and don't allow it
6448
- $templateJson.foreach = {
6478
+ $taskJson.foreach = {
6449
6479
  formatName: formatName,
6450
6480
  subformatName: subformatName,
6451
6481
  parameterName: parameterName,
@@ -6463,11 +6493,11 @@
6463
6493
  return "---"; // <- TODO: [🛋] Implement
6464
6494
  },
6465
6495
  /**
6466
- * Reads the FOREACH command from the `TemplateJson`
6496
+ * Reads the FOREACH command from the `TaskJson`
6467
6497
  *
6468
6498
  * Note: This is used in `pipelineJsonToString` utility
6469
6499
  */
6470
- takeFromTemplateJson: function ($templateJson) {
6500
+ takeFromTaskJson: function ($taskJson) {
6471
6501
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6472
6502
  },
6473
6503
  };
@@ -6490,11 +6520,11 @@
6490
6520
  * BOILERPLATE command can be used in:
6491
6521
  */
6492
6522
  isUsedInPipelineHead: false,
6493
- isUsedInPipelineTemplate: true,
6523
+ isUsedInPipelineTask: true,
6494
6524
  /**
6495
6525
  * Description of the FORMAT command
6496
6526
  */
6497
- description: spaceTrim__default["default"]("\n Format command describes the desired output of the template (after post-processing)\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
6527
+ description: spaceTrim__default["default"]("\n Format command describes the desired output of the task (after post-processing)\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
6498
6528
  /**
6499
6529
  * Link to documentation
6500
6530
  */
@@ -6521,13 +6551,13 @@
6521
6551
  /**
6522
6552
  * Apply the FORMAT command to the `pipelineJson`
6523
6553
  *
6524
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6554
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6525
6555
  */
6526
- $applyToTemplateJson: function (command, $templateJson) {
6527
- if ($templateJson.format !== undefined && command.format !== $templateJson.format) {
6528
- throw new ParseError("Format format is already defined to \"".concat($templateJson.format, "\".\n Now you try to redefine it by \"").concat(command.format, "\""));
6556
+ $applyToTaskJson: function (command, $taskJson) {
6557
+ if ($taskJson.format !== undefined && command.format !== $taskJson.format) {
6558
+ throw new ParseError("Format format is already defined to \"".concat($taskJson.format, "\".\n Now you try to redefine it by \"").concat(command.format, "\""));
6529
6559
  }
6530
- $templateJson.format = command.format;
6560
+ $taskJson.format = command.format;
6531
6561
  },
6532
6562
  /**
6533
6563
  * Converts the FORMAT command back to string
@@ -6538,11 +6568,11 @@
6538
6568
  return "---"; // <- TODO: [🛋] Implement
6539
6569
  },
6540
6570
  /**
6541
- * Reads the FORMAT command from the `TemplateJson`
6571
+ * Reads the FORMAT command from the `TaskJson`
6542
6572
  *
6543
6573
  * Note: This is used in `pipelineJsonToString` utility
6544
6574
  */
6545
- takeFromTemplateJson: function ($templateJson) {
6575
+ takeFromTaskJson: function ($taskJson) {
6546
6576
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6547
6577
  },
6548
6578
  };
@@ -6552,37 +6582,68 @@
6552
6582
  *
6553
6583
  * @public exported from `@promptbook/core`
6554
6584
  */
6555
- var ChatFormfactorDefinition = {
6585
+ var ChatbotFormfactorDefinition = {
6556
6586
  name: 'CHATBOT',
6557
6587
  aliasNames: ['CHAT'],
6558
6588
  description: "@@@",
6559
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6589
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/174",
6560
6590
  pipelineInterface: {
6561
- inputParameterNames: ['previousTitle', 'previousConversationSummary', 'userMessage'],
6562
- outputParameterNames: ['title', 'conversationSummary', 'chatbotResponse'],
6563
- /*
6564
- <- TODO: !!!!!! Change to
6565
-
6566
- - INPUT PARAMETER `{previousTitle}` Previous title of the conversation
6567
- - INPUT PARAMETER `{previousConversationSummary}` Previous conversation summary
6568
- - INPUT PARAMETER `{userMessage}` User message
6569
- - OUTPUT PARAMETER `{title}` Title of the conversation
6570
- - OUTPUT PARAMETER `{conversationSummary}` Summary of the conversation
6571
- - OUTPUT PARAMETER `{chatbotResponse}` Chatbot response
6591
+ inputParameters: [
6592
+ {
6593
+ name: 'previousTitle',
6594
+ description: "Previous title of the conversation",
6595
+ isInput: true,
6596
+ isOutput: false,
6597
+ },
6598
+ {
6599
+ name: 'previousConversationSummary',
6600
+ description: "Previous conversation summary",
6601
+ isInput: true,
6602
+ isOutput: false,
6603
+ },
6604
+ { name: 'userMessage', description: "User message", isInput: true, isOutput: false },
6605
+ ],
6606
+ outputParameters: [
6607
+ { name: 'title', description: "Title of the conversation", isInput: false, isOutput: true },
6608
+ { name: 'conversationSummary', description: "Summary of the conversation", isInput: false, isOutput: true },
6609
+ { name: 'chatbotResponse', description: "Chatbot response", isInput: false, isOutput: true },
6610
+ ],
6611
+ },
6612
+ };
6572
6613
 
6573
- */
6614
+ /**
6615
+ * Generator is form of app that @@@
6616
+ *
6617
+ * @public exported from `@promptbook/core`
6618
+ */
6619
+ var GeneratorFormfactorDefinition = {
6620
+ name: 'GENERATOR',
6621
+ description: "@@@",
6622
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
6623
+ pipelineInterface: {
6624
+ inputParameters: [
6625
+ /* @@@ */
6626
+ ],
6627
+ outputParameters: [
6628
+ /* @@@ */
6629
+ ],
6574
6630
  },
6575
6631
  };
6576
6632
 
6577
6633
  /**
6578
6634
  * @@@
6579
6635
  *
6636
+ * @see https://github.com/webgptorg/promptbook/discussions/171
6637
+ *
6580
6638
  * @public exported from `@promptbook/core`
6581
6639
  */
6582
6640
  var GENERIC_PIPELINE_INTERFACE = {
6583
- inputParameterNames: [],
6584
- outputParameterNames: [],
6641
+ inputParameters: [],
6642
+ outputParameters: [],
6585
6643
  };
6644
+ /**
6645
+ * Note: [💞] Ignore a discrepancy between file name and entity name
6646
+ */
6586
6647
 
6587
6648
  /**
6588
6649
  * @@@
@@ -6592,10 +6653,29 @@
6592
6653
  var GenericFormfactorDefinition = {
6593
6654
  name: 'GENERIC',
6594
6655
  description: "@@@",
6595
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6656
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/173",
6596
6657
  pipelineInterface: GENERIC_PIPELINE_INTERFACE,
6597
6658
  };
6598
6659
 
6660
+ /**
6661
+ * Matcher is form of app that @@@
6662
+ *
6663
+ * @public exported from `@promptbook/core`
6664
+ */
6665
+ var MatcherFormfactorDefinition = {
6666
+ name: 'EXPERIMENTAL_MATCHER',
6667
+ description: "@@@",
6668
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
6669
+ pipelineInterface: {
6670
+ inputParameters: [
6671
+ /* @@@ */
6672
+ ],
6673
+ outputParameters: [
6674
+ /* @@@ */
6675
+ ],
6676
+ },
6677
+ };
6678
+
6599
6679
  /**
6600
6680
  * Sheets is form of app that @@@
6601
6681
  *
@@ -6604,10 +6684,24 @@
6604
6684
  var SheetsFormfactorDefinition = {
6605
6685
  name: 'SHEETS',
6606
6686
  description: "@@@",
6607
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6687
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/176",
6608
6688
  pipelineInterface: {
6609
- inputParameterNames: ['inputSheet'],
6610
- outputParameterNames: ['outputSheet'],
6689
+ inputParameters: [
6690
+ {
6691
+ name: 'inputSheet',
6692
+ description: "Input sheet to be processed as csv",
6693
+ isInput: true,
6694
+ isOutput: false,
6695
+ },
6696
+ ],
6697
+ outputParameters: [
6698
+ {
6699
+ name: 'outputSheet',
6700
+ description: "Output sheet as csv",
6701
+ isInput: false,
6702
+ isOutput: true,
6703
+ },
6704
+ ],
6611
6705
  },
6612
6706
  };
6613
6707
 
@@ -6619,10 +6713,26 @@
6619
6713
  var TranslatorFormfactorDefinition = {
6620
6714
  name: 'TRANSLATOR',
6621
6715
  description: "@@@",
6622
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6716
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/175",
6623
6717
  pipelineInterface: {
6624
- inputParameterNames: ['inputMessage'],
6625
- outputParameterNames: ['outputMessage'],
6718
+ inputParameters: [
6719
+ {
6720
+ name: 'inputMessage',
6721
+ description: "Input message to be translated",
6722
+ isInput: true,
6723
+ isOutput: false,
6724
+ },
6725
+ ],
6726
+ outputParameters: [
6727
+ {
6728
+ name: 'outputMessage',
6729
+ description: "Translated output message",
6730
+ isInput: false,
6731
+ isOutput: true,
6732
+ },
6733
+ ],
6734
+ // <- TODO: [🤓] Maybe add {summary}
6735
+ // <- TODO: [🧠] maybe change to {inputText}, {inputText} / or make system for any name of first input and first outpur parameter
6626
6736
  },
6627
6737
  };
6628
6738
 
@@ -6633,10 +6743,15 @@
6633
6743
  */
6634
6744
  var FORMFACTOR_DEFINITIONS = [
6635
6745
  GenericFormfactorDefinition,
6636
- ChatFormfactorDefinition,
6746
+ ChatbotFormfactorDefinition,
6637
6747
  TranslatorFormfactorDefinition,
6638
6748
  SheetsFormfactorDefinition,
6749
+ MatcherFormfactorDefinition,
6750
+ GeneratorFormfactorDefinition,
6639
6751
  ];
6752
+ /**
6753
+ * Note: [💞] Ignore a discrepancy between file name and entity name
6754
+ */
6640
6755
 
6641
6756
  /**
6642
6757
  * Parses the formfactor command
@@ -6659,7 +6774,7 @@
6659
6774
  * FORMFACTOR command can be used in:
6660
6775
  */
6661
6776
  isUsedInPipelineHead: true,
6662
- isUsedInPipelineTemplate: false,
6777
+ isUsedInPipelineTask: false,
6663
6778
  /**
6664
6779
  * Description of the FORMFACTOR command
6665
6780
  */
@@ -6741,11 +6856,11 @@
6741
6856
  * BOILERPLATE command can be used in:
6742
6857
  */
6743
6858
  isUsedInPipelineHead: false,
6744
- isUsedInPipelineTemplate: true,
6859
+ isUsedInPipelineTask: true,
6745
6860
  /**
6746
6861
  * Description of the JOKER command
6747
6862
  */
6748
- description: "Joker parameter is used instead of executing the template result if jokers value meets the expectations requirements",
6863
+ description: "Joker parameter is used instead of executing the task result if jokers value meets the expectations requirements",
6749
6864
  /**
6750
6865
  * Link to documentation
6751
6866
  */
@@ -6772,11 +6887,11 @@
6772
6887
  /**
6773
6888
  * Apply the JOKER command to the `pipelineJson`
6774
6889
  *
6775
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6890
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6776
6891
  */
6777
- $applyToTemplateJson: function (command, $templateJson) {
6778
- $templateJson.jokerParameterNames = $templateJson.jokerParameterNames || [];
6779
- $templateJson.jokerParameterNames.push(command.parameterName);
6892
+ $applyToTaskJson: function (command, $taskJson) {
6893
+ $taskJson.jokerParameterNames = $taskJson.jokerParameterNames || [];
6894
+ $taskJson.jokerParameterNames.push(command.parameterName);
6780
6895
  },
6781
6896
  /**
6782
6897
  * Converts the JOKER command back to string
@@ -6787,11 +6902,11 @@
6787
6902
  return "---"; // <- TODO: [🛋] Implement
6788
6903
  },
6789
6904
  /**
6790
- * Reads the JOKER command from the `TemplateJson`
6905
+ * Reads the JOKER command from the `TaskJson`
6791
6906
  *
6792
6907
  * Note: This is used in `pipelineJsonToString` utility
6793
6908
  */
6794
- takeFromTemplateJson: function ($templateJson) {
6909
+ takeFromTaskJson: function ($taskJson) {
6795
6910
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6796
6911
  },
6797
6912
  };
@@ -6818,11 +6933,11 @@
6818
6933
  * BOILERPLATE command can be used in:
6819
6934
  */
6820
6935
  isUsedInPipelineHead: true,
6821
- isUsedInPipelineTemplate: true,
6936
+ isUsedInPipelineTask: true,
6822
6937
  /**
6823
6938
  * Description of the MODEL command
6824
6939
  */
6825
- description: "Tells which `modelRequirements` (for example which model) to use for the prompt template execution",
6940
+ description: "Tells which `modelRequirements` (for example which model) to use for the prompt task execution",
6826
6941
  /**
6827
6942
  * Link to documentation
6828
6943
  */
@@ -6896,30 +7011,30 @@
6896
7011
  /**
6897
7012
  * Apply the MODEL command to the `pipelineJson`
6898
7013
  *
6899
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7014
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6900
7015
  */
6901
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6902
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
6903
- throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
7016
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
7017
+ if ($taskJson.taskType !== 'PROMPT_TASK') {
7018
+ throw new ParseError("MODEL command can only be used in PROMPT_TASK block");
6904
7019
  }
6905
- $templateJson.modelRequirements = $templateJson.modelRequirements || {};
7020
+ $taskJson.modelRequirements = $taskJson.modelRequirements || {};
6906
7021
  // TODO: [🚜] DRY
6907
- if ($templateJson.modelRequirements[command.key] !== undefined) {
6908
- if ($templateJson.modelRequirements[command.key] === command.value) {
7022
+ if ($taskJson.modelRequirements[command.key] !== undefined) {
7023
+ if ($taskJson.modelRequirements[command.key] === command.value) {
6909
7024
  console.warn("Multiple commands `MODEL ".concat({
6910
7025
  modelName: 'NAME',
6911
7026
  modelVariant: 'VARIANT',
6912
7027
  maxTokens: '???',
6913
- }[command.key], " ").concat(command.value, "` in the template \"").concat($templateJson.title || $templateJson.name, "\""));
7028
+ }[command.key], " ").concat(command.value, "` in the task \"").concat($taskJson.title || $taskJson.name, "\""));
6914
7029
  }
6915
7030
  else {
6916
- throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL `".concat(command.key, "` in the template \"").concat($templateJson.title || $templateJson.name, "\"\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($templateJson.modelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
7031
+ throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL `".concat(command.key, "` in the task \"").concat($taskJson.title || $taskJson.name, "\"\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($taskJson.modelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
6917
7032
  }
6918
7033
  }
6919
7034
  if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
6920
- console.log(spaceTrim__default["default"]("\n Setting MODEL `".concat(command.key, "` in the template \"").concat($templateJson.title || $templateJson.name, "\" to the same value as in the pipeline head\n\n In pipeline head:\n - MODEL ").concat(command.key, " ").concat(($pipelineJson.defaultModelRequirements || {})[command.key], "\n\n But same value is used in the template:\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
7035
+ console.log(spaceTrim__default["default"]("\n Setting MODEL `".concat(command.key, "` in the task \"").concat($taskJson.title || $taskJson.name, "\" to the same value as in the pipeline head\n\n In pipeline head:\n - MODEL ").concat(command.key, " ").concat(($pipelineJson.defaultModelRequirements || {})[command.key], "\n\n But same value is used in the task:\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
6921
7036
  }
6922
- $templateJson.modelRequirements[command.key] = command.value;
7037
+ $taskJson.modelRequirements[command.key] = command.value;
6923
7038
  },
6924
7039
  /**
6925
7040
  * Converts the MODEL command back to string
@@ -6938,11 +7053,11 @@
6938
7053
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6939
7054
  },
6940
7055
  /**
6941
- * Reads the MODEL command from the `TemplateJson`
7056
+ * Reads the MODEL command from the `TaskJson`
6942
7057
  *
6943
7058
  * Note: This is used in `pipelineJsonToString` utility
6944
7059
  */
6945
- takeFromTemplateJson: function ($templateJson) {
7060
+ takeFromTaskJson: function ($taskJson) {
6946
7061
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6947
7062
  },
6948
7063
  };
@@ -6969,11 +7084,11 @@
6969
7084
  * BOILERPLATE command can be used in:
6970
7085
  */
6971
7086
  isUsedInPipelineHead: true,
6972
- isUsedInPipelineTemplate: true,
7087
+ isUsedInPipelineTask: true,
6973
7088
  /**
6974
7089
  * Description of the PARAMETER command
6975
7090
  */
6976
- description: "Describes one parameter of the template",
7091
+ description: "Describes one parameter of the task",
6977
7092
  /**
6978
7093
  * Link to documentation
6979
7094
  */
@@ -7021,9 +7136,9 @@
7021
7136
  /**
7022
7137
  * Apply the PARAMETER command to the `pipelineJson`
7023
7138
  *
7024
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7139
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7025
7140
  */
7026
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7141
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
7027
7142
  // Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
7028
7143
  },
7029
7144
  /**
@@ -7043,11 +7158,11 @@
7043
7158
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7044
7159
  },
7045
7160
  /**
7046
- * Reads the PARAMETER command from the `TemplateJson`
7161
+ * Reads the PARAMETER command from the `TaskJson`
7047
7162
  *
7048
7163
  * Note: This is used in `pipelineJsonToString` utility
7049
7164
  */
7050
- takeFromTemplateJson: function ($templateJson) {
7165
+ takeFromTaskJson: function ($taskJson) {
7051
7166
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7052
7167
  },
7053
7168
  };
@@ -7071,7 +7186,7 @@
7071
7186
  * PERSONA command can be used in:
7072
7187
  */
7073
7188
  isUsedInPipelineHead: true,
7074
- isUsedInPipelineTemplate: true,
7189
+ isUsedInPipelineTask: true,
7075
7190
  /**
7076
7191
  * Description of the PERSONA command
7077
7192
  */
@@ -7110,9 +7225,9 @@
7110
7225
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7111
7226
  */
7112
7227
  $applyToPipelineJson: function (command, $pipelineJson) {
7113
- $applyToTemplateJson(command, null, $pipelineJson);
7228
+ $applyToTaskJson(command, null, $pipelineJson);
7114
7229
  },
7115
- $applyToTemplateJson: $applyToTemplateJson,
7230
+ $applyToTaskJson: $applyToTaskJson,
7116
7231
  /**
7117
7232
  * Converts the PERSONA command back to string
7118
7233
  *
@@ -7130,26 +7245,26 @@
7130
7245
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7131
7246
  },
7132
7247
  /**
7133
- * Reads the PERSONA command from the `TemplateJson`
7248
+ * Reads the PERSONA command from the `TaskJson`
7134
7249
  *
7135
7250
  * Note: This is used in `pipelineJsonToString` utility
7136
7251
  */
7137
- takeFromTemplateJson: function ($templateJson) {
7252
+ takeFromTaskJson: function ($taskJson) {
7138
7253
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7139
7254
  },
7140
7255
  };
7141
7256
  /**
7142
7257
  * Apply the PERSONA command to the `pipelineJson`
7143
7258
  *
7144
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7259
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7145
7260
  */
7146
- function $applyToTemplateJson(command, $templateJson, $pipelineJson) {
7261
+ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
7147
7262
  var personaName = command.personaName, personaDescription = command.personaDescription;
7148
- if ($templateJson !== null) {
7149
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
7150
- throw new ParseError("PERSONA command can be used only in PROMPT_TEMPLATE block");
7263
+ if ($taskJson !== null) {
7264
+ if ($taskJson.taskType !== 'PROMPT_TASK') {
7265
+ throw new ParseError("PERSONA command can be used only in PROMPT_TASK block");
7151
7266
  }
7152
- $templateJson.personaName = personaName;
7267
+ $taskJson.personaName = personaName;
7153
7268
  }
7154
7269
  var persona = $pipelineJson.personas.find(function (persona) { return persona.name === personaName; });
7155
7270
  if (persona === undefined) {
@@ -7203,7 +7318,7 @@
7203
7318
  * BOILERPLATE command can be used in:
7204
7319
  */
7205
7320
  isUsedInPipelineHead: false,
7206
- isUsedInPipelineTemplate: true,
7321
+ isUsedInPipelineTask: true,
7207
7322
  /**
7208
7323
  * Description of the POSTPROCESS command
7209
7324
  */
@@ -7241,11 +7356,11 @@
7241
7356
  /**
7242
7357
  * Apply the POSTPROCESS command to the `pipelineJson`
7243
7358
  *
7244
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7359
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7245
7360
  */
7246
- $applyToTemplateJson: function (command, $templateJson) {
7247
- $templateJson.postprocessingFunctionNames = $templateJson.postprocessingFunctionNames || [];
7248
- $templateJson.postprocessingFunctionNames.push(command.functionName);
7361
+ $applyToTaskJson: function (command, $taskJson) {
7362
+ $taskJson.postprocessingFunctionNames = $taskJson.postprocessingFunctionNames || [];
7363
+ $taskJson.postprocessingFunctionNames.push(command.functionName);
7249
7364
  },
7250
7365
  /**
7251
7366
  * Converts the POSTPROCESS command back to string
@@ -7256,11 +7371,11 @@
7256
7371
  return "---"; // <- TODO: [🛋] Implement
7257
7372
  },
7258
7373
  /**
7259
- * Reads the POSTPROCESS command from the `TemplateJson`
7374
+ * Reads the POSTPROCESS command from the `TaskJson`
7260
7375
  *
7261
7376
  * Note: This is used in `pipelineJsonToString` utility
7262
7377
  */
7263
- takeFromTemplateJson: function ($templateJson) {
7378
+ takeFromTaskJson: function ($taskJson) {
7264
7379
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7265
7380
  },
7266
7381
  };
@@ -7285,7 +7400,7 @@
7285
7400
  * BOILERPLATE command can be used in:
7286
7401
  */
7287
7402
  isUsedInPipelineHead: true,
7288
- isUsedInPipelineTemplate: false,
7403
+ isUsedInPipelineTask: false,
7289
7404
  /**
7290
7405
  * Description of the URL command
7291
7406
  */
@@ -7329,7 +7444,7 @@
7329
7444
  spaceTrim(
7330
7445
  `
7331
7446
  URL must not contain hash
7332
- Hash is used for identification of the template in the pipeline
7447
+ Hash is used for identification of the section of the pipeline
7333
7448
  `,
7334
7449
  ),
7335
7450
  );
@@ -7381,11 +7496,11 @@
7381
7496
  * ACTION command can be used in:
7382
7497
  */
7383
7498
  isUsedInPipelineHead: true,
7384
- isUsedInPipelineTemplate: false,
7499
+ isUsedInPipelineTask: false,
7385
7500
  /**
7386
7501
  * Description of the ACTION command
7387
7502
  */
7388
- description: "Actions influences from the pipeline or template into external world. Like turning on a light, sending an email, etc.",
7503
+ description: "Actions influences from the pipeline or task into external world. Like turning on a light, sending an email, etc.",
7389
7504
  /**
7390
7505
  * Link to documentation
7391
7506
  */
@@ -7447,11 +7562,11 @@
7447
7562
  * INSTRUMENT command can be used in:
7448
7563
  */
7449
7564
  isUsedInPipelineHead: true,
7450
- isUsedInPipelineTemplate: false,
7565
+ isUsedInPipelineTask: false,
7451
7566
  /**
7452
7567
  * Description of the INSTRUMENT command
7453
7568
  */
7454
- description: "Instrument command is used to specify the instrument to be used in the pipeline or template like search, calculate, etc.",
7569
+ description: "Instrument command is used to specify the instrument to be used in the pipeline or task like search, calculate, etc.",
7455
7570
  /**
7456
7571
  * Link to documentation
7457
7572
  */
@@ -7504,7 +7619,7 @@
7504
7619
  * @private internal index of `parseCommand`
7505
7620
  */
7506
7621
  var COMMANDS = [
7507
- templateCommandParser,
7622
+ sectionCommandParser,
7508
7623
  expectCommandParser,
7509
7624
  formatCommandParser,
7510
7625
  jokerCommandParser,
@@ -7522,6 +7637,9 @@
7522
7637
  boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
7523
7638
  // <- Note: [♓️] This is the order of the commands in the pipeline, BUT its not used in parsing and before usage maybe it should be done better
7524
7639
  ];
7640
+ /**
7641
+ * Note: [💞] Ignore a discrepancy between file name and entity name
7642
+ */
7525
7643
 
7526
7644
  /**
7527
7645
  * Gets the parser for the command
@@ -7582,7 +7700,6 @@
7582
7700
  normalized = normalized.split('(').join('');
7583
7701
  normalized = normalized.split(')').join('');
7584
7702
  normalized = normalizeTo_SCREAMING_CASE(normalized);
7585
- normalized = normalized.split('DIALOGUE').join('DIALOG');
7586
7703
  var items = raw
7587
7704
  .trim()
7588
7705
  // Note: [🐡]
@@ -7663,12 +7780,12 @@
7663
7780
  var commandName = normalizeTo_SCREAMING_CASE(commandNameRaw);
7664
7781
  var _loop_1 = function (commandParser) {
7665
7782
  // <- Note: [🦦] Its strange that this type assertion is needed
7666
- var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTemplate = commandParser.isUsedInPipelineTemplate, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
7783
+ var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTask = commandParser.isUsedInPipelineTask, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
7667
7784
  if (just(false)) ;
7668
7785
  else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
7669
7786
  return "continue";
7670
7787
  }
7671
- else if (usagePlace === 'PIPELINE_TEMPLATE' && !isUsedInPipelineTemplate) {
7788
+ else if (usagePlace === 'PIPELINE_TASK' && !isUsedInPipelineTask) {
7672
7789
  return "continue";
7673
7790
  }
7674
7791
  var names = __spreadArray(__spreadArray([name_1], __read((aliasNames || [])), false), __read((deprecatedNames || [])), false);
@@ -7770,7 +7887,7 @@
7770
7887
  function extractOneBlockFromMarkdown(markdown) {
7771
7888
  var codeBlocks = extractAllBlocksFromMarkdown(markdown);
7772
7889
  if (codeBlocks.length !== 1) {
7773
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n There should be exactly 1 code block in template, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
7890
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n There should be exactly 1 code block in task section, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
7774
7891
  }
7775
7892
  return codeBlocks[0];
7776
7893
  }
@@ -7985,7 +8102,7 @@
7985
8102
  description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
7986
8103
  formfactorName: 'GENERIC',
7987
8104
  parameters: [],
7988
- templates: [],
8105
+ tasks: [],
7989
8106
  knowledgeSources: [],
7990
8107
  knowledgePieces: [],
7991
8108
  personas: [],
@@ -8077,7 +8194,7 @@
8077
8194
  var command = parseCommand(listItem, 'PIPELINE_HEAD');
8078
8195
  var commandParser = getParserForCommand(command);
8079
8196
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
8080
- 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: [🚞]
8197
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Command `".concat(command.type, "` is not allowed in the head of the pipeline ONLY at the pipeline task\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
8081
8198
  }
8082
8199
  try {
8083
8200
  commandParser.$applyToPipelineJson(command, $pipelineJson);
@@ -8109,7 +8226,7 @@
8109
8226
  }
8110
8227
  var _loop_2 = function (section) {
8111
8228
  var e_5, _l, e_6, _m;
8112
- // TODO: Parse template description (the content out of the codeblock and lists)
8229
+ // TODO: Parse section's description (the content out of the codeblock and lists)
8113
8230
  var listItems_2 = extractAllListItemsFromMarkdown(section.content);
8114
8231
  var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
8115
8232
  // TODO: [🎾][1] DRY description
@@ -8123,10 +8240,10 @@
8123
8240
  if (description_1 === '') {
8124
8241
  description_1 = undefined;
8125
8242
  }
8126
- var $templateJson = {
8127
- isTemplateTypeSet: false,
8128
- isTemplate: true,
8129
- templateType: undefined /* <- Note: [🍙] Putting here placeholder to keep `templateType` on top at final JSON */,
8243
+ var $taskJson = {
8244
+ isSectionTypeSet: false,
8245
+ isTask: true,
8246
+ taskType: undefined /* <- Note: [🍙] Putting here placeholder to keep `taskType` on top at final JSON */,
8130
8247
  name: titleToName(section.title),
8131
8248
  title: section.title,
8132
8249
  description: description_1,
@@ -8138,35 +8255,35 @@
8138
8255
  if (resultingParameterNameMatch &&
8139
8256
  resultingParameterNameMatch.groups !== undefined &&
8140
8257
  resultingParameterNameMatch.groups.resultingParamName !== undefined) {
8141
- $templateJson.resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
8258
+ $taskJson.resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
8142
8259
  }
8143
- // TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineTemplateCommands`
8260
+ // TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineTaskCommands`
8144
8261
  var commands = listItems_2.map(function (listItem) { return ({
8145
8262
  listItem: listItem,
8146
- command: parseCommand(listItem, 'PIPELINE_TEMPLATE'),
8263
+ command: parseCommand(listItem, 'PIPELINE_TASK'),
8147
8264
  }); });
8148
- // Note: If block type is not set, set it to 'PROMPT_TEMPLATE'
8265
+ // Note: If block type is not set, set it to 'PROMPT_TASK'
8149
8266
  if (commands.some(function (_a) {
8150
8267
  var command = _a.command;
8151
- return command.type === 'TEMPLATE';
8268
+ return command.type === 'SECTION';
8152
8269
  }) === false) {
8153
- templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
8270
+ sectionCommandParser.$applyToTaskJson({ type: 'SECTION', taskType: 'PROMPT_TASK' }, $taskJson, $pipelineJson);
8154
8271
  }
8155
8272
  var _loop_4 = function (listItem, command) {
8156
8273
  var commandParser = getParserForCommand(command);
8157
- if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
8158
- 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: [🚞]
8274
+ if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
8275
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Command `".concat(command.type, "` is not allowed in the task of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
8159
8276
  }
8160
8277
  try {
8161
- commandParser.$applyToTemplateJson(
8278
+ commandParser.$applyToTaskJson(
8162
8279
  // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitelly
8163
- command, $templateJson, $pipelineJson);
8280
+ command, $taskJson, $pipelineJson);
8164
8281
  }
8165
8282
  catch (error) {
8166
8283
  if (!(error instanceof ParseError)) {
8167
8284
  throw error;
8168
8285
  }
8169
- 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: [🚞]
8286
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Command `".concat(command.type, "` failed to apply to the task\n\n The error:\n ").concat(block(error.message), "\n\n Current state of the task:\n ").concat(block(JSON.stringify($taskJson, 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: [🚞]
8170
8287
  }
8171
8288
  if (command.type === 'PARAMETER') {
8172
8289
  defineParam(command);
@@ -8187,22 +8304,21 @@
8187
8304
  }
8188
8305
  finally { if (e_5) throw e_5.error; }
8189
8306
  }
8190
- // TODO: [🍧] Should be done in TEMPLATE command
8191
- if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
8307
+ // TODO: [🍧] Should be done in SECTION command
8308
+ if ($taskJson.taskType === 'SCRIPT_TASK') {
8192
8309
  if (!language) {
8193
- 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 "); }));
8310
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the `SCRIPT` task\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
8194
8311
  }
8195
8312
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
8196
8313
  throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
8197
8314
  }
8198
- $templateJson.contentLanguage =
8199
- language;
8315
+ $taskJson.contentLanguage = language;
8200
8316
  }
8201
- $templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
8317
+ $taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
8202
8318
  try {
8203
- for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
8319
+ for (var _q = (e_6 = void 0, __values($taskJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
8204
8320
  var parameterName = _r.value;
8205
- // TODO: [🧠] This definition should be made first in the template
8321
+ // TODO: [🧠] This definition should be made first in the task
8206
8322
  defineParam({
8207
8323
  parameterName: parameterName,
8208
8324
  parameterDescription: null,
@@ -8221,13 +8337,13 @@
8221
8337
  }
8222
8338
  /*
8223
8339
  // TODO: [🍧] This should be checked in `MODEL` command + better error message
8224
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
8340
+ if ($taskJson.taskType !== 'PROMPT_TASK' && $taskJson.modelRequirements !== undefined) {
8225
8341
  throw new UnexpectedError(
8226
8342
  spaceTrim(
8227
8343
  (block) => `
8228
8344
  Model requirements are defined for the block type ${
8229
- $templateJson.templateType
8230
- } which is not a PROMPT TEMPLATE
8345
+ $taskJson.taskType
8346
+ } which is not a \`PROMPT\` task
8231
8347
 
8232
8348
  This should be avoided by the \`modelCommandParser\`
8233
8349
 
@@ -8237,16 +8353,16 @@
8237
8353
  );
8238
8354
  }
8239
8355
  */
8240
- if ($templateJson.isTemplate) {
8241
- delete $templateJson.isTemplateTypeSet;
8242
- delete $templateJson.isTemplate;
8243
- // TODO: [🍙] Maybe do reorder of `$templateJson` here
8244
- $pipelineJson.templates.push($templateJson);
8356
+ if ($taskJson.isTask) {
8357
+ delete $taskJson.isSectionTypeSet;
8358
+ delete $taskJson.isTask;
8359
+ // TODO: [🍙] Maybe do reorder of `$taskJson` here
8360
+ $pipelineJson.tasks.push($taskJson);
8245
8361
  }
8246
8362
  };
8247
8363
  try {
8248
8364
  // =============================================================
8249
- // Note: 4️⃣ Process each template of the pipeline
8365
+ // Note: 4️⃣ Process each section of the pipeline
8250
8366
  for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
8251
8367
  var section = pipelineSections_1_1.value;
8252
8368
  _loop_2(section);
@@ -8263,7 +8379,7 @@
8263
8379
  // Note: 5️⃣ Mark parameters as INPUT if not explicitly set
8264
8380
  if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
8265
8381
  var _loop_3 = function (parameter) {
8266
- var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
8382
+ var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
8267
8383
  if (!isThisParameterResulting) {
8268
8384
  parameter.isInput = true;
8269
8385
  }
@@ -8303,13 +8419,13 @@
8303
8419
  }
8304
8420
  // =============================================================
8305
8421
  // Note: 7️⃣ Cleanup of undefined values
8306
- $pipelineJson.templates.forEach(function (templates) {
8422
+ $pipelineJson.tasks.forEach(function (tasks) {
8307
8423
  var e_7, _a;
8308
8424
  try {
8309
- for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
8425
+ for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
8310
8426
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
8311
8427
  if (value === undefined) {
8312
- delete templates[key];
8428
+ delete tasks[key];
8313
8429
  }
8314
8430
  }
8315
8431
  }
@@ -8349,7 +8465,7 @@
8349
8465
  * TODO: Use spaceTrim more effectively
8350
8466
  * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
8351
8467
  * TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
8352
- * TODO: [♈] Probbably move expectations from templates to parameters
8468
+ * TODO: [♈] Probbably move expectations from tasks to parameters
8353
8469
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
8354
8470
  * TODO: [🍙] Make some standard order of json properties
8355
8471
  */