@promptbook/cli 0.75.0-0 → 0.75.0-2

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 (158) hide show
  1. package/README.md +1 -0
  2. package/esm/index.es.js +704 -481
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +29 -19
  6. package/esm/typings/src/_packages/types.index.d.ts +58 -50
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -4
  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 +2 -2
  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/SECTION/SectionType.d.ts +13 -0
  28. package/esm/typings/src/commands/{TEMPLATE/templateCommandParser.d.ts → SECTION/sectionCommandParser.d.ts} +6 -6
  29. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  30. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +17 -17
  31. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +1 -1
  32. package/esm/typings/src/commands/index.d.ts +4 -1
  33. package/esm/typings/src/config.d.ts +3 -1
  34. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +2 -2
  35. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
  36. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +3 -3
  37. package/esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts +1 -1
  38. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  39. package/esm/typings/src/conversion/utils/{extractParameterNamesFromTemplate.d.ts → extractParameterNamesFromTask.d.ts} +2 -2
  40. package/esm/typings/src/conversion/utils/renameParameter.d.ts +1 -1
  41. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +3 -2
  42. package/esm/typings/src/conversion/validation/validatePipeline.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/createPipelineExecutor/{$OngoingTemplateResult.d.ts → $OngoingTaskResult.d.ts} +1 -1
  47. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +1 -1
  48. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +1 -1
  49. package/esm/typings/src/execution/createPipelineExecutor/{20-executeTemplate.d.ts → 20-executeTask.d.ts} +7 -7
  50. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -5
  51. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +1 -1
  52. package/esm/typings/src/execution/createPipelineExecutor/{getContextForTemplate.d.ts → getContextForTask.d.ts} +2 -2
  53. package/esm/typings/src/execution/createPipelineExecutor/{getExamplesForTemplate.d.ts → getExamplesForTask.d.ts} +2 -2
  54. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +27 -0
  55. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +30 -0
  56. package/esm/typings/src/{types → execution}/execution-report/ExecutionPromptReportJson.d.ts +2 -2
  57. package/esm/typings/src/{types → execution}/execution-report/ExecutionReportJson.d.ts +4 -4
  58. package/esm/typings/src/{types → execution}/execution-report/ExecutionReportStringOptions.d.ts +1 -1
  59. package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  60. package/esm/typings/src/execution/utils/usage-constants.d.ts +3 -0
  61. package/esm/typings/src/formats/index.d.ts +3 -0
  62. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +14 -0
  63. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +9 -1
  64. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +4 -1
  65. package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +15 -0
  66. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +5 -1
  67. package/esm/typings/src/formfactors/index.d.ts +39 -3
  68. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +14 -0
  69. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +14 -0
  70. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +14 -0
  71. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
  72. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +3 -0
  73. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +1 -0
  74. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +3 -0
  75. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
  76. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  77. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  78. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +3 -0
  79. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +1 -0
  80. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  81. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/PipelineInterface.d.ts +5 -2
  82. package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +14 -0
  83. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/getPipelineInterface.d.ts +3 -1
  84. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineImplementingInterface.d.ts +5 -1
  85. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineInterfacesEqual.d.ts +2 -0
  86. package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +13 -0
  87. package/esm/typings/src/{types → pipeline}/PipelineJson/Expectations.d.ts +2 -2
  88. package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgePieceJson.d.ts +7 -6
  89. package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgeSourceJson.d.ts +3 -3
  90. package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +96 -0
  91. package/esm/typings/src/{types → pipeline}/PipelineJson/PersonaJson.d.ts +4 -4
  92. package/esm/typings/src/{types → pipeline}/PipelineJson/PipelineJson.d.ts +10 -10
  93. package/esm/typings/src/{types → pipeline}/PipelineJson/PreparationJson.d.ts +1 -1
  94. package/esm/typings/src/{types/PipelineJson/PromptTemplateJson.d.ts → pipeline/PipelineJson/PromptTaskJson.d.ts} +8 -8
  95. package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +20 -0
  96. package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +13 -0
  97. package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +11 -0
  98. package/esm/typings/src/{types/PipelineJson/TemplateJsonCommon.d.ts → pipeline/PipelineJson/TaskJsonCommon.d.ts} +13 -13
  99. package/esm/typings/src/{types → pipeline}/PipelineString.d.ts +1 -1
  100. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -2
  101. package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
  102. package/esm/typings/src/prepare/{prepareTemplates.d.ts → prepareTasks.d.ts} +7 -7
  103. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -1
  104. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -1
  105. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +2 -2
  106. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  107. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +1 -1
  108. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
  109. package/esm/typings/src/scrapers/document/register-metadata.d.ts +3 -0
  110. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
  111. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
  112. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +3 -0
  113. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  114. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
  115. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +3 -0
  116. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -1
  117. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
  118. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +3 -0
  119. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +1 -1
  120. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
  121. package/esm/typings/src/scrapers/website/register-metadata.d.ts +3 -0
  122. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +1 -0
  123. package/esm/typings/src/types/Prompt.d.ts +1 -1
  124. package/esm/typings/src/types/TaskProgress.d.ts +2 -2
  125. package/esm/typings/src/types/typeAliasEmoji.d.ts +3 -0
  126. package/esm/typings/src/types/typeAliases.d.ts +1 -0
  127. package/esm/typings/src/utils/emojis.d.ts +1 -0
  128. package/esm/typings/src/utils/expectation-counters/{config.d.ts → constants.d.ts} +4 -0
  129. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
  130. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
  131. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
  132. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
  133. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  134. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
  135. package/esm/typings/src/utils/expectation-counters/index.d.ts +3 -2
  136. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -0
  137. package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +2 -2
  138. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +1 -1
  139. package/esm/typings/src/version.d.ts +2 -1
  140. package/package.json +4 -3
  141. package/umd/index.umd.js +704 -481
  142. package/umd/index.umd.js.map +1 -1
  143. package/esm/typings/src/commands/TEMPLATE/TemplateCommand.d.ts +0 -11
  144. package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +0 -15
  145. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +0 -27
  146. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +0 -30
  147. package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +0 -10
  148. package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +0 -13
  149. package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +0 -39
  150. package/esm/typings/src/types/PipelineJson/ScriptTemplateJson.d.ts +0 -20
  151. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +0 -13
  152. package/esm/typings/src/types/PipelineJson/TemplateJson.d.ts +0 -11
  153. /package/esm/typings/src/commands/{TEMPLATE/templateCommand.test.d.ts → SECTION/sectionCommand.test.d.ts} +0 -0
  154. /package/esm/typings/src/conversion/utils/{extractParameterNamesFromTemplate.test.d.ts → extractParameterNamesFromTask.test.d.ts} +0 -0
  155. /package/esm/typings/src/{types → execution}/execution-report/ExecutionReportString.d.ts +0 -0
  156. /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.d.ts +0 -0
  157. /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.test.d.ts +0 -0
  158. /package/esm/typings/src/{types → execution}/execution-report/executionReportJsonToString.d.ts +0 -0
package/umd/index.umd.js CHANGED
@@ -49,9 +49,10 @@
49
49
  *
50
50
  * @see https://github.com/webgptorg/promptbook
51
51
  */
52
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
52
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-1';
53
53
  /**
54
54
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
55
+ * Note: [💞] Ignore a discrepancy between file name and entity name
55
56
  */
56
57
 
57
58
  /*! *****************************************************************************
@@ -399,7 +400,7 @@
399
400
  *
400
401
  * @public exported from `@promptbook/core`
401
402
  */
402
- var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
403
+ var CLAIM = "It's time for a paradigm shift. The future of software in plain English, French or Latin";
403
404
  // <- TODO: [🐊] Pick the best claim
404
405
  /**
405
406
  * When the title is not provided, the default title is used
@@ -569,6 +570,8 @@
569
570
  // Note: In normal situations, we check the pipeline logic:
570
571
  true);
571
572
  /**
573
+ * TODO: Extract `constants.ts` from `config.ts`
574
+ * Note: [💞] Ignore a discrepancy between file name and entity name
572
575
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
573
576
  */
574
577
 
@@ -619,6 +622,7 @@
619
622
  }
620
623
  /**
621
624
  * TODO: [🗽] Unite branding and make single place for it
625
+ * Note: [💞] Ignore a discrepancy between file name and entity name
622
626
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
623
627
  */
624
628
 
@@ -652,6 +656,7 @@
652
656
  }
653
657
  /**
654
658
  * TODO: [🧠][🐣] Make here some easter egg with generated hello greeting via LLM models
659
+ * Note: [💞] Ignore a discrepancy between file name and entity name
655
660
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
656
661
  */
657
662
 
@@ -734,7 +739,7 @@
734
739
  */
735
740
  function pipelineJsonToString(pipelineJson) {
736
741
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
737
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
742
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, tasks = pipelineJson.tasks;
738
743
  var pipelineString = "# ".concat(title);
739
744
  if (description) {
740
745
  pipelineString += '\n\n';
@@ -784,13 +789,13 @@
784
789
  pipelineString += '\n\n';
785
790
  pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
786
791
  try {
787
- for (var templates_1 = __values(templates), templates_1_1 = templates_1.next(); !templates_1_1.done; templates_1_1 = templates_1.next()) {
788
- var template = templates_1_1.value;
792
+ for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
793
+ var template = tasks_1_1.value;
789
794
  var
790
795
  /* Note: Not using:> name, */
791
796
  title_1 = template.title, description_1 = template.description,
792
797
  /* Note: dependentParameterNames, */
793
- jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
798
+ jokers = template.jokerParameterNames, taskType = template.taskType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
794
799
  pipelineString += '\n\n';
795
800
  pipelineString += "## ".concat(title_1);
796
801
  if (description_1) {
@@ -799,7 +804,7 @@
799
804
  }
800
805
  var commands_1 = [];
801
806
  var contentLanguage = 'text';
802
- if (templateType === 'PROMPT_TEMPLATE') {
807
+ if (taskType === 'PROMPT_TASK') {
803
808
  var modelRequirements = template.modelRequirements;
804
809
  var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
805
810
  commands_1.push("EXECUTE PROMPT TEMPLATE");
@@ -810,11 +815,11 @@
810
815
  commands_1.push("MODEL NAME `".concat(modelName, "`"));
811
816
  }
812
817
  }
813
- else if (templateType === 'SIMPLE_TEMPLATE') {
818
+ else if (taskType === 'SIMPLE_TASK') {
814
819
  commands_1.push("SIMPLE TEMPLATE");
815
820
  // Note: Nothing special here
816
821
  }
817
- else if (templateType === 'SCRIPT_TEMPLATE') {
822
+ else if (taskType === 'SCRIPT_TASK') {
818
823
  commands_1.push("SCRIPT TEMPLATE");
819
824
  if (template.contentLanguage) {
820
825
  contentLanguage = template.contentLanguage;
@@ -823,7 +828,7 @@
823
828
  contentLanguage = '';
824
829
  }
825
830
  }
826
- else if (templateType === 'DIALOG_TEMPLATE') {
831
+ else if (taskType === 'DIALOG_TASK') {
827
832
  commands_1.push("DIALOG TEMPLATE");
828
833
  // Note: Nothing special here
829
834
  } // <- }else if([🅱]
@@ -905,7 +910,7 @@
905
910
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
906
911
  finally {
907
912
  try {
908
- if (templates_1_1 && !templates_1_1.done && (_c = templates_1.return)) _c.call(templates_1);
913
+ if (tasks_1_1 && !tasks_1_1.done && (_c = tasks_1.return)) _c.call(tasks_1);
909
914
  }
910
915
  finally { if (e_3) throw e_3.error; }
911
916
  }
@@ -1074,6 +1079,9 @@
1074
1079
  pagesCount: { value: 0, isUncertain: true },
1075
1080
  },
1076
1081
  });
1082
+ /**
1083
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1084
+ */
1077
1085
 
1078
1086
  /**
1079
1087
  * @@@
@@ -1489,8 +1497,8 @@
1489
1497
  else if (errors.length > 1) {
1490
1498
  throw new PipelineExecutionError(
1491
1499
  // TODO: Tell which execution tools failed like
1492
- // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
1493
- // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
1500
+ // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
1501
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
1494
1502
  // 3) ...
1495
1503
  spaceTrim__default["default"](function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
1496
1504
  .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
@@ -1565,7 +1573,7 @@
1565
1573
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
1566
1574
  */
1567
1575
 
1568
- 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"}];
1576
+ 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:"./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}],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:"./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}],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:"./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}],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:"./promptbook-collection/prepare-persona.book.md"}];
1569
1577
 
1570
1578
  /**
1571
1579
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -1819,24 +1827,23 @@
1819
1827
  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 "); }));
1820
1828
  }
1821
1829
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1822
- if (!Array.isArray(pipeline.templates)) {
1830
+ if (!Array.isArray(pipeline.tasks)) {
1823
1831
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
1824
- 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 "); }));
1832
+ 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 "); }));
1825
1833
  }
1826
1834
  var _loop_1 = function (parameter) {
1827
1835
  if (parameter.isInput && parameter.isOutput) {
1828
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
1836
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Parameter `{".concat(parameter.name, "}` can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
1829
1837
  }
1830
1838
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
1831
1839
  if (!parameter.isInput &&
1832
1840
  !parameter.isOutput &&
1833
- !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
1834
- 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 "); }));
1841
+ !pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
1842
+ 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 "); }));
1835
1843
  }
1836
- // Note: Testing that parameter is either input or result of some template
1837
- if (!parameter.isInput &&
1838
- !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
1839
- 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 "); }));
1844
+ // Note: Testing that parameter is either input or result of some task
1845
+ if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
1846
+ 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 "); }));
1840
1847
  }
1841
1848
  };
1842
1849
  try {
@@ -1853,7 +1860,7 @@
1853
1860
  }
1854
1861
  finally { if (e_1) throw e_1.error; }
1855
1862
  }
1856
- // Note: All input parameters are defined - so that they can be used as result of some template
1863
+ // Note: All input parameters are defined - so that they can be used as result of some task
1857
1864
  var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
1858
1865
  var isInput = _a.isInput;
1859
1866
  return isInput;
@@ -1861,27 +1868,27 @@
1861
1868
  var name = _a.name;
1862
1869
  return name;
1863
1870
  }));
1864
- var _loop_2 = function (template) {
1871
+ var _loop_2 = function (task) {
1865
1872
  var e_4, _h, e_5, _j;
1866
- if (definedParameters.has(template.resultingParameterName)) {
1867
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1873
+ if (definedParameters.has(task.resultingParameterName)) {
1874
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1868
1875
  }
1869
- if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1870
- 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 "); }));
1876
+ if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
1877
+ 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 "); }));
1871
1878
  }
1872
- definedParameters.add(template.resultingParameterName);
1873
- if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
1874
- if (!template.format &&
1875
- !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1876
- 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 "); }));
1879
+ definedParameters.add(task.resultingParameterName);
1880
+ if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
1881
+ if (!task.format &&
1882
+ !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1883
+ 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 "); }));
1877
1884
  }
1878
1885
  var _loop_4 = function (joker) {
1879
- if (!template.dependentParameterNames.includes(joker)) {
1880
- 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 "); }));
1886
+ if (!task.dependentParameterNames.includes(joker)) {
1887
+ 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 "); }));
1881
1888
  }
1882
1889
  };
1883
1890
  try {
1884
- for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1891
+ for (var _k = (e_4 = void 0, __values(task.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1885
1892
  var joker = _l.value;
1886
1893
  _loop_4(joker);
1887
1894
  }
@@ -1894,7 +1901,7 @@
1894
1901
  finally { if (e_4) throw e_4.error; }
1895
1902
  }
1896
1903
  }
1897
- if (template.expectations) {
1904
+ if (task.expectations) {
1898
1905
  var _loop_5 = function (unit, min, max) {
1899
1906
  if (min !== undefined && max !== undefined && min > max) {
1900
1907
  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 "); }));
@@ -1907,7 +1914,7 @@
1907
1914
  }
1908
1915
  };
1909
1916
  try {
1910
- for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1917
+ for (var _m = (e_5 = void 0, __values(Object.entries(task.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1911
1918
  var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
1912
1919
  _loop_5(unit, min, max);
1913
1920
  }
@@ -1922,10 +1929,10 @@
1922
1929
  }
1923
1930
  };
1924
1931
  try {
1925
- // Note: Checking each template individually
1926
- for (var _f = __values(pipeline.templates), _g = _f.next(); !_g.done; _g = _f.next()) {
1927
- var template = _g.value;
1928
- _loop_2(template);
1932
+ // Note: Checking each task individually
1933
+ for (var _f = __values(pipeline.tasks), _g = _f.next(); !_g.done; _g = _f.next()) {
1934
+ var task = _g.value;
1935
+ _loop_2(task);
1929
1936
  }
1930
1937
  }
1931
1938
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1959,37 +1966,48 @@
1959
1966
  }
1960
1967
  finally { if (e_3) throw e_3.error; }
1961
1968
  }
1962
- var unresovedTemplates = __spreadArray([], __read(pipeline.templates), false);
1969
+ var unresovedTemplates = __spreadArray([], __read(pipeline.tasks), false);
1963
1970
  var loopLimit = LOOP_LIMIT;
1964
1971
  var _loop_3 = function () {
1965
1972
  if (loopLimit-- < 0) {
1966
1973
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1967
1974
  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 "); }));
1968
1975
  }
1969
- var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1970
- return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1976
+ var currentlyResovedTemplates = unresovedTemplates.filter(function (task) {
1977
+ return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1971
1978
  });
1972
1979
  if (currentlyResovedTemplates.length === 0) {
1973
1980
  throw new PipelineLogicError(
1974
1981
  // TODO: [🐎] DRY
1975
- 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
1982
+ 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
1976
1983
  .map(function (_a) {
1977
1984
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
1978
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
1979
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1985
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
1986
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
1980
1987
  .join(' and '));
1981
1988
  })
1982
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n\n "); }));
1989
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
1990
+ .filter(function (name) {
1991
+ return !RESERVED_PARAMETER_NAMES.includes(name);
1992
+ })
1993
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1994
+ .join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
1995
+ .filter(function (name) {
1996
+ return RESERVED_PARAMETER_NAMES.includes(name);
1997
+ })
1998
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1999
+ .join('\n')), "\n\n\n "); }));
1983
2000
  }
1984
2001
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1985
2002
  var resultingParameterName = _a.resultingParameterName;
1986
2003
  return resultingParameterName;
1987
2004
  })), false);
1988
- unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
2005
+ unresovedTemplates = unresovedTemplates.filter(function (task) { return !currentlyResovedTemplates.includes(task); });
1989
2006
  };
1990
2007
  while (unresovedTemplates.length > 0) {
1991
2008
  _loop_3();
1992
2009
  }
2010
+ // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
1993
2011
  }
1994
2012
  /**
1995
2013
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -2046,9 +2064,9 @@
2046
2064
  }(Error));
2047
2065
 
2048
2066
  /**
2049
- * Parses the template and returns the list of all parameter names
2067
+ * Parses the task and returns the list of all parameter names
2050
2068
  *
2051
- * @param template the template with parameters in {curly} braces
2069
+ * @param template the task with parameters in {curly} braces
2052
2070
  * @returns the list of parameter names
2053
2071
  * @public exported from `@promptbook/utils`
2054
2072
  */
@@ -2079,10 +2097,10 @@
2079
2097
  * @public exported from `@promptbook/core`
2080
2098
  */
2081
2099
  function unpreparePipeline(pipeline) {
2082
- var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, templates = pipeline.templates;
2100
+ var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
2083
2101
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
2084
2102
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
2085
- templates = templates.map(function (template) {
2103
+ tasks = tasks.map(function (template) {
2086
2104
  var dependentParameterNames = template.dependentParameterNames;
2087
2105
  var parameterNames = extractParameterNames(template.preparedContent || '');
2088
2106
  dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
@@ -2090,7 +2108,7 @@
2090
2108
  delete templateUnprepared.preparedContent;
2091
2109
  return templateUnprepared;
2092
2110
  });
2093
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { templates: templates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
2111
+ return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
2094
2112
  }
2095
2113
  /**
2096
2114
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -2289,6 +2307,9 @@
2289
2307
  UnexpectedError: UnexpectedError,
2290
2308
  // TODO: [🪑]> VersionMismatchError,
2291
2309
  };
2310
+ /**
2311
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2312
+ */
2292
2313
 
2293
2314
  /**
2294
2315
  * Deserializes the error object
@@ -2350,8 +2371,8 @@
2350
2371
  return false;
2351
2372
  }
2352
2373
  /*
2353
- TODO: [🧠][🍫] `templates` can not be determined if they are fully prepared SO ignoring them
2354
- > if (!pipeline.templates.every(({ preparedContent }) => preparedContent === undefined)) {
2374
+ TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
2375
+ > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
2355
2376
  > return false;
2356
2377
  > }
2357
2378
  */
@@ -2364,7 +2385,7 @@
2364
2385
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2365
2386
  * - [🏍] ? Is context in each template
2366
2387
  * - [♨] Are examples prepared
2367
- * - [♨] Are templates prepared
2388
+ * - [♨] Are tasks prepared
2368
2389
  */
2369
2390
 
2370
2391
  /**
@@ -2441,9 +2462,9 @@
2441
2462
  * @throws {ParseError} if the script is invalid
2442
2463
  * @public exported from `@promptbook/utils`
2443
2464
  */
2444
- function extractParameterNamesFromTemplate(template) {
2465
+ function extractParameterNamesFromTask(template) {
2445
2466
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
2446
- var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
2467
+ var title = template.title, description = template.description, taskType = template.taskType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
2447
2468
  var parameterNames = new Set();
2448
2469
  try {
2449
2470
  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()) {
@@ -2458,7 +2479,7 @@
2458
2479
  }
2459
2480
  finally { if (e_1) throw e_1.error; }
2460
2481
  }
2461
- if (templateType === 'SCRIPT_TEMPLATE') {
2482
+ if (taskType === 'SCRIPT_TASK') {
2462
2483
  try {
2463
2484
  for (var _g = __values(extractVariables(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
2464
2485
  var parameterName = _h.value;
@@ -2902,6 +2923,9 @@
2902
2923
  TextFormatDefinition,
2903
2924
  CsvFormatDefinition,
2904
2925
  ];
2926
+ /**
2927
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2928
+ */
2905
2929
 
2906
2930
  /**
2907
2931
  * Maps available parameters to expected parameters
@@ -3122,11 +3146,11 @@
3122
3146
  for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
3123
3147
  var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
3124
3148
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
3125
- throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
3149
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
3126
3150
  }
3127
3151
  else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
3128
3152
  // TODO: [🍵]
3129
- throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
3153
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
3130
3154
  }
3131
3155
  }
3132
3156
  }
@@ -3137,7 +3161,7 @@
3137
3161
  }
3138
3162
  finally { if (e_1) throw e_1.error; }
3139
3163
  }
3140
- var replacedTemplate = template;
3164
+ var replacedTemplates = template;
3141
3165
  var match;
3142
3166
  var loopLimit = LOOP_LIMIT;
3143
3167
  var _loop_1 = function () {
@@ -3153,11 +3177,11 @@
3153
3177
  throw new PipelineExecutionError('Parameter is already opened or not closed');
3154
3178
  }
3155
3179
  if (parameters[parameterName] === undefined) {
3156
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
3180
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
3157
3181
  }
3158
3182
  var parameterValue = parameters[parameterName];
3159
3183
  if (parameterValue === undefined) {
3160
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
3184
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
3161
3185
  }
3162
3186
  parameterValue = parameterValue.toString();
3163
3187
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
@@ -3166,24 +3190,24 @@
3166
3190
  .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
3167
3191
  .join('\n');
3168
3192
  }
3169
- replacedTemplate =
3170
- replacedTemplate.substring(0, match.index + precol.length) +
3193
+ replacedTemplates =
3194
+ replacedTemplates.substring(0, match.index + precol.length) +
3171
3195
  parameterValue +
3172
- replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
3196
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
3173
3197
  };
3174
3198
  while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
3175
- .exec(replacedTemplate))) {
3199
+ .exec(replacedTemplates))) {
3176
3200
  _loop_1();
3177
3201
  }
3178
3202
  // [💫] Check if there are parameters that are not closed properly
3179
- if (/{\w+$/.test(replacedTemplate)) {
3203
+ if (/{\w+$/.test(replacedTemplates)) {
3180
3204
  throw new PipelineExecutionError('Parameter is not closed');
3181
3205
  }
3182
3206
  // [💫] Check if there are parameters that are not opened properly
3183
- if (/^\w+}/.test(replacedTemplate)) {
3207
+ if (/^\w+}/.test(replacedTemplates)) {
3184
3208
  throw new PipelineExecutionError('Parameter is not opened');
3185
3209
  }
3186
- return replacedTemplate;
3210
+ return replacedTemplates;
3187
3211
  }
3188
3212
 
3189
3213
  /**
@@ -3213,6 +3237,10 @@
3213
3237
  * @public exported from `@promptbook/utils`
3214
3238
  */
3215
3239
  var LINES_PER_STANDARD_PAGE = 44;
3240
+ /**
3241
+ * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
3242
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3243
+ */
3216
3244
 
3217
3245
  /**
3218
3246
  * Counts number of lines in the text
@@ -3552,6 +3580,7 @@
3552
3580
  };
3553
3581
  /**
3554
3582
  * TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
3583
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3555
3584
  */
3556
3585
 
3557
3586
  /**
@@ -3600,12 +3629,12 @@
3600
3629
  */
3601
3630
  function executeAttempts(options) {
3602
3631
  return __awaiter(this, void 0, void 0, function () {
3603
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3632
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTaskResult, _llms, llmTools, _loop_1, attempt, state_1;
3604
3633
  return __generator(this, function (_a) {
3605
3634
  switch (_a.label) {
3606
3635
  case 0:
3607
- 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;
3608
- $ongoingTemplateResult = {
3636
+ 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;
3637
+ $ongoingTaskResult = {
3609
3638
  $result: null,
3610
3639
  $resultString: null,
3611
3640
  $expectError: null,
@@ -3625,52 +3654,51 @@
3625
3654
  if (isJokerAttempt && !jokerParameterName) {
3626
3655
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
3627
3656
  }
3628
- $ongoingTemplateResult.$result = null;
3629
- $ongoingTemplateResult.$resultString = null;
3630
- $ongoingTemplateResult.$expectError = null;
3657
+ $ongoingTaskResult.$result = null;
3658
+ $ongoingTaskResult.$resultString = null;
3659
+ $ongoingTaskResult.$expectError = null;
3631
3660
  if (isJokerAttempt) {
3632
3661
  if (parameters[jokerParameterName] === undefined) {
3633
3662
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
3634
3663
  // <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
3635
3664
  }
3636
3665
  else {
3637
- $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
3666
+ $ongoingTaskResult.$resultString = parameters[jokerParameterName];
3638
3667
  }
3639
3668
  }
3640
3669
  _t.label = 1;
3641
3670
  case 1:
3642
3671
  _t.trys.push([1, 43, 44, 45]);
3643
3672
  if (!!isJokerAttempt) return [3 /*break*/, 25];
3644
- _b = template.templateType;
3673
+ _b = task.taskType;
3645
3674
  switch (_b) {
3646
- case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3647
- case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
3648
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
3649
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
3675
+ case 'SIMPLE_TASK': return [3 /*break*/, 2];
3676
+ case 'PROMPT_TASK': return [3 /*break*/, 3];
3677
+ case 'SCRIPT_TASK': return [3 /*break*/, 11];
3678
+ case 'DIALOG_TASK': return [3 /*break*/, 22];
3650
3679
  }
3651
3680
  return [3 /*break*/, 24];
3652
3681
  case 2:
3653
- $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
3682
+ $ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
3654
3683
  return [3 /*break*/, 25];
3655
3684
  case 3:
3656
- modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
3657
- $ongoingTemplateResult.$prompt = {
3658
- title: template.title,
3685
+ modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
3686
+ $ongoingTaskResult.$prompt = {
3687
+ title: task.title,
3659
3688
  pipelineUrl: "".concat(preparedPipeline.pipelineUrl
3660
3689
  ? preparedPipeline.pipelineUrl
3661
- : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
3662
- // <- TODO: Here should be maybe also subformat index to distinguish between same template with different subformat values
3690
+ : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(task.name
3691
+ // <- TODO: Here should be maybe also subformat index to distinguish between same task with different subformat values
3663
3692
  ),
3664
3693
  parameters: parameters,
3665
3694
  content: preparedContent,
3666
3695
  modelRequirements: modelRequirements,
3667
3696
  expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
3668
3697
  var name = _a.name;
3669
- return name === template.personaName;
3670
- }) ||
3671
- {})), template.expectations),
3672
- format: template.format,
3673
- postprocessingFunctionNames: template.postprocessingFunctionNames,
3698
+ return name === task.personaName;
3699
+ }) || {})), task.expectations),
3700
+ format: task.format,
3701
+ postprocessingFunctionNames: task.postprocessingFunctionNames,
3674
3702
  }; // <- TODO: Not very good type guard
3675
3703
  _c = modelRequirements.modelVariant;
3676
3704
  switch (_c) {
@@ -3680,36 +3708,35 @@
3680
3708
  }
3681
3709
  return [3 /*break*/, 9];
3682
3710
  case 4:
3683
- _d = $ongoingTemplateResult;
3711
+ _d = $ongoingTaskResult;
3684
3712
  return [4 /*yield*/, llmTools.callChatModel(
3685
3713
  // <- TODO: [🧁] Check that `callChatModel` is defined
3686
- $deepFreeze($ongoingTemplateResult.$prompt))];
3714
+ $deepFreeze($ongoingTaskResult.$prompt))];
3687
3715
  case 5:
3688
3716
  _d.$chatResult = _t.sent();
3689
3717
  // TODO: [🍬] Destroy chatThread
3690
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
3691
- $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
3718
+ $ongoingTaskResult.$result = $ongoingTaskResult.$chatResult;
3719
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$chatResult.content;
3692
3720
  return [3 /*break*/, 10];
3693
3721
  case 6:
3694
- _e = $ongoingTemplateResult;
3722
+ _e = $ongoingTaskResult;
3695
3723
  return [4 /*yield*/, llmTools.callCompletionModel(
3696
3724
  // <- TODO: [🧁] Check that `callCompletionModel` is defined
3697
- $deepFreeze($ongoingTemplateResult.$prompt))];
3725
+ $deepFreeze($ongoingTaskResult.$prompt))];
3698
3726
  case 7:
3699
3727
  _e.$completionResult = _t.sent();
3700
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
3701
- $ongoingTemplateResult.$resultString =
3702
- $ongoingTemplateResult.$completionResult.content;
3728
+ $ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
3729
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
3703
3730
  return [3 /*break*/, 10];
3704
3731
  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 "); }));
3705
- 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 "); }));
3732
+ 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 "); }));
3706
3733
  case 10: return [3 /*break*/, 25];
3707
3734
  case 11:
3708
3735
  if (arrayableToArray(tools.script).length === 0) {
3709
3736
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3710
3737
  }
3711
- if (!template.contentLanguage) {
3712
- 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 "); }));
3738
+ if (!task.contentLanguage) {
3739
+ 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 "); }));
3713
3740
  }
3714
3741
  _t.label = 12;
3715
3742
  case 12:
@@ -3722,9 +3749,9 @@
3722
3749
  _t.label = 14;
3723
3750
  case 14:
3724
3751
  _t.trys.push([14, 16, , 17]);
3725
- _h = $ongoingTemplateResult;
3752
+ _h = $ongoingTaskResult;
3726
3753
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
3727
- scriptLanguage: template.contentLanguage,
3754
+ scriptLanguage: task.contentLanguage,
3728
3755
  script: preparedContent,
3729
3756
  parameters: parameters,
3730
3757
  }))];
@@ -3739,7 +3766,7 @@
3739
3766
  if (error_1 instanceof UnexpectedError) {
3740
3767
  throw error_1;
3741
3768
  }
3742
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
3769
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_1);
3743
3770
  return [3 /*break*/, 17];
3744
3771
  case 17:
3745
3772
  _g = _f.next();
@@ -3756,14 +3783,14 @@
3756
3783
  finally { if (e_1) throw e_1.error; }
3757
3784
  return [7 /*endfinally*/];
3758
3785
  case 21:
3759
- if ($ongoingTemplateResult.$resultString !== null) {
3786
+ if ($ongoingTaskResult.$resultString !== null) {
3760
3787
  return [3 /*break*/, 25];
3761
3788
  }
3762
- if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
3763
- throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
3789
+ if ($ongoingTaskResult.$scriptPipelineExecutionErrors.length === 1) {
3790
+ throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
3764
3791
  }
3765
3792
  else {
3766
- 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
3793
+ 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
3767
3794
  .map(function (error) { return '- ' + error.message; })
3768
3795
  .join('\n\n')), "\n "); }));
3769
3796
  }
@@ -3771,27 +3798,27 @@
3771
3798
  if (tools.userInterface === undefined) {
3772
3799
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3773
3800
  }
3774
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3775
- _j = $ongoingTemplateResult;
3801
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
3802
+ _j = $ongoingTaskResult;
3776
3803
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
3777
- promptTitle: template.title,
3778
- promptMessage: replaceParameters(template.description || '', parameters),
3804
+ promptTitle: task.title,
3805
+ promptMessage: replaceParameters(task.description || '', parameters),
3779
3806
  defaultValue: replaceParameters(preparedContent, parameters),
3780
3807
  // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
3781
3808
  placeholder: undefined,
3782
3809
  priority: priority,
3783
3810
  }))];
3784
3811
  case 23:
3785
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3812
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
3786
3813
  _j.$resultString = _t.sent();
3787
3814
  return [3 /*break*/, 25];
3788
- case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3815
+ case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3789
3816
  case 25:
3790
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3817
+ if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
3791
3818
  _t.label = 26;
3792
3819
  case 26:
3793
3820
  _t.trys.push([26, 40, 41, 42]);
3794
- _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
3821
+ _k = (e_3 = void 0, __values(task.postprocessingFunctionNames)), _l = _k.next();
3795
3822
  _t.label = 27;
3796
3823
  case 27:
3797
3824
  if (!!_l.done) return [3 /*break*/, 39];
@@ -3808,13 +3835,13 @@
3808
3835
  _t.label = 30;
3809
3836
  case 30:
3810
3837
  _t.trys.push([30, 32, , 33]);
3811
- _p = $ongoingTemplateResult;
3838
+ _p = $ongoingTaskResult;
3812
3839
  return [4 /*yield*/, scriptTools.execute({
3813
3840
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
3814
3841
  script: "".concat(functionName, "(resultString)"),
3815
3842
  parameters: {
3816
- resultString: $ongoingTemplateResult.$resultString || '',
3817
- // Note: No ...parametersForTemplate, because working with result only
3843
+ resultString: $ongoingTaskResult.$resultString || '',
3844
+ // Note: No ...parametersForTask, because working with result only
3818
3845
  },
3819
3846
  })];
3820
3847
  case 31:
@@ -3830,7 +3857,7 @@
3830
3857
  throw error_2;
3831
3858
  }
3832
3859
  postprocessingError = error_2;
3833
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
3860
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_2);
3834
3861
  return [3 /*break*/, 33];
3835
3862
  case 33:
3836
3863
  _o = _m.next();
@@ -3867,12 +3894,12 @@
3867
3894
  return [7 /*endfinally*/];
3868
3895
  case 42:
3869
3896
  // TODO: [💝] Unite object for expecting amount and format
3870
- if (template.format) {
3871
- if (template.format === 'JSON') {
3872
- if (!isValidJsonString($ongoingTemplateResult.$resultString || '')) {
3897
+ if (task.format) {
3898
+ if (task.format === 'JSON') {
3899
+ if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
3873
3900
  // TODO: [🏢] Do more universally via `FormatDefinition`
3874
3901
  try {
3875
- $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
3902
+ $ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
3876
3903
  }
3877
3904
  catch (error) {
3878
3905
  throw new ExpectError(spaceTrim.spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
@@ -3881,12 +3908,12 @@
3881
3908
  }
3882
3909
  }
3883
3910
  else {
3884
- throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3911
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3885
3912
  }
3886
3913
  }
3887
3914
  // TODO: [💝] Unite object for expecting amount and format
3888
- if (template.expectations) {
3889
- checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
3915
+ if (task.expectations) {
3916
+ checkExpectations(task.expectations, $ongoingTaskResult.$resultString || '');
3890
3917
  }
3891
3918
  return [2 /*return*/, "break-attempts"];
3892
3919
  case 43:
@@ -3894,38 +3921,38 @@
3894
3921
  if (!(error_3 instanceof ExpectError)) {
3895
3922
  throw error_3;
3896
3923
  }
3897
- $ongoingTemplateResult.$expectError = error_3;
3924
+ $ongoingTaskResult.$expectError = error_3;
3898
3925
  return [3 /*break*/, 45];
3899
3926
  case 44:
3900
3927
  if (!isJokerAttempt &&
3901
- template.templateType === 'PROMPT_TEMPLATE' &&
3902
- $ongoingTemplateResult.$prompt
3928
+ task.taskType === 'PROMPT_TASK' &&
3929
+ $ongoingTaskResult.$prompt
3903
3930
  // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
3904
3931
  // In that case we don’t want to make a report about it because it’s not a llm execution error
3905
3932
  ) {
3906
- // TODO: [🧠] Maybe put other templateTypes into report
3933
+ // TODO: [🧠] Maybe put other taskTypes into report
3907
3934
  $executionReport.promptExecutions.push({
3908
- prompt: __assign({}, $ongoingTemplateResult.$prompt),
3909
- result: $ongoingTemplateResult.$result || undefined,
3910
- error: $ongoingTemplateResult.$expectError === null
3935
+ prompt: __assign({}, $ongoingTaskResult.$prompt),
3936
+ result: $ongoingTaskResult.$result || undefined,
3937
+ error: $ongoingTaskResult.$expectError === null
3911
3938
  ? undefined
3912
- : serializeError($ongoingTemplateResult.$expectError),
3939
+ : serializeError($ongoingTaskResult.$expectError),
3913
3940
  });
3914
3941
  }
3915
3942
  return [7 /*endfinally*/];
3916
3943
  case 45:
3917
- if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
3944
+ if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
3918
3945
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) {
3919
3946
  var _a, _b, _c;
3920
- 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) || '')
3947
+ 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) || '')
3921
3948
  .split('\n')
3922
3949
  .map(function (line) { return "> ".concat(line); })
3923
- .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) || '')
3950
+ .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) || '')
3924
3951
  .split('\n')
3925
3952
  .map(function (line) { return "> ".concat(line); })
3926
- .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
3953
+ .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTaskResult.$resultString === null
3927
3954
  ? 'null'
3928
- : $ongoingTemplateResult.$resultString
3955
+ : $ongoingTaskResult.$resultString
3929
3956
  .split('\n')
3930
3957
  .map(function (line) { return "> ".concat(line); })
3931
3958
  .join('\n')), "\n ---\n ");
@@ -3950,10 +3977,10 @@
3950
3977
  attempt++;
3951
3978
  return [3 /*break*/, 1];
3952
3979
  case 4:
3953
- if ($ongoingTemplateResult.$resultString === null) {
3980
+ if ($ongoingTaskResult.$resultString === null) {
3954
3981
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3955
3982
  }
3956
- return [2 /*return*/, $ongoingTemplateResult.$resultString];
3983
+ return [2 /*return*/, $ongoingTaskResult.$resultString];
3957
3984
  }
3958
3985
  });
3959
3986
  });
@@ -3969,36 +3996,36 @@
3969
3996
  */
3970
3997
  function executeFormatSubvalues(options) {
3971
3998
  return __awaiter(this, void 0, void 0, function () {
3972
- var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3999
+ var task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3973
4000
  var _this = this;
3974
4001
  return __generator(this, function (_a) {
3975
4002
  switch (_a.label) {
3976
4003
  case 0:
3977
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
3978
- if (template.foreach === undefined) {
4004
+ task = options.task, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
4005
+ if (task.foreach === undefined) {
3979
4006
  return [2 /*return*/, /* not await */ executeAttempts(options)];
3980
4007
  }
3981
4008
  if (jokerParameterNames.length !== 0) {
3982
4009
  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 "); }));
3983
4010
  }
3984
- parameterValue = parameters[template.foreach.parameterName] || '';
4011
+ parameterValue = parameters[task.foreach.parameterName] || '';
3985
4012
  formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
3986
- return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(template.foreach.formatName);
4013
+ return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(task.foreach.formatName);
3987
4014
  });
3988
4015
  if (formatDefinition === undefined) {
3989
4016
  throw new UnexpectedError(
3990
4017
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
3991
- 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; })
4018
+ 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; })
3992
4019
  .map(function (formatName) { return "- ".concat(formatName); })
3993
4020
  .join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
3994
4021
  }
3995
4022
  subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
3996
- return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(template.foreach.subformatName);
4023
+ return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(task.foreach.subformatName);
3997
4024
  });
3998
4025
  if (subvalueDefinition === undefined) {
3999
4026
  throw new UnexpectedError(
4000
4027
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
4001
- 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
4028
+ 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
4002
4029
  .map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
4003
4030
  .map(function (subvalueName) { return "- ".concat(subvalueName); })
4004
4031
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -4007,7 +4034,7 @@
4007
4034
  formatSettings = csvSettings;
4008
4035
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
4009
4036
  }
4010
- return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
4037
+ return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
4011
4038
  var mappedParameters, allSubparameters, subresultString;
4012
4039
  return __generator(this, function (_a) {
4013
4040
  switch (_a.label) {
@@ -4016,7 +4043,7 @@
4016
4043
  // TODO: When done [🐚] Report progress also for each subvalue here
4017
4044
  try {
4018
4045
  mappedParameters = mapAvailableToExpectedParameters({
4019
- expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
4046
+ expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
4020
4047
  availableParameters: subparameters,
4021
4048
  });
4022
4049
  }
@@ -4049,7 +4076,7 @@
4049
4076
  *
4050
4077
  * @private internal utility of `createPipelineExecutor`
4051
4078
  */
4052
- function getContextForTemplate(template) {
4079
+ function getContextForTask(task) {
4053
4080
  return __awaiter(this, void 0, void 0, function () {
4054
4081
  return __generator(this, function (_a) {
4055
4082
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
@@ -4062,15 +4089,10 @@
4062
4089
  *
4063
4090
  * @private internal utility of `createPipelineExecutor`
4064
4091
  */
4065
- function getKnowledgeForTemplate(options) {
4092
+ function getExamplesForTask(task) {
4066
4093
  return __awaiter(this, void 0, void 0, function () {
4067
- var preparedPipeline;
4068
4094
  return __generator(this, function (_a) {
4069
- preparedPipeline = options.preparedPipeline, options.template;
4070
- return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4071
- var content = _a.content;
4072
- return "- ".concat(content);
4073
- }).join('\n')];
4095
+ return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4074
4096
  });
4075
4097
  });
4076
4098
  }
@@ -4080,10 +4102,15 @@
4080
4102
  *
4081
4103
  * @private internal utility of `createPipelineExecutor`
4082
4104
  */
4083
- function getExamplesForTemplate(template) {
4105
+ function getKnowledgeForTask(options) {
4084
4106
  return __awaiter(this, void 0, void 0, function () {
4107
+ var preparedPipeline;
4085
4108
  return __generator(this, function (_a) {
4086
- return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4109
+ preparedPipeline = options.preparedPipeline, options.task;
4110
+ return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4111
+ var content = _a.content;
4112
+ return "- ".concat(content);
4113
+ }).join('\n')];
4087
4114
  });
4088
4115
  });
4089
4116
  }
@@ -4093,21 +4120,21 @@
4093
4120
  *
4094
4121
  * @private internal utility of `createPipelineExecutor`
4095
4122
  */
4096
- function getReservedParametersForTemplate(options) {
4123
+ function getReservedParametersForTask(options) {
4097
4124
  return __awaiter(this, void 0, void 0, function () {
4098
- var preparedPipeline, template, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
4125
+ var preparedPipeline, task, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
4099
4126
  var e_1, _a;
4100
4127
  return __generator(this, function (_b) {
4101
4128
  switch (_b.label) {
4102
4129
  case 0:
4103
- preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
4104
- return [4 /*yield*/, getContextForTemplate()];
4130
+ preparedPipeline = options.preparedPipeline, task = options.task, pipelineIdentification = options.pipelineIdentification;
4131
+ return [4 /*yield*/, getContextForTask()];
4105
4132
  case 1:
4106
4133
  context = _b.sent();
4107
- return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
4134
+ return [4 /*yield*/, getKnowledgeForTask({ preparedPipeline: preparedPipeline, task: task })];
4108
4135
  case 2:
4109
4136
  knowledge = _b.sent();
4110
- return [4 /*yield*/, getExamplesForTemplate()];
4137
+ return [4 /*yield*/, getExamplesForTask()];
4111
4138
  case 3:
4112
4139
  examples = _b.sent();
4113
4140
  currentDate = new Date().toISOString();
@@ -4150,31 +4177,31 @@
4150
4177
  *
4151
4178
  * @private internal utility of `createPipelineExecutor`
4152
4179
  */
4153
- function executeTemplate(options) {
4180
+ function executeTask(options) {
4154
4181
  return __awaiter(this, void 0, void 0, function () {
4155
- 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;
4182
+ 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;
4156
4183
  var e_1, _g, _h;
4157
4184
  return __generator(this, function (_j) {
4158
4185
  switch (_j.label) {
4159
4186
  case 0:
4160
- 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;
4161
- name = "pipeline-executor-frame-".concat(currentTemplate.name);
4162
- title = currentTemplate.title;
4163
- priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
4187
+ 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;
4188
+ name = "pipeline-executor-frame-".concat(currentTask.name);
4189
+ title = currentTask.title;
4190
+ priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
4164
4191
  return [4 /*yield*/, onProgress({
4165
4192
  name: name,
4166
4193
  title: title,
4167
4194
  isStarted: false,
4168
4195
  isDone: false,
4169
- templateType: currentTemplate.templateType,
4170
- parameterName: currentTemplate.resultingParameterName,
4196
+ taskType: currentTask.taskType,
4197
+ parameterName: currentTask.resultingParameterName,
4171
4198
  parameterValue: null,
4172
4199
  // <- [🍸]
4173
4200
  })];
4174
4201
  case 1:
4175
4202
  _j.sent();
4176
- usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
4177
- dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
4203
+ usedParameterNames = extractParameterNamesFromTask(currentTask);
4204
+ dependentParameterNames = new Set(currentTask.dependentParameterNames);
4178
4205
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4179
4206
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
4180
4207
  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)
@@ -4185,9 +4212,9 @@
4185
4212
  }
4186
4213
  _c = (_b = Object).freeze;
4187
4214
  _d = [{}];
4188
- return [4 /*yield*/, getReservedParametersForTemplate({
4215
+ return [4 /*yield*/, getReservedParametersForTask({
4189
4216
  preparedPipeline: preparedPipeline,
4190
- template: currentTemplate,
4217
+ task: currentTask,
4191
4218
  pipelineIdentification: pipelineIdentification,
4192
4219
  })];
4193
4220
  case 2:
@@ -4205,11 +4232,11 @@
4205
4232
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4206
4233
  // Houston, we have a problem
4207
4234
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
4208
- 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 "); }));
4235
+ 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 "); }));
4209
4236
  }
4210
4237
  };
4211
4238
  try {
4212
- // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
4239
+ // Note: [2] Check that all used parameters are defined and removing unused parameters for this task
4213
4240
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4214
4241
  for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4215
4242
  parameterName = _f.value;
@@ -4225,18 +4252,16 @@
4225
4252
  }
4226
4253
  // 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
4227
4254
  Object.freeze(parameters);
4228
- maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
4229
- jokerParameterNames = currentTemplate.jokerParameterNames || [];
4230
- preparedContent = (currentTemplate.preparedContent || '{content}')
4231
- .split('{content}')
4232
- .join(currentTemplate.content);
4255
+ maxAttempts = currentTask.taskType === 'DIALOG_TASK' ? Infinity : maxExecutionAttempts;
4256
+ jokerParameterNames = currentTask.jokerParameterNames || [];
4257
+ preparedContent = (currentTask.preparedContent || '{content}').split('{content}').join(currentTask.content);
4233
4258
  return [4 /*yield*/, executeFormatSubvalues({
4234
4259
  jokerParameterNames: jokerParameterNames,
4235
4260
  priority: priority,
4236
4261
  maxAttempts: maxAttempts,
4237
4262
  preparedContent: preparedContent,
4238
4263
  parameters: parameters,
4239
- template: currentTemplate,
4264
+ task: currentTask,
4240
4265
  preparedPipeline: preparedPipeline,
4241
4266
  tools: tools,
4242
4267
  $executionReport: $executionReport,
@@ -4249,15 +4274,15 @@
4249
4274
  title: title,
4250
4275
  isStarted: true,
4251
4276
  isDone: true,
4252
- templateType: currentTemplate.templateType,
4253
- parameterName: currentTemplate.resultingParameterName,
4277
+ taskType: currentTask.taskType,
4278
+ parameterName: currentTask.resultingParameterName,
4254
4279
  parameterValue: resultString,
4255
4280
  // <- [🍸]
4256
4281
  })];
4257
4282
  case 4:
4258
4283
  _j.sent();
4259
4284
  return [2 /*return*/, Object.freeze((_h = {},
4260
- _h[currentTemplate.resultingParameterName] =
4285
+ _h[currentTask.resultingParameterName] =
4261
4286
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
4262
4287
  resultString,
4263
4288
  _h))];
@@ -4284,7 +4309,7 @@
4284
4309
  var _loop_1 = function (parameter) {
4285
4310
  if (parametersToPass[parameter.name] === undefined) {
4286
4311
  // [4]
4287
- $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
4312
+ $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
4288
4313
  return "continue";
4289
4314
  }
4290
4315
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -4319,7 +4344,7 @@
4319
4344
  */
4320
4345
  function executePipeline(options) {
4321
4346
  return __awaiter(this, void 0, void 0, function () {
4322
- 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;
4347
+ 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;
4323
4348
  var e_1, _f, e_2, _g;
4324
4349
  return __generator(this, function (_h) {
4325
4350
  switch (_h.label) {
@@ -4371,7 +4396,7 @@
4371
4396
  case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
4372
4397
  isSuccessful: false,
4373
4398
  errors: __spreadArray([
4374
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
4399
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
4375
4400
  ], __read(errors), false).map(serializeError),
4376
4401
  warnings: [],
4377
4402
  executionReport: executionReport,
@@ -4419,7 +4444,7 @@
4419
4444
  case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
4420
4445
  isSuccessful: false,
4421
4446
  errors: __spreadArray([
4422
- new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4447
+ new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4423
4448
  ], __read(errors), false).map(serializeError),
4424
4449
  warnings: warnings.map(serializeError),
4425
4450
  executionReport: executionReport,
@@ -4473,11 +4498,11 @@
4473
4498
  var name = _a.name;
4474
4499
  return name;
4475
4500
  });
4476
- unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.templates), false);
4501
+ unresovedTasks_1 = __spreadArray([], __read(preparedPipeline.tasks), false);
4477
4502
  resolving_1 = [];
4478
4503
  loopLimit = LOOP_LIMIT;
4479
4504
  _loop_2 = function () {
4480
- var currentTemplate, work_1;
4505
+ var currentTask, work_1;
4481
4506
  return __generator(this, function (_k) {
4482
4507
  switch (_k.label) {
4483
4508
  case 0:
@@ -4485,31 +4510,41 @@
4485
4510
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
4486
4511
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
4487
4512
  }
4488
- currentTemplate = unresovedTemplates_1.find(function (template) {
4489
- return template.dependentParameterNames.every(function (name) {
4513
+ currentTask = unresovedTasks_1.find(function (task) {
4514
+ return task.dependentParameterNames.every(function (name) {
4490
4515
  return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
4491
4516
  });
4492
4517
  });
4493
- if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
4518
+ if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
4494
4519
  throw new UnexpectedError(
4495
4520
  // TODO: [🐎] DRY
4496
- 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
4521
+ 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
4497
4522
  .map(function (_a) {
4498
4523
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
4499
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
4500
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
4524
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
4525
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
4501
4526
  .join(' and '));
4502
4527
  })
4503
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameterNames_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
4528
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
4529
+ .filter(function (name) {
4530
+ return !RESERVED_PARAMETER_NAMES.includes(name);
4531
+ })
4532
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
4533
+ .join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
4534
+ .filter(function (name) {
4535
+ return RESERVED_PARAMETER_NAMES.includes(name);
4536
+ })
4537
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
4538
+ .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
4504
4539
  case 1:
4505
- if (!!currentTemplate) return [3 /*break*/, 3];
4540
+ if (!!currentTask) return [3 /*break*/, 3];
4506
4541
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
4507
4542
  case 2:
4508
4543
  /* [🤹‍♂️] */ _k.sent();
4509
4544
  return [3 /*break*/, 4];
4510
4545
  case 3:
4511
- unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
4512
- work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4546
+ unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
4547
+ work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4513
4548
  if (isReturned) {
4514
4549
  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)
4515
4550
  .split('\n')
@@ -4519,16 +4554,16 @@
4519
4554
  if (onProgress) {
4520
4555
  onProgress(progress);
4521
4556
  }
4522
- }, $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 "); }) }))
4557
+ }, $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 "); }) }))
4523
4558
  .then(function (newParametersToPass) {
4524
4559
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
4525
- resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
4560
+ resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
4526
4561
  })
4527
4562
  .then(function () {
4528
4563
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
4529
4564
  });
4530
4565
  // <- Note: Errors are catched here [3]
4531
- // 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
4566
+ // 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
4532
4567
  resolving_1.push(work_1);
4533
4568
  _k.label = 4;
4534
4569
  case 4: return [2 /*return*/];
@@ -4537,7 +4572,7 @@
4537
4572
  };
4538
4573
  _h.label = 21;
4539
4574
  case 21:
4540
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
4575
+ if (!(unresovedTasks_1.length > 0)) return [3 /*break*/, 23];
4541
4576
  return [5 /*yield**/, _loop_2()];
4542
4577
  case 22:
4543
4578
  _h.sent();
@@ -5078,6 +5113,9 @@
5078
5113
  normalizedName = normalizedName.replace(/-$/, '');
5079
5114
  return normalizedName;
5080
5115
  }
5116
+ /**
5117
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5118
+ */
5081
5119
 
5082
5120
  /**
5083
5121
  * Creates unique name for the source
@@ -5449,7 +5487,7 @@
5449
5487
  */
5450
5488
  function clonePipeline(pipeline) {
5451
5489
  // Note: Not using spread operator (...) because @@@
5452
- 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;
5490
+ 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;
5453
5491
  return {
5454
5492
  pipelineUrl: pipelineUrl,
5455
5493
  sourceFile: sourceFile,
@@ -5458,7 +5496,7 @@
5458
5496
  description: description,
5459
5497
  formfactorName: formfactorName,
5460
5498
  parameters: parameters,
5461
- templates: templates,
5499
+ tasks: tasks,
5462
5500
  knowledgeSources: knowledgeSources,
5463
5501
  knowledgePieces: knowledgePieces,
5464
5502
  personas: personas,
@@ -5474,17 +5512,17 @@
5474
5512
  *
5475
5513
  * @public exported from `@promptbook/core`
5476
5514
  */
5477
- function prepareTemplates(pipeline, tools, options) {
5515
+ function prepareTasks(pipeline, tools, options) {
5478
5516
  return __awaiter(this, void 0, void 0, function () {
5479
- var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
5517
+ var _a, maxParallelCount, tasks, knowledgePiecesCount, tasksPrepared;
5480
5518
  var _this = this;
5481
5519
  return __generator(this, function (_b) {
5482
5520
  switch (_b.label) {
5483
5521
  case 0:
5484
5522
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
5485
- templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5486
- templatesPrepared = new Array(templates.length);
5487
- 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 () {
5523
+ tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5524
+ tasksPrepared = new Array(tasks.length);
5525
+ return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
5488
5526
  var dependentParameterNames, preparedContent, preparedTemplate;
5489
5527
  return __generator(this, function (_a) {
5490
5528
  dependentParameterNames = template.dependentParameterNames;
@@ -5497,13 +5535,13 @@
5497
5535
  ], false);
5498
5536
  }
5499
5537
  preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
5500
- templatesPrepared[index] = preparedTemplate;
5538
+ tasksPrepared[index] = preparedTemplate;
5501
5539
  return [2 /*return*/];
5502
5540
  });
5503
5541
  }); })];
5504
5542
  case 1:
5505
5543
  _b.sent();
5506
- return [2 /*return*/, { templatesPrepared: templatesPrepared }];
5544
+ return [2 /*return*/, { tasksPrepared: tasksPrepared }];
5507
5545
  }
5508
5546
  });
5509
5547
  });
@@ -5511,7 +5549,7 @@
5511
5549
  /**
5512
5550
  * TODO: [🧠] Add context to each template (if missing)
5513
5551
  * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
5514
- * TODO: [♨][main] !!! Prepare index the examples and maybe templates
5552
+ * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
5515
5553
  * TODO: Write tests for `preparePipeline`
5516
5554
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
5517
5555
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -5528,12 +5566,12 @@
5528
5566
  */
5529
5567
  function preparePipeline(pipeline, tools, options) {
5530
5568
  return __awaiter(this, void 0, void 0, function () {
5531
- var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, templates,
5569
+ var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, tasks,
5532
5570
  /*
5533
5571
  <- TODO: [🧠][🪑] `promptbookVersion` */
5534
5572
  knowledgeSources /*
5535
5573
  <- TODO: [🧊] `knowledgePieces` */, personas /*
5536
- <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, templatesPrepared /* TODO: parameters: parametersPrepared*/;
5574
+ <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
5537
5575
  var _this = this;
5538
5576
  return __generator(this, function (_c) {
5539
5577
  switch (_c.label) {
@@ -5542,7 +5580,7 @@
5542
5580
  return [2 /*return*/, pipeline];
5543
5581
  }
5544
5582
  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;
5545
- parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5583
+ parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5546
5584
  if (tools === undefined || tools.llm === undefined) {
5547
5585
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
5548
5586
  }
@@ -5585,9 +5623,9 @@
5585
5623
  case 2:
5586
5624
  partialknowledgePiecesPrepared = _c.sent();
5587
5625
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
5588
- return [4 /*yield*/, prepareTemplates({
5626
+ return [4 /*yield*/, prepareTasks({
5589
5627
  parameters: parameters,
5590
- templates: templates,
5628
+ tasks: tasks,
5591
5629
  knowledgePiecesCount: knowledgePiecesPrepared.length,
5592
5630
  }, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), {
5593
5631
  rootDirname: rootDirname,
@@ -5595,12 +5633,12 @@
5595
5633
  isVerbose: isVerbose,
5596
5634
  })];
5597
5635
  case 3:
5598
- templatesPrepared = (_c.sent()).templatesPrepared;
5636
+ tasksPrepared = (_c.sent()).tasksPrepared;
5599
5637
  // ----- /Templates preparation -----
5600
5638
  // Note: Count total usage
5601
5639
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
5602
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
5603
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
5640
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
5641
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
5604
5642
  knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
5605
5643
  }
5606
5644
  });
@@ -5630,7 +5668,7 @@
5630
5668
  * BOILERPLATE command can be used in:
5631
5669
  */
5632
5670
  isUsedInPipelineHead: true,
5633
- isUsedInPipelineTemplate: false,
5671
+ isUsedInPipelineTask: false,
5634
5672
  /**
5635
5673
  * Description of the KNOWLEDGE command
5636
5674
  */
@@ -5708,36 +5746,36 @@
5708
5746
  */
5709
5747
 
5710
5748
  /**
5711
- * Template type describes the way how the template is templated
5749
+ * Section type describes the way how the section is sectiond
5712
5750
  *
5713
- * @see https://github.com/webgptorg/promptbook#template-type
5714
5751
  * @public exported from `@promptbook/core`
5715
5752
  */
5716
- var TemplateTypes = [
5717
- 'PROMPT_TEMPLATE',
5718
- 'SIMPLE_TEMPLATE',
5719
- 'SCRIPT_TEMPLATE',
5720
- 'DIALOG_TEMPLATE',
5753
+ var SectionTypes = [
5754
+ 'PROMPT_TASK',
5755
+ 'SIMPLE_TASK',
5756
+ 'SCRIPT_TASK',
5757
+ 'DIALOG_TASK',
5721
5758
  'EXAMPLE',
5722
5759
  'KNOWLEDGE',
5723
5760
  'INSTRUMENT',
5724
5761
  'ACTION',
5725
5762
  // <- [🅱]
5726
5763
  ];
5764
+ // <- TODO: !!!!!! Make alongside `SectionType` the `TaskType`, `TaskType` + [⛱] and ACRY
5727
5765
 
5728
5766
  /**
5729
- * Parses the template command
5767
+ * Parses the section command
5730
5768
  *
5731
5769
  * @see `documentationUrl` for more details
5732
5770
  * @private within the commands folder
5733
5771
  */
5734
- var templateCommandParser = {
5772
+ var sectionCommandParser = {
5735
5773
  /**
5736
5774
  * Name of the command
5737
5775
  */
5738
- name: 'TEMPLATE',
5776
+ name: 'SECTION',
5739
5777
  /**
5740
- * Aliases for the TEMPLATE command
5778
+ * Aliases for the SECTION command
5741
5779
  */
5742
5780
  aliasNames: [
5743
5781
  'PROMPT',
@@ -5751,24 +5789,24 @@
5751
5789
  'ACTION', // <- Note: [⛱]
5752
5790
  ],
5753
5791
  /**
5754
- * Aliases for the TEMPLATE command
5792
+ * Aliases for the SECTION command
5755
5793
  */
5756
- deprecatedNames: ['BLOCK', 'EXECUTE'],
5794
+ deprecatedNames: ['TEMPLATE', 'BLOCK', 'EXECUTE'],
5757
5795
  /**
5758
5796
  * BOILERPLATE command can be used in:
5759
5797
  */
5760
5798
  isUsedInPipelineHead: false,
5761
- isUsedInPipelineTemplate: true,
5799
+ isUsedInPipelineTask: true,
5762
5800
  /**
5763
- * Description of the TEMPLATE command
5801
+ * Description of the SECTION command
5764
5802
  */
5765
- description: "What should the code template template do",
5803
+ description: "Defines the purpose of the markdown section - if its a task and which type or something else",
5766
5804
  /**
5767
5805
  * Link to documentation
5768
5806
  */
5769
5807
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/64',
5770
5808
  /**
5771
- * Example usages of the TEMPLATE command
5809
+ * Example usages of the SECTION command
5772
5810
  */
5773
5811
  examples: [
5774
5812
  // Short form:
@@ -5783,101 +5821,100 @@
5783
5821
  'ACTION',
5784
5822
  // -----------------
5785
5823
  // Recommended (reversed) form:
5786
- 'PROMPT TEMPLATE',
5787
- 'SIMPLE TEMPLATE',
5788
- 'SCRIPT TEMPLATE',
5789
- 'DIALOG TEMPLATE',
5824
+ 'PROMPT SECTION',
5825
+ 'SIMPLE SECTION',
5826
+ 'SCRIPT SECTION',
5827
+ 'DIALOG SECTION',
5790
5828
  // <- [🅱]
5791
- 'SAMPLE TEMPLATE',
5792
- 'KNOWLEDGE TEMPLATE',
5793
- 'INSTRUMENT TEMPLATE',
5794
- 'ACTION TEMPLATE',
5829
+ 'EXAMPLE SECTION',
5830
+ 'KNOWLEDGE SECTION',
5831
+ 'INSTRUMENT SECTION',
5832
+ 'ACTION SECTION',
5795
5833
  // -----------------
5796
5834
  // Standard form:
5797
- 'TEMPLATE PROMPT',
5798
- 'TEMPLATE SIMPLE',
5799
- 'TEMPLATE SCRIPT',
5800
- 'TEMPLATE DIALOG',
5835
+ 'SECTION PROMPT',
5836
+ 'SECTION SIMPLE',
5837
+ 'SECTION SCRIPT',
5838
+ 'SECTION DIALOG',
5801
5839
  // <- [🅱]
5802
- 'SAMPLE TEMPLATE',
5803
- 'KNOWLEDGE TEMPLATE',
5804
- 'INSTRUMENT TEMPLATE',
5805
- 'ACTION TEMPLATE',
5840
+ 'SECTION EXAMPLE',
5841
+ 'SECTION KNOWLEDGE',
5842
+ 'SECTION INSTRUMENT',
5843
+ 'SECTION ACTION',
5806
5844
  ],
5807
5845
  // TODO: [♓️] order: -10 /* <- Note: Putting before other commands */
5808
5846
  /**
5809
- * Parses the TEMPLATE command
5847
+ * Parses the SECTION command
5810
5848
  */
5811
5849
  parse: function (input) {
5812
5850
  var normalized = input.normalized;
5813
5851
  normalized = normalized.split('SAMPLE').join('EXAMPLE');
5814
- var templateTypes = TemplateTypes.filter(function (templateType) {
5815
- return normalized.includes(templateType.split('_TEMPLATE').join(''));
5816
- });
5817
- if (templateTypes.length !== 1) {
5818
- 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 "); }));
5852
+ normalized = normalized.split('EXECUTE_').join('');
5853
+ var taskTypes = SectionTypes.filter(function (taskType) { return normalized.includes(taskType.split('_TASK').join('')); });
5854
+ if (taskTypes.length !== 1) {
5855
+ 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 "); }));
5819
5856
  }
5820
- var templateType = templateTypes[0];
5857
+ var taskType = taskTypes[0];
5821
5858
  return {
5822
- type: 'TEMPLATE',
5823
- templateType: templateType,
5859
+ type: 'SECTION',
5860
+ taskType: taskType,
5824
5861
  };
5825
5862
  },
5826
5863
  /**
5827
- * Apply the TEMPLATE command to the `pipelineJson`
5864
+ * Apply the SECTION command to the `pipelineJson`
5828
5865
  *
5829
- * Note: `$` is used to indicate that this function mutates given `templateJson`
5866
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
5830
5867
  */
5831
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
5832
- if ($templateJson.isTemplateTypeSet === true) {
5833
- throw new ParseError(spaceTrim__default["default"]("\n Template type is already defined in the template.\n It can be defined only once.\n "));
5868
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
5869
+ if ($taskJson.isSectionTypeSet === true) {
5870
+ throw new ParseError(spaceTrim__default["default"]("\n Section type is already defined in the section.\n It can be defined only once.\n "));
5834
5871
  }
5835
- $templateJson.isTemplateTypeSet = true;
5872
+ $taskJson.isSectionTypeSet = true;
5836
5873
  // TODO: [🍧] Rearrange better - but at bottom and unwrap from function
5837
5874
  var expectResultingParameterName = function () {
5838
- if ($templateJson.resultingParameterName) {
5875
+ if ($taskJson.resultingParameterName) {
5839
5876
  return;
5840
5877
  }
5841
- throw new ParseError(" Template section must end with -> {parameterName}");
5878
+ throw new ParseError("Task section and example section must end with return statement -> {parameterName}");
5842
5879
  };
5843
- if ($templateJson.content === undefined) {
5844
- throw new UnexpectedError("Content is missing in the templateJson - probbably commands are applied in wrong order");
5880
+ if ($taskJson.content === undefined) {
5881
+ throw new UnexpectedError("Content is missing in the taskJson - probbably commands are applied in wrong order");
5845
5882
  }
5846
- if (command.templateType === 'EXAMPLE') {
5883
+ if (command.taskType === 'EXAMPLE') {
5847
5884
  expectResultingParameterName();
5848
- var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $templateJson.resultingParameterName; });
5885
+ var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $taskJson.resultingParameterName; });
5849
5886
  if (parameter === undefined) {
5850
- throw new ParseError("Can not find parameter {".concat($templateJson.resultingParameterName, "} to assign example value on it"));
5887
+ throw new ParseError("Can not find parameter {".concat($taskJson.resultingParameterName, "} to assign example value on it"));
5851
5888
  }
5852
5889
  parameter.exampleValues = parameter.exampleValues || [];
5853
- parameter.exampleValues.push($templateJson.content);
5854
- $templateJson.isTemplate = false;
5890
+ parameter.exampleValues.push($taskJson.content);
5891
+ $taskJson.isTask = false;
5855
5892
  return;
5856
5893
  }
5857
- if (command.templateType === 'KNOWLEDGE') {
5894
+ if (command.taskType === 'KNOWLEDGE') {
5858
5895
  knowledgeCommandParser.$applyToPipelineJson({
5859
5896
  type: 'KNOWLEDGE',
5860
- sourceContent: $templateJson.content, // <- TODO: [🐝][main] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5897
+ sourceContent: $taskJson.content, // <- TODO: [🐝][main] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5861
5898
  }, $pipelineJson);
5862
- $templateJson.isTemplate = false;
5899
+ $taskJson.isTask = false;
5863
5900
  return;
5864
5901
  }
5865
- if (command.templateType === 'ACTION') {
5902
+ if (command.taskType === 'ACTION') {
5866
5903
  console.error(new NotYetImplementedError('Actions are not implemented yet'));
5867
- $templateJson.isTemplate = false;
5904
+ $taskJson.isTask = false;
5868
5905
  return;
5869
5906
  }
5870
- if (command.templateType === 'INSTRUMENT') {
5907
+ if (command.taskType === 'INSTRUMENT') {
5871
5908
  console.error(new NotYetImplementedError('Instruments are not implemented yet'));
5872
- $templateJson.isTemplate = false;
5909
+ $taskJson.isTask = false;
5873
5910
  return;
5874
5911
  }
5875
5912
  expectResultingParameterName();
5876
- $templateJson.templateType = command.templateType;
5877
- $templateJson.isTemplate = true;
5913
+ $taskJson.taskType = command.taskType;
5914
+ $taskJson.isTask = true;
5878
5915
  },
5879
5916
  /**
5880
- * Converts the TEMPLATE command back to string
5917
+ * Converts the SECTION command back to string
5881
5918
  *
5882
5919
  * Note: This is used in `pipelineJsonToString` utility
5883
5920
  */
@@ -5885,11 +5922,11 @@
5885
5922
  return "---"; // <- TODO: [🛋] Implement
5886
5923
  },
5887
5924
  /**
5888
- * Reads the TEMPLATE command from the `TemplateJson`
5925
+ * Reads the SECTION command from the `TaskJson`
5889
5926
  *
5890
5927
  * Note: This is used in `pipelineJsonToString` utility
5891
5928
  */
5892
- takeFromTemplateJson: function ($templateJson) {
5929
+ takeFromTaskJson: function ($taskJson) {
5893
5930
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5894
5931
  },
5895
5932
  };
@@ -5897,8 +5934,8 @@
5897
5934
  * Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
5898
5935
  * 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
5899
5936
  * - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
5900
- * 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
5901
- * - KNOWLEDGE TEMPLATE
5937
+ * 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
5938
+ * - KNOWLEDGE SECTION
5902
5939
  *
5903
5940
  * ```
5904
5941
  * Look at https://en.wikipedia.org/wiki/Artificial_intelligence
@@ -5926,7 +5963,7 @@
5926
5963
  * BOILERPLATE command can be used in:
5927
5964
  */
5928
5965
  isUsedInPipelineHead: true,
5929
- isUsedInPipelineTemplate: true,
5966
+ isUsedInPipelineTask: true,
5930
5967
  /**
5931
5968
  * Description of the BOILERPLATE command
5932
5969
  */
@@ -5967,9 +6004,9 @@
5967
6004
  /**
5968
6005
  * Apply the BOILERPLATE command to the `pipelineJson`
5969
6006
  *
5970
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6007
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
5971
6008
  */
5972
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6009
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
5973
6010
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
5974
6011
  },
5975
6012
  /**
@@ -5989,11 +6026,11 @@
5989
6026
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
5990
6027
  },
5991
6028
  /**
5992
- * Reads the BOILERPLATE command from the `TemplateJson`
6029
+ * Reads the BOILERPLATE command from the `TaskJson`
5993
6030
  *
5994
6031
  * Note: This is used in `pipelineJsonToString` utility
5995
6032
  */
5996
- takeFromTemplateJson: function ($templateJson) {
6033
+ takeFromTaskJson: function ($taskJson) {
5997
6034
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
5998
6035
  },
5999
6036
  };
@@ -6014,7 +6051,7 @@
6014
6051
  * BOILERPLATE command can be used in:
6015
6052
  */
6016
6053
  isUsedInPipelineHead: true,
6017
- isUsedInPipelineTemplate: false,
6054
+ isUsedInPipelineTask: false,
6018
6055
  /**
6019
6056
  * Description of the BOOK_VERSION command
6020
6057
  */
@@ -6168,7 +6205,7 @@
6168
6205
  * BOILERPLATE command can be used in:
6169
6206
  */
6170
6207
  isUsedInPipelineHead: false,
6171
- isUsedInPipelineTemplate: true,
6208
+ isUsedInPipelineTask: true,
6172
6209
  /**
6173
6210
  * Description of the FORMAT command
6174
6211
  */
@@ -6264,24 +6301,24 @@
6264
6301
  /**
6265
6302
  * Apply the FORMAT command to the `pipelineJson`
6266
6303
  *
6267
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6304
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6268
6305
  */
6269
- $applyToTemplateJson: function (command, $templateJson) {
6306
+ $applyToTaskJson: function (command, $taskJson) {
6270
6307
  // eslint-disable-next-line no-case-declarations
6271
6308
  var unit = command.unit.toLowerCase();
6272
- $templateJson.expectations = $templateJson.expectations || {};
6273
- $templateJson.expectations[unit] = $templateJson.expectations[unit] || {};
6309
+ $taskJson.expectations = $taskJson.expectations || {};
6310
+ $taskJson.expectations[unit] = $taskJson.expectations[unit] || {};
6274
6311
  if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
6275
- if ($templateJson.expectations[unit].min !== undefined) {
6276
- throw new ParseError("Already defined minumum ".concat($templateJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6312
+ if ($taskJson.expectations[unit].min !== undefined) {
6313
+ throw new ParseError("Already defined minumum ".concat($taskJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6277
6314
  }
6278
- $templateJson.expectations[unit].min = command.amount;
6315
+ $taskJson.expectations[unit].min = command.amount;
6279
6316
  } /* not else */
6280
6317
  if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
6281
- if ($templateJson.expectations[unit].max !== undefined) {
6282
- throw new ParseError("Already defined maximum ".concat($templateJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6318
+ if ($taskJson.expectations[unit].max !== undefined) {
6319
+ throw new ParseError("Already defined maximum ".concat($taskJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6283
6320
  }
6284
- $templateJson.expectations[unit].max = command.amount;
6321
+ $taskJson.expectations[unit].max = command.amount;
6285
6322
  }
6286
6323
  },
6287
6324
  /**
@@ -6293,11 +6330,11 @@
6293
6330
  return "---"; // <- TODO: [🛋] Implement
6294
6331
  },
6295
6332
  /**
6296
- * Reads the FORMAT command from the `TemplateJson`
6333
+ * Reads the FORMAT command from the `TaskJson`
6297
6334
  *
6298
6335
  * Note: This is used in `pipelineJsonToString` utility
6299
6336
  */
6300
- takeFromTemplateJson: function ($templateJson) {
6337
+ takeFromTaskJson: function ($taskJson) {
6301
6338
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6302
6339
  },
6303
6340
  };
@@ -6504,7 +6541,7 @@
6504
6541
  * FOREACH command can be used in:
6505
6542
  */
6506
6543
  isUsedInPipelineHead: false,
6507
- isUsedInPipelineTemplate: true,
6544
+ isUsedInPipelineTask: true,
6508
6545
  /**
6509
6546
  * Description of the FOREACH command
6510
6547
  */
@@ -6603,13 +6640,13 @@
6603
6640
  /**
6604
6641
  * Apply the FOREACH command to the `pipelineJson`
6605
6642
  *
6606
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6643
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6607
6644
  */
6608
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6645
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
6609
6646
  var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName, inputSubparameterNames = command.inputSubparameterNames, outputSubparameterName = command.outputSubparameterName;
6610
6647
  // TODO: [🍭] Detect double use
6611
6648
  // TODO: [🍭] Detect usage with JOKER and don't allow it
6612
- $templateJson.foreach = {
6649
+ $taskJson.foreach = {
6613
6650
  formatName: formatName,
6614
6651
  subformatName: subformatName,
6615
6652
  parameterName: parameterName,
@@ -6627,11 +6664,11 @@
6627
6664
  return "---"; // <- TODO: [🛋] Implement
6628
6665
  },
6629
6666
  /**
6630
- * Reads the FOREACH command from the `TemplateJson`
6667
+ * Reads the FOREACH command from the `TaskJson`
6631
6668
  *
6632
6669
  * Note: This is used in `pipelineJsonToString` utility
6633
6670
  */
6634
- takeFromTemplateJson: function ($templateJson) {
6671
+ takeFromTaskJson: function ($taskJson) {
6635
6672
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6636
6673
  },
6637
6674
  };
@@ -6654,7 +6691,7 @@
6654
6691
  * BOILERPLATE command can be used in:
6655
6692
  */
6656
6693
  isUsedInPipelineHead: false,
6657
- isUsedInPipelineTemplate: true,
6694
+ isUsedInPipelineTask: true,
6658
6695
  /**
6659
6696
  * Description of the FORMAT command
6660
6697
  */
@@ -6685,13 +6722,13 @@
6685
6722
  /**
6686
6723
  * Apply the FORMAT command to the `pipelineJson`
6687
6724
  *
6688
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6725
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6689
6726
  */
6690
- $applyToTemplateJson: function (command, $templateJson) {
6691
- if ($templateJson.format !== undefined && command.format !== $templateJson.format) {
6692
- throw new ParseError("Format format is already defined to \"".concat($templateJson.format, "\".\n Now you try to redefine it by \"").concat(command.format, "\""));
6727
+ $applyToTaskJson: function (command, $taskJson) {
6728
+ if ($taskJson.format !== undefined && command.format !== $taskJson.format) {
6729
+ throw new ParseError("Format format is already defined to \"".concat($taskJson.format, "\".\n Now you try to redefine it by \"").concat(command.format, "\""));
6693
6730
  }
6694
- $templateJson.format = command.format;
6731
+ $taskJson.format = command.format;
6695
6732
  },
6696
6733
  /**
6697
6734
  * Converts the FORMAT command back to string
@@ -6702,11 +6739,11 @@
6702
6739
  return "---"; // <- TODO: [🛋] Implement
6703
6740
  },
6704
6741
  /**
6705
- * Reads the FORMAT command from the `TemplateJson`
6742
+ * Reads the FORMAT command from the `TaskJson`
6706
6743
  *
6707
6744
  * Note: This is used in `pipelineJsonToString` utility
6708
6745
  */
6709
- takeFromTemplateJson: function ($templateJson) {
6746
+ takeFromTaskJson: function ($taskJson) {
6710
6747
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6711
6748
  },
6712
6749
  };
@@ -6716,12 +6753,43 @@
6716
6753
  *
6717
6754
  * @public exported from `@promptbook/core`
6718
6755
  */
6719
- var ChatFormfactorDefinition = {
6720
- name: 'CHAT',
6756
+ var ChatbotFormfactorDefinition = {
6757
+ name: 'CHATBOT',
6758
+ aliasNames: ['CHAT'],
6721
6759
  description: "@@@",
6722
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6760
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/174",
6761
+ pipelineInterface: {
6762
+ inputParameterNames: ['previousTitle', 'previousConversationSummary', 'userMessage'],
6763
+ outputParameterNames: ['title', 'conversationSummary', 'chatbotResponse'],
6764
+ /*
6765
+ <- TODO: !!!!!! Change to full interfaces
6766
+
6767
+ - INPUT PARAMETER `{previousTitle}` Previous title of the conversation
6768
+ - INPUT PARAMETER `{previousConversationSummary}` Previous conversation summary
6769
+ - INPUT PARAMETER `{userMessage}` User message
6770
+ - OUTPUT PARAMETER `{title}` Title of the conversation
6771
+ - OUTPUT PARAMETER `{conversationSummary}` Summary of the conversation
6772
+ - OUTPUT PARAMETER `{chatbotResponse}` Chatbot response
6773
+
6774
+ */
6775
+ },
6723
6776
  };
6724
6777
 
6778
+ /**
6779
+ * @@@
6780
+ *
6781
+ * @see https://github.com/webgptorg/promptbook/discussions/171
6782
+ *
6783
+ * @public exported from `@promptbook/core`
6784
+ */
6785
+ var GENERIC_PIPELINE_INTERFACE = {
6786
+ inputParameterNames: [],
6787
+ outputParameterNames: [],
6788
+ };
6789
+ /**
6790
+ * Note: [💞] Ignore a discrepancy between file name and entity name
6791
+ */
6792
+
6725
6793
  /**
6726
6794
  * @@@
6727
6795
  *
@@ -6730,7 +6798,59 @@
6730
6798
  var GenericFormfactorDefinition = {
6731
6799
  name: 'GENERIC',
6732
6800
  description: "@@@",
6733
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6801
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/173",
6802
+ pipelineInterface: GENERIC_PIPELINE_INTERFACE,
6803
+ };
6804
+
6805
+ /**
6806
+ * Matcher is form of app that @@@
6807
+ *
6808
+ * @public exported from `@promptbook/core`
6809
+ */
6810
+ var MatcherFormfactorDefinition = {
6811
+ name: 'EXPERIMENTAL_MATCHER',
6812
+ description: "@@@",
6813
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
6814
+ pipelineInterface: {
6815
+ inputParameterNames: [
6816
+ /* @@@ */
6817
+ ],
6818
+ outputParameterNames: [
6819
+ /* @@@ */
6820
+ ],
6821
+ },
6822
+ };
6823
+
6824
+ /**
6825
+ * Sheets is form of app that @@@
6826
+ *
6827
+ * @public exported from `@promptbook/core`
6828
+ */
6829
+ var SheetsFormfactorDefinition = {
6830
+ name: 'SHEETS',
6831
+ description: "@@@",
6832
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/176",
6833
+ pipelineInterface: {
6834
+ inputParameterNames: ['inputSheet'],
6835
+ outputParameterNames: ['outputSheet'],
6836
+ },
6837
+ };
6838
+
6839
+ /**
6840
+ * Translator is form of app that @@@
6841
+ *
6842
+ * @public exported from `@promptbook/core`
6843
+ */
6844
+ var TranslatorFormfactorDefinition = {
6845
+ name: 'TRANSLATOR',
6846
+ description: "@@@",
6847
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/175",
6848
+ pipelineInterface: {
6849
+ inputParameterNames: ['inputMessage'],
6850
+ outputParameterNames: ['outputMessage'],
6851
+ // <- TODO: !!!!!! Maybe add {summary}
6852
+ // <- TODO: [🧠] maybe change to {inputText}, {inputText} / or make system for any name of first input and first outpur parameter
6853
+ },
6734
6854
  };
6735
6855
 
6736
6856
  /**
@@ -6738,7 +6858,16 @@
6738
6858
  *
6739
6859
  * @public exported from `@promptbook/core`
6740
6860
  */
6741
- var FORMFACTOR_DEFINITIONS = [GenericFormfactorDefinition, ChatFormfactorDefinition];
6861
+ var FORMFACTOR_DEFINITIONS = [
6862
+ GenericFormfactorDefinition,
6863
+ ChatbotFormfactorDefinition,
6864
+ TranslatorFormfactorDefinition,
6865
+ SheetsFormfactorDefinition,
6866
+ MatcherFormfactorDefinition,
6867
+ ];
6868
+ /**
6869
+ * Note: [💞] Ignore a discrepancy between file name and entity name
6870
+ */
6742
6871
 
6743
6872
  /**
6744
6873
  * Parses the formfactor command
@@ -6761,7 +6890,7 @@
6761
6890
  * FORMFACTOR command can be used in:
6762
6891
  */
6763
6892
  isUsedInPipelineHead: true,
6764
- isUsedInPipelineTemplate: false,
6893
+ isUsedInPipelineTask: false,
6765
6894
  /**
6766
6895
  * Description of the FORMFACTOR command
6767
6896
  */
@@ -6773,7 +6902,7 @@
6773
6902
  /**
6774
6903
  * Example usages of the FORMFACTOR command
6775
6904
  */
6776
- examples: ['FORMFACTOR Chat', 'FORMFACTOR Generic'],
6905
+ examples: ['FORMFACTOR Chatbot', 'FF Chat'],
6777
6906
  /**
6778
6907
  * Parses the FORMFACTOR command
6779
6908
  */
@@ -6782,16 +6911,19 @@
6782
6911
  if (args.length !== 1) {
6783
6912
  throw new ParseError("FORMFACTOR command requires exactly one argument");
6784
6913
  }
6785
- var formfactorName = args[0].toUpperCase();
6786
- if (!FORMFACTOR_DEFINITIONS.some(function (definition) { return definition.name === formfactorName; })) {
6787
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown formfactor name \"".concat(formfactorName, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
6914
+ var formfactorNameCandidate = args[0].toUpperCase();
6915
+ var formfactor = FORMFACTOR_DEFINITIONS.find(function (definition) {
6916
+ return __spreadArray([definition.name], __read(__assign({ aliasNames: [] }, definition).aliasNames), false).includes(formfactorNameCandidate);
6917
+ });
6918
+ if (formfactor === undefined) {
6919
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown formfactor name \"".concat(formfactorNameCandidate, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
6788
6920
  var name = _a.name;
6789
6921
  return "- ".concat(name);
6790
6922
  }).join('\n')), "\n "); }));
6791
6923
  }
6792
6924
  return {
6793
6925
  type: 'FORMFACTOR',
6794
- formfactorName: formfactorName,
6926
+ formfactorName: formfactor.name,
6795
6927
  };
6796
6928
  },
6797
6929
  /**
@@ -6840,7 +6972,7 @@
6840
6972
  * BOILERPLATE command can be used in:
6841
6973
  */
6842
6974
  isUsedInPipelineHead: false,
6843
- isUsedInPipelineTemplate: true,
6975
+ isUsedInPipelineTask: true,
6844
6976
  /**
6845
6977
  * Description of the JOKER command
6846
6978
  */
@@ -6871,11 +7003,11 @@
6871
7003
  /**
6872
7004
  * Apply the JOKER command to the `pipelineJson`
6873
7005
  *
6874
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7006
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6875
7007
  */
6876
- $applyToTemplateJson: function (command, $templateJson) {
6877
- $templateJson.jokerParameterNames = $templateJson.jokerParameterNames || [];
6878
- $templateJson.jokerParameterNames.push(command.parameterName);
7008
+ $applyToTaskJson: function (command, $taskJson) {
7009
+ $taskJson.jokerParameterNames = $taskJson.jokerParameterNames || [];
7010
+ $taskJson.jokerParameterNames.push(command.parameterName);
6879
7011
  },
6880
7012
  /**
6881
7013
  * Converts the JOKER command back to string
@@ -6886,11 +7018,11 @@
6886
7018
  return "---"; // <- TODO: [🛋] Implement
6887
7019
  },
6888
7020
  /**
6889
- * Reads the JOKER command from the `TemplateJson`
7021
+ * Reads the JOKER command from the `TaskJson`
6890
7022
  *
6891
7023
  * Note: This is used in `pipelineJsonToString` utility
6892
7024
  */
6893
- takeFromTemplateJson: function ($templateJson) {
7025
+ takeFromTaskJson: function ($taskJson) {
6894
7026
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6895
7027
  },
6896
7028
  };
@@ -6917,11 +7049,11 @@
6917
7049
  * BOILERPLATE command can be used in:
6918
7050
  */
6919
7051
  isUsedInPipelineHead: true,
6920
- isUsedInPipelineTemplate: true,
7052
+ isUsedInPipelineTask: true,
6921
7053
  /**
6922
7054
  * Description of the MODEL command
6923
7055
  */
6924
- description: "Tells which `modelRequirements` (for example which model) to use for the prompt template execution",
7056
+ description: "Tells which `modelRequirements` (for example which model) to use for the prompt task execution",
6925
7057
  /**
6926
7058
  * Link to documentation
6927
7059
  */
@@ -6995,30 +7127,30 @@
6995
7127
  /**
6996
7128
  * Apply the MODEL command to the `pipelineJson`
6997
7129
  *
6998
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7130
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6999
7131
  */
7000
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7001
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
7002
- throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
7132
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
7133
+ if ($taskJson.taskType !== 'PROMPT_TASK') {
7134
+ throw new ParseError("MODEL command can only be used in PROMPT_TASK block");
7003
7135
  }
7004
- $templateJson.modelRequirements = $templateJson.modelRequirements || {};
7136
+ $taskJson.modelRequirements = $taskJson.modelRequirements || {};
7005
7137
  // TODO: [🚜] DRY
7006
- if ($templateJson.modelRequirements[command.key] !== undefined) {
7007
- if ($templateJson.modelRequirements[command.key] === command.value) {
7138
+ if ($taskJson.modelRequirements[command.key] !== undefined) {
7139
+ if ($taskJson.modelRequirements[command.key] === command.value) {
7008
7140
  console.warn("Multiple commands `MODEL ".concat({
7009
7141
  modelName: 'NAME',
7010
7142
  modelVariant: 'VARIANT',
7011
7143
  maxTokens: '???',
7012
- }[command.key], " ").concat(command.value, "` in the template \"").concat($templateJson.title || $templateJson.name, "\""));
7144
+ }[command.key], " ").concat(command.value, "` in the task \"").concat($taskJson.title || $taskJson.name, "\""));
7013
7145
  }
7014
7146
  else {
7015
- 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 ")));
7147
+ 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 ")));
7016
7148
  }
7017
7149
  }
7018
7150
  if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
7019
- 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 ")));
7151
+ 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 ")));
7020
7152
  }
7021
- $templateJson.modelRequirements[command.key] = command.value;
7153
+ $taskJson.modelRequirements[command.key] = command.value;
7022
7154
  },
7023
7155
  /**
7024
7156
  * Converts the MODEL command back to string
@@ -7037,11 +7169,11 @@
7037
7169
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7038
7170
  },
7039
7171
  /**
7040
- * Reads the MODEL command from the `TemplateJson`
7172
+ * Reads the MODEL command from the `TaskJson`
7041
7173
  *
7042
7174
  * Note: This is used in `pipelineJsonToString` utility
7043
7175
  */
7044
- takeFromTemplateJson: function ($templateJson) {
7176
+ takeFromTaskJson: function ($taskJson) {
7045
7177
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7046
7178
  },
7047
7179
  };
@@ -7068,7 +7200,7 @@
7068
7200
  * BOILERPLATE command can be used in:
7069
7201
  */
7070
7202
  isUsedInPipelineHead: true,
7071
- isUsedInPipelineTemplate: true,
7203
+ isUsedInPipelineTask: true,
7072
7204
  /**
7073
7205
  * Description of the PARAMETER command
7074
7206
  */
@@ -7091,7 +7223,7 @@
7091
7223
  // <- TODO: When [🥶] fixed, change to:
7092
7224
  // > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
7093
7225
  if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
7094
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Parameter {".concat(parameterNameRaw, "} can not contain another parameter in description\n\n The description:\n ").concat(block(parameterDescriptionRaw), "\n "); }));
7226
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Parameter `{".concat(parameterNameRaw, "}` can not contain another parameter in description\n\n The description:\n ").concat(block(parameterDescriptionRaw), "\n "); }));
7095
7227
  }
7096
7228
  var isInput = normalized.startsWith('INPUT');
7097
7229
  var isOutput = normalized.startsWith('OUTPUT');
@@ -7120,9 +7252,9 @@
7120
7252
  /**
7121
7253
  * Apply the PARAMETER command to the `pipelineJson`
7122
7254
  *
7123
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7255
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7124
7256
  */
7125
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7257
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
7126
7258
  // Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
7127
7259
  },
7128
7260
  /**
@@ -7142,11 +7274,11 @@
7142
7274
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7143
7275
  },
7144
7276
  /**
7145
- * Reads the PARAMETER command from the `TemplateJson`
7277
+ * Reads the PARAMETER command from the `TaskJson`
7146
7278
  *
7147
7279
  * Note: This is used in `pipelineJsonToString` utility
7148
7280
  */
7149
- takeFromTemplateJson: function ($templateJson) {
7281
+ takeFromTaskJson: function ($taskJson) {
7150
7282
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7151
7283
  },
7152
7284
  };
@@ -7170,7 +7302,7 @@
7170
7302
  * PERSONA command can be used in:
7171
7303
  */
7172
7304
  isUsedInPipelineHead: true,
7173
- isUsedInPipelineTemplate: true,
7305
+ isUsedInPipelineTask: true,
7174
7306
  /**
7175
7307
  * Description of the PERSONA command
7176
7308
  */
@@ -7209,9 +7341,9 @@
7209
7341
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7210
7342
  */
7211
7343
  $applyToPipelineJson: function (command, $pipelineJson) {
7212
- $applyToTemplateJson(command, null, $pipelineJson);
7344
+ $applyToTaskJson(command, null, $pipelineJson);
7213
7345
  },
7214
- $applyToTemplateJson: $applyToTemplateJson,
7346
+ $applyToTaskJson: $applyToTaskJson,
7215
7347
  /**
7216
7348
  * Converts the PERSONA command back to string
7217
7349
  *
@@ -7229,26 +7361,26 @@
7229
7361
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7230
7362
  },
7231
7363
  /**
7232
- * Reads the PERSONA command from the `TemplateJson`
7364
+ * Reads the PERSONA command from the `TaskJson`
7233
7365
  *
7234
7366
  * Note: This is used in `pipelineJsonToString` utility
7235
7367
  */
7236
- takeFromTemplateJson: function ($templateJson) {
7368
+ takeFromTaskJson: function ($taskJson) {
7237
7369
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7238
7370
  },
7239
7371
  };
7240
7372
  /**
7241
7373
  * Apply the PERSONA command to the `pipelineJson`
7242
7374
  *
7243
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7375
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7244
7376
  */
7245
- function $applyToTemplateJson(command, $templateJson, $pipelineJson) {
7377
+ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
7246
7378
  var personaName = command.personaName, personaDescription = command.personaDescription;
7247
- if ($templateJson !== null) {
7248
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
7249
- throw new ParseError("PERSONA command can be used only in PROMPT_TEMPLATE block");
7379
+ if ($taskJson !== null) {
7380
+ if ($taskJson.taskType !== 'PROMPT_TASK') {
7381
+ throw new ParseError("PERSONA command can be used only in PROMPT_TASK block");
7250
7382
  }
7251
- $templateJson.personaName = personaName;
7383
+ $taskJson.personaName = personaName;
7252
7384
  }
7253
7385
  var persona = $pipelineJson.personas.find(function (persona) { return persona.name === personaName; });
7254
7386
  if (persona === undefined) {
@@ -7302,7 +7434,7 @@
7302
7434
  * BOILERPLATE command can be used in:
7303
7435
  */
7304
7436
  isUsedInPipelineHead: false,
7305
- isUsedInPipelineTemplate: true,
7437
+ isUsedInPipelineTask: true,
7306
7438
  /**
7307
7439
  * Description of the POSTPROCESS command
7308
7440
  */
@@ -7340,11 +7472,11 @@
7340
7472
  /**
7341
7473
  * Apply the POSTPROCESS command to the `pipelineJson`
7342
7474
  *
7343
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7475
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7344
7476
  */
7345
- $applyToTemplateJson: function (command, $templateJson) {
7346
- $templateJson.postprocessingFunctionNames = $templateJson.postprocessingFunctionNames || [];
7347
- $templateJson.postprocessingFunctionNames.push(command.functionName);
7477
+ $applyToTaskJson: function (command, $taskJson) {
7478
+ $taskJson.postprocessingFunctionNames = $taskJson.postprocessingFunctionNames || [];
7479
+ $taskJson.postprocessingFunctionNames.push(command.functionName);
7348
7480
  },
7349
7481
  /**
7350
7482
  * Converts the POSTPROCESS command back to string
@@ -7355,11 +7487,11 @@
7355
7487
  return "---"; // <- TODO: [🛋] Implement
7356
7488
  },
7357
7489
  /**
7358
- * Reads the POSTPROCESS command from the `TemplateJson`
7490
+ * Reads the POSTPROCESS command from the `TaskJson`
7359
7491
  *
7360
7492
  * Note: This is used in `pipelineJsonToString` utility
7361
7493
  */
7362
- takeFromTemplateJson: function ($templateJson) {
7494
+ takeFromTaskJson: function ($taskJson) {
7363
7495
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7364
7496
  },
7365
7497
  };
@@ -7384,7 +7516,7 @@
7384
7516
  * BOILERPLATE command can be used in:
7385
7517
  */
7386
7518
  isUsedInPipelineHead: true,
7387
- isUsedInPipelineTemplate: false,
7519
+ isUsedInPipelineTask: false,
7388
7520
  /**
7389
7521
  * Description of the URL command
7390
7522
  */
@@ -7480,7 +7612,7 @@
7480
7612
  * ACTION command can be used in:
7481
7613
  */
7482
7614
  isUsedInPipelineHead: true,
7483
- isUsedInPipelineTemplate: false,
7615
+ isUsedInPipelineTask: false,
7484
7616
  /**
7485
7617
  * Description of the ACTION command
7486
7618
  */
@@ -7546,7 +7678,7 @@
7546
7678
  * INSTRUMENT command can be used in:
7547
7679
  */
7548
7680
  isUsedInPipelineHead: true,
7549
- isUsedInPipelineTemplate: false,
7681
+ isUsedInPipelineTask: false,
7550
7682
  /**
7551
7683
  * Description of the INSTRUMENT command
7552
7684
  */
@@ -7603,7 +7735,7 @@
7603
7735
  * @private internal index of `parseCommand`
7604
7736
  */
7605
7737
  var COMMANDS = [
7606
- templateCommandParser,
7738
+ sectionCommandParser,
7607
7739
  expectCommandParser,
7608
7740
  formatCommandParser,
7609
7741
  jokerCommandParser,
@@ -7621,6 +7753,9 @@
7621
7753
  boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
7622
7754
  // <- 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
7623
7755
  ];
7756
+ /**
7757
+ * Note: [💞] Ignore a discrepancy between file name and entity name
7758
+ */
7624
7759
 
7625
7760
  /**
7626
7761
  * Gets the parser for the command
@@ -7681,7 +7816,7 @@
7681
7816
  normalized = normalized.split('(').join('');
7682
7817
  normalized = normalized.split(')').join('');
7683
7818
  normalized = normalizeTo_SCREAMING_CASE(normalized);
7684
- normalized = normalized.split('DIALOGUE').join('DIALOG');
7819
+ normalized = normalized.split('DIALOGUE').join('DIALOG'); // <- TODO: !!!!!! Move to sectionCommandParser
7685
7820
  var items = raw
7686
7821
  .trim()
7687
7822
  // Note: [🐡]
@@ -7762,12 +7897,12 @@
7762
7897
  var commandName = normalizeTo_SCREAMING_CASE(commandNameRaw);
7763
7898
  var _loop_1 = function (commandParser) {
7764
7899
  // <- Note: [🦦] Its strange that this type assertion is needed
7765
- var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTemplate = commandParser.isUsedInPipelineTemplate, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
7900
+ var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTask = commandParser.isUsedInPipelineTask, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
7766
7901
  if (just(false)) ;
7767
7902
  else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
7768
7903
  return "continue";
7769
7904
  }
7770
- else if (usagePlace === 'PIPELINE_TEMPLATE' && !isUsedInPipelineTemplate) {
7905
+ else if (usagePlace === 'PIPELINE_TASK' && !isUsedInPipelineTask) {
7771
7906
  return "continue";
7772
7907
  }
7773
7908
  var names = __spreadArray(__spreadArray([name_1], __read((aliasNames || [])), false), __read((deprecatedNames || [])), false);
@@ -8084,7 +8219,7 @@
8084
8219
  description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
8085
8220
  formfactorName: 'GENERIC',
8086
8221
  parameters: [],
8087
- templates: [],
8222
+ tasks: [],
8088
8223
  knowledgeSources: [],
8089
8224
  knowledgePieces: [],
8090
8225
  personas: [],
@@ -8137,7 +8272,7 @@
8137
8272
  existingParameter.description &&
8138
8273
  existingParameter.description !== parameterDescription &&
8139
8274
  parameterDescription) {
8140
- throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
8275
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
8141
8276
  }
8142
8277
  if (existingParameter) {
8143
8278
  if (parameterDescription) {
@@ -8222,10 +8357,10 @@
8222
8357
  if (description_1 === '') {
8223
8358
  description_1 = undefined;
8224
8359
  }
8225
- var $templateJson = {
8226
- isTemplateTypeSet: false,
8227
- isTemplate: true,
8228
- templateType: undefined /* <- Note: [🍙] Putting here placeholder to keep `templateType` on top at final JSON */,
8360
+ var $taskJson = {
8361
+ isSectionTypeSet: false,
8362
+ isTask: true,
8363
+ taskType: undefined /* <- Note: [🍙] Putting here placeholder to keep `taskType` on top at final JSON */,
8229
8364
  name: titleToName(section.title),
8230
8365
  title: section.title,
8231
8366
  description: description_1,
@@ -8237,35 +8372,35 @@
8237
8372
  if (resultingParameterNameMatch &&
8238
8373
  resultingParameterNameMatch.groups !== undefined &&
8239
8374
  resultingParameterNameMatch.groups.resultingParamName !== undefined) {
8240
- $templateJson.resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
8375
+ $taskJson.resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
8241
8376
  }
8242
8377
  // TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineTemplateCommands`
8243
8378
  var commands = listItems_2.map(function (listItem) { return ({
8244
8379
  listItem: listItem,
8245
- command: parseCommand(listItem, 'PIPELINE_TEMPLATE'),
8380
+ command: parseCommand(listItem, 'PIPELINE_TASK'),
8246
8381
  }); });
8247
- // Note: If block type is not set, set it to 'PROMPT_TEMPLATE'
8382
+ // Note: If block type is not set, set it to 'PROMPT_TASK'
8248
8383
  if (commands.some(function (_a) {
8249
8384
  var command = _a.command;
8250
- return command.type === 'TEMPLATE';
8385
+ return command.type === 'SECTION';
8251
8386
  }) === false) {
8252
- templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
8387
+ sectionCommandParser.$applyToTaskJson({ type: 'SECTION', taskType: 'PROMPT_TASK' }, $taskJson, $pipelineJson);
8253
8388
  }
8254
8389
  var _loop_4 = function (listItem, command) {
8255
8390
  var commandParser = getParserForCommand(command);
8256
- if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
8391
+ if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
8257
8392
  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: [🚞]
8258
8393
  }
8259
8394
  try {
8260
- commandParser.$applyToTemplateJson(
8395
+ commandParser.$applyToTaskJson(
8261
8396
  // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitelly
8262
- command, $templateJson, $pipelineJson);
8397
+ command, $taskJson, $pipelineJson);
8263
8398
  }
8264
8399
  catch (error) {
8265
8400
  if (!(error instanceof ParseError)) {
8266
8401
  throw error;
8267
8402
  }
8268
- 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: [🚞]
8403
+ 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($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: [🚞]
8269
8404
  }
8270
8405
  if (command.type === 'PARAMETER') {
8271
8406
  defineParam(command);
@@ -8287,19 +8422,18 @@
8287
8422
  finally { if (e_5) throw e_5.error; }
8288
8423
  }
8289
8424
  // TODO: [🍧] Should be done in TEMPLATE command
8290
- if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
8425
+ if ($taskJson.taskType === 'SCRIPT_TASK') {
8291
8426
  if (!language) {
8292
8427
  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 "); }));
8293
8428
  }
8294
8429
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
8295
8430
  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 "); }));
8296
8431
  }
8297
- $templateJson.contentLanguage =
8298
- language;
8432
+ $taskJson.contentLanguage = language;
8299
8433
  }
8300
- $templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
8434
+ $taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
8301
8435
  try {
8302
- for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
8436
+ for (var _q = (e_6 = void 0, __values($taskJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
8303
8437
  var parameterName = _r.value;
8304
8438
  // TODO: [🧠] This definition should be made first in the template
8305
8439
  defineParam({
@@ -8320,12 +8454,12 @@
8320
8454
  }
8321
8455
  /*
8322
8456
  // TODO: [🍧] This should be checked in `MODEL` command + better error message
8323
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
8457
+ if ($taskJson.taskType !== 'PROMPT_TASK' && $taskJson.modelRequirements !== undefined) {
8324
8458
  throw new UnexpectedError(
8325
8459
  spaceTrim(
8326
8460
  (block) => `
8327
8461
  Model requirements are defined for the block type ${
8328
- $templateJson.templateType
8462
+ $taskJson.taskType
8329
8463
  } which is not a PROMPT TEMPLATE
8330
8464
 
8331
8465
  This should be avoided by the \`modelCommandParser\`
@@ -8336,11 +8470,11 @@
8336
8470
  );
8337
8471
  }
8338
8472
  */
8339
- if ($templateJson.isTemplate) {
8340
- delete $templateJson.isTemplateTypeSet;
8341
- delete $templateJson.isTemplate;
8342
- // TODO: [🍙] Maybe do reorder of `$templateJson` here
8343
- $pipelineJson.templates.push($templateJson);
8473
+ if ($taskJson.isTask) {
8474
+ delete $taskJson.isSectionTypeSet;
8475
+ delete $taskJson.isTask;
8476
+ // TODO: [🍙] Maybe do reorder of `$taskJson` here
8477
+ $pipelineJson.tasks.push($taskJson);
8344
8478
  }
8345
8479
  };
8346
8480
  try {
@@ -8362,7 +8496,7 @@
8362
8496
  // Note: 5️⃣ Mark parameters as INPUT if not explicitly set
8363
8497
  if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
8364
8498
  var _loop_3 = function (parameter) {
8365
- var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
8499
+ var isThisParameterResulting = $pipelineJson.tasks.some(function (template) { return template.resultingParameterName === parameter.name; });
8366
8500
  if (!isThisParameterResulting) {
8367
8501
  parameter.isInput = true;
8368
8502
  }
@@ -8402,13 +8536,13 @@
8402
8536
  }
8403
8537
  // =============================================================
8404
8538
  // Note: 7️⃣ Cleanup of undefined values
8405
- $pipelineJson.templates.forEach(function (templates) {
8539
+ $pipelineJson.tasks.forEach(function (tasks) {
8406
8540
  var e_7, _a;
8407
8541
  try {
8408
- for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
8542
+ for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
8409
8543
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
8410
8544
  if (value === undefined) {
8411
- delete templates[key];
8545
+ delete tasks[key];
8412
8546
  }
8413
8547
  }
8414
8548
  }
@@ -8448,7 +8582,7 @@
8448
8582
  * TODO: Use spaceTrim more effectively
8449
8583
  * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
8450
8584
  * TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
8451
- * TODO: [♈] Probbably move expectations from templates to parameters
8585
+ * TODO: [♈] Probbably move expectations from tasks to parameters
8452
8586
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
8453
8587
  * TODO: [🍙] Make some standard order of json properties
8454
8588
  */
@@ -9513,10 +9647,10 @@
9513
9647
  /*
9514
9648
  Note: Remapping error
9515
9649
  From: [PipelineUrlError: thing is not defined],
9516
- To: [PipelineExecutionError: Parameter {thing} is not defined],
9650
+ To: [PipelineExecutionError: Parameter `{thing}` is not defined],
9517
9651
  */
9518
9652
  if (!statementToEvaluate.includes(undefinedName_1 + '(')) {
9519
- throw new PipelineExecutionError(spaceTrim__default["default"](function (block) { return "\n\n Parameter {".concat(undefinedName_1, "} is not defined\n\n This happen during evaluation of the javascript, which has access to the following parameters as javascript variables:\n\n ").concat(block(Object.keys(parameters)
9653
+ throw new PipelineExecutionError(spaceTrim__default["default"](function (block) { return "\n\n Parameter `{".concat(undefinedName_1, "}` is not defined\n\n This happen during evaluation of the javascript, which has access to the following parameters as javascript variables:\n\n ").concat(block(Object.keys(parameters)
9520
9654
  .map(function (key) { return " - ".concat(key, "\n"); })
9521
9655
  .join('')), "\n\n The script is:\n ```javascript\n ").concat(block(script), "\n ```\n\n Original error message:\n ").concat(block(error_1.message), "\n\n\n "); }));
9522
9656
  }
@@ -10631,6 +10765,7 @@
10631
10765
  /**
10632
10766
  * TODO: [🥃][main] !!! Allow `ptbk make` without configuring any llm tools
10633
10767
  * TODO: [0] DRY Javascript and typescript - Maybe make ONLY typescript and for javascript just remove types
10768
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10634
10769
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
10635
10770
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
10636
10771
  */
@@ -10679,13 +10814,13 @@
10679
10814
  if (parameter.isInput) {
10680
10815
  return 'input';
10681
10816
  }
10682
- var template = pipelineJson.templates.find(function (template) { return template.resultingParameterName === parameterName; });
10817
+ var template = pipelineJson.tasks.find(function (template) { return template.resultingParameterName === parameterName; });
10683
10818
  if (!template) {
10684
10819
  throw new Error("Could not find template for {".concat(parameterName, "}"));
10685
10820
  }
10686
10821
  return normalizeTo_camelCase('template-' + titleToName(template.title));
10687
10822
  };
10688
- var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.templates
10823
+ var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
10689
10824
  .flatMap(function (_a) {
10690
10825
  var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
10691
10826
  return __spreadArray([
@@ -10703,7 +10838,7 @@
10703
10838
  var name = _a.name;
10704
10839
  return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
10705
10840
  })
10706
- .join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.templates
10841
+ .join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.tasks
10707
10842
  .map(function (template) {
10708
10843
  var link = linkTemplate(template);
10709
10844
  if (link === null) {
@@ -10742,8 +10877,8 @@
10742
10877
  case 1:
10743
10878
  pipelineJson = _a.sent();
10744
10879
  promptbookMermaid_1 = renderPromptbookMermaid(pipelineJson, {
10745
- linkTemplate: function (template) {
10746
- return { href: "#".concat(template.name), title: template.title };
10880
+ linkTemplate: function (task) {
10881
+ return { href: "#".concat(task.name), title: task.title };
10747
10882
  },
10748
10883
  });
10749
10884
  promptbookMermaidBlock = spaceTrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
@@ -10855,20 +10990,11 @@
10855
10990
  }
10856
10991
  /**
10857
10992
  * TODO: [😶] Unite floder listing
10993
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10858
10994
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
10859
10995
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
10860
10996
  */
10861
10997
 
10862
- /**
10863
- * Pretty print an embedding vector for logging
10864
- *
10865
- * @public exported from `@promptbook/core`
10866
- */
10867
- function embeddingVectorToString(embeddingVector) {
10868
- var vectorLength = Math.pow(embeddingVector.reduce(function (acc, val) { return acc + Math.pow(val, 2); }, 0), 0.5);
10869
- return "[EmbeddingVector; ".concat(embeddingVector.length, " dimensions; length: ").concat(vectorLength.toFixed(2), "; ").concat(embeddingVector.slice(0, 3).join(', '), "...]");
10870
- }
10871
-
10872
10998
  /**
10873
10999
  * Format either small or big number
10874
11000
  *
@@ -10969,6 +11095,16 @@
10969
11095
  * TODO: [🏛] This can be part of markdown builder
10970
11096
  */
10971
11097
 
11098
+ /**
11099
+ * Pretty print an embedding vector for logging
11100
+ *
11101
+ * @public exported from `@promptbook/core`
11102
+ */
11103
+ function embeddingVectorToString(embeddingVector) {
11104
+ var vectorLength = Math.pow(embeddingVector.reduce(function (acc, val) { return acc + Math.pow(val, 2); }, 0), 0.5);
11105
+ return "[EmbeddingVector; ".concat(embeddingVector.length, " dimensions; length: ").concat(vectorLength.toFixed(2), "; ").concat(embeddingVector.slice(0, 3).join(', '), "...]");
11106
+ }
11107
+
10972
11108
  /**
10973
11109
  * Default options for generating an execution report string
10974
11110
  *
@@ -11116,22 +11252,22 @@
11116
11252
  }
11117
11253
  var _loop_1 = function (promptExecution) {
11118
11254
  executionReportString += '\n\n\n\n' + "## ".concat(promptExecution.prompt.title);
11119
- var templateList = [];
11255
+ var taskList = [];
11120
11256
  // TODO: What if startedAt OR/AND completedAt is not defined?
11121
11257
  var startedAt = moment__default["default"]((_c = (_b = promptExecution.result) === null || _b === void 0 ? void 0 : _b.timing) === null || _c === void 0 ? void 0 : _c.start);
11122
11258
  var completedAt = moment__default["default"]((_e = (_d = promptExecution.result) === null || _d === void 0 ? void 0 : _d.timing) === null || _e === void 0 ? void 0 : _e.complete);
11123
11259
  var duration = moment__default["default"].duration(completedAt.diff(startedAt));
11124
11260
  // Not need here:
11125
- // > templateList.push(`STARTED AT ${moment(startedAt).calendar()}`);
11126
- templateList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
11261
+ // > taskList.push(`STARTED AT ${moment(startedAt).calendar()}`);
11262
+ taskList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
11127
11263
  if (typeof ((_g = (_f = promptExecution.result) === null || _f === void 0 ? void 0 : _f.usage) === null || _g === void 0 ? void 0 : _g.price) === 'number') {
11128
- templateList.push("COST $".concat(formatNumber(promptExecution.result.usage.price * (1 + taxRate))) +
11264
+ taskList.push("COST $".concat(formatNumber(promptExecution.result.usage.price * (1 + taxRate))) +
11129
11265
  (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
11130
11266
  }
11131
11267
  else {
11132
- templateList.push("COST UNKNOWN");
11268
+ taskList.push("COST UNKNOWN");
11133
11269
  }
11134
- executionReportString += '\n\n' + templateList.map(function (header) { return "- ".concat(header); }).join('\n');
11270
+ executionReportString += '\n\n' + taskList.map(function (header) { return "- ".concat(header); }).join('\n');
11135
11271
  /*
11136
11272
  - MODEL VARIANT ${promptExecution.prompt.modelRequirements.modelVariant}
11137
11273
  - MODEL NAME \`${promptExecution.result?.model}\` (requested \`${
@@ -11201,21 +11337,25 @@
11201
11337
  'Path to book file');
11202
11338
  runCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
11203
11339
  runCommand.option('-v, --verbose', "Is output verbose", false);
11204
- runCommand.option('--no-interactive', "Input is not interactive", false);
11340
+ runCommand.option('--no-interactive', "Input is not interactive, if true you need to pass all the input parameters through --json");
11341
+ runCommand.option('-j, --json <json>', "Pass all or some input parameters as JSON record, if used the output is also returned as JSON");
11205
11342
  runCommand.option('-s, --save-report <path>', "Save report to file");
11206
- // TODO: !!!!!! Implement non-interactive mode - allow to pass input parameters as JSON
11207
- // TODO: !!!!!! JSON output
11208
11343
  runCommand.action(function (filePathRaw, options) { return __awaiter(_this, void 0, void 0, function () {
11209
- var isCacheReloaded, isVerbose, saveReport, prepareAndScrapeOptions, fs, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, e_1_1, llm, executables, tools, pipelineString, pipeline, error_1, pipelineExecutor, questions, response, inputParameters, result, isSuccessful, errors, warnings, outputParameters, executionReport, executionReportString, _a, _b, error, _c, _d, warning, _e, _f, key, value, separator;
11344
+ var isCacheReloaded, isInteractive, json, isVerbose, saveReport, inputParameters, prepareAndScrapeOptions, fs, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, e_1_1, llm, executables, tools, pipelineString, pipeline, error_1, pipelineExecutor, questions, response, result, isSuccessful, errors, warnings, outputParameters, executionReport, executionReportString, _a, _b, error, _c, _d, warning, _e, _f, key, value, separator;
11210
11345
  var e_1, _g, _h, e_2, _j, e_3, _k, e_4, _l;
11211
11346
  return __generator(this, function (_m) {
11212
11347
  switch (_m.label) {
11213
11348
  case 0:
11214
- isCacheReloaded = options.reload, options.interactive, isVerbose = options.verbose, saveReport = options.saveReport;
11349
+ isCacheReloaded = options.reload, isInteractive = options.interactive, json = options.json, isVerbose = options.verbose, saveReport = options.saveReport;
11215
11350
  if (saveReport && !saveReport.endsWith('.json') && !saveReport.endsWith('.md')) {
11216
11351
  console.error(colors__default["default"].red("Report file must be .json or .md"));
11217
11352
  return [2 /*return*/, process.exit(1)];
11218
11353
  }
11354
+ inputParameters = {};
11355
+ if (json) {
11356
+ inputParameters = JSON.parse(json);
11357
+ // <- TODO: Maybe check shape of passed JSON and if its valid parameters Record
11358
+ }
11219
11359
  prepareAndScrapeOptions = {
11220
11360
  isVerbose: isVerbose,
11221
11361
  isCacheReloaded: isCacheReloaded,
@@ -11319,7 +11459,7 @@
11319
11459
  if (isVerbose) {
11320
11460
  console.info(colors__default["default"].gray('--- Validating pipeline ---'));
11321
11461
  }
11322
- // TODO: !!!!!! Same try-catch for LogicError
11462
+ // TODO: Same try-catch for LogicError
11323
11463
  validatePipeline(pipeline);
11324
11464
  if (isVerbose) {
11325
11465
  console.info(colors__default["default"].gray('--- Creating executor ---'));
@@ -11339,6 +11479,10 @@
11339
11479
  .filter(function (_a) {
11340
11480
  var isInput = _a.isInput;
11341
11481
  return isInput;
11482
+ })
11483
+ .filter(function (_a) {
11484
+ var name = _a.name;
11485
+ return typeof inputParameters[name] !== 'string';
11342
11486
  })
11343
11487
  .map(function (_a) {
11344
11488
  var name = _a.name, exampleValues = _a.exampleValues;
@@ -11359,10 +11503,45 @@
11359
11503
  // TODO: Maybe use> validate: value => value < 18 ? `Forbidden` : true
11360
11504
  };
11361
11505
  });
11506
+ if (isInteractive === false && questions.length !== 0) {
11507
+ console.error(colors__default["default"].red(spaceTrim__default["default"](function (block) { return "\n When using --no-interactive you need to pass all the input parameters through --json\n\n You are missing:\n ".concat(block(pipeline.parameters
11508
+ .filter(function (_a) {
11509
+ var isInput = _a.isInput;
11510
+ return isInput;
11511
+ })
11512
+ .filter(function (_a) {
11513
+ var parameterName = _a.name;
11514
+ return !questions.some(function (_a) {
11515
+ var questionName = _a.name;
11516
+ return questionName === parameterName;
11517
+ });
11518
+ })
11519
+ .map(function (_a) {
11520
+ var name = _a.name, description = _a.description;
11521
+ return "- **".concat(name, "** ").concat(description);
11522
+ })
11523
+ .join('\n')), "\n\n Example:\n --json '").concat(JSON.stringify(Object.fromEntries(pipeline.parameters
11524
+ .filter(function (_a) {
11525
+ var isInput = _a.isInput;
11526
+ return isInput;
11527
+ })
11528
+ .map(function (_a) {
11529
+ var name = _a.name, exampleValues = _a.exampleValues;
11530
+ return [
11531
+ name,
11532
+ inputParameters[name] || (exampleValues || [])[0] || '...',
11533
+ ];
11534
+ })))
11535
+ .split("'")
11536
+ .join("\\'"), "'\n "); })));
11537
+ return [2 /*return*/, process.exit(1)];
11538
+ }
11362
11539
  return [4 /*yield*/, prompts__default["default"](questions)];
11363
11540
  case 16:
11364
11541
  response = _m.sent();
11365
- inputParameters = response;
11542
+ // <- TODO: [🧠] Change behavior according to the formfactor
11543
+ inputParameters = __assign(__assign({}, inputParameters), response);
11544
+ // TODO: Maybe do some validation of the response (and --json argument which is passed)
11366
11545
  if (isVerbose) {
11367
11546
  console.info(colors__default["default"].gray('--- Executing ---'));
11368
11547
  }
@@ -11399,7 +11578,9 @@
11399
11578
  console.info(colors__default["default"].gray('--- Usage ---'));
11400
11579
  console.info(colors__default["default"].cyan(usageToHuman(result.usage)));
11401
11580
  }
11402
- console.info(colors__default["default"].gray('--- Result ---'));
11581
+ if (json === undefined || isVerbose === true) {
11582
+ console.info(colors__default["default"].gray('--- Result ---'));
11583
+ }
11403
11584
  try {
11404
11585
  // TODO: [🧠] Should be errors or warnings shown first
11405
11586
  for (_a = __values(errors || []), _b = _a.next(); !_b.done; _b = _a.next()) {
@@ -11427,20 +11608,25 @@
11427
11608
  }
11428
11609
  finally { if (e_3) throw e_3.error; }
11429
11610
  }
11430
- try {
11431
- for (_e = __values(Object.keys(outputParameters)), _f = _e.next(); !_f.done; _f = _e.next()) {
11432
- key = _f.value;
11433
- value = outputParameters[key] || colors__default["default"].grey(colors__default["default"].italic('(nothing)'));
11434
- separator = countLines(value) > 1 || countWords(value) > 100 ? ':\n' : ': ';
11435
- console.info(colors__default["default"].green(colors__default["default"].bold(key) + separator + value));
11436
- }
11437
- }
11438
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
11439
- finally {
11611
+ if (json === undefined) {
11440
11612
  try {
11441
- if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
11613
+ for (_e = __values(Object.keys(outputParameters)), _f = _e.next(); !_f.done; _f = _e.next()) {
11614
+ key = _f.value;
11615
+ value = outputParameters[key] || colors__default["default"].grey(colors__default["default"].italic('(nothing)'));
11616
+ separator = countLines(value) > 1 || countWords(value) > 100 ? ':\n' : ': ';
11617
+ console.info(colors__default["default"].green(colors__default["default"].bold(key) + separator + value));
11618
+ }
11619
+ }
11620
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
11621
+ finally {
11622
+ try {
11623
+ if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
11624
+ }
11625
+ finally { if (e_4) throw e_4.error; }
11442
11626
  }
11443
- finally { if (e_4) throw e_4.error; }
11627
+ }
11628
+ else {
11629
+ console.info(JSON.stringify(outputParameters, null, 4));
11444
11630
  }
11445
11631
  return [2 /*return*/, process.exit(0)];
11446
11632
  }
@@ -11451,6 +11637,7 @@
11451
11637
  * TODO: !!!!! Catch and wrap all errors from CLI
11452
11638
  * TODO: [🧠] Pass `maxExecutionAttempts`, `csvSettings`
11453
11639
  * TODO: [🥃][main] !!! Allow `ptbk run` without configuring any llm tools
11640
+ * Note: [💞] Ignore a discrepancy between file name and entity name
11454
11641
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
11455
11642
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
11456
11643
  */
@@ -11573,6 +11760,7 @@
11573
11760
  }
11574
11761
  /**
11575
11762
  * TODO: [😶] Unite floder listing
11763
+ * Note: [💞] Ignore a discrepancy between file name and entity name
11576
11764
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
11577
11765
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
11578
11766
  * Note: This is named "test-command.ts" to avoid name collision with jest unit test files
@@ -11632,6 +11820,7 @@
11632
11820
  _initialize_promptbookCli: promptbookCli,
11633
11821
  };
11634
11822
  /**
11823
+ * Note: [💞] Ignore a discrepancy between file name and entity name
11635
11824
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
11636
11825
  */
11637
11826
 
@@ -11675,6 +11864,9 @@
11675
11864
  return null;
11676
11865
  },
11677
11866
  });
11867
+ /**
11868
+ * Note: [💞] Ignore a discrepancy between file name and entity name
11869
+ */
11678
11870
 
11679
11871
  /**
11680
11872
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
@@ -11973,6 +12165,7 @@
11973
12165
  * TODO: [🧠] Some mechanism to propagate unsureness
11974
12166
  * TODO: [🧠][👮‍♀️] Put here more info like description, isVision, trainingDateCutoff, languages, strengths ( Top-level performance, intelligence, fluency, and understanding), contextWindow,...
11975
12167
  * TODO: [🎰] Some mechanism to auto-update available models
12168
+ * Note: [💞] Ignore a discrepancy between file name and entity name
11976
12169
  */
11977
12170
 
11978
12171
  /**
@@ -12356,6 +12549,7 @@
12356
12549
  var _AnthropicClaudeRegistration = $llmToolsRegister.register(createAnthropicClaudeExecutionTools);
12357
12550
  /**
12358
12551
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
12552
+ * Note: [💞] Ignore a discrepancy between file name and entity name
12359
12553
  */
12360
12554
 
12361
12555
  /**
@@ -12404,6 +12598,9 @@
12404
12598
  return null;
12405
12599
  },
12406
12600
  });
12601
+ /**
12602
+ * Note: [💞] Ignore a discrepancy between file name and entity name
12603
+ */
12407
12604
 
12408
12605
  /**
12409
12606
  * List of available OpenAI models with pricing
@@ -12801,6 +12998,7 @@
12801
12998
  * TODO: [🍓] Make better
12802
12999
  * TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
12803
13000
  * TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
13001
+ * Note: [💞] Ignore a discrepancy between file name and entity name
12804
13002
  */
12805
13003
 
12806
13004
  /**
@@ -13142,6 +13340,7 @@
13142
13340
  var _AzureOpenAiRegistration = $llmToolsRegister.register(createAzureOpenAiExecutionTools);
13143
13341
  /**
13144
13342
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
13343
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13145
13344
  */
13146
13345
 
13147
13346
  /**
@@ -13223,6 +13422,9 @@
13223
13422
  */
13224
13423
  },
13225
13424
  });
13425
+ /**
13426
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13427
+ */
13226
13428
 
13227
13429
  /**
13228
13430
  * Detects if the code is running in a browser environment in main thread (Not in a web worker)
@@ -13881,6 +14083,7 @@
13881
14083
  var _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);
13882
14084
  /**
13883
14085
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
14086
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13884
14087
  */
13885
14088
 
13886
14089
  /**
@@ -14139,6 +14342,9 @@
14139
14342
  * @public exported from `@promptbook/cli`
14140
14343
  */
14141
14344
  var _MarkdownScraperMetadataRegistration = $scrapersMetadataRegister.register(markdownScraperMetadata);
14345
+ /**
14346
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14347
+ */
14142
14348
 
14143
14349
  /**
14144
14350
  * Scraper for markdown files
@@ -14333,6 +14539,9 @@
14333
14539
  * @public exported from `@promptbook/cli`
14334
14540
  */
14335
14541
  var _DocumentScraperMetadataRegistration = $scrapersMetadataRegister.register(documentScraperMetadata);
14542
+ /**
14543
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14544
+ */
14336
14545
 
14337
14546
  /**
14338
14547
  * Scraper of .docx and .odt files
@@ -14497,6 +14706,9 @@
14497
14706
  * @public exported from `@promptbook/cli`
14498
14707
  */
14499
14708
  var _LegacyDocumentScraperMetadataRegistration = $scrapersMetadataRegister.register(legacyDocumentScraperMetadata);
14709
+ /**
14710
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14711
+ */
14500
14712
 
14501
14713
  /**
14502
14714
  * Scraper for old document files (like .doc and .rtf)
@@ -14666,6 +14878,7 @@
14666
14878
  var _LegacyDocumentScraperRegistration = $scrapersRegister.register(createLegacyDocumentScraper);
14667
14879
  /**
14668
14880
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
14881
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14669
14882
  */
14670
14883
 
14671
14884
  /**
@@ -14691,6 +14904,7 @@
14691
14904
  var _DocumentScraperRegistration = $scrapersRegister.register(createDocumentScraper);
14692
14905
  /**
14693
14906
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
14907
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14694
14908
  */
14695
14909
 
14696
14910
  /**
@@ -14716,6 +14930,7 @@
14716
14930
  var _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownScraper);
14717
14931
  /**
14718
14932
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
14933
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14719
14934
  */
14720
14935
 
14721
14936
  /**
@@ -14741,6 +14956,9 @@
14741
14956
  * @public exported from `@promptbook/cli`
14742
14957
  */
14743
14958
  var _PdfScraperMetadataRegistration = $scrapersMetadataRegister.register(pdfScraperMetadata);
14959
+ /**
14960
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14961
+ */
14744
14962
 
14745
14963
  /**
14746
14964
  * Scraper for .pdf files
@@ -14824,6 +15042,7 @@
14824
15042
  var _PdfScraperRegistration = $scrapersRegister.register(createPdfScraper);
14825
15043
  /**
14826
15044
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
15045
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14827
15046
  */
14828
15047
 
14829
15048
  /**
@@ -14849,6 +15068,9 @@
14849
15068
  * @public exported from `@promptbook/cli`
14850
15069
  */
14851
15070
  var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
15071
+ /**
15072
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15073
+ */
14852
15074
 
14853
15075
  /**
14854
15076
  * Create a new showdown converter instance
@@ -15021,6 +15243,7 @@
15021
15243
  var _WebsiteScraperRegistration = $scrapersRegister.register(createWebsiteScraper);
15022
15244
  /**
15023
15245
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
15246
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15024
15247
  */
15025
15248
 
15026
15249
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;