@promptbook/core 0.75.0-1 → 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 (156) hide show
  1. package/README.md +1 -0
  2. package/esm/index.es.js +1002 -926
  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 +22 -20
  6. package/esm/typings/src/_packages/types.index.d.ts +58 -50
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  8. package/esm/typings/src/cli/cli-commands/about.d.ts +1 -0
  9. package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -0
  10. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -0
  11. package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -0
  12. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -0
  13. package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -0
  14. package/esm/typings/src/cli/main.d.ts +1 -0
  15. package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
  16. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
  17. package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
  18. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
  19. package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
  20. package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +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 +2 -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/_common/AbstractFormfactorDefinition.d.ts +4 -1
  63. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +3 -0
  64. package/esm/typings/src/formfactors/{chat/ChatFormfactorDefinition.d.ts → chatbot/ChatbotFormfactorDefinition.d.ts} +2 -2
  65. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +1 -1
  66. package/esm/typings/src/formfactors/index.d.ts +15 -4
  67. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +14 -0
  68. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +1 -1
  69. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
  70. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
  71. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +3 -0
  72. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +1 -0
  73. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +3 -0
  74. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
  75. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  76. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  77. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +3 -0
  78. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +1 -0
  79. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  80. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/PipelineInterface.d.ts +3 -0
  81. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/constants.d.ts +5 -0
  82. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/getPipelineInterface.d.ts +3 -1
  83. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineImplementingInterface.d.ts +5 -1
  84. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineInterfacesEqual.d.ts +2 -0
  85. package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +13 -0
  86. package/esm/typings/src/{types → pipeline}/PipelineJson/Expectations.d.ts +2 -2
  87. package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgePieceJson.d.ts +7 -6
  88. package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgeSourceJson.d.ts +3 -3
  89. package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +96 -0
  90. package/esm/typings/src/{types → pipeline}/PipelineJson/PersonaJson.d.ts +4 -4
  91. package/esm/typings/src/{types → pipeline}/PipelineJson/PipelineJson.d.ts +10 -10
  92. package/esm/typings/src/{types → pipeline}/PipelineJson/PreparationJson.d.ts +1 -1
  93. package/esm/typings/src/{types/PipelineJson/PromptTemplateJson.d.ts → pipeline/PipelineJson/PromptTaskJson.d.ts} +8 -8
  94. package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +20 -0
  95. package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +13 -0
  96. package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +11 -0
  97. package/esm/typings/src/{types/PipelineJson/TemplateJsonCommon.d.ts → pipeline/PipelineJson/TaskJsonCommon.d.ts} +13 -13
  98. package/esm/typings/src/{types → pipeline}/PipelineString.d.ts +1 -1
  99. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -2
  100. package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
  101. package/esm/typings/src/prepare/{prepareTemplates.d.ts → prepareTasks.d.ts} +7 -7
  102. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -1
  103. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -1
  104. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +2 -2
  105. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  106. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +1 -1
  107. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
  108. package/esm/typings/src/scrapers/document/register-metadata.d.ts +3 -0
  109. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
  110. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
  111. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +3 -0
  112. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  113. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
  114. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +3 -0
  115. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -1
  116. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
  117. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +3 -0
  118. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +1 -1
  119. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
  120. package/esm/typings/src/scrapers/website/register-metadata.d.ts +3 -0
  121. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +1 -0
  122. package/esm/typings/src/types/Prompt.d.ts +1 -1
  123. package/esm/typings/src/types/TaskProgress.d.ts +2 -2
  124. package/esm/typings/src/types/typeAliasEmoji.d.ts +3 -0
  125. package/esm/typings/src/types/typeAliases.d.ts +1 -0
  126. package/esm/typings/src/utils/emojis.d.ts +1 -0
  127. package/esm/typings/src/utils/expectation-counters/constants.d.ts +1 -0
  128. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
  129. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
  130. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
  131. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
  132. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  133. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
  134. package/esm/typings/src/utils/expectation-counters/index.d.ts +3 -2
  135. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -0
  136. package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +2 -2
  137. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +1 -1
  138. package/esm/typings/src/version.d.ts +2 -1
  139. package/package.json +4 -3
  140. package/umd/index.umd.js +1009 -932
  141. package/umd/index.umd.js.map +1 -1
  142. package/esm/typings/src/commands/TEMPLATE/TemplateCommand.d.ts +0 -11
  143. package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +0 -15
  144. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +0 -27
  145. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +0 -30
  146. package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +0 -13
  147. package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +0 -39
  148. package/esm/typings/src/types/PipelineJson/ScriptTemplateJson.d.ts +0 -20
  149. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +0 -13
  150. package/esm/typings/src/types/PipelineJson/TemplateJson.d.ts +0 -11
  151. /package/esm/typings/src/commands/{TEMPLATE/templateCommand.test.d.ts → SECTION/sectionCommand.test.d.ts} +0 -0
  152. /package/esm/typings/src/conversion/utils/{extractParameterNamesFromTemplate.test.d.ts → extractParameterNamesFromTask.test.d.ts} +0 -0
  153. /package/esm/typings/src/{types → execution}/execution-report/ExecutionReportString.d.ts +0 -0
  154. /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.d.ts +0 -0
  155. /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.test.d.ts +0 -0
  156. /package/esm/typings/src/{types → execution}/execution-report/executionReportJsonToString.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -7,8 +7,8 @@ import { join, basename } from 'path';
7
7
  import { SHA256 } from 'crypto-js';
8
8
  import hexEncoder from 'crypto-js/enc-hex';
9
9
  import { lookup } from 'mime-types';
10
- import sha256 from 'crypto-js/sha256';
11
10
  import moment from 'moment';
11
+ import sha256 from 'crypto-js/sha256';
12
12
 
13
13
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
14
14
  /**
@@ -22,9 +22,10 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
22
22
  *
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-1';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
+ * Note: [💞] Ignore a discrepancy between file name and entity name
28
29
  */
29
30
 
30
31
  /*! *****************************************************************************
@@ -225,7 +226,7 @@ function capitalize(word) {
225
226
  */
226
227
  function pipelineJsonToString(pipelineJson) {
227
228
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
228
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
229
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, tasks = pipelineJson.tasks;
229
230
  var pipelineString = "# ".concat(title);
230
231
  if (description) {
231
232
  pipelineString += '\n\n';
@@ -275,13 +276,13 @@ function pipelineJsonToString(pipelineJson) {
275
276
  pipelineString += '\n\n';
276
277
  pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
277
278
  try {
278
- for (var templates_1 = __values(templates), templates_1_1 = templates_1.next(); !templates_1_1.done; templates_1_1 = templates_1.next()) {
279
- var template = templates_1_1.value;
279
+ for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
280
+ var template = tasks_1_1.value;
280
281
  var
281
282
  /* Note: Not using:> name, */
282
283
  title_1 = template.title, description_1 = template.description,
283
284
  /* Note: dependentParameterNames, */
284
- jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
285
+ jokers = template.jokerParameterNames, taskType = template.taskType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
285
286
  pipelineString += '\n\n';
286
287
  pipelineString += "## ".concat(title_1);
287
288
  if (description_1) {
@@ -290,7 +291,7 @@ function pipelineJsonToString(pipelineJson) {
290
291
  }
291
292
  var commands_1 = [];
292
293
  var contentLanguage = 'text';
293
- if (templateType === 'PROMPT_TEMPLATE') {
294
+ if (taskType === 'PROMPT_TASK') {
294
295
  var modelRequirements = template.modelRequirements;
295
296
  var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
296
297
  commands_1.push("EXECUTE PROMPT TEMPLATE");
@@ -301,11 +302,11 @@ function pipelineJsonToString(pipelineJson) {
301
302
  commands_1.push("MODEL NAME `".concat(modelName, "`"));
302
303
  }
303
304
  }
304
- else if (templateType === 'SIMPLE_TEMPLATE') {
305
+ else if (taskType === 'SIMPLE_TASK') {
305
306
  commands_1.push("SIMPLE TEMPLATE");
306
307
  // Note: Nothing special here
307
308
  }
308
- else if (templateType === 'SCRIPT_TEMPLATE') {
309
+ else if (taskType === 'SCRIPT_TASK') {
309
310
  commands_1.push("SCRIPT TEMPLATE");
310
311
  if (template.contentLanguage) {
311
312
  contentLanguage = template.contentLanguage;
@@ -314,7 +315,7 @@ function pipelineJsonToString(pipelineJson) {
314
315
  contentLanguage = '';
315
316
  }
316
317
  }
317
- else if (templateType === 'DIALOG_TEMPLATE') {
318
+ else if (taskType === 'DIALOG_TASK') {
318
319
  commands_1.push("DIALOG TEMPLATE");
319
320
  // Note: Nothing special here
320
321
  } // <- }else if([🅱]
@@ -396,7 +397,7 @@ function pipelineJsonToString(pipelineJson) {
396
397
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
397
398
  finally {
398
399
  try {
399
- if (templates_1_1 && !templates_1_1.done && (_c = templates_1.return)) _c.call(templates_1);
400
+ if (tasks_1_1 && !tasks_1_1.done && (_c = tasks_1.return)) _c.call(tasks_1);
400
401
  }
401
402
  finally { if (e_3) throw e_3.error; }
402
403
  }
@@ -647,7 +648,7 @@ var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so t
647
648
  *
648
649
  * @public exported from `@promptbook/core`
649
650
  */
650
- var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
651
+ var CLAIM = "It's time for a paradigm shift. The future of software in plain English, French or Latin";
651
652
  // <- TODO: [🐊] Pick the best claim
652
653
  /**
653
654
  * When the title is not provided, the default title is used
@@ -819,6 +820,7 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
819
820
  true);
820
821
  /**
821
822
  * TODO: Extract `constants.ts` from `config.ts`
823
+ * Note: [💞] Ignore a discrepancy between file name and entity name
822
824
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
823
825
  */
824
826
 
@@ -1074,9 +1076,9 @@ function validatePipelineCore(pipeline) {
1074
1076
  throw new ParseError(spaceTrim$1(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 "); }));
1075
1077
  }
1076
1078
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1077
- if (!Array.isArray(pipeline.templates)) {
1079
+ if (!Array.isArray(pipeline.tasks)) {
1078
1080
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
1079
- throw new ParseError(spaceTrim$1(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 "); }));
1081
+ throw new ParseError(spaceTrim$1(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 "); }));
1080
1082
  }
1081
1083
  var _loop_1 = function (parameter) {
1082
1084
  if (parameter.isInput && parameter.isOutput) {
@@ -1085,13 +1087,12 @@ function validatePipelineCore(pipeline) {
1085
1087
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
1086
1088
  if (!parameter.isInput &&
1087
1089
  !parameter.isOutput &&
1088
- !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
1090
+ !pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
1089
1091
  throw new PipelineLogicError(spaceTrim$1(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 "); }));
1090
1092
  }
1091
- // Note: Testing that parameter is either input or result of some template
1092
- if (!parameter.isInput &&
1093
- !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
1094
- throw new PipelineLogicError(spaceTrim$1(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 "); }));
1093
+ // Note: Testing that parameter is either input or result of some task
1094
+ if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
1095
+ throw new PipelineLogicError(spaceTrim$1(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 "); }));
1095
1096
  }
1096
1097
  };
1097
1098
  try {
@@ -1108,7 +1109,7 @@ function validatePipelineCore(pipeline) {
1108
1109
  }
1109
1110
  finally { if (e_1) throw e_1.error; }
1110
1111
  }
1111
- // Note: All input parameters are defined - so that they can be used as result of some template
1112
+ // Note: All input parameters are defined - so that they can be used as result of some task
1112
1113
  var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
1113
1114
  var isInput = _a.isInput;
1114
1115
  return isInput;
@@ -1116,27 +1117,27 @@ function validatePipelineCore(pipeline) {
1116
1117
  var name = _a.name;
1117
1118
  return name;
1118
1119
  }));
1119
- var _loop_2 = function (template) {
1120
+ var _loop_2 = function (task) {
1120
1121
  var e_4, _h, e_5, _j;
1121
- if (definedParameters.has(template.resultingParameterName)) {
1122
- throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1122
+ if (definedParameters.has(task.resultingParameterName)) {
1123
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1123
1124
  }
1124
- if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1125
- throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
1125
+ if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
1126
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(task.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
1126
1127
  }
1127
- definedParameters.add(template.resultingParameterName);
1128
- if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
1129
- if (!template.format &&
1130
- !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1131
- throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
1128
+ definedParameters.add(task.resultingParameterName);
1129
+ if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
1130
+ if (!task.format &&
1131
+ !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1132
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Joker parameters are used for {".concat(task.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
1132
1133
  }
1133
1134
  var _loop_4 = function (joker) {
1134
- if (!template.dependentParameterNames.includes(joker)) {
1135
- throw new PipelineLogicError(spaceTrim$1(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 "); }));
1135
+ if (!task.dependentParameterNames.includes(joker)) {
1136
+ throw new PipelineLogicError(spaceTrim$1(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 "); }));
1136
1137
  }
1137
1138
  };
1138
1139
  try {
1139
- for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1140
+ for (var _k = (e_4 = void 0, __values(task.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1140
1141
  var joker = _l.value;
1141
1142
  _loop_4(joker);
1142
1143
  }
@@ -1149,7 +1150,7 @@ function validatePipelineCore(pipeline) {
1149
1150
  finally { if (e_4) throw e_4.error; }
1150
1151
  }
1151
1152
  }
1152
- if (template.expectations) {
1153
+ if (task.expectations) {
1153
1154
  var _loop_5 = function (unit, min, max) {
1154
1155
  if (min !== undefined && max !== undefined && min > max) {
1155
1156
  throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -1162,7 +1163,7 @@ function validatePipelineCore(pipeline) {
1162
1163
  }
1163
1164
  };
1164
1165
  try {
1165
- for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1166
+ for (var _m = (e_5 = void 0, __values(Object.entries(task.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1166
1167
  var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
1167
1168
  _loop_5(unit, min, max);
1168
1169
  }
@@ -1177,10 +1178,10 @@ function validatePipelineCore(pipeline) {
1177
1178
  }
1178
1179
  };
1179
1180
  try {
1180
- // Note: Checking each template individually
1181
- for (var _f = __values(pipeline.templates), _g = _f.next(); !_g.done; _g = _f.next()) {
1182
- var template = _g.value;
1183
- _loop_2(template);
1181
+ // Note: Checking each task individually
1182
+ for (var _f = __values(pipeline.tasks), _g = _f.next(); !_g.done; _g = _f.next()) {
1183
+ var task = _g.value;
1184
+ _loop_2(task);
1184
1185
  }
1185
1186
  }
1186
1187
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1214,15 +1215,15 @@ function validatePipelineCore(pipeline) {
1214
1215
  }
1215
1216
  finally { if (e_3) throw e_3.error; }
1216
1217
  }
1217
- var unresovedTemplates = __spreadArray([], __read(pipeline.templates), false);
1218
+ var unresovedTemplates = __spreadArray([], __read(pipeline.tasks), false);
1218
1219
  var loopLimit = LOOP_LIMIT;
1219
1220
  var _loop_3 = function () {
1220
1221
  if (loopLimit-- < 0) {
1221
1222
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1222
1223
  throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
1223
1224
  }
1224
- var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1225
- return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1225
+ var currentlyResovedTemplates = unresovedTemplates.filter(function (task) {
1226
+ return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1226
1227
  });
1227
1228
  if (currentlyResovedTemplates.length === 0) {
1228
1229
  throw new PipelineLogicError(
@@ -1250,7 +1251,7 @@ function validatePipelineCore(pipeline) {
1250
1251
  var resultingParameterName = _a.resultingParameterName;
1251
1252
  return resultingParameterName;
1252
1253
  })), false);
1253
- unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
1254
+ unresovedTemplates = unresovedTemplates.filter(function (task) { return !currentlyResovedTemplates.includes(task); });
1254
1255
  };
1255
1256
  while (unresovedTemplates.length > 0) {
1256
1257
  _loop_3();
@@ -1312,9 +1313,9 @@ var PipelineUrlError = /** @class */ (function (_super) {
1312
1313
  }(Error));
1313
1314
 
1314
1315
  /**
1315
- * Parses the template and returns the list of all parameter names
1316
+ * Parses the task and returns the list of all parameter names
1316
1317
  *
1317
- * @param template the template with parameters in {curly} braces
1318
+ * @param template the task with parameters in {curly} braces
1318
1319
  * @returns the list of parameter names
1319
1320
  * @public exported from `@promptbook/utils`
1320
1321
  */
@@ -1345,10 +1346,10 @@ function extractParameterNames(template) {
1345
1346
  * @public exported from `@promptbook/core`
1346
1347
  */
1347
1348
  function unpreparePipeline(pipeline) {
1348
- var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, templates = pipeline.templates;
1349
+ var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
1349
1350
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
1350
1351
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
1351
- templates = templates.map(function (template) {
1352
+ tasks = tasks.map(function (template) {
1352
1353
  var dependentParameterNames = template.dependentParameterNames;
1353
1354
  var parameterNames = extractParameterNames(template.preparedContent || '');
1354
1355
  dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
@@ -1356,7 +1357,7 @@ function unpreparePipeline(pipeline) {
1356
1357
  delete templateUnprepared.preparedContent;
1357
1358
  return templateUnprepared;
1358
1359
  });
1359
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { templates: templates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1360
+ return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1360
1361
  }
1361
1362
  /**
1362
1363
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -1672,22 +1673,22 @@ function createSubcollection(collection, predicate) {
1672
1673
  }
1673
1674
 
1674
1675
  /**
1675
- * Template type describes the way how the template is templated
1676
+ * Section type describes the way how the section is sectiond
1676
1677
  *
1677
- * @see https://github.com/webgptorg/promptbook#template-type
1678
1678
  * @public exported from `@promptbook/core`
1679
1679
  */
1680
- var TemplateTypes = [
1681
- 'PROMPT_TEMPLATE',
1682
- 'SIMPLE_TEMPLATE',
1683
- 'SCRIPT_TEMPLATE',
1684
- 'DIALOG_TEMPLATE',
1680
+ var SectionTypes = [
1681
+ 'PROMPT_TASK',
1682
+ 'SIMPLE_TASK',
1683
+ 'SCRIPT_TASK',
1684
+ 'DIALOG_TASK',
1685
1685
  'EXAMPLE',
1686
1686
  'KNOWLEDGE',
1687
1687
  'INSTRUMENT',
1688
1688
  'ACTION',
1689
1689
  // <- [🅱]
1690
1690
  ];
1691
+ // <- TODO: !!!!!! Make alongside `SectionType` the `TaskType`, `TaskType` + [⛱] and ACRY
1691
1692
 
1692
1693
  /**
1693
1694
  * This error type indicates that some tools are missing for pipeline execution or preparation
@@ -1833,6 +1834,9 @@ var UNCERTAIN_USAGE = $deepFreeze({
1833
1834
  pagesCount: { value: 0, isUncertain: true },
1834
1835
  },
1835
1836
  });
1837
+ /**
1838
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1839
+ */
1836
1840
 
1837
1841
  /**
1838
1842
  * @@@
@@ -2324,7 +2328,7 @@ function joinLlmExecutionTools() {
2324
2328
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2325
2329
  */
2326
2330
 
2327
- 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"}];
2331
+ 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"}];
2328
2332
 
2329
2333
  /**
2330
2334
  * This error indicates that the pipeline collection cannot be propperly loaded
@@ -2428,6 +2432,9 @@ var ERRORS = {
2428
2432
  UnexpectedError: UnexpectedError,
2429
2433
  // TODO: [🪑]> VersionMismatchError,
2430
2434
  };
2435
+ /**
2436
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2437
+ */
2431
2438
 
2432
2439
  /**
2433
2440
  * Deserializes the error object
@@ -2489,8 +2496,8 @@ function isPipelinePrepared(pipeline) {
2489
2496
  return false;
2490
2497
  }
2491
2498
  /*
2492
- TODO: [🧠][🍫] `templates` can not be determined if they are fully prepared SO ignoring them
2493
- > if (!pipeline.templates.every(({ preparedContent }) => preparedContent === undefined)) {
2499
+ TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
2500
+ > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
2494
2501
  > return false;
2495
2502
  > }
2496
2503
  */
@@ -2503,7 +2510,7 @@ function isPipelinePrepared(pipeline) {
2503
2510
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2504
2511
  * - [🏍] ? Is context in each template
2505
2512
  * - [♨] Are examples prepared
2506
- * - [♨] Are templates prepared
2513
+ * - [♨] Are tasks prepared
2507
2514
  */
2508
2515
 
2509
2516
  /**
@@ -2580,9 +2587,9 @@ function extractVariables(script) {
2580
2587
  * @throws {ParseError} if the script is invalid
2581
2588
  * @public exported from `@promptbook/utils`
2582
2589
  */
2583
- function extractParameterNamesFromTemplate(template) {
2590
+ function extractParameterNamesFromTask(template) {
2584
2591
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
2585
- var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
2592
+ var title = template.title, description = template.description, taskType = template.taskType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
2586
2593
  var parameterNames = new Set();
2587
2594
  try {
2588
2595
  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()) {
@@ -2597,7 +2604,7 @@ function extractParameterNamesFromTemplate(template) {
2597
2604
  }
2598
2605
  finally { if (e_1) throw e_1.error; }
2599
2606
  }
2600
- if (templateType === 'SCRIPT_TEMPLATE') {
2607
+ if (taskType === 'SCRIPT_TASK') {
2601
2608
  try {
2602
2609
  for (var _g = __values(extractVariables(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
2603
2610
  var parameterName = _h.value;
@@ -3028,6 +3035,9 @@ var FORMAT_DEFINITIONS = [
3028
3035
  TextFormatDefinition,
3029
3036
  CsvFormatDefinition,
3030
3037
  ];
3038
+ /**
3039
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3040
+ */
3031
3041
 
3032
3042
  /**
3033
3043
  * Maps available parameters to expected parameters
@@ -3263,7 +3273,7 @@ function replaceParameters(template, parameters) {
3263
3273
  }
3264
3274
  finally { if (e_1) throw e_1.error; }
3265
3275
  }
3266
- var replacedTemplate = template;
3276
+ var replacedTemplates = template;
3267
3277
  var match;
3268
3278
  var loopLimit = LOOP_LIMIT;
3269
3279
  var _loop_1 = function () {
@@ -3292,24 +3302,24 @@ function replaceParameters(template, parameters) {
3292
3302
  .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
3293
3303
  .join('\n');
3294
3304
  }
3295
- replacedTemplate =
3296
- replacedTemplate.substring(0, match.index + precol.length) +
3305
+ replacedTemplates =
3306
+ replacedTemplates.substring(0, match.index + precol.length) +
3297
3307
  parameterValue +
3298
- replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
3308
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
3299
3309
  };
3300
3310
  while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
3301
- .exec(replacedTemplate))) {
3311
+ .exec(replacedTemplates))) {
3302
3312
  _loop_1();
3303
3313
  }
3304
3314
  // [💫] Check if there are parameters that are not closed properly
3305
- if (/{\w+$/.test(replacedTemplate)) {
3315
+ if (/{\w+$/.test(replacedTemplates)) {
3306
3316
  throw new PipelineExecutionError('Parameter is not closed');
3307
3317
  }
3308
3318
  // [💫] Check if there are parameters that are not opened properly
3309
- if (/^\w+}/.test(replacedTemplate)) {
3319
+ if (/^\w+}/.test(replacedTemplates)) {
3310
3320
  throw new PipelineExecutionError('Parameter is not opened');
3311
3321
  }
3312
- return replacedTemplate;
3322
+ return replacedTemplates;
3313
3323
  }
3314
3324
 
3315
3325
  /**
@@ -3341,6 +3351,7 @@ var CHARACTERS_PER_STANDARD_LINE = 63;
3341
3351
  var LINES_PER_STANDARD_PAGE = 44;
3342
3352
  /**
3343
3353
  * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
3354
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3344
3355
  */
3345
3356
 
3346
3357
  /**
@@ -3681,6 +3692,7 @@ var CountUtils = {
3681
3692
  };
3682
3693
  /**
3683
3694
  * TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
3695
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3684
3696
  */
3685
3697
 
3686
3698
  /**
@@ -3751,12 +3763,12 @@ function isPassingExpectations(expectations, value) {
3751
3763
  */
3752
3764
  function executeAttempts(options) {
3753
3765
  return __awaiter(this, void 0, void 0, function () {
3754
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3766
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTaskResult, _llms, llmTools, _loop_1, attempt, state_1;
3755
3767
  return __generator(this, function (_a) {
3756
3768
  switch (_a.label) {
3757
3769
  case 0:
3758
- 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;
3759
- $ongoingTemplateResult = {
3770
+ 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;
3771
+ $ongoingTaskResult = {
3760
3772
  $result: null,
3761
3773
  $resultString: null,
3762
3774
  $expectError: null,
@@ -3776,52 +3788,51 @@ function executeAttempts(options) {
3776
3788
  if (isJokerAttempt && !jokerParameterName) {
3777
3789
  throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
3778
3790
  }
3779
- $ongoingTemplateResult.$result = null;
3780
- $ongoingTemplateResult.$resultString = null;
3781
- $ongoingTemplateResult.$expectError = null;
3791
+ $ongoingTaskResult.$result = null;
3792
+ $ongoingTaskResult.$resultString = null;
3793
+ $ongoingTaskResult.$expectError = null;
3782
3794
  if (isJokerAttempt) {
3783
3795
  if (parameters[jokerParameterName] === undefined) {
3784
3796
  throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
3785
3797
  // <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
3786
3798
  }
3787
3799
  else {
3788
- $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
3800
+ $ongoingTaskResult.$resultString = parameters[jokerParameterName];
3789
3801
  }
3790
3802
  }
3791
3803
  _t.label = 1;
3792
3804
  case 1:
3793
3805
  _t.trys.push([1, 43, 44, 45]);
3794
3806
  if (!!isJokerAttempt) return [3 /*break*/, 25];
3795
- _b = template.templateType;
3807
+ _b = task.taskType;
3796
3808
  switch (_b) {
3797
- case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3798
- case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
3799
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
3800
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
3809
+ case 'SIMPLE_TASK': return [3 /*break*/, 2];
3810
+ case 'PROMPT_TASK': return [3 /*break*/, 3];
3811
+ case 'SCRIPT_TASK': return [3 /*break*/, 11];
3812
+ case 'DIALOG_TASK': return [3 /*break*/, 22];
3801
3813
  }
3802
3814
  return [3 /*break*/, 24];
3803
3815
  case 2:
3804
- $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
3816
+ $ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
3805
3817
  return [3 /*break*/, 25];
3806
3818
  case 3:
3807
- modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
3808
- $ongoingTemplateResult.$prompt = {
3809
- title: template.title,
3819
+ modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
3820
+ $ongoingTaskResult.$prompt = {
3821
+ title: task.title,
3810
3822
  pipelineUrl: "".concat(preparedPipeline.pipelineUrl
3811
3823
  ? preparedPipeline.pipelineUrl
3812
- : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
3813
- // <- TODO: Here should be maybe also subformat index to distinguish between same template with different subformat values
3824
+ : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(task.name
3825
+ // <- TODO: Here should be maybe also subformat index to distinguish between same task with different subformat values
3814
3826
  ),
3815
3827
  parameters: parameters,
3816
3828
  content: preparedContent,
3817
3829
  modelRequirements: modelRequirements,
3818
3830
  expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
3819
3831
  var name = _a.name;
3820
- return name === template.personaName;
3821
- }) ||
3822
- {})), template.expectations),
3823
- format: template.format,
3824
- postprocessingFunctionNames: template.postprocessingFunctionNames,
3832
+ return name === task.personaName;
3833
+ }) || {})), task.expectations),
3834
+ format: task.format,
3835
+ postprocessingFunctionNames: task.postprocessingFunctionNames,
3825
3836
  }; // <- TODO: Not very good type guard
3826
3837
  _c = modelRequirements.modelVariant;
3827
3838
  switch (_c) {
@@ -3831,36 +3842,35 @@ function executeAttempts(options) {
3831
3842
  }
3832
3843
  return [3 /*break*/, 9];
3833
3844
  case 4:
3834
- _d = $ongoingTemplateResult;
3845
+ _d = $ongoingTaskResult;
3835
3846
  return [4 /*yield*/, llmTools.callChatModel(
3836
3847
  // <- TODO: [🧁] Check that `callChatModel` is defined
3837
- $deepFreeze($ongoingTemplateResult.$prompt))];
3848
+ $deepFreeze($ongoingTaskResult.$prompt))];
3838
3849
  case 5:
3839
3850
  _d.$chatResult = _t.sent();
3840
3851
  // TODO: [🍬] Destroy chatThread
3841
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
3842
- $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
3852
+ $ongoingTaskResult.$result = $ongoingTaskResult.$chatResult;
3853
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$chatResult.content;
3843
3854
  return [3 /*break*/, 10];
3844
3855
  case 6:
3845
- _e = $ongoingTemplateResult;
3856
+ _e = $ongoingTaskResult;
3846
3857
  return [4 /*yield*/, llmTools.callCompletionModel(
3847
3858
  // <- TODO: [🧁] Check that `callCompletionModel` is defined
3848
- $deepFreeze($ongoingTemplateResult.$prompt))];
3859
+ $deepFreeze($ongoingTaskResult.$prompt))];
3849
3860
  case 7:
3850
3861
  _e.$completionResult = _t.sent();
3851
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
3852
- $ongoingTemplateResult.$resultString =
3853
- $ongoingTemplateResult.$completionResult.content;
3862
+ $ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
3863
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
3854
3864
  return [3 /*break*/, 10];
3855
3865
  case 8: throw new PipelineExecutionError(spaceTrim$1(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 "); }));
3856
- case 9: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3866
+ case 9: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(task.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3857
3867
  case 10: return [3 /*break*/, 25];
3858
3868
  case 11:
3859
3869
  if (arrayableToArray(tools.script).length === 0) {
3860
3870
  throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3861
3871
  }
3862
- if (!template.contentLanguage) {
3863
- throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3872
+ if (!task.contentLanguage) {
3873
+ throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT TASK \"".concat(task.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3864
3874
  }
3865
3875
  _t.label = 12;
3866
3876
  case 12:
@@ -3873,9 +3883,9 @@ function executeAttempts(options) {
3873
3883
  _t.label = 14;
3874
3884
  case 14:
3875
3885
  _t.trys.push([14, 16, , 17]);
3876
- _h = $ongoingTemplateResult;
3886
+ _h = $ongoingTaskResult;
3877
3887
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
3878
- scriptLanguage: template.contentLanguage,
3888
+ scriptLanguage: task.contentLanguage,
3879
3889
  script: preparedContent,
3880
3890
  parameters: parameters,
3881
3891
  }))];
@@ -3890,7 +3900,7 @@ function executeAttempts(options) {
3890
3900
  if (error_1 instanceof UnexpectedError) {
3891
3901
  throw error_1;
3892
3902
  }
3893
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
3903
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_1);
3894
3904
  return [3 /*break*/, 17];
3895
3905
  case 17:
3896
3906
  _g = _f.next();
@@ -3907,14 +3917,14 @@ function executeAttempts(options) {
3907
3917
  finally { if (e_1) throw e_1.error; }
3908
3918
  return [7 /*endfinally*/];
3909
3919
  case 21:
3910
- if ($ongoingTemplateResult.$resultString !== null) {
3920
+ if ($ongoingTaskResult.$resultString !== null) {
3911
3921
  return [3 /*break*/, 25];
3912
3922
  }
3913
- if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
3914
- throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
3923
+ if ($ongoingTaskResult.$scriptPipelineExecutionErrors.length === 1) {
3924
+ throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
3915
3925
  }
3916
3926
  else {
3917
- throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
3927
+ throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat($ongoingTaskResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTaskResult.$scriptPipelineExecutionErrors
3918
3928
  .map(function (error) { return '- ' + error.message; })
3919
3929
  .join('\n\n')), "\n "); }));
3920
3930
  }
@@ -3922,27 +3932,27 @@ function executeAttempts(options) {
3922
3932
  if (tools.userInterface === undefined) {
3923
3933
  throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3924
3934
  }
3925
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3926
- _j = $ongoingTemplateResult;
3935
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
3936
+ _j = $ongoingTaskResult;
3927
3937
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
3928
- promptTitle: template.title,
3929
- promptMessage: replaceParameters(template.description || '', parameters),
3938
+ promptTitle: task.title,
3939
+ promptMessage: replaceParameters(task.description || '', parameters),
3930
3940
  defaultValue: replaceParameters(preparedContent, parameters),
3931
3941
  // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
3932
3942
  placeholder: undefined,
3933
3943
  priority: priority,
3934
3944
  }))];
3935
3945
  case 23:
3936
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3946
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
3937
3947
  _j.$resultString = _t.sent();
3938
3948
  return [3 /*break*/, 25];
3939
- case 24: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3949
+ case 24: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3940
3950
  case 25:
3941
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3951
+ if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
3942
3952
  _t.label = 26;
3943
3953
  case 26:
3944
3954
  _t.trys.push([26, 40, 41, 42]);
3945
- _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
3955
+ _k = (e_3 = void 0, __values(task.postprocessingFunctionNames)), _l = _k.next();
3946
3956
  _t.label = 27;
3947
3957
  case 27:
3948
3958
  if (!!_l.done) return [3 /*break*/, 39];
@@ -3959,13 +3969,13 @@ function executeAttempts(options) {
3959
3969
  _t.label = 30;
3960
3970
  case 30:
3961
3971
  _t.trys.push([30, 32, , 33]);
3962
- _p = $ongoingTemplateResult;
3972
+ _p = $ongoingTaskResult;
3963
3973
  return [4 /*yield*/, scriptTools.execute({
3964
3974
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
3965
3975
  script: "".concat(functionName, "(resultString)"),
3966
3976
  parameters: {
3967
- resultString: $ongoingTemplateResult.$resultString || '',
3968
- // Note: No ...parametersForTemplate, because working with result only
3977
+ resultString: $ongoingTaskResult.$resultString || '',
3978
+ // Note: No ...parametersForTask, because working with result only
3969
3979
  },
3970
3980
  })];
3971
3981
  case 31:
@@ -3981,7 +3991,7 @@ function executeAttempts(options) {
3981
3991
  throw error_2;
3982
3992
  }
3983
3993
  postprocessingError = error_2;
3984
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
3994
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_2);
3985
3995
  return [3 /*break*/, 33];
3986
3996
  case 33:
3987
3997
  _o = _m.next();
@@ -4018,12 +4028,12 @@ function executeAttempts(options) {
4018
4028
  return [7 /*endfinally*/];
4019
4029
  case 42:
4020
4030
  // TODO: [💝] Unite object for expecting amount and format
4021
- if (template.format) {
4022
- if (template.format === 'JSON') {
4023
- if (!isValidJsonString($ongoingTemplateResult.$resultString || '')) {
4031
+ if (task.format) {
4032
+ if (task.format === 'JSON') {
4033
+ if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
4024
4034
  // TODO: [🏢] Do more universally via `FormatDefinition`
4025
4035
  try {
4026
- $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
4036
+ $ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
4027
4037
  }
4028
4038
  catch (error) {
4029
4039
  throw new ExpectError(spaceTrim$1(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
@@ -4032,12 +4042,12 @@ function executeAttempts(options) {
4032
4042
  }
4033
4043
  }
4034
4044
  else {
4035
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4045
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4036
4046
  }
4037
4047
  }
4038
4048
  // TODO: [💝] Unite object for expecting amount and format
4039
- if (template.expectations) {
4040
- checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
4049
+ if (task.expectations) {
4050
+ checkExpectations(task.expectations, $ongoingTaskResult.$resultString || '');
4041
4051
  }
4042
4052
  return [2 /*return*/, "break-attempts"];
4043
4053
  case 43:
@@ -4045,38 +4055,38 @@ function executeAttempts(options) {
4045
4055
  if (!(error_3 instanceof ExpectError)) {
4046
4056
  throw error_3;
4047
4057
  }
4048
- $ongoingTemplateResult.$expectError = error_3;
4058
+ $ongoingTaskResult.$expectError = error_3;
4049
4059
  return [3 /*break*/, 45];
4050
4060
  case 44:
4051
4061
  if (!isJokerAttempt &&
4052
- template.templateType === 'PROMPT_TEMPLATE' &&
4053
- $ongoingTemplateResult.$prompt
4062
+ task.taskType === 'PROMPT_TASK' &&
4063
+ $ongoingTaskResult.$prompt
4054
4064
  // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
4055
4065
  // In that case we don’t want to make a report about it because it’s not a llm execution error
4056
4066
  ) {
4057
- // TODO: [🧠] Maybe put other templateTypes into report
4067
+ // TODO: [🧠] Maybe put other taskTypes into report
4058
4068
  $executionReport.promptExecutions.push({
4059
- prompt: __assign({}, $ongoingTemplateResult.$prompt),
4060
- result: $ongoingTemplateResult.$result || undefined,
4061
- error: $ongoingTemplateResult.$expectError === null
4069
+ prompt: __assign({}, $ongoingTaskResult.$prompt),
4070
+ result: $ongoingTaskResult.$result || undefined,
4071
+ error: $ongoingTaskResult.$expectError === null
4062
4072
  ? undefined
4063
- : serializeError($ongoingTemplateResult.$expectError),
4073
+ : serializeError($ongoingTaskResult.$expectError),
4064
4074
  });
4065
4075
  }
4066
4076
  return [7 /*endfinally*/];
4067
4077
  case 45:
4068
- if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
4078
+ if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
4069
4079
  throw new PipelineExecutionError(spaceTrim$1(function (block) {
4070
4080
  var _a, _b, _c;
4071
- 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) || '')
4081
+ 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) || '')
4072
4082
  .split('\n')
4073
4083
  .map(function (line) { return "> ".concat(line); })
4074
- .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) || '')
4084
+ .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) || '')
4075
4085
  .split('\n')
4076
4086
  .map(function (line) { return "> ".concat(line); })
4077
- .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
4087
+ .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTaskResult.$resultString === null
4078
4088
  ? 'null'
4079
- : $ongoingTemplateResult.$resultString
4089
+ : $ongoingTaskResult.$resultString
4080
4090
  .split('\n')
4081
4091
  .map(function (line) { return "> ".concat(line); })
4082
4092
  .join('\n')), "\n ---\n ");
@@ -4101,10 +4111,10 @@ function executeAttempts(options) {
4101
4111
  attempt++;
4102
4112
  return [3 /*break*/, 1];
4103
4113
  case 4:
4104
- if ($ongoingTemplateResult.$resultString === null) {
4114
+ if ($ongoingTaskResult.$resultString === null) {
4105
4115
  throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
4106
4116
  }
4107
- return [2 /*return*/, $ongoingTemplateResult.$resultString];
4117
+ return [2 /*return*/, $ongoingTaskResult.$resultString];
4108
4118
  }
4109
4119
  });
4110
4120
  });
@@ -4120,36 +4130,36 @@ function executeAttempts(options) {
4120
4130
  */
4121
4131
  function executeFormatSubvalues(options) {
4122
4132
  return __awaiter(this, void 0, void 0, function () {
4123
- var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
4133
+ var task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
4124
4134
  var _this = this;
4125
4135
  return __generator(this, function (_a) {
4126
4136
  switch (_a.label) {
4127
4137
  case 0:
4128
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
4129
- if (template.foreach === undefined) {
4138
+ task = options.task, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
4139
+ if (task.foreach === undefined) {
4130
4140
  return [2 /*return*/, /* not await */ executeAttempts(options)];
4131
4141
  }
4132
4142
  if (jokerParameterNames.length !== 0) {
4133
4143
  throw new UnexpectedError(spaceTrim(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 "); }));
4134
4144
  }
4135
- parameterValue = parameters[template.foreach.parameterName] || '';
4145
+ parameterValue = parameters[task.foreach.parameterName] || '';
4136
4146
  formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
4137
- return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(template.foreach.formatName);
4147
+ return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(task.foreach.formatName);
4138
4148
  });
4139
4149
  if (formatDefinition === undefined) {
4140
4150
  throw new UnexpectedError(
4141
4151
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
4142
- spaceTrim(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; })
4152
+ spaceTrim(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; })
4143
4153
  .map(function (formatName) { return "- ".concat(formatName); })
4144
4154
  .join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
4145
4155
  }
4146
4156
  subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
4147
- return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(template.foreach.subformatName);
4157
+ return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(task.foreach.subformatName);
4148
4158
  });
4149
4159
  if (subvalueDefinition === undefined) {
4150
4160
  throw new UnexpectedError(
4151
4161
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
4152
- spaceTrim(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
4162
+ spaceTrim(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
4153
4163
  .map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
4154
4164
  .map(function (subvalueName) { return "- ".concat(subvalueName); })
4155
4165
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -4158,7 +4168,7 @@ function executeFormatSubvalues(options) {
4158
4168
  formatSettings = csvSettings;
4159
4169
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
4160
4170
  }
4161
- return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
4171
+ return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
4162
4172
  var mappedParameters, allSubparameters, subresultString;
4163
4173
  return __generator(this, function (_a) {
4164
4174
  switch (_a.label) {
@@ -4167,7 +4177,7 @@ function executeFormatSubvalues(options) {
4167
4177
  // TODO: When done [🐚] Report progress also for each subvalue here
4168
4178
  try {
4169
4179
  mappedParameters = mapAvailableToExpectedParameters({
4170
- expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
4180
+ expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
4171
4181
  availableParameters: subparameters,
4172
4182
  });
4173
4183
  }
@@ -4200,7 +4210,7 @@ function executeFormatSubvalues(options) {
4200
4210
  *
4201
4211
  * @private internal utility of `createPipelineExecutor`
4202
4212
  */
4203
- function getContextForTemplate(template) {
4213
+ function getContextForTask(task) {
4204
4214
  return __awaiter(this, void 0, void 0, function () {
4205
4215
  return __generator(this, function (_a) {
4206
4216
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
@@ -4213,15 +4223,10 @@ function getContextForTemplate(template) {
4213
4223
  *
4214
4224
  * @private internal utility of `createPipelineExecutor`
4215
4225
  */
4216
- function getKnowledgeForTemplate(options) {
4226
+ function getExamplesForTask(task) {
4217
4227
  return __awaiter(this, void 0, void 0, function () {
4218
- var preparedPipeline;
4219
4228
  return __generator(this, function (_a) {
4220
- preparedPipeline = options.preparedPipeline, options.template;
4221
- return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4222
- var content = _a.content;
4223
- return "- ".concat(content);
4224
- }).join('\n')];
4229
+ return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4225
4230
  });
4226
4231
  });
4227
4232
  }
@@ -4231,10 +4236,15 @@ function getKnowledgeForTemplate(options) {
4231
4236
  *
4232
4237
  * @private internal utility of `createPipelineExecutor`
4233
4238
  */
4234
- function getExamplesForTemplate(template) {
4239
+ function getKnowledgeForTask(options) {
4235
4240
  return __awaiter(this, void 0, void 0, function () {
4241
+ var preparedPipeline;
4236
4242
  return __generator(this, function (_a) {
4237
- return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4243
+ preparedPipeline = options.preparedPipeline, options.task;
4244
+ return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4245
+ var content = _a.content;
4246
+ return "- ".concat(content);
4247
+ }).join('\n')];
4238
4248
  });
4239
4249
  });
4240
4250
  }
@@ -4244,21 +4254,21 @@ function getExamplesForTemplate(template) {
4244
4254
  *
4245
4255
  * @private internal utility of `createPipelineExecutor`
4246
4256
  */
4247
- function getReservedParametersForTemplate(options) {
4257
+ function getReservedParametersForTask(options) {
4248
4258
  return __awaiter(this, void 0, void 0, function () {
4249
- var preparedPipeline, template, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
4259
+ var preparedPipeline, task, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
4250
4260
  var e_1, _a;
4251
4261
  return __generator(this, function (_b) {
4252
4262
  switch (_b.label) {
4253
4263
  case 0:
4254
- preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
4255
- return [4 /*yield*/, getContextForTemplate()];
4264
+ preparedPipeline = options.preparedPipeline, task = options.task, pipelineIdentification = options.pipelineIdentification;
4265
+ return [4 /*yield*/, getContextForTask()];
4256
4266
  case 1:
4257
4267
  context = _b.sent();
4258
- return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
4268
+ return [4 /*yield*/, getKnowledgeForTask({ preparedPipeline: preparedPipeline, task: task })];
4259
4269
  case 2:
4260
4270
  knowledge = _b.sent();
4261
- return [4 /*yield*/, getExamplesForTemplate()];
4271
+ return [4 /*yield*/, getExamplesForTask()];
4262
4272
  case 3:
4263
4273
  examples = _b.sent();
4264
4274
  currentDate = new Date().toISOString();
@@ -4301,31 +4311,31 @@ function getReservedParametersForTemplate(options) {
4301
4311
  *
4302
4312
  * @private internal utility of `createPipelineExecutor`
4303
4313
  */
4304
- function executeTemplate(options) {
4314
+ function executeTask(options) {
4305
4315
  return __awaiter(this, void 0, void 0, function () {
4306
- 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;
4316
+ 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;
4307
4317
  var e_1, _g, _h;
4308
4318
  return __generator(this, function (_j) {
4309
4319
  switch (_j.label) {
4310
4320
  case 0:
4311
- 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;
4312
- name = "pipeline-executor-frame-".concat(currentTemplate.name);
4313
- title = currentTemplate.title;
4314
- priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
4321
+ 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;
4322
+ name = "pipeline-executor-frame-".concat(currentTask.name);
4323
+ title = currentTask.title;
4324
+ priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
4315
4325
  return [4 /*yield*/, onProgress({
4316
4326
  name: name,
4317
4327
  title: title,
4318
4328
  isStarted: false,
4319
4329
  isDone: false,
4320
- templateType: currentTemplate.templateType,
4321
- parameterName: currentTemplate.resultingParameterName,
4330
+ taskType: currentTask.taskType,
4331
+ parameterName: currentTask.resultingParameterName,
4322
4332
  parameterValue: null,
4323
4333
  // <- [🍸]
4324
4334
  })];
4325
4335
  case 1:
4326
4336
  _j.sent();
4327
- usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
4328
- dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
4337
+ usedParameterNames = extractParameterNamesFromTask(currentTask);
4338
+ dependentParameterNames = new Set(currentTask.dependentParameterNames);
4329
4339
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4330
4340
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
4331
4341
  throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Dependent parameters are not consistent with used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames)
@@ -4336,9 +4346,9 @@ function executeTemplate(options) {
4336
4346
  }
4337
4347
  _c = (_b = Object).freeze;
4338
4348
  _d = [{}];
4339
- return [4 /*yield*/, getReservedParametersForTemplate({
4349
+ return [4 /*yield*/, getReservedParametersForTask({
4340
4350
  preparedPipeline: preparedPipeline,
4341
- template: currentTemplate,
4351
+ task: currentTask,
4342
4352
  pipelineIdentification: pipelineIdentification,
4343
4353
  })];
4344
4354
  case 2:
@@ -4356,11 +4366,11 @@ function executeTemplate(options) {
4356
4366
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4357
4367
  // Houston, we have a problem
4358
4368
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
4359
- throw new UnexpectedError(spaceTrim$1(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 "); }));
4369
+ throw new UnexpectedError(spaceTrim$1(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 "); }));
4360
4370
  }
4361
4371
  };
4362
4372
  try {
4363
- // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
4373
+ // Note: [2] Check that all used parameters are defined and removing unused parameters for this task
4364
4374
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4365
4375
  for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4366
4376
  parameterName = _f.value;
@@ -4376,18 +4386,16 @@ function executeTemplate(options) {
4376
4386
  }
4377
4387
  // 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
4378
4388
  Object.freeze(parameters);
4379
- maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
4380
- jokerParameterNames = currentTemplate.jokerParameterNames || [];
4381
- preparedContent = (currentTemplate.preparedContent || '{content}')
4382
- .split('{content}')
4383
- .join(currentTemplate.content);
4389
+ maxAttempts = currentTask.taskType === 'DIALOG_TASK' ? Infinity : maxExecutionAttempts;
4390
+ jokerParameterNames = currentTask.jokerParameterNames || [];
4391
+ preparedContent = (currentTask.preparedContent || '{content}').split('{content}').join(currentTask.content);
4384
4392
  return [4 /*yield*/, executeFormatSubvalues({
4385
4393
  jokerParameterNames: jokerParameterNames,
4386
4394
  priority: priority,
4387
4395
  maxAttempts: maxAttempts,
4388
4396
  preparedContent: preparedContent,
4389
4397
  parameters: parameters,
4390
- template: currentTemplate,
4398
+ task: currentTask,
4391
4399
  preparedPipeline: preparedPipeline,
4392
4400
  tools: tools,
4393
4401
  $executionReport: $executionReport,
@@ -4400,15 +4408,15 @@ function executeTemplate(options) {
4400
4408
  title: title,
4401
4409
  isStarted: true,
4402
4410
  isDone: true,
4403
- templateType: currentTemplate.templateType,
4404
- parameterName: currentTemplate.resultingParameterName,
4411
+ taskType: currentTask.taskType,
4412
+ parameterName: currentTask.resultingParameterName,
4405
4413
  parameterValue: resultString,
4406
4414
  // <- [🍸]
4407
4415
  })];
4408
4416
  case 4:
4409
4417
  _j.sent();
4410
4418
  return [2 /*return*/, Object.freeze((_h = {},
4411
- _h[currentTemplate.resultingParameterName] =
4419
+ _h[currentTask.resultingParameterName] =
4412
4420
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
4413
4421
  resultString,
4414
4422
  _h))];
@@ -4470,7 +4478,7 @@ function filterJustOutputParameters(options) {
4470
4478
  */
4471
4479
  function executePipeline(options) {
4472
4480
  return __awaiter(this, void 0, void 0, function () {
4473
- 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;
4481
+ 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;
4474
4482
  var e_1, _f, e_2, _g;
4475
4483
  return __generator(this, function (_h) {
4476
4484
  switch (_h.label) {
@@ -4624,11 +4632,11 @@ function executePipeline(options) {
4624
4632
  var name = _a.name;
4625
4633
  return name;
4626
4634
  });
4627
- unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.templates), false);
4635
+ unresovedTasks_1 = __spreadArray([], __read(preparedPipeline.tasks), false);
4628
4636
  resolving_1 = [];
4629
4637
  loopLimit = LOOP_LIMIT;
4630
4638
  _loop_2 = function () {
4631
- var currentTemplate, work_1;
4639
+ var currentTask, work_1;
4632
4640
  return __generator(this, function (_k) {
4633
4641
  switch (_k.label) {
4634
4642
  case 0:
@@ -4636,15 +4644,15 @@ function executePipeline(options) {
4636
4644
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
4637
4645
  throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
4638
4646
  }
4639
- currentTemplate = unresovedTemplates_1.find(function (template) {
4640
- return template.dependentParameterNames.every(function (name) {
4647
+ currentTask = unresovedTasks_1.find(function (task) {
4648
+ return task.dependentParameterNames.every(function (name) {
4641
4649
  return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
4642
4650
  });
4643
4651
  });
4644
- if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
4652
+ if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
4645
4653
  throw new UnexpectedError(
4646
4654
  // TODO: [🐎] DRY
4647
- spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates_1
4655
+ spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks_1
4648
4656
  .map(function (_a) {
4649
4657
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
4650
4658
  return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
@@ -4663,14 +4671,14 @@ function executePipeline(options) {
4663
4671
  .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
4664
4672
  .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
4665
4673
  case 1:
4666
- if (!!currentTemplate) return [3 /*break*/, 3];
4674
+ if (!!currentTask) return [3 /*break*/, 3];
4667
4675
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
4668
4676
  case 2:
4669
4677
  /* [🤹‍♂️] */ _k.sent();
4670
4678
  return [3 /*break*/, 4];
4671
4679
  case 3:
4672
- unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
4673
- work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4680
+ unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
4681
+ work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4674
4682
  if (isReturned) {
4675
4683
  throw new UnexpectedError(spaceTrim$1(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)
4676
4684
  .split('\n')
@@ -4680,16 +4688,16 @@ function executePipeline(options) {
4680
4688
  if (onProgress) {
4681
4689
  onProgress(progress);
4682
4690
  }
4683
- }, $executionReport: executionReport, pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
4691
+ }, $executionReport: executionReport, pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
4684
4692
  .then(function (newParametersToPass) {
4685
4693
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
4686
- resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
4694
+ resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
4687
4695
  })
4688
4696
  .then(function () {
4689
4697
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
4690
4698
  });
4691
4699
  // <- Note: Errors are catched here [3]
4692
- // 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
4700
+ // 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
4693
4701
  resolving_1.push(work_1);
4694
4702
  _k.label = 4;
4695
4703
  case 4: return [2 /*return*/];
@@ -4698,7 +4706,7 @@ function executePipeline(options) {
4698
4706
  };
4699
4707
  _h.label = 21;
4700
4708
  case 21:
4701
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
4709
+ if (!(unresovedTasks_1.length > 0)) return [3 /*break*/, 23];
4702
4710
  return [5 /*yield**/, _loop_2()];
4703
4711
  case 22:
4704
4712
  _h.sent();
@@ -5239,6 +5247,9 @@ function normalizeToKebabCase(text) {
5239
5247
  normalizedName = normalizedName.replace(/-$/, '');
5240
5248
  return normalizedName;
5241
5249
  }
5250
+ /**
5251
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5252
+ */
5242
5253
 
5243
5254
  /**
5244
5255
  * Creates unique name for the source
@@ -5610,7 +5621,7 @@ TODO: [🧊] This is how it can look in future
5610
5621
  */
5611
5622
  function clonePipeline(pipeline) {
5612
5623
  // Note: Not using spread operator (...) because @@@
5613
- 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;
5624
+ 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;
5614
5625
  return {
5615
5626
  pipelineUrl: pipelineUrl,
5616
5627
  sourceFile: sourceFile,
@@ -5619,7 +5630,7 @@ function clonePipeline(pipeline) {
5619
5630
  description: description,
5620
5631
  formfactorName: formfactorName,
5621
5632
  parameters: parameters,
5622
- templates: templates,
5633
+ tasks: tasks,
5623
5634
  knowledgeSources: knowledgeSources,
5624
5635
  knowledgePieces: knowledgePieces,
5625
5636
  personas: personas,
@@ -5635,17 +5646,17 @@ function clonePipeline(pipeline) {
5635
5646
  *
5636
5647
  * @public exported from `@promptbook/core`
5637
5648
  */
5638
- function prepareTemplates(pipeline, tools, options) {
5649
+ function prepareTasks(pipeline, tools, options) {
5639
5650
  return __awaiter(this, void 0, void 0, function () {
5640
- var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
5651
+ var _a, maxParallelCount, tasks, knowledgePiecesCount, tasksPrepared;
5641
5652
  var _this = this;
5642
5653
  return __generator(this, function (_b) {
5643
5654
  switch (_b.label) {
5644
5655
  case 0:
5645
5656
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
5646
- templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5647
- templatesPrepared = new Array(templates.length);
5648
- 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 () {
5657
+ tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5658
+ tasksPrepared = new Array(tasks.length);
5659
+ 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 () {
5649
5660
  var dependentParameterNames, preparedContent, preparedTemplate;
5650
5661
  return __generator(this, function (_a) {
5651
5662
  dependentParameterNames = template.dependentParameterNames;
@@ -5658,13 +5669,13 @@ function prepareTemplates(pipeline, tools, options) {
5658
5669
  ], false);
5659
5670
  }
5660
5671
  preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
5661
- templatesPrepared[index] = preparedTemplate;
5672
+ tasksPrepared[index] = preparedTemplate;
5662
5673
  return [2 /*return*/];
5663
5674
  });
5664
5675
  }); })];
5665
5676
  case 1:
5666
5677
  _b.sent();
5667
- return [2 /*return*/, { templatesPrepared: templatesPrepared }];
5678
+ return [2 /*return*/, { tasksPrepared: tasksPrepared }];
5668
5679
  }
5669
5680
  });
5670
5681
  });
@@ -5672,7 +5683,7 @@ function prepareTemplates(pipeline, tools, options) {
5672
5683
  /**
5673
5684
  * TODO: [🧠] Add context to each template (if missing)
5674
5685
  * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
5675
- * TODO: [♨][main] !!! Prepare index the examples and maybe templates
5686
+ * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
5676
5687
  * TODO: Write tests for `preparePipeline`
5677
5688
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
5678
5689
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -5689,12 +5700,12 @@ function prepareTemplates(pipeline, tools, options) {
5689
5700
  */
5690
5701
  function preparePipeline(pipeline, tools, options) {
5691
5702
  return __awaiter(this, void 0, void 0, function () {
5692
- var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, templates,
5703
+ var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, tasks,
5693
5704
  /*
5694
5705
  <- TODO: [🧠][🪑] `promptbookVersion` */
5695
5706
  knowledgeSources /*
5696
5707
  <- TODO: [🧊] `knowledgePieces` */, personas /*
5697
- <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, templatesPrepared /* TODO: parameters: parametersPrepared*/;
5708
+ <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
5698
5709
  var _this = this;
5699
5710
  return __generator(this, function (_c) {
5700
5711
  switch (_c.label) {
@@ -5703,7 +5714,7 @@ function preparePipeline(pipeline, tools, options) {
5703
5714
  return [2 /*return*/, pipeline];
5704
5715
  }
5705
5716
  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;
5706
- parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5717
+ parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5707
5718
  if (tools === undefined || tools.llm === undefined) {
5708
5719
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
5709
5720
  }
@@ -5746,9 +5757,9 @@ function preparePipeline(pipeline, tools, options) {
5746
5757
  case 2:
5747
5758
  partialknowledgePiecesPrepared = _c.sent();
5748
5759
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
5749
- return [4 /*yield*/, prepareTemplates({
5760
+ return [4 /*yield*/, prepareTasks({
5750
5761
  parameters: parameters,
5751
- templates: templates,
5762
+ tasks: tasks,
5752
5763
  knowledgePiecesCount: knowledgePiecesPrepared.length,
5753
5764
  }, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), {
5754
5765
  rootDirname: rootDirname,
@@ -5756,12 +5767,12 @@ function preparePipeline(pipeline, tools, options) {
5756
5767
  isVerbose: isVerbose,
5757
5768
  })];
5758
5769
  case 3:
5759
- templatesPrepared = (_c.sent()).templatesPrepared;
5770
+ tasksPrepared = (_c.sent()).tasksPrepared;
5760
5771
  // ----- /Templates preparation -----
5761
5772
  // Note: Count total usage
5762
5773
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
5763
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
5764
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
5774
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
5775
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
5765
5776
  knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
5766
5777
  }
5767
5778
  });
@@ -5791,7 +5802,7 @@ var knowledgeCommandParser = {
5791
5802
  * BOILERPLATE command can be used in:
5792
5803
  */
5793
5804
  isUsedInPipelineHead: true,
5794
- isUsedInPipelineTemplate: false,
5805
+ isUsedInPipelineTask: false,
5795
5806
  /**
5796
5807
  * Description of the KNOWLEDGE command
5797
5808
  */
@@ -5869,18 +5880,18 @@ var knowledgeCommandParser = {
5869
5880
  */
5870
5881
 
5871
5882
  /**
5872
- * Parses the template command
5883
+ * Parses the section command
5873
5884
  *
5874
5885
  * @see `documentationUrl` for more details
5875
5886
  * @private within the commands folder
5876
5887
  */
5877
- var templateCommandParser = {
5888
+ var sectionCommandParser = {
5878
5889
  /**
5879
5890
  * Name of the command
5880
5891
  */
5881
- name: 'TEMPLATE',
5892
+ name: 'SECTION',
5882
5893
  /**
5883
- * Aliases for the TEMPLATE command
5894
+ * Aliases for the SECTION command
5884
5895
  */
5885
5896
  aliasNames: [
5886
5897
  'PROMPT',
@@ -5894,24 +5905,24 @@ var templateCommandParser = {
5894
5905
  'ACTION', // <- Note: [⛱]
5895
5906
  ],
5896
5907
  /**
5897
- * Aliases for the TEMPLATE command
5908
+ * Aliases for the SECTION command
5898
5909
  */
5899
- deprecatedNames: ['BLOCK', 'EXECUTE'],
5910
+ deprecatedNames: ['TEMPLATE', 'BLOCK', 'EXECUTE'],
5900
5911
  /**
5901
5912
  * BOILERPLATE command can be used in:
5902
5913
  */
5903
5914
  isUsedInPipelineHead: false,
5904
- isUsedInPipelineTemplate: true,
5915
+ isUsedInPipelineTask: true,
5905
5916
  /**
5906
- * Description of the TEMPLATE command
5917
+ * Description of the SECTION command
5907
5918
  */
5908
- description: "What should the code template template do",
5919
+ description: "Defines the purpose of the markdown section - if its a task and which type or something else",
5909
5920
  /**
5910
5921
  * Link to documentation
5911
5922
  */
5912
5923
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/64',
5913
5924
  /**
5914
- * Example usages of the TEMPLATE command
5925
+ * Example usages of the SECTION command
5915
5926
  */
5916
5927
  examples: [
5917
5928
  // Short form:
@@ -5926,101 +5937,100 @@ var templateCommandParser = {
5926
5937
  'ACTION',
5927
5938
  // -----------------
5928
5939
  // Recommended (reversed) form:
5929
- 'PROMPT TEMPLATE',
5930
- 'SIMPLE TEMPLATE',
5931
- 'SCRIPT TEMPLATE',
5932
- 'DIALOG TEMPLATE',
5940
+ 'PROMPT SECTION',
5941
+ 'SIMPLE SECTION',
5942
+ 'SCRIPT SECTION',
5943
+ 'DIALOG SECTION',
5933
5944
  // <- [🅱]
5934
- 'SAMPLE TEMPLATE',
5935
- 'KNOWLEDGE TEMPLATE',
5936
- 'INSTRUMENT TEMPLATE',
5937
- 'ACTION TEMPLATE',
5945
+ 'EXAMPLE SECTION',
5946
+ 'KNOWLEDGE SECTION',
5947
+ 'INSTRUMENT SECTION',
5948
+ 'ACTION SECTION',
5938
5949
  // -----------------
5939
5950
  // Standard form:
5940
- 'TEMPLATE PROMPT',
5941
- 'TEMPLATE SIMPLE',
5942
- 'TEMPLATE SCRIPT',
5943
- 'TEMPLATE DIALOG',
5951
+ 'SECTION PROMPT',
5952
+ 'SECTION SIMPLE',
5953
+ 'SECTION SCRIPT',
5954
+ 'SECTION DIALOG',
5944
5955
  // <- [🅱]
5945
- 'SAMPLE TEMPLATE',
5946
- 'KNOWLEDGE TEMPLATE',
5947
- 'INSTRUMENT TEMPLATE',
5948
- 'ACTION TEMPLATE',
5956
+ 'SECTION EXAMPLE',
5957
+ 'SECTION KNOWLEDGE',
5958
+ 'SECTION INSTRUMENT',
5959
+ 'SECTION ACTION',
5949
5960
  ],
5950
5961
  // TODO: [♓️] order: -10 /* <- Note: Putting before other commands */
5951
5962
  /**
5952
- * Parses the TEMPLATE command
5963
+ * Parses the SECTION command
5953
5964
  */
5954
5965
  parse: function (input) {
5955
5966
  var normalized = input.normalized;
5956
5967
  normalized = normalized.split('SAMPLE').join('EXAMPLE');
5957
- var templateTypes = TemplateTypes.filter(function (templateType) {
5958
- return normalized.includes(templateType.split('_TEMPLATE').join(''));
5959
- });
5960
- if (templateTypes.length !== 1) {
5961
- throw new ParseError(spaceTrim(function (template) { return "\n Unknown template type in TEMPLATE command\n\n Supported template types are:\n ".concat(template(TemplateTypes.join(', ')), "\n "); }));
5968
+ normalized = normalized.split('EXECUTE_').join('');
5969
+ var taskTypes = SectionTypes.filter(function (taskType) { return normalized.includes(taskType.split('_TASK').join('')); });
5970
+ if (taskTypes.length !== 1) {
5971
+ throw new ParseError(spaceTrim(function (block) { return "\n Unknown section type \"".concat(normalized, "\"\n\n Supported section types are:\n ").concat(block(SectionTypes.join(', ')), "\n "); }));
5962
5972
  }
5963
- var templateType = templateTypes[0];
5973
+ var taskType = taskTypes[0];
5964
5974
  return {
5965
- type: 'TEMPLATE',
5966
- templateType: templateType,
5975
+ type: 'SECTION',
5976
+ taskType: taskType,
5967
5977
  };
5968
5978
  },
5969
5979
  /**
5970
- * Apply the TEMPLATE command to the `pipelineJson`
5980
+ * Apply the SECTION command to the `pipelineJson`
5971
5981
  *
5972
- * Note: `$` is used to indicate that this function mutates given `templateJson`
5982
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
5973
5983
  */
5974
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
5975
- if ($templateJson.isTemplateTypeSet === true) {
5976
- throw new ParseError(spaceTrim("\n Template type is already defined in the template.\n It can be defined only once.\n "));
5984
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
5985
+ if ($taskJson.isSectionTypeSet === true) {
5986
+ throw new ParseError(spaceTrim("\n Section type is already defined in the section.\n It can be defined only once.\n "));
5977
5987
  }
5978
- $templateJson.isTemplateTypeSet = true;
5988
+ $taskJson.isSectionTypeSet = true;
5979
5989
  // TODO: [🍧] Rearrange better - but at bottom and unwrap from function
5980
5990
  var expectResultingParameterName = function () {
5981
- if ($templateJson.resultingParameterName) {
5991
+ if ($taskJson.resultingParameterName) {
5982
5992
  return;
5983
5993
  }
5984
- throw new ParseError(" Template section must end with -> {parameterName}");
5994
+ throw new ParseError("Task section and example section must end with return statement -> {parameterName}");
5985
5995
  };
5986
- if ($templateJson.content === undefined) {
5987
- throw new UnexpectedError("Content is missing in the templateJson - probbably commands are applied in wrong order");
5996
+ if ($taskJson.content === undefined) {
5997
+ throw new UnexpectedError("Content is missing in the taskJson - probbably commands are applied in wrong order");
5988
5998
  }
5989
- if (command.templateType === 'EXAMPLE') {
5999
+ if (command.taskType === 'EXAMPLE') {
5990
6000
  expectResultingParameterName();
5991
- var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $templateJson.resultingParameterName; });
6001
+ var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $taskJson.resultingParameterName; });
5992
6002
  if (parameter === undefined) {
5993
- throw new ParseError("Can not find parameter {".concat($templateJson.resultingParameterName, "} to assign example value on it"));
6003
+ throw new ParseError("Can not find parameter {".concat($taskJson.resultingParameterName, "} to assign example value on it"));
5994
6004
  }
5995
6005
  parameter.exampleValues = parameter.exampleValues || [];
5996
- parameter.exampleValues.push($templateJson.content);
5997
- $templateJson.isTemplate = false;
6006
+ parameter.exampleValues.push($taskJson.content);
6007
+ $taskJson.isTask = false;
5998
6008
  return;
5999
6009
  }
6000
- if (command.templateType === 'KNOWLEDGE') {
6010
+ if (command.taskType === 'KNOWLEDGE') {
6001
6011
  knowledgeCommandParser.$applyToPipelineJson({
6002
6012
  type: 'KNOWLEDGE',
6003
- sourceContent: $templateJson.content, // <- TODO: [🐝][main] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
6013
+ sourceContent: $taskJson.content, // <- TODO: [🐝][main] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
6004
6014
  }, $pipelineJson);
6005
- $templateJson.isTemplate = false;
6015
+ $taskJson.isTask = false;
6006
6016
  return;
6007
6017
  }
6008
- if (command.templateType === 'ACTION') {
6018
+ if (command.taskType === 'ACTION') {
6009
6019
  console.error(new NotYetImplementedError('Actions are not implemented yet'));
6010
- $templateJson.isTemplate = false;
6020
+ $taskJson.isTask = false;
6011
6021
  return;
6012
6022
  }
6013
- if (command.templateType === 'INSTRUMENT') {
6023
+ if (command.taskType === 'INSTRUMENT') {
6014
6024
  console.error(new NotYetImplementedError('Instruments are not implemented yet'));
6015
- $templateJson.isTemplate = false;
6025
+ $taskJson.isTask = false;
6016
6026
  return;
6017
6027
  }
6018
6028
  expectResultingParameterName();
6019
- $templateJson.templateType = command.templateType;
6020
- $templateJson.isTemplate = true;
6029
+ $taskJson.taskType = command.taskType;
6030
+ $taskJson.isTask = true;
6021
6031
  },
6022
6032
  /**
6023
- * Converts the TEMPLATE command back to string
6033
+ * Converts the SECTION command back to string
6024
6034
  *
6025
6035
  * Note: This is used in `pipelineJsonToString` utility
6026
6036
  */
@@ -6028,11 +6038,11 @@ var templateCommandParser = {
6028
6038
  return "---"; // <- TODO: [🛋] Implement
6029
6039
  },
6030
6040
  /**
6031
- * Reads the TEMPLATE command from the `TemplateJson`
6041
+ * Reads the SECTION command from the `TaskJson`
6032
6042
  *
6033
6043
  * Note: This is used in `pipelineJsonToString` utility
6034
6044
  */
6035
- takeFromTemplateJson: function ($templateJson) {
6045
+ takeFromTaskJson: function ($taskJson) {
6036
6046
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6037
6047
  },
6038
6048
  };
@@ -6040,8 +6050,8 @@ var templateCommandParser = {
6040
6050
  * Note: [⛱] There are two types of KNOWLEDGE, ACTION and INSTRUMENT commands:
6041
6051
  * 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
6042
6052
  * - KNOWLEDGE Look at https://en.wikipedia.org/wiki/Artificial_intelligence
6043
- * 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
6044
- * - KNOWLEDGE TEMPLATE
6053
+ * 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
6054
+ * - KNOWLEDGE SECTION
6045
6055
  *
6046
6056
  * ```
6047
6057
  * Look at https://en.wikipedia.org/wiki/Artificial_intelligence
@@ -6069,7 +6079,7 @@ var boilerplateCommandParser = {
6069
6079
  * BOILERPLATE command can be used in:
6070
6080
  */
6071
6081
  isUsedInPipelineHead: true,
6072
- isUsedInPipelineTemplate: true,
6082
+ isUsedInPipelineTask: true,
6073
6083
  /**
6074
6084
  * Description of the BOILERPLATE command
6075
6085
  */
@@ -6110,9 +6120,9 @@ var boilerplateCommandParser = {
6110
6120
  /**
6111
6121
  * Apply the BOILERPLATE command to the `pipelineJson`
6112
6122
  *
6113
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6123
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6114
6124
  */
6115
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6125
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
6116
6126
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6117
6127
  },
6118
6128
  /**
@@ -6132,11 +6142,11 @@ var boilerplateCommandParser = {
6132
6142
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6133
6143
  },
6134
6144
  /**
6135
- * Reads the BOILERPLATE command from the `TemplateJson`
6145
+ * Reads the BOILERPLATE command from the `TaskJson`
6136
6146
  *
6137
6147
  * Note: This is used in `pipelineJsonToString` utility
6138
6148
  */
6139
- takeFromTemplateJson: function ($templateJson) {
6149
+ takeFromTaskJson: function ($taskJson) {
6140
6150
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
6141
6151
  },
6142
6152
  };
@@ -6157,7 +6167,7 @@ var bookVersionCommandParser = {
6157
6167
  * BOILERPLATE command can be used in:
6158
6168
  */
6159
6169
  isUsedInPipelineHead: true,
6160
- isUsedInPipelineTemplate: false,
6170
+ isUsedInPipelineTask: false,
6161
6171
  /**
6162
6172
  * Description of the BOOK_VERSION command
6163
6173
  */
@@ -6311,7 +6321,7 @@ var expectCommandParser = {
6311
6321
  * BOILERPLATE command can be used in:
6312
6322
  */
6313
6323
  isUsedInPipelineHead: false,
6314
- isUsedInPipelineTemplate: true,
6324
+ isUsedInPipelineTask: true,
6315
6325
  /**
6316
6326
  * Description of the FORMAT command
6317
6327
  */
@@ -6407,24 +6417,24 @@ var expectCommandParser = {
6407
6417
  /**
6408
6418
  * Apply the FORMAT command to the `pipelineJson`
6409
6419
  *
6410
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6420
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6411
6421
  */
6412
- $applyToTemplateJson: function (command, $templateJson) {
6422
+ $applyToTaskJson: function (command, $taskJson) {
6413
6423
  // eslint-disable-next-line no-case-declarations
6414
6424
  var unit = command.unit.toLowerCase();
6415
- $templateJson.expectations = $templateJson.expectations || {};
6416
- $templateJson.expectations[unit] = $templateJson.expectations[unit] || {};
6425
+ $taskJson.expectations = $taskJson.expectations || {};
6426
+ $taskJson.expectations[unit] = $taskJson.expectations[unit] || {};
6417
6427
  if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
6418
- if ($templateJson.expectations[unit].min !== undefined) {
6419
- throw new ParseError("Already defined minumum ".concat($templateJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6428
+ if ($taskJson.expectations[unit].min !== undefined) {
6429
+ throw new ParseError("Already defined minumum ".concat($taskJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6420
6430
  }
6421
- $templateJson.expectations[unit].min = command.amount;
6431
+ $taskJson.expectations[unit].min = command.amount;
6422
6432
  } /* not else */
6423
6433
  if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
6424
- if ($templateJson.expectations[unit].max !== undefined) {
6425
- throw new ParseError("Already defined maximum ".concat($templateJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6434
+ if ($taskJson.expectations[unit].max !== undefined) {
6435
+ throw new ParseError("Already defined maximum ".concat($taskJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
6426
6436
  }
6427
- $templateJson.expectations[unit].max = command.amount;
6437
+ $taskJson.expectations[unit].max = command.amount;
6428
6438
  }
6429
6439
  },
6430
6440
  /**
@@ -6436,11 +6446,11 @@ var expectCommandParser = {
6436
6446
  return "---"; // <- TODO: [🛋] Implement
6437
6447
  },
6438
6448
  /**
6439
- * Reads the FORMAT command from the `TemplateJson`
6449
+ * Reads the FORMAT command from the `TaskJson`
6440
6450
  *
6441
6451
  * Note: This is used in `pipelineJsonToString` utility
6442
6452
  */
6443
- takeFromTemplateJson: function ($templateJson) {
6453
+ takeFromTaskJson: function ($taskJson) {
6444
6454
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6445
6455
  },
6446
6456
  };
@@ -6647,7 +6657,7 @@ var foreachCommandParser = {
6647
6657
  * FOREACH command can be used in:
6648
6658
  */
6649
6659
  isUsedInPipelineHead: false,
6650
- isUsedInPipelineTemplate: true,
6660
+ isUsedInPipelineTask: true,
6651
6661
  /**
6652
6662
  * Description of the FOREACH command
6653
6663
  */
@@ -6746,13 +6756,13 @@ var foreachCommandParser = {
6746
6756
  /**
6747
6757
  * Apply the FOREACH command to the `pipelineJson`
6748
6758
  *
6749
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6759
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6750
6760
  */
6751
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
6761
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
6752
6762
  var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName, inputSubparameterNames = command.inputSubparameterNames, outputSubparameterName = command.outputSubparameterName;
6753
6763
  // TODO: [🍭] Detect double use
6754
6764
  // TODO: [🍭] Detect usage with JOKER and don't allow it
6755
- $templateJson.foreach = {
6765
+ $taskJson.foreach = {
6756
6766
  formatName: formatName,
6757
6767
  subformatName: subformatName,
6758
6768
  parameterName: parameterName,
@@ -6770,11 +6780,11 @@ var foreachCommandParser = {
6770
6780
  return "---"; // <- TODO: [🛋] Implement
6771
6781
  },
6772
6782
  /**
6773
- * Reads the FOREACH command from the `TemplateJson`
6783
+ * Reads the FOREACH command from the `TaskJson`
6774
6784
  *
6775
6785
  * Note: This is used in `pipelineJsonToString` utility
6776
6786
  */
6777
- takeFromTemplateJson: function ($templateJson) {
6787
+ takeFromTaskJson: function ($taskJson) {
6778
6788
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6779
6789
  },
6780
6790
  };
@@ -6797,7 +6807,7 @@ var formatCommandParser = {
6797
6807
  * BOILERPLATE command can be used in:
6798
6808
  */
6799
6809
  isUsedInPipelineHead: false,
6800
- isUsedInPipelineTemplate: true,
6810
+ isUsedInPipelineTask: true,
6801
6811
  /**
6802
6812
  * Description of the FORMAT command
6803
6813
  */
@@ -6828,13 +6838,13 @@ var formatCommandParser = {
6828
6838
  /**
6829
6839
  * Apply the FORMAT command to the `pipelineJson`
6830
6840
  *
6831
- * Note: `$` is used to indicate that this function mutates given `templateJson`
6841
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
6832
6842
  */
6833
- $applyToTemplateJson: function (command, $templateJson) {
6834
- if ($templateJson.format !== undefined && command.format !== $templateJson.format) {
6835
- throw new ParseError("Format format is already defined to \"".concat($templateJson.format, "\".\n Now you try to redefine it by \"").concat(command.format, "\""));
6843
+ $applyToTaskJson: function (command, $taskJson) {
6844
+ if ($taskJson.format !== undefined && command.format !== $taskJson.format) {
6845
+ throw new ParseError("Format format is already defined to \"".concat($taskJson.format, "\".\n Now you try to redefine it by \"").concat(command.format, "\""));
6836
6846
  }
6837
- $templateJson.format = command.format;
6847
+ $taskJson.format = command.format;
6838
6848
  },
6839
6849
  /**
6840
6850
  * Converts the FORMAT command back to string
@@ -6845,11 +6855,11 @@ var formatCommandParser = {
6845
6855
  return "---"; // <- TODO: [🛋] Implement
6846
6856
  },
6847
6857
  /**
6848
- * Reads the FORMAT command from the `TemplateJson`
6858
+ * Reads the FORMAT command from the `TaskJson`
6849
6859
  *
6850
6860
  * Note: This is used in `pipelineJsonToString` utility
6851
6861
  */
6852
- takeFromTemplateJson: function ($templateJson) {
6862
+ takeFromTaskJson: function ($taskJson) {
6853
6863
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6854
6864
  },
6855
6865
  };
@@ -6859,16 +6869,16 @@ var formatCommandParser = {
6859
6869
  *
6860
6870
  * @public exported from `@promptbook/core`
6861
6871
  */
6862
- var ChatFormfactorDefinition = {
6872
+ var ChatbotFormfactorDefinition = {
6863
6873
  name: 'CHATBOT',
6864
6874
  aliasNames: ['CHAT'],
6865
6875
  description: "@@@",
6866
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6876
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/174",
6867
6877
  pipelineInterface: {
6868
6878
  inputParameterNames: ['previousTitle', 'previousConversationSummary', 'userMessage'],
6869
6879
  outputParameterNames: ['title', 'conversationSummary', 'chatbotResponse'],
6870
6880
  /*
6871
- <- TODO: !!!!!! Change to
6881
+ <- TODO: !!!!!! Change to full interfaces
6872
6882
 
6873
6883
  - INPUT PARAMETER `{previousTitle}` Previous title of the conversation
6874
6884
  - INPUT PARAMETER `{previousConversationSummary}` Previous conversation summary
@@ -6884,12 +6894,17 @@ var ChatFormfactorDefinition = {
6884
6894
  /**
6885
6895
  * @@@
6886
6896
  *
6897
+ * @see https://github.com/webgptorg/promptbook/discussions/171
6898
+ *
6887
6899
  * @public exported from `@promptbook/core`
6888
6900
  */
6889
6901
  var GENERIC_PIPELINE_INTERFACE = {
6890
6902
  inputParameterNames: [],
6891
6903
  outputParameterNames: [],
6892
6904
  };
6905
+ /**
6906
+ * Note: [💞] Ignore a discrepancy between file name and entity name
6907
+ */
6893
6908
 
6894
6909
  /**
6895
6910
  * @@@
@@ -6899,10 +6914,29 @@ var GENERIC_PIPELINE_INTERFACE = {
6899
6914
  var GenericFormfactorDefinition = {
6900
6915
  name: 'GENERIC',
6901
6916
  description: "@@@",
6902
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6917
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/173",
6903
6918
  pipelineInterface: GENERIC_PIPELINE_INTERFACE,
6904
6919
  };
6905
6920
 
6921
+ /**
6922
+ * Matcher is form of app that @@@
6923
+ *
6924
+ * @public exported from `@promptbook/core`
6925
+ */
6926
+ var MatcherFormfactorDefinition = {
6927
+ name: 'EXPERIMENTAL_MATCHER',
6928
+ description: "@@@",
6929
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
6930
+ pipelineInterface: {
6931
+ inputParameterNames: [
6932
+ /* @@@ */
6933
+ ],
6934
+ outputParameterNames: [
6935
+ /* @@@ */
6936
+ ],
6937
+ },
6938
+ };
6939
+
6906
6940
  /**
6907
6941
  * Sheets is form of app that @@@
6908
6942
  *
@@ -6911,7 +6945,7 @@ var GenericFormfactorDefinition = {
6911
6945
  var SheetsFormfactorDefinition = {
6912
6946
  name: 'SHEETS',
6913
6947
  description: "@@@",
6914
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6948
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/176",
6915
6949
  pipelineInterface: {
6916
6950
  inputParameterNames: ['inputSheet'],
6917
6951
  outputParameterNames: ['outputSheet'],
@@ -6926,10 +6960,12 @@ var SheetsFormfactorDefinition = {
6926
6960
  var TranslatorFormfactorDefinition = {
6927
6961
  name: 'TRANSLATOR',
6928
6962
  description: "@@@",
6929
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
6963
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/175",
6930
6964
  pipelineInterface: {
6931
6965
  inputParameterNames: ['inputMessage'],
6932
6966
  outputParameterNames: ['outputMessage'],
6967
+ // <- TODO: !!!!!! Maybe add {summary}
6968
+ // <- TODO: [🧠] maybe change to {inputText}, {inputText} / or make system for any name of first input and first outpur parameter
6933
6969
  },
6934
6970
  };
6935
6971
 
@@ -6940,10 +6976,14 @@ var TranslatorFormfactorDefinition = {
6940
6976
  */
6941
6977
  var FORMFACTOR_DEFINITIONS = [
6942
6978
  GenericFormfactorDefinition,
6943
- ChatFormfactorDefinition,
6979
+ ChatbotFormfactorDefinition,
6944
6980
  TranslatorFormfactorDefinition,
6945
6981
  SheetsFormfactorDefinition,
6982
+ MatcherFormfactorDefinition,
6946
6983
  ];
6984
+ /**
6985
+ * Note: [💞] Ignore a discrepancy between file name and entity name
6986
+ */
6947
6987
 
6948
6988
  /**
6949
6989
  * Parses the formfactor command
@@ -6966,7 +7006,7 @@ var formfactorCommandParser = {
6966
7006
  * FORMFACTOR command can be used in:
6967
7007
  */
6968
7008
  isUsedInPipelineHead: true,
6969
- isUsedInPipelineTemplate: false,
7009
+ isUsedInPipelineTask: false,
6970
7010
  /**
6971
7011
  * Description of the FORMFACTOR command
6972
7012
  */
@@ -7048,7 +7088,7 @@ var jokerCommandParser = {
7048
7088
  * BOILERPLATE command can be used in:
7049
7089
  */
7050
7090
  isUsedInPipelineHead: false,
7051
- isUsedInPipelineTemplate: true,
7091
+ isUsedInPipelineTask: true,
7052
7092
  /**
7053
7093
  * Description of the JOKER command
7054
7094
  */
@@ -7079,11 +7119,11 @@ var jokerCommandParser = {
7079
7119
  /**
7080
7120
  * Apply the JOKER command to the `pipelineJson`
7081
7121
  *
7082
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7122
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7083
7123
  */
7084
- $applyToTemplateJson: function (command, $templateJson) {
7085
- $templateJson.jokerParameterNames = $templateJson.jokerParameterNames || [];
7086
- $templateJson.jokerParameterNames.push(command.parameterName);
7124
+ $applyToTaskJson: function (command, $taskJson) {
7125
+ $taskJson.jokerParameterNames = $taskJson.jokerParameterNames || [];
7126
+ $taskJson.jokerParameterNames.push(command.parameterName);
7087
7127
  },
7088
7128
  /**
7089
7129
  * Converts the JOKER command back to string
@@ -7094,11 +7134,11 @@ var jokerCommandParser = {
7094
7134
  return "---"; // <- TODO: [🛋] Implement
7095
7135
  },
7096
7136
  /**
7097
- * Reads the JOKER command from the `TemplateJson`
7137
+ * Reads the JOKER command from the `TaskJson`
7098
7138
  *
7099
7139
  * Note: This is used in `pipelineJsonToString` utility
7100
7140
  */
7101
- takeFromTemplateJson: function ($templateJson) {
7141
+ takeFromTaskJson: function ($taskJson) {
7102
7142
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7103
7143
  },
7104
7144
  };
@@ -7125,11 +7165,11 @@ var modelCommandParser = {
7125
7165
  * BOILERPLATE command can be used in:
7126
7166
  */
7127
7167
  isUsedInPipelineHead: true,
7128
- isUsedInPipelineTemplate: true,
7168
+ isUsedInPipelineTask: true,
7129
7169
  /**
7130
7170
  * Description of the MODEL command
7131
7171
  */
7132
- description: "Tells which `modelRequirements` (for example which model) to use for the prompt template execution",
7172
+ description: "Tells which `modelRequirements` (for example which model) to use for the prompt task execution",
7133
7173
  /**
7134
7174
  * Link to documentation
7135
7175
  */
@@ -7203,30 +7243,30 @@ var modelCommandParser = {
7203
7243
  /**
7204
7244
  * Apply the MODEL command to the `pipelineJson`
7205
7245
  *
7206
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7246
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7207
7247
  */
7208
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7209
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
7210
- throw new ParseError("MODEL command can only be used in PROMPT_TEMPLATE block");
7248
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
7249
+ if ($taskJson.taskType !== 'PROMPT_TASK') {
7250
+ throw new ParseError("MODEL command can only be used in PROMPT_TASK block");
7211
7251
  }
7212
- $templateJson.modelRequirements = $templateJson.modelRequirements || {};
7252
+ $taskJson.modelRequirements = $taskJson.modelRequirements || {};
7213
7253
  // TODO: [🚜] DRY
7214
- if ($templateJson.modelRequirements[command.key] !== undefined) {
7215
- if ($templateJson.modelRequirements[command.key] === command.value) {
7254
+ if ($taskJson.modelRequirements[command.key] !== undefined) {
7255
+ if ($taskJson.modelRequirements[command.key] === command.value) {
7216
7256
  console.warn("Multiple commands `MODEL ".concat({
7217
7257
  modelName: 'NAME',
7218
7258
  modelVariant: 'VARIANT',
7219
7259
  maxTokens: '???',
7220
- }[command.key], " ").concat(command.value, "` in the template \"").concat($templateJson.title || $templateJson.name, "\""));
7260
+ }[command.key], " ").concat(command.value, "` in the task \"").concat($taskJson.title || $taskJson.name, "\""));
7221
7261
  }
7222
7262
  else {
7223
- throw new ParseError(spaceTrim("\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 ")));
7263
+ throw new ParseError(spaceTrim("\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 ")));
7224
7264
  }
7225
7265
  }
7226
7266
  if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
7227
- console.log(spaceTrim("\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 ")));
7267
+ console.log(spaceTrim("\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 ")));
7228
7268
  }
7229
- $templateJson.modelRequirements[command.key] = command.value;
7269
+ $taskJson.modelRequirements[command.key] = command.value;
7230
7270
  },
7231
7271
  /**
7232
7272
  * Converts the MODEL command back to string
@@ -7245,11 +7285,11 @@ var modelCommandParser = {
7245
7285
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7246
7286
  },
7247
7287
  /**
7248
- * Reads the MODEL command from the `TemplateJson`
7288
+ * Reads the MODEL command from the `TaskJson`
7249
7289
  *
7250
7290
  * Note: This is used in `pipelineJsonToString` utility
7251
7291
  */
7252
- takeFromTemplateJson: function ($templateJson) {
7292
+ takeFromTaskJson: function ($taskJson) {
7253
7293
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7254
7294
  },
7255
7295
  };
@@ -7276,7 +7316,7 @@ var parameterCommandParser = {
7276
7316
  * BOILERPLATE command can be used in:
7277
7317
  */
7278
7318
  isUsedInPipelineHead: true,
7279
- isUsedInPipelineTemplate: true,
7319
+ isUsedInPipelineTask: true,
7280
7320
  /**
7281
7321
  * Description of the PARAMETER command
7282
7322
  */
@@ -7328,9 +7368,9 @@ var parameterCommandParser = {
7328
7368
  /**
7329
7369
  * Apply the PARAMETER command to the `pipelineJson`
7330
7370
  *
7331
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7371
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7332
7372
  */
7333
- $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7373
+ $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
7334
7374
  // Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
7335
7375
  },
7336
7376
  /**
@@ -7350,11 +7390,11 @@ var parameterCommandParser = {
7350
7390
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7351
7391
  },
7352
7392
  /**
7353
- * Reads the PARAMETER command from the `TemplateJson`
7393
+ * Reads the PARAMETER command from the `TaskJson`
7354
7394
  *
7355
7395
  * Note: This is used in `pipelineJsonToString` utility
7356
7396
  */
7357
- takeFromTemplateJson: function ($templateJson) {
7397
+ takeFromTaskJson: function ($taskJson) {
7358
7398
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7359
7399
  },
7360
7400
  };
@@ -7378,7 +7418,7 @@ var personaCommandParser = {
7378
7418
  * PERSONA command can be used in:
7379
7419
  */
7380
7420
  isUsedInPipelineHead: true,
7381
- isUsedInPipelineTemplate: true,
7421
+ isUsedInPipelineTask: true,
7382
7422
  /**
7383
7423
  * Description of the PERSONA command
7384
7424
  */
@@ -7417,9 +7457,9 @@ var personaCommandParser = {
7417
7457
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7418
7458
  */
7419
7459
  $applyToPipelineJson: function (command, $pipelineJson) {
7420
- $applyToTemplateJson(command, null, $pipelineJson);
7460
+ $applyToTaskJson(command, null, $pipelineJson);
7421
7461
  },
7422
- $applyToTemplateJson: $applyToTemplateJson,
7462
+ $applyToTaskJson: $applyToTaskJson,
7423
7463
  /**
7424
7464
  * Converts the PERSONA command back to string
7425
7465
  *
@@ -7437,26 +7477,26 @@ var personaCommandParser = {
7437
7477
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7438
7478
  },
7439
7479
  /**
7440
- * Reads the PERSONA command from the `TemplateJson`
7480
+ * Reads the PERSONA command from the `TaskJson`
7441
7481
  *
7442
7482
  * Note: This is used in `pipelineJsonToString` utility
7443
7483
  */
7444
- takeFromTemplateJson: function ($templateJson) {
7484
+ takeFromTaskJson: function ($taskJson) {
7445
7485
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7446
7486
  },
7447
7487
  };
7448
7488
  /**
7449
7489
  * Apply the PERSONA command to the `pipelineJson`
7450
7490
  *
7451
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7491
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7452
7492
  */
7453
- function $applyToTemplateJson(command, $templateJson, $pipelineJson) {
7493
+ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
7454
7494
  var personaName = command.personaName, personaDescription = command.personaDescription;
7455
- if ($templateJson !== null) {
7456
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE') {
7457
- throw new ParseError("PERSONA command can be used only in PROMPT_TEMPLATE block");
7495
+ if ($taskJson !== null) {
7496
+ if ($taskJson.taskType !== 'PROMPT_TASK') {
7497
+ throw new ParseError("PERSONA command can be used only in PROMPT_TASK block");
7458
7498
  }
7459
- $templateJson.personaName = personaName;
7499
+ $taskJson.personaName = personaName;
7460
7500
  }
7461
7501
  var persona = $pipelineJson.personas.find(function (persona) { return persona.name === personaName; });
7462
7502
  if (persona === undefined) {
@@ -7510,7 +7550,7 @@ var postprocessCommandParser = {
7510
7550
  * BOILERPLATE command can be used in:
7511
7551
  */
7512
7552
  isUsedInPipelineHead: false,
7513
- isUsedInPipelineTemplate: true,
7553
+ isUsedInPipelineTask: true,
7514
7554
  /**
7515
7555
  * Description of the POSTPROCESS command
7516
7556
  */
@@ -7548,11 +7588,11 @@ var postprocessCommandParser = {
7548
7588
  /**
7549
7589
  * Apply the POSTPROCESS command to the `pipelineJson`
7550
7590
  *
7551
- * Note: `$` is used to indicate that this function mutates given `templateJson`
7591
+ * Note: `$` is used to indicate that this function mutates given `taskJson`
7552
7592
  */
7553
- $applyToTemplateJson: function (command, $templateJson) {
7554
- $templateJson.postprocessingFunctionNames = $templateJson.postprocessingFunctionNames || [];
7555
- $templateJson.postprocessingFunctionNames.push(command.functionName);
7593
+ $applyToTaskJson: function (command, $taskJson) {
7594
+ $taskJson.postprocessingFunctionNames = $taskJson.postprocessingFunctionNames || [];
7595
+ $taskJson.postprocessingFunctionNames.push(command.functionName);
7556
7596
  },
7557
7597
  /**
7558
7598
  * Converts the POSTPROCESS command back to string
@@ -7563,11 +7603,11 @@ var postprocessCommandParser = {
7563
7603
  return "---"; // <- TODO: [🛋] Implement
7564
7604
  },
7565
7605
  /**
7566
- * Reads the POSTPROCESS command from the `TemplateJson`
7606
+ * Reads the POSTPROCESS command from the `TaskJson`
7567
7607
  *
7568
7608
  * Note: This is used in `pipelineJsonToString` utility
7569
7609
  */
7570
- takeFromTemplateJson: function ($templateJson) {
7610
+ takeFromTaskJson: function ($taskJson) {
7571
7611
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7572
7612
  },
7573
7613
  };
@@ -7592,7 +7632,7 @@ var urlCommandParser = {
7592
7632
  * BOILERPLATE command can be used in:
7593
7633
  */
7594
7634
  isUsedInPipelineHead: true,
7595
- isUsedInPipelineTemplate: false,
7635
+ isUsedInPipelineTask: false,
7596
7636
  /**
7597
7637
  * Description of the URL command
7598
7638
  */
@@ -7688,7 +7728,7 @@ var actionCommandParser = {
7688
7728
  * ACTION command can be used in:
7689
7729
  */
7690
7730
  isUsedInPipelineHead: true,
7691
- isUsedInPipelineTemplate: false,
7731
+ isUsedInPipelineTask: false,
7692
7732
  /**
7693
7733
  * Description of the ACTION command
7694
7734
  */
@@ -7754,7 +7794,7 @@ var instrumentCommandParser = {
7754
7794
  * INSTRUMENT command can be used in:
7755
7795
  */
7756
7796
  isUsedInPipelineHead: true,
7757
- isUsedInPipelineTemplate: false,
7797
+ isUsedInPipelineTask: false,
7758
7798
  /**
7759
7799
  * Description of the INSTRUMENT command
7760
7800
  */
@@ -7811,7 +7851,7 @@ var instrumentCommandParser = {
7811
7851
  * @private internal index of `parseCommand`
7812
7852
  */
7813
7853
  var COMMANDS = [
7814
- templateCommandParser,
7854
+ sectionCommandParser,
7815
7855
  expectCommandParser,
7816
7856
  formatCommandParser,
7817
7857
  jokerCommandParser,
@@ -7829,6 +7869,9 @@ var COMMANDS = [
7829
7869
  boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
7830
7870
  // <- 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
7831
7871
  ];
7872
+ /**
7873
+ * Note: [💞] Ignore a discrepancy between file name and entity name
7874
+ */
7832
7875
 
7833
7876
  /**
7834
7877
  * Gets the parser for the command
@@ -7889,7 +7932,7 @@ function parseCommand(raw, usagePlace) {
7889
7932
  normalized = normalized.split('(').join('');
7890
7933
  normalized = normalized.split(')').join('');
7891
7934
  normalized = normalizeTo_SCREAMING_CASE(normalized);
7892
- normalized = normalized.split('DIALOGUE').join('DIALOG');
7935
+ normalized = normalized.split('DIALOGUE').join('DIALOG'); // <- TODO: !!!!!! Move to sectionCommandParser
7893
7936
  var items = raw
7894
7937
  .trim()
7895
7938
  // Note: [🐡]
@@ -7970,12 +8013,12 @@ function parseCommandVariant(input) {
7970
8013
  var commandName = normalizeTo_SCREAMING_CASE(commandNameRaw);
7971
8014
  var _loop_1 = function (commandParser) {
7972
8015
  // <- Note: [🦦] Its strange that this type assertion is needed
7973
- var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTemplate = commandParser.isUsedInPipelineTemplate, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
8016
+ var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTask = commandParser.isUsedInPipelineTask, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
7974
8017
  if (just(false)) ;
7975
8018
  else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
7976
8019
  return "continue";
7977
8020
  }
7978
- else if (usagePlace === 'PIPELINE_TEMPLATE' && !isUsedInPipelineTemplate) {
8021
+ else if (usagePlace === 'PIPELINE_TASK' && !isUsedInPipelineTask) {
7979
8022
  return "continue";
7980
8023
  }
7981
8024
  var names = __spreadArray(__spreadArray([name_1], __read((aliasNames || [])), false), __read((deprecatedNames || [])), false);
@@ -8292,7 +8335,7 @@ function pipelineStringToJsonSync(pipelineString) {
8292
8335
  description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
8293
8336
  formfactorName: 'GENERIC',
8294
8337
  parameters: [],
8295
- templates: [],
8338
+ tasks: [],
8296
8339
  knowledgeSources: [],
8297
8340
  knowledgePieces: [],
8298
8341
  personas: [],
@@ -8430,10 +8473,10 @@ function pipelineStringToJsonSync(pipelineString) {
8430
8473
  if (description_1 === '') {
8431
8474
  description_1 = undefined;
8432
8475
  }
8433
- var $templateJson = {
8434
- isTemplateTypeSet: false,
8435
- isTemplate: true,
8436
- templateType: undefined /* <- Note: [🍙] Putting here placeholder to keep `templateType` on top at final JSON */,
8476
+ var $taskJson = {
8477
+ isSectionTypeSet: false,
8478
+ isTask: true,
8479
+ taskType: undefined /* <- Note: [🍙] Putting here placeholder to keep `taskType` on top at final JSON */,
8437
8480
  name: titleToName(section.title),
8438
8481
  title: section.title,
8439
8482
  description: description_1,
@@ -8445,35 +8488,35 @@ function pipelineStringToJsonSync(pipelineString) {
8445
8488
  if (resultingParameterNameMatch &&
8446
8489
  resultingParameterNameMatch.groups !== undefined &&
8447
8490
  resultingParameterNameMatch.groups.resultingParamName !== undefined) {
8448
- $templateJson.resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
8491
+ $taskJson.resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
8449
8492
  }
8450
8493
  // TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineTemplateCommands`
8451
8494
  var commands = listItems_2.map(function (listItem) { return ({
8452
8495
  listItem: listItem,
8453
- command: parseCommand(listItem, 'PIPELINE_TEMPLATE'),
8496
+ command: parseCommand(listItem, 'PIPELINE_TASK'),
8454
8497
  }); });
8455
- // Note: If block type is not set, set it to 'PROMPT_TEMPLATE'
8498
+ // Note: If block type is not set, set it to 'PROMPT_TASK'
8456
8499
  if (commands.some(function (_a) {
8457
8500
  var command = _a.command;
8458
- return command.type === 'TEMPLATE';
8501
+ return command.type === 'SECTION';
8459
8502
  }) === false) {
8460
- templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
8503
+ sectionCommandParser.$applyToTaskJson({ type: 'SECTION', taskType: 'PROMPT_TASK' }, $taskJson, $pipelineJson);
8461
8504
  }
8462
8505
  var _loop_4 = function (listItem, command) {
8463
8506
  var commandParser = getParserForCommand(command);
8464
- if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
8507
+ if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
8465
8508
  throw new ParseError(spaceTrim$1(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: [🚞]
8466
8509
  }
8467
8510
  try {
8468
- commandParser.$applyToTemplateJson(
8511
+ commandParser.$applyToTaskJson(
8469
8512
  // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitelly
8470
- command, $templateJson, $pipelineJson);
8513
+ command, $taskJson, $pipelineJson);
8471
8514
  }
8472
8515
  catch (error) {
8473
8516
  if (!(error instanceof ParseError)) {
8474
8517
  throw error;
8475
8518
  }
8476
- throw new ParseError(spaceTrim$1(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: [🚞]
8519
+ throw new ParseError(spaceTrim$1(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: [🚞]
8477
8520
  }
8478
8521
  if (command.type === 'PARAMETER') {
8479
8522
  defineParam(command);
@@ -8495,19 +8538,18 @@ function pipelineStringToJsonSync(pipelineString) {
8495
8538
  finally { if (e_5) throw e_5.error; }
8496
8539
  }
8497
8540
  // TODO: [🍧] Should be done in TEMPLATE command
8498
- if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
8541
+ if ($taskJson.taskType === 'SCRIPT_TASK') {
8499
8542
  if (!language) {
8500
8543
  throw new ParseError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the SCRIPT TEMPLATE\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
8501
8544
  }
8502
8545
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
8503
8546
  throw new ParseError(spaceTrim$1(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 "); }));
8504
8547
  }
8505
- $templateJson.contentLanguage =
8506
- language;
8548
+ $taskJson.contentLanguage = language;
8507
8549
  }
8508
- $templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
8550
+ $taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
8509
8551
  try {
8510
- for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
8552
+ for (var _q = (e_6 = void 0, __values($taskJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
8511
8553
  var parameterName = _r.value;
8512
8554
  // TODO: [🧠] This definition should be made first in the template
8513
8555
  defineParam({
@@ -8528,12 +8570,12 @@ function pipelineStringToJsonSync(pipelineString) {
8528
8570
  }
8529
8571
  /*
8530
8572
  // TODO: [🍧] This should be checked in `MODEL` command + better error message
8531
- if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
8573
+ if ($taskJson.taskType !== 'PROMPT_TASK' && $taskJson.modelRequirements !== undefined) {
8532
8574
  throw new UnexpectedError(
8533
8575
  spaceTrim(
8534
8576
  (block) => `
8535
8577
  Model requirements are defined for the block type ${
8536
- $templateJson.templateType
8578
+ $taskJson.taskType
8537
8579
  } which is not a PROMPT TEMPLATE
8538
8580
 
8539
8581
  This should be avoided by the \`modelCommandParser\`
@@ -8544,11 +8586,11 @@ function pipelineStringToJsonSync(pipelineString) {
8544
8586
  );
8545
8587
  }
8546
8588
  */
8547
- if ($templateJson.isTemplate) {
8548
- delete $templateJson.isTemplateTypeSet;
8549
- delete $templateJson.isTemplate;
8550
- // TODO: [🍙] Maybe do reorder of `$templateJson` here
8551
- $pipelineJson.templates.push($templateJson);
8589
+ if ($taskJson.isTask) {
8590
+ delete $taskJson.isSectionTypeSet;
8591
+ delete $taskJson.isTask;
8592
+ // TODO: [🍙] Maybe do reorder of `$taskJson` here
8593
+ $pipelineJson.tasks.push($taskJson);
8552
8594
  }
8553
8595
  };
8554
8596
  try {
@@ -8570,7 +8612,7 @@ function pipelineStringToJsonSync(pipelineString) {
8570
8612
  // Note: 5️⃣ Mark parameters as INPUT if not explicitly set
8571
8613
  if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
8572
8614
  var _loop_3 = function (parameter) {
8573
- var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
8615
+ var isThisParameterResulting = $pipelineJson.tasks.some(function (template) { return template.resultingParameterName === parameter.name; });
8574
8616
  if (!isThisParameterResulting) {
8575
8617
  parameter.isInput = true;
8576
8618
  }
@@ -8610,13 +8652,13 @@ function pipelineStringToJsonSync(pipelineString) {
8610
8652
  }
8611
8653
  // =============================================================
8612
8654
  // Note: 7️⃣ Cleanup of undefined values
8613
- $pipelineJson.templates.forEach(function (templates) {
8655
+ $pipelineJson.tasks.forEach(function (tasks) {
8614
8656
  var e_7, _a;
8615
8657
  try {
8616
- for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
8658
+ for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
8617
8659
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
8618
8660
  if (value === undefined) {
8619
- delete templates[key];
8661
+ delete tasks[key];
8620
8662
  }
8621
8663
  }
8622
8664
  }
@@ -8656,7 +8698,7 @@ function pipelineStringToJsonSync(pipelineString) {
8656
8698
  * TODO: Use spaceTrim more effectively
8657
8699
  * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
8658
8700
  * TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
8659
- * TODO: [♈] Probbably move expectations from templates to parameters
8701
+ * TODO: [♈] Probbably move expectations from tasks to parameters
8660
8702
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
8661
8703
  * TODO: [🍙] Make some standard order of json properties
8662
8704
  */
@@ -8750,13 +8792,13 @@ function renderPromptbookMermaid(pipelineJson, options) {
8750
8792
  if (parameter.isInput) {
8751
8793
  return 'input';
8752
8794
  }
8753
- var template = pipelineJson.templates.find(function (template) { return template.resultingParameterName === parameterName; });
8795
+ var template = pipelineJson.tasks.find(function (template) { return template.resultingParameterName === parameterName; });
8754
8796
  if (!template) {
8755
8797
  throw new Error("Could not find template for {".concat(parameterName, "}"));
8756
8798
  }
8757
8799
  return normalizeTo_camelCase('template-' + titleToName(template.title));
8758
8800
  };
8759
- var promptbookMermaid = spaceTrim$1(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
8801
+ var promptbookMermaid = spaceTrim$1(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
8760
8802
  .flatMap(function (_a) {
8761
8803
  var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
8762
8804
  return __spreadArray([
@@ -8774,7 +8816,7 @@ function renderPromptbookMermaid(pipelineJson, options) {
8774
8816
  var name = _a.name;
8775
8817
  return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
8776
8818
  })
8777
- .join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.templates
8819
+ .join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.tasks
8778
8820
  .map(function (template) {
8779
8821
  var link = linkTemplate(template);
8780
8822
  if (link === null) {
@@ -8813,8 +8855,8 @@ function prettifyPipelineString(pipelineString, options) {
8813
8855
  case 1:
8814
8856
  pipelineJson = _a.sent();
8815
8857
  promptbookMermaid_1 = renderPromptbookMermaid(pipelineJson, {
8816
- linkTemplate: function (template) {
8817
- return { href: "#".concat(template.name), title: template.title };
8858
+ linkTemplate: function (task) {
8859
+ return { href: "#".concat(task.name), title: task.title };
8818
8860
  },
8819
8861
  });
8820
8862
  promptbookMermaidBlock = spaceTrim$1(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
@@ -8940,259 +8982,580 @@ function embeddingVectorToString(embeddingVector) {
8940
8982
  }
8941
8983
 
8942
8984
  /**
8943
- * Function usageToWorktime will take usage and estimate saved worktime in hours of reading / writing
8944
- *
8945
- * Note: This is an estimate based of theese sources:
8946
- * - https://jecas.cz/doba-cteni
8947
- * - https://www.originalnitonery.cz/blog/psani-vsemi-deseti-se-muzete-naucit-i-sami-doma
8985
+ * Format either small or big number
8948
8986
  *
8949
- * @public exported from `@promptbook/core`
8987
+ * @private within the repository
8950
8988
  */
8951
- function usageToWorktime(usage) {
8952
- var value = usage.input.wordsCount.value / (200 /* words per minute */ * 60) +
8953
- usage.output.wordsCount.value / (40 /* words per minute */ * 60);
8954
- var isUncertain = usage.input.wordsCount.isUncertain || usage.output.wordsCount.isUncertain;
8955
- var uncertainNumber = { value: value };
8956
- if (isUncertain === true) {
8957
- uncertainNumber.isUncertain = true;
8989
+ function formatNumber(value) {
8990
+ if (value === 0) {
8991
+ return '0';
8958
8992
  }
8959
- return uncertainNumber;
8993
+ for (var exponent = 0; exponent < 15; exponent++) {
8994
+ var factor = Math.pow(10, exponent);
8995
+ var valueRounded = Math.round(value * factor) / factor;
8996
+ if (Math.abs(value - valueRounded) / value <
8997
+ 0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
8998
+ return valueRounded.toFixed(exponent);
8999
+ }
9000
+ }
9001
+ return value.toString();
8960
9002
  }
8961
9003
 
8962
9004
  /**
8963
- * Function `usageToHuman` will take usage and convert it to human readable report
9005
+ * Create a markdown table from a 2D array of strings
8964
9006
  *
8965
- * @public exported from `@promptbook/core`
9007
+ * @public exported from `@promptbook/markdown-utils`
8966
9008
  */
8967
- function usageToHuman(usage) {
8968
- var reportItems = [];
8969
- var uncertainNumberToHuman = function (_a) {
8970
- var value = _a.value, isUncertain = _a.isUncertain;
8971
- return "".concat(isUncertain ? 'approximately ' : '').concat(Math.round(value * 100) / 100);
8972
- };
8973
- if (usage.price.value > 0.01
8974
- // <- TODO: [🍓][🧞‍♂️][👩🏽‍🤝‍🧑🏻] Configure negligible value - default value to config + value to `UsageToHumanSettings`
8975
- ) {
8976
- reportItems.push("Cost ".concat(uncertainNumberToHuman(usage.price), " USD"));
8977
- }
8978
- else {
8979
- reportItems.push("Negligible cost");
8980
- }
8981
- var worktime = usageToWorktime(usage);
8982
- if (worktime.value >
8983
- 1 / 60
8984
- // <- TODO: [🍓][🧞‍♂️][👩🏽‍🤝‍🧑🏻]
8985
- ) {
8986
- reportItems.push("Saved ".concat(uncertainNumberToHuman(usageToWorktime(usage)), " hours of human time"));
8987
- // TODO: [🍓][🧞‍♂️] Show minutes, seconds, days NOT 0.1 hours
8988
- }
8989
- if (usage.output.charactersCount.value > 0) {
8990
- reportItems.push("Written ".concat(uncertainNumberToHuman(usage.output.charactersCount), " characters"));
8991
- }
8992
- if (reportItems.length === 0) {
8993
- // Note: For negligible usage, we report at least something
8994
- reportItems.push('Negligible');
8995
- }
8996
- return spaceTrim(function (block) { return "\n Usage:\n ".concat(block(reportItems.map(function (item) { return "- ".concat(item); }).join('\n')), "\n "); });
9009
+ function createMarkdownTable(table) {
9010
+ var columnWidths = table.reduce(function (widths, row) {
9011
+ row.forEach(function (subformat, columnIndex) {
9012
+ var cellLength = subformat.length;
9013
+ if (!widths[columnIndex] || cellLength > widths[columnIndex]) {
9014
+ widths[columnIndex] = cellLength;
9015
+ }
9016
+ });
9017
+ return widths;
9018
+ }, []);
9019
+ var header = "| ".concat(table[0]
9020
+ .map(function (subformat, columnIndex) { return subformat.padEnd(columnWidths[columnIndex]); })
9021
+ .join(' | '), " |");
9022
+ var separator = "|".concat(columnWidths.map(function (width) { return '-'.repeat(width + 2); }).join('|'), "|");
9023
+ var rows = table.slice(1).map(function (row) {
9024
+ var paddedRow = row.map(function (subformat, columnIndex) {
9025
+ return subformat.padEnd(columnWidths[columnIndex]);
9026
+ });
9027
+ return "| ".concat(paddedRow.join(' | '), " |");
9028
+ });
9029
+ return __spreadArray([header, separator], __read(rows), false).join('\n');
8997
9030
  }
8998
9031
  /**
8999
- * TODO: [🍓][🧞‍♂️] Use "$1" not "1 USD"
9000
- * TODO: [🍓][🧞‍♂️] Use markdown formatting like "Cost approximately **$1**"
9001
- * TODO: [🍓][🧞‍♂️] Report in minutes, seconds, days NOT 0.1 hours
9002
- * TODO: [🧠] Maybe make from `uncertainNumberToHuman` separate exported utility
9003
- * TODO: [🧠] Maybe use "~" instead of "approximately"
9004
- * TODO: [🏛] Maybe make some markdown builder
9032
+ * TODO: [🏛] This can be part of markdown builder
9005
9033
  */
9006
9034
 
9007
9035
  /**
9008
- * Boilerplate is form of app that @@@
9036
+ * Function createMarkdownChart will draw a chart in markdown from ⬛+🟦 tiles
9009
9037
  *
9010
- * @public exported from `@promptbook/core`
9038
+ * @public exported from `@promptbook/markdown-utils`
9039
+ */
9040
+ function createMarkdownChart(options) {
9041
+ var e_1, _a;
9042
+ var nameHeader = options.nameHeader, valueHeader = options.valueHeader, items = options.items, width = options.width, unitName = options.unitName;
9043
+ var from = Math.min.apply(Math, __spreadArray([], __read(items.map(function (item) { return item.from; })), false));
9044
+ var to = Math.max.apply(Math, __spreadArray([], __read(items.map(function (item) { return item.to; })), false));
9045
+ var scale = width / (to - from);
9046
+ var table = [[nameHeader, valueHeader]];
9047
+ try {
9048
+ for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
9049
+ var item = items_1_1.value;
9050
+ var before = Math.round((item.from - from) * scale);
9051
+ var during = Math.round((item.to - item.from) * scale);
9052
+ var after = width - before - during;
9053
+ table.push([removeEmojis(item.title).trim(), '░'.repeat(before) + '█'.repeat(during) + '░'.repeat(after)]);
9054
+ }
9055
+ }
9056
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9057
+ finally {
9058
+ try {
9059
+ if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
9060
+ }
9061
+ finally { if (e_1) throw e_1.error; }
9062
+ }
9063
+ var legend = "_Note: Each \u2588 represents ".concat(formatNumber(1 / scale), " ").concat(unitName, ", width of ").concat(valueHeader.toLowerCase(), " is ").concat(formatNumber(to - from), " ").concat(unitName, " = ").concat(width, " squares_");
9064
+ return createMarkdownTable(table) + '\n\n' + legend;
9065
+ }
9066
+ /**
9067
+ * TODO: Maybe use Mermain Gant Diagrams
9068
+ * @see https://jojozhuang.github.io/tutorial/mermaid-cheat-sheet/
9011
9069
  */
9012
- var BoilerplateFormfactorDefinition = {
9013
- name: 'BOILERPLATE',
9014
- description: "@@@",
9015
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
9016
- pipelineInterface: {
9017
- inputParameterNames: [],
9018
- outputParameterNames: [],
9019
- },
9020
- };
9021
9070
 
9022
9071
  /**
9023
- * @@@
9072
+ * Function escapeMarkdownBlock will escape markdown block if needed
9073
+ * It is useful when you want have block in block
9024
9074
  *
9025
- * Note: `$` is used to indicate that this interacts with the global scope
9026
- * @singleton Only one instance of each register is created per build, but thare can be more @@@
9027
- * @public exported from `@promptbook/core`
9075
+ * @public exported from `@promptbook/markdown-utils`
9028
9076
  */
9029
- var $llmToolsMetadataRegister = new $Register('llm_tools_metadata');
9077
+ function escapeMarkdownBlock(value) {
9078
+ return value.replace(/```/g, '\\`\\`\\`');
9079
+ }
9030
9080
  /**
9031
- * TODO: [®] DRY Register logic
9081
+ * TODO: [🏛] This can be part of markdown builder
9032
9082
  */
9033
9083
 
9034
9084
  /**
9035
- * @@@
9085
+ * Default options for generating an execution report string
9036
9086
  *
9037
- * Note: `$` is used to indicate that this interacts with the global scope
9038
- * @singleton Only one instance of each register is created per build, but thare can be more @@@
9039
9087
  * @public exported from `@promptbook/core`
9040
9088
  */
9041
- var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
9042
- /**
9043
- * TODO: [®] DRY Register logic
9044
- */
9089
+ var ExecutionReportStringOptionsDefaults = {
9090
+ taxRate: 0,
9091
+ chartsWidth: 36,
9092
+ };
9045
9093
 
9046
9094
  /**
9047
- * Creates a message with all registered LLM tools
9048
- *
9049
- * Note: This function is used to create a (error) message when there is no constructor for some LLM provider
9095
+ * Count the duration of working time
9050
9096
  *
9051
- * @private internal function of `createLlmToolsFromConfiguration` and `$provideLlmToolsFromEnv`
9097
+ * @private within the repository
9052
9098
  */
9053
- function $registeredLlmToolsMessage() {
9054
- var e_1, _a, e_2, _b;
9055
- /**
9056
- * Mixes registered LLM tools from $llmToolsMetadataRegister and $llmToolsRegister
9057
- */
9058
- var all = [];
9059
- var _loop_1 = function (packageName, className) {
9060
- if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
9061
- return "continue";
9099
+ function countWorkingDuration(items) {
9100
+ var e_1, _a;
9101
+ var steps = Array.from(new Set(items.flatMap(function (item) { return [item.from, item.to]; })));
9102
+ steps.sort(function (a, b) { return a - b; });
9103
+ var intervals = steps.map(function (step, index) { return [step, steps[index + 1] || 0]; }).slice(0, -1);
9104
+ var duration = 0;
9105
+ var _loop_1 = function (interval) {
9106
+ var _b = __read(interval, 2), from = _b[0], to = _b[1];
9107
+ if (items.some(function (item) { return item.from < to && item.to > from; })) {
9108
+ duration += to - from;
9062
9109
  }
9063
- all.push({ packageName: packageName, className: className });
9064
9110
  };
9065
9111
  try {
9066
- for (var _c = __values($llmToolsMetadataRegister.list()), _d = _c.next(); !_d.done; _d = _c.next()) {
9067
- var _e = _d.value, packageName = _e.packageName, className = _e.className;
9068
- _loop_1(packageName, className);
9112
+ for (var intervals_1 = __values(intervals), intervals_1_1 = intervals_1.next(); !intervals_1_1.done; intervals_1_1 = intervals_1.next()) {
9113
+ var interval = intervals_1_1.value;
9114
+ _loop_1(interval);
9069
9115
  }
9070
9116
  }
9071
9117
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
9072
9118
  finally {
9073
9119
  try {
9074
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
9120
+ if (intervals_1_1 && !intervals_1_1.done && (_a = intervals_1.return)) _a.call(intervals_1);
9075
9121
  }
9076
9122
  finally { if (e_1) throw e_1.error; }
9077
9123
  }
9078
- var _loop_2 = function (packageName, className) {
9079
- if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
9080
- return "continue";
9081
- }
9082
- all.push({ packageName: packageName, className: className });
9083
- };
9084
- try {
9085
- for (var _f = __values($llmToolsRegister.list()), _g = _f.next(); !_g.done; _g = _f.next()) {
9086
- var _h = _g.value, packageName = _h.packageName, className = _h.className;
9087
- _loop_2(packageName, className);
9088
- }
9089
- }
9090
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
9091
- finally {
9092
- try {
9093
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
9094
- }
9095
- finally { if (e_2) throw e_2.error; }
9096
- }
9097
- var metadata = all.map(function (metadata) {
9098
- var isMetadataAviailable = $llmToolsMetadataRegister
9099
- .list()
9100
- .find(function (_a) {
9101
- var packageName = _a.packageName, className = _a.className;
9102
- return metadata.packageName === packageName && metadata.className === className;
9124
+ return duration;
9125
+ }
9126
+
9127
+ /**
9128
+ * Converts execution report from JSON to string format
9129
+ *
9130
+ * @public exported from `@promptbook/core`
9131
+ */
9132
+ function executionReportJsonToString(executionReportJson, options) {
9133
+ var e_1, _a;
9134
+ var _b, _c, _d, _e, _f, _g;
9135
+ var _h = __assign(__assign({}, ExecutionReportStringOptionsDefaults), (options || {})), taxRate = _h.taxRate, chartsWidth = _h.chartsWidth;
9136
+ var executionReportString = spaceTrim$1(function (block) { return "\n # ".concat(executionReportJson.title || 'Execution report', "\n\n ").concat(block(executionReportJson.description || ''), "\n "); });
9137
+ var headerList = [];
9138
+ if (executionReportJson.pipelineUrl) {
9139
+ headerList.push("PIPELINE URL ".concat(executionReportJson.pipelineUrl));
9140
+ }
9141
+ headerList.push("PROMPTBOOK VERSION ".concat(executionReportJson.promptbookUsedVersion) +
9142
+ (!executionReportJson.promptbookRequestedVersion
9143
+ ? ''
9144
+ : " *(requested ".concat(executionReportJson.promptbookRequestedVersion, ")*")));
9145
+ if (executionReportJson.promptExecutions.length !== 0) {
9146
+ // TODO: What if startedAt OR/AND completedAt is not defined?
9147
+ var startedAt = moment(Math.min.apply(Math, __spreadArray([], __read(executionReportJson.promptExecutions
9148
+ .filter(function (promptExecution) { var _a, _b; return (_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.start; })
9149
+ .map(function (promptExecution) { return moment(promptExecution.result.timing.start).valueOf(); })), false)));
9150
+ var completedAt = moment(Math.max.apply(Math, __spreadArray([], __read(executionReportJson.promptExecutions
9151
+ .filter(function (promptExecution) { var _a, _b; return (_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.complete; })
9152
+ .map(function (promptExecution) { return moment(promptExecution.result.timing.complete).valueOf(); })), false)));
9153
+ var timingItems = executionReportJson.promptExecutions.map(function (promptExecution) {
9154
+ var _a, _b, _c, _d;
9155
+ return ({
9156
+ title: promptExecution.prompt.title,
9157
+ from: moment((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.start).valueOf() / 1000,
9158
+ to: moment((_d = (_c = promptExecution.result) === null || _c === void 0 ? void 0 : _c.timing) === null || _d === void 0 ? void 0 : _d.complete).valueOf() / 1000,
9159
+ });
9103
9160
  });
9104
- var isInstalled = $llmToolsRegister
9105
- .list()
9106
- .find(function (_a) {
9107
- var packageName = _a.packageName, className = _a.className;
9108
- return metadata.packageName === packageName && metadata.className === className;
9161
+ var costItems = executionReportJson.promptExecutions
9162
+ .filter(function (promptExecution) { var _a, _b; return typeof ((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) === 'number'; })
9163
+ .map(function (promptExecution) {
9164
+ var _a, _b;
9165
+ return ({
9166
+ title: promptExecution.prompt.title,
9167
+ from: 0,
9168
+ to: (((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price.value) || 0) /* <- TODO: look at uncertain numbers */ *
9169
+ (1 + taxRate),
9170
+ });
9109
9171
  });
9110
- return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled });
9111
- });
9112
- if (metadata.length === 0) {
9113
- return "No LLM providers are available.";
9172
+ var duration = moment.duration(completedAt.diff(startedAt));
9173
+ var llmDuration = moment.duration(countWorkingDuration(timingItems) * 1000);
9174
+ var executionsWithKnownCost = executionReportJson.promptExecutions.filter(function (promptExecution) { var _a, _b; return (((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) || 'UNKNOWN') !== 'UNKNOWN'; });
9175
+ var cost = executionsWithKnownCost.reduce(function (cost, promptExecution) {
9176
+ return cost + (promptExecution.result.usage.price.value /* <- Look at uncertain number */ || 0);
9177
+ }, 0);
9178
+ headerList.push("STARTED AT ".concat(moment(startedAt).format("YYYY-MM-DD HH:mm:ss")));
9179
+ headerList.push("COMPLETED AT ".concat(moment(completedAt).format("YYYY-MM-DD HH:mm:ss")));
9180
+ headerList.push("TOTAL DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
9181
+ headerList.push("TOTAL LLM DURATION ".concat(llmDuration.humanize(MOMENT_ARG_THRESHOLDS)));
9182
+ headerList.push("TOTAL COST $".concat(formatNumber(cost * (1 + taxRate))) +
9183
+ (executionsWithKnownCost.length === executionReportJson.promptExecutions.length
9184
+ ? ''
9185
+ : " *(Some cost is unknown)*") +
9186
+ (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
9187
+ executionReportString += '\n\n' + headerList.map(function (header) { return "- ".concat(header); }).join('\n');
9188
+ executionReportString +=
9189
+ '\n\n' +
9190
+ '## 🗃 Index' +
9191
+ '\n\n' +
9192
+ executionReportJson.promptExecutions
9193
+ .map(function (promptExecution) {
9194
+ // TODO: Make some better system to convert hedings to links
9195
+ var hash = normalizeToKebabCase(promptExecution.prompt.title);
9196
+ if (/^\s*\p{Extended_Pictographic}/u.test(promptExecution.prompt.title)) {
9197
+ hash = '-' + hash;
9198
+ }
9199
+ // TODO: Make working hash link for the template in md + pdf
9200
+ return "- [".concat(promptExecution.prompt.title, "](#").concat(hash, ")");
9201
+ })
9202
+ .join('\n');
9203
+ executionReportString +=
9204
+ '\n\n' +
9205
+ '## ⌚ Time chart' +
9206
+ '\n\n' +
9207
+ createMarkdownChart({
9208
+ nameHeader: 'Template',
9209
+ valueHeader: 'Timeline',
9210
+ items: timingItems,
9211
+ width: chartsWidth,
9212
+ unitName: 'seconds',
9213
+ });
9214
+ executionReportString +=
9215
+ '\n\n' +
9216
+ '## 💸 Cost chart' +
9217
+ '\n\n' +
9218
+ createMarkdownChart({
9219
+ nameHeader: 'Template',
9220
+ valueHeader: 'Cost',
9221
+ items: costItems,
9222
+ width: chartsWidth,
9223
+ unitName: 'USD',
9224
+ });
9114
9225
  }
9115
- return spaceTrim(function (block) { return "\n Available LLM providers are:\n ".concat(block(metadata
9116
- .map(function (_a, i) {
9117
- var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled;
9118
- var more;
9119
- if (just(false)) {
9120
- more = '';
9226
+ else {
9227
+ headerList.push("TOTAL COST $0 *(Nothing executed)*");
9228
+ }
9229
+ var _loop_1 = function (promptExecution) {
9230
+ executionReportString += '\n\n\n\n' + "## ".concat(promptExecution.prompt.title);
9231
+ var taskList = [];
9232
+ // TODO: What if startedAt OR/AND completedAt is not defined?
9233
+ var startedAt = moment((_c = (_b = promptExecution.result) === null || _b === void 0 ? void 0 : _b.timing) === null || _c === void 0 ? void 0 : _c.start);
9234
+ var completedAt = moment((_e = (_d = promptExecution.result) === null || _d === void 0 ? void 0 : _d.timing) === null || _e === void 0 ? void 0 : _e.complete);
9235
+ var duration = moment.duration(completedAt.diff(startedAt));
9236
+ // Not need here:
9237
+ // > taskList.push(`STARTED AT ${moment(startedAt).calendar()}`);
9238
+ taskList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
9239
+ if (typeof ((_g = (_f = promptExecution.result) === null || _f === void 0 ? void 0 : _f.usage) === null || _g === void 0 ? void 0 : _g.price) === 'number') {
9240
+ taskList.push("COST $".concat(formatNumber(promptExecution.result.usage.price * (1 + taxRate))) +
9241
+ (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
9121
9242
  }
9122
- else if (!isMetadataAviailable && !isInstalled) {
9123
- // TODO: [�][�] Maybe do allow to do auto-install if package not registered and not found
9124
- more = "(not installed and no metadata, looks like a unexpected behavior)";
9243
+ else {
9244
+ taskList.push("COST UNKNOWN");
9125
9245
  }
9126
- else if (isMetadataAviailable && !isInstalled) {
9127
- // TODO: [�][�]
9128
- more = "(not installed)";
9246
+ executionReportString += '\n\n' + taskList.map(function (header) { return "- ".concat(header); }).join('\n');
9247
+ /*
9248
+ - MODEL VARIANT ${promptExecution.prompt.modelRequirements.modelVariant}
9249
+ - MODEL NAME \`${promptExecution.result?.model}\` (requested \`${
9250
+ promptExecution.prompt.modelRequirements.modelName
9251
+
9252
+ */
9253
+ if (just(true)) {
9254
+ executionReportString +=
9255
+ '\n\n\n\n' +
9256
+ spaceTrim$1(function (block) {
9257
+ var _a;
9258
+ return "\n\n ### Prompt\n\n ```\n ".concat(block(escapeMarkdownBlock(((_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.rawPromptContent) || promptExecution.prompt.content)), "\n ```\n\n ");
9259
+ });
9129
9260
  }
9130
- else if (!isMetadataAviailable && isInstalled) {
9131
- more = "(no metadata, looks like a unexpected behavior)";
9261
+ if (promptExecution.result && promptExecution.result.content) {
9262
+ executionReportString += '\n\n\n\n' + '### Result' + '\n\n';
9263
+ if (promptExecution.result === undefined) {
9264
+ executionReportString += '*No result*';
9265
+ }
9266
+ else if (typeof promptExecution.result.content === 'string') {
9267
+ executionReportString += spaceTrim$1(function (block) { return "\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.result.content)), "\n ```\n "); });
9268
+ }
9269
+ else {
9270
+ executionReportString += embeddingVectorToString(promptExecution.result.content);
9271
+ }
9132
9272
  }
9133
- else if (isMetadataAviailable && isInstalled) {
9134
- more = "(installed)";
9273
+ if (promptExecution.error && promptExecution.error.message) {
9274
+ executionReportString +=
9275
+ '\n\n\n\n' +
9276
+ spaceTrim$1(function (block) { return "\n\n ### Error\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.error.message)), "\n ```\n\n "); });
9135
9277
  }
9136
- else {
9137
- more = "(unknown state, looks like a unexpected behavior)";
9278
+ };
9279
+ try {
9280
+ for (var _j = __values(executionReportJson.promptExecutions), _k = _j.next(); !_k.done; _k = _j.next()) {
9281
+ var promptExecution = _k.value;
9282
+ _loop_1(promptExecution);
9138
9283
  }
9139
- return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` ").concat(more);
9140
- })
9141
- .join('\n')), "\n "); });
9284
+ }
9285
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9286
+ finally {
9287
+ try {
9288
+ if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
9289
+ }
9290
+ finally { if (e_1) throw e_1.error; }
9291
+ }
9292
+ executionReportString = prettifyMarkdown(executionReportString);
9293
+ return executionReportString;
9142
9294
  }
9143
9295
  /**
9144
- * TODO: [®] DRY Register logic
9296
+ * TODO: Add mermaid chart for every report
9297
+ * TODO: [🧠] Allow to filter out some parts of the report by options
9298
+ * TODO: [🧠] Should be in generated file GENERATOR_WARNING
9145
9299
  */
9146
9300
 
9147
9301
  /**
9148
- * @@@
9302
+ * Function usageToWorktime will take usage and estimate saved worktime in hours of reading / writing
9149
9303
  *
9150
- * Note: This function is not cached, every call creates new instance of `MultipleLlmExecutionTools`
9304
+ * Note: This is an estimate based of theese sources:
9305
+ * - https://jecas.cz/doba-cteni
9306
+ * - https://www.originalnitonery.cz/blog/psani-vsemi-deseti-se-muzete-naucit-i-sami-doma
9151
9307
  *
9152
- * @returns @@@
9153
9308
  * @public exported from `@promptbook/core`
9154
9309
  */
9155
- function createLlmToolsFromConfiguration(configuration, options) {
9156
- if (options === void 0) { options = {}; }
9157
- var _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a, userId = options.userId;
9158
- var llmTools = configuration.map(function (llmConfiguration) {
9159
- var registeredItem = $llmToolsRegister
9160
- .list()
9161
- .find(function (_a) {
9162
- var packageName = _a.packageName, className = _a.className;
9163
- return llmConfiguration.packageName === packageName && llmConfiguration.className === className;
9164
- });
9165
- if (registeredItem === undefined) {
9166
- throw new Error(spaceTrim(function (block) { return "\n There is no constructor for LLM provider `".concat(llmConfiguration.className, "` from `").concat(llmConfiguration.packageName, "`\n\n You have probably forgotten install and import the provider package.\n To fix this issue, you can:\n\n Install:\n\n > npm install ").concat(llmConfiguration.packageName, "\n\n And import:\n\n > import '").concat(llmConfiguration.packageName, "';\n\n\n ").concat(block($registeredLlmToolsMessage()), "\n "); }));
9167
- }
9168
- return registeredItem(__assign({ isVerbose: isVerbose, userId: userId }, llmConfiguration.options));
9169
- });
9170
- return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
9310
+ function usageToWorktime(usage) {
9311
+ var value = usage.input.wordsCount.value / (200 /* words per minute */ * 60) +
9312
+ usage.output.wordsCount.value / (40 /* words per minute */ * 60);
9313
+ var isUncertain = usage.input.wordsCount.isUncertain || usage.output.wordsCount.isUncertain;
9314
+ var uncertainNumber = { value: value };
9315
+ if (isUncertain === true) {
9316
+ uncertainNumber.isUncertain = true;
9317
+ }
9318
+ return uncertainNumber;
9171
9319
  }
9172
- /**
9173
- * TODO: [🎌] Together with `createLlmToolsFromConfiguration` + 'EXECUTION_TOOLS_CLASSES' gets to `@promptbook/core` ALL model providers, make this more efficient
9174
- * TODO: [🧠][🎌] Dynamically install required providers
9175
- * TODO: @@@ write discussion about this - wizzard
9176
- * TODO: [🧠][🍛] Which name is better `createLlmToolsFromConfig` or `createLlmToolsFromConfiguration`?
9177
- * TODO: [🧠] Is there some meaningfull way how to test this util
9178
- * TODO: This should be maybe not under `_common` but under `utils`
9179
- * TODO: [®] DRY Register logic
9180
- */
9181
9320
 
9182
9321
  /**
9183
- * Stores data in memory (HEAP)
9322
+ * Function `usageToHuman` will take usage and convert it to human readable report
9184
9323
  *
9185
9324
  * @public exported from `@promptbook/core`
9186
9325
  */
9187
- var MemoryStorage = /** @class */ (function () {
9188
- function MemoryStorage() {
9189
- this.storage = {};
9326
+ function usageToHuman(usage) {
9327
+ var reportItems = [];
9328
+ var uncertainNumberToHuman = function (_a) {
9329
+ var value = _a.value, isUncertain = _a.isUncertain;
9330
+ return "".concat(isUncertain ? 'approximately ' : '').concat(Math.round(value * 100) / 100);
9331
+ };
9332
+ if (usage.price.value > 0.01
9333
+ // <- TODO: [🍓][🧞‍♂️][👩🏽‍🤝‍🧑🏻] Configure negligible value - default value to config + value to `UsageToHumanSettings`
9334
+ ) {
9335
+ reportItems.push("Cost ".concat(uncertainNumberToHuman(usage.price), " USD"));
9190
9336
  }
9191
- Object.defineProperty(MemoryStorage.prototype, "length", {
9192
- /**
9193
- * Returns the number of key/value pairs currently present in the list associated with the object.
9194
- */
9195
- get: function () {
9337
+ else {
9338
+ reportItems.push("Negligible cost");
9339
+ }
9340
+ var worktime = usageToWorktime(usage);
9341
+ if (worktime.value >
9342
+ 1 / 60
9343
+ // <- TODO: [🍓][🧞‍♂️][👩🏽‍🤝‍🧑🏻]
9344
+ ) {
9345
+ reportItems.push("Saved ".concat(uncertainNumberToHuman(usageToWorktime(usage)), " hours of human time"));
9346
+ // TODO: [🍓][🧞‍♂️] Show minutes, seconds, days NOT 0.1 hours
9347
+ }
9348
+ if (usage.output.charactersCount.value > 0) {
9349
+ reportItems.push("Written ".concat(uncertainNumberToHuman(usage.output.charactersCount), " characters"));
9350
+ }
9351
+ if (reportItems.length === 0) {
9352
+ // Note: For negligible usage, we report at least something
9353
+ reportItems.push('Negligible');
9354
+ }
9355
+ return spaceTrim(function (block) { return "\n Usage:\n ".concat(block(reportItems.map(function (item) { return "- ".concat(item); }).join('\n')), "\n "); });
9356
+ }
9357
+ /**
9358
+ * TODO: [🍓][🧞‍♂️] Use "$1" not "1 USD"
9359
+ * TODO: [🍓][🧞‍♂️] Use markdown formatting like "Cost approximately **$1**"
9360
+ * TODO: [🍓][🧞‍♂️] Report in minutes, seconds, days NOT 0.1 hours
9361
+ * TODO: [🧠] Maybe make from `uncertainNumberToHuman` separate exported utility
9362
+ * TODO: [🧠] Maybe use "~" instead of "approximately"
9363
+ * TODO: [🏛] Maybe make some markdown builder
9364
+ */
9365
+
9366
+ /**
9367
+ * Boilerplate is form of app that @@@
9368
+ *
9369
+ * @public exported from `@promptbook/core`
9370
+ */
9371
+ var BoilerplateFormfactorDefinition = {
9372
+ name: 'BOILERPLATE',
9373
+ description: "@@@",
9374
+ documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@",
9375
+ pipelineInterface: {
9376
+ inputParameterNames: [
9377
+ /* @@@ */
9378
+ ],
9379
+ outputParameterNames: [
9380
+ /* @@@ */
9381
+ ],
9382
+ },
9383
+ };
9384
+
9385
+ /**
9386
+ * @@@
9387
+ *
9388
+ * Note: `$` is used to indicate that this interacts with the global scope
9389
+ * @singleton Only one instance of each register is created per build, but thare can be more @@@
9390
+ * @public exported from `@promptbook/core`
9391
+ */
9392
+ var $llmToolsMetadataRegister = new $Register('llm_tools_metadata');
9393
+ /**
9394
+ * TODO: [®] DRY Register logic
9395
+ */
9396
+
9397
+ /**
9398
+ * @@@
9399
+ *
9400
+ * Note: `$` is used to indicate that this interacts with the global scope
9401
+ * @singleton Only one instance of each register is created per build, but thare can be more @@@
9402
+ * @public exported from `@promptbook/core`
9403
+ */
9404
+ var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
9405
+ /**
9406
+ * TODO: [®] DRY Register logic
9407
+ */
9408
+
9409
+ /**
9410
+ * Creates a message with all registered LLM tools
9411
+ *
9412
+ * Note: This function is used to create a (error) message when there is no constructor for some LLM provider
9413
+ *
9414
+ * @private internal function of `createLlmToolsFromConfiguration` and `$provideLlmToolsFromEnv`
9415
+ */
9416
+ function $registeredLlmToolsMessage() {
9417
+ var e_1, _a, e_2, _b;
9418
+ /**
9419
+ * Mixes registered LLM tools from $llmToolsMetadataRegister and $llmToolsRegister
9420
+ */
9421
+ var all = [];
9422
+ var _loop_1 = function (packageName, className) {
9423
+ if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
9424
+ return "continue";
9425
+ }
9426
+ all.push({ packageName: packageName, className: className });
9427
+ };
9428
+ try {
9429
+ for (var _c = __values($llmToolsMetadataRegister.list()), _d = _c.next(); !_d.done; _d = _c.next()) {
9430
+ var _e = _d.value, packageName = _e.packageName, className = _e.className;
9431
+ _loop_1(packageName, className);
9432
+ }
9433
+ }
9434
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9435
+ finally {
9436
+ try {
9437
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
9438
+ }
9439
+ finally { if (e_1) throw e_1.error; }
9440
+ }
9441
+ var _loop_2 = function (packageName, className) {
9442
+ if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
9443
+ return "continue";
9444
+ }
9445
+ all.push({ packageName: packageName, className: className });
9446
+ };
9447
+ try {
9448
+ for (var _f = __values($llmToolsRegister.list()), _g = _f.next(); !_g.done; _g = _f.next()) {
9449
+ var _h = _g.value, packageName = _h.packageName, className = _h.className;
9450
+ _loop_2(packageName, className);
9451
+ }
9452
+ }
9453
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
9454
+ finally {
9455
+ try {
9456
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
9457
+ }
9458
+ finally { if (e_2) throw e_2.error; }
9459
+ }
9460
+ var metadata = all.map(function (metadata) {
9461
+ var isMetadataAviailable = $llmToolsMetadataRegister
9462
+ .list()
9463
+ .find(function (_a) {
9464
+ var packageName = _a.packageName, className = _a.className;
9465
+ return metadata.packageName === packageName && metadata.className === className;
9466
+ });
9467
+ var isInstalled = $llmToolsRegister
9468
+ .list()
9469
+ .find(function (_a) {
9470
+ var packageName = _a.packageName, className = _a.className;
9471
+ return metadata.packageName === packageName && metadata.className === className;
9472
+ });
9473
+ return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled });
9474
+ });
9475
+ if (metadata.length === 0) {
9476
+ return "No LLM providers are available.";
9477
+ }
9478
+ return spaceTrim(function (block) { return "\n Available LLM providers are:\n ".concat(block(metadata
9479
+ .map(function (_a, i) {
9480
+ var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled;
9481
+ var more;
9482
+ if (just(false)) {
9483
+ more = '';
9484
+ }
9485
+ else if (!isMetadataAviailable && !isInstalled) {
9486
+ // TODO: [�][�] Maybe do allow to do auto-install if package not registered and not found
9487
+ more = "(not installed and no metadata, looks like a unexpected behavior)";
9488
+ }
9489
+ else if (isMetadataAviailable && !isInstalled) {
9490
+ // TODO: [�][�]
9491
+ more = "(not installed)";
9492
+ }
9493
+ else if (!isMetadataAviailable && isInstalled) {
9494
+ more = "(no metadata, looks like a unexpected behavior)";
9495
+ }
9496
+ else if (isMetadataAviailable && isInstalled) {
9497
+ more = "(installed)";
9498
+ }
9499
+ else {
9500
+ more = "(unknown state, looks like a unexpected behavior)";
9501
+ }
9502
+ return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` ").concat(more);
9503
+ })
9504
+ .join('\n')), "\n "); });
9505
+ }
9506
+ /**
9507
+ * TODO: [®] DRY Register logic
9508
+ */
9509
+
9510
+ /**
9511
+ * @@@
9512
+ *
9513
+ * Note: This function is not cached, every call creates new instance of `MultipleLlmExecutionTools`
9514
+ *
9515
+ * @returns @@@
9516
+ * @public exported from `@promptbook/core`
9517
+ */
9518
+ function createLlmToolsFromConfiguration(configuration, options) {
9519
+ if (options === void 0) { options = {}; }
9520
+ var _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a, userId = options.userId;
9521
+ var llmTools = configuration.map(function (llmConfiguration) {
9522
+ var registeredItem = $llmToolsRegister
9523
+ .list()
9524
+ .find(function (_a) {
9525
+ var packageName = _a.packageName, className = _a.className;
9526
+ return llmConfiguration.packageName === packageName && llmConfiguration.className === className;
9527
+ });
9528
+ if (registeredItem === undefined) {
9529
+ throw new Error(spaceTrim(function (block) { return "\n There is no constructor for LLM provider `".concat(llmConfiguration.className, "` from `").concat(llmConfiguration.packageName, "`\n\n You have probably forgotten install and import the provider package.\n To fix this issue, you can:\n\n Install:\n\n > npm install ").concat(llmConfiguration.packageName, "\n\n And import:\n\n > import '").concat(llmConfiguration.packageName, "';\n\n\n ").concat(block($registeredLlmToolsMessage()), "\n "); }));
9530
+ }
9531
+ return registeredItem(__assign({ isVerbose: isVerbose, userId: userId }, llmConfiguration.options));
9532
+ });
9533
+ return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
9534
+ }
9535
+ /**
9536
+ * TODO: [🎌] Together with `createLlmToolsFromConfiguration` + 'EXECUTION_TOOLS_CLASSES' gets to `@promptbook/core` ALL model providers, make this more efficient
9537
+ * TODO: [🧠][🎌] Dynamically install required providers
9538
+ * TODO: @@@ write discussion about this - wizzard
9539
+ * TODO: [🧠][🍛] Which name is better `createLlmToolsFromConfig` or `createLlmToolsFromConfiguration`?
9540
+ * TODO: [🧠] Is there some meaningfull way how to test this util
9541
+ * TODO: This should be maybe not under `_common` but under `utils`
9542
+ * TODO: [®] DRY Register logic
9543
+ */
9544
+
9545
+ /**
9546
+ * Stores data in memory (HEAP)
9547
+ *
9548
+ * @public exported from `@promptbook/core`
9549
+ */
9550
+ var MemoryStorage = /** @class */ (function () {
9551
+ function MemoryStorage() {
9552
+ this.storage = {};
9553
+ }
9554
+ Object.defineProperty(MemoryStorage.prototype, "length", {
9555
+ /**
9556
+ * Returns the number of key/value pairs currently present in the list associated with the object.
9557
+ */
9558
+ get: function () {
9196
9559
  return Object.keys(this.storage).length;
9197
9560
  },
9198
9561
  enumerable: false,
@@ -9445,6 +9808,9 @@ var _AnthropicClaudeMetadataRegistration = $llmToolsMetadataRegister.register({
9445
9808
  return null;
9446
9809
  },
9447
9810
  });
9811
+ /**
9812
+ * Note: [💞] Ignore a discrepancy between file name and entity name
9813
+ */
9448
9814
 
9449
9815
  /**
9450
9816
  * Registration of LLM provider metadata
@@ -9492,6 +9858,9 @@ var _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
9492
9858
  return null;
9493
9859
  },
9494
9860
  });
9861
+ /**
9862
+ * Note: [💞] Ignore a discrepancy between file name and entity name
9863
+ */
9495
9864
 
9496
9865
  /**
9497
9866
  * Registration of LLM provider metadata
@@ -9572,10 +9941,15 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
9572
9941
  */
9573
9942
  },
9574
9943
  });
9944
+ /**
9945
+ * Note: [💞] Ignore a discrepancy between file name and entity name
9946
+ */
9575
9947
 
9576
9948
  /**
9577
9949
  * @@@
9578
9950
  *
9951
+ * @see https://github.com/webgptorg/promptbook/discussions/171
9952
+ *
9579
9953
  * @public exported from `@promptbook/core`
9580
9954
  */
9581
9955
  function getPipelineInterface(pipeline) {
@@ -9625,6 +9999,8 @@ function getPipelineInterface(pipeline) {
9625
9999
  /**
9626
10000
  * @@@
9627
10001
  *
10002
+ * @see https://github.com/webgptorg/promptbook/discussions/171
10003
+ *
9628
10004
  * @public exported from `@promptbook/core`
9629
10005
  */
9630
10006
  function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
@@ -9639,6 +10015,8 @@ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
9639
10015
  /**
9640
10016
  * @@@
9641
10017
  *
10018
+ * @see https://github.com/webgptorg/promptbook/discussions/171
10019
+ *
9642
10020
  * @public exported from `@promptbook/core`
9643
10021
  */
9644
10022
  function isPipelineImplementingInterface(options) {
@@ -9677,6 +10055,9 @@ var legacyDocumentScraperMetadata = $deepFreeze({
9677
10055
  * @public exported from `@promptbook/cli`
9678
10056
  */
9679
10057
  var _LegacyDocumentScraperMetadataRegistration = $scrapersMetadataRegister.register(legacyDocumentScraperMetadata);
10058
+ /**
10059
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10060
+ */
9680
10061
 
9681
10062
  /**
9682
10063
  * Metadata of the scraper
@@ -9701,6 +10082,9 @@ var documentScraperMetadata = $deepFreeze({
9701
10082
  * @public exported from `@promptbook/cli`
9702
10083
  */
9703
10084
  var _DocumentScraperMetadataRegistration = $scrapersMetadataRegister.register(documentScraperMetadata);
10085
+ /**
10086
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10087
+ */
9704
10088
 
9705
10089
  /**
9706
10090
  * Metadata of the scraper
@@ -9725,6 +10109,9 @@ var markdownScraperMetadata = $deepFreeze({
9725
10109
  * @public exported from `@promptbook/cli`
9726
10110
  */
9727
10111
  var _MarkdownScraperMetadataRegistration = $scrapersMetadataRegister.register(markdownScraperMetadata);
10112
+ /**
10113
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10114
+ */
9728
10115
 
9729
10116
  /**
9730
10117
  * Metadata of the scraper
@@ -9749,6 +10136,9 @@ var pdfScraperMetadata = $deepFreeze({
9749
10136
  * @public exported from `@promptbook/cli`
9750
10137
  */
9751
10138
  var _PdfScraperMetadataRegistration = $scrapersMetadataRegister.register(pdfScraperMetadata);
10139
+ /**
10140
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10141
+ */
9752
10142
 
9753
10143
  /**
9754
10144
  * Metadata of the scraper
@@ -9773,6 +10163,9 @@ var websiteScraperMetadata = $deepFreeze({
9773
10163
  * @public exported from `@promptbook/cli`
9774
10164
  */
9775
10165
  var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
10166
+ /**
10167
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10168
+ */
9776
10169
 
9777
10170
  /**
9778
10171
  * Behaves like a storage but forgets everything you put in it
@@ -9855,322 +10248,5 @@ var PrefixStorage = /** @class */ (function () {
9855
10248
  return PrefixStorage;
9856
10249
  }());
9857
10250
 
9858
- /**
9859
- * Format either small or big number
9860
- *
9861
- * @private within the repository
9862
- */
9863
- function formatNumber(value) {
9864
- if (value === 0) {
9865
- return '0';
9866
- }
9867
- for (var exponent = 0; exponent < 15; exponent++) {
9868
- var factor = Math.pow(10, exponent);
9869
- var valueRounded = Math.round(value * factor) / factor;
9870
- if (Math.abs(value - valueRounded) / value <
9871
- 0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
9872
- return valueRounded.toFixed(exponent);
9873
- }
9874
- }
9875
- return value.toString();
9876
- }
9877
-
9878
- /**
9879
- * Create a markdown table from a 2D array of strings
9880
- *
9881
- * @public exported from `@promptbook/markdown-utils`
9882
- */
9883
- function createMarkdownTable(table) {
9884
- var columnWidths = table.reduce(function (widths, row) {
9885
- row.forEach(function (subformat, columnIndex) {
9886
- var cellLength = subformat.length;
9887
- if (!widths[columnIndex] || cellLength > widths[columnIndex]) {
9888
- widths[columnIndex] = cellLength;
9889
- }
9890
- });
9891
- return widths;
9892
- }, []);
9893
- var header = "| ".concat(table[0]
9894
- .map(function (subformat, columnIndex) { return subformat.padEnd(columnWidths[columnIndex]); })
9895
- .join(' | '), " |");
9896
- var separator = "|".concat(columnWidths.map(function (width) { return '-'.repeat(width + 2); }).join('|'), "|");
9897
- var rows = table.slice(1).map(function (row) {
9898
- var paddedRow = row.map(function (subformat, columnIndex) {
9899
- return subformat.padEnd(columnWidths[columnIndex]);
9900
- });
9901
- return "| ".concat(paddedRow.join(' | '), " |");
9902
- });
9903
- return __spreadArray([header, separator], __read(rows), false).join('\n');
9904
- }
9905
- /**
9906
- * TODO: [🏛] This can be part of markdown builder
9907
- */
9908
-
9909
- /**
9910
- * Function createMarkdownChart will draw a chart in markdown from ⬛+🟦 tiles
9911
- *
9912
- * @public exported from `@promptbook/markdown-utils`
9913
- */
9914
- function createMarkdownChart(options) {
9915
- var e_1, _a;
9916
- var nameHeader = options.nameHeader, valueHeader = options.valueHeader, items = options.items, width = options.width, unitName = options.unitName;
9917
- var from = Math.min.apply(Math, __spreadArray([], __read(items.map(function (item) { return item.from; })), false));
9918
- var to = Math.max.apply(Math, __spreadArray([], __read(items.map(function (item) { return item.to; })), false));
9919
- var scale = width / (to - from);
9920
- var table = [[nameHeader, valueHeader]];
9921
- try {
9922
- for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
9923
- var item = items_1_1.value;
9924
- var before = Math.round((item.from - from) * scale);
9925
- var during = Math.round((item.to - item.from) * scale);
9926
- var after = width - before - during;
9927
- table.push([removeEmojis(item.title).trim(), '░'.repeat(before) + '█'.repeat(during) + '░'.repeat(after)]);
9928
- }
9929
- }
9930
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
9931
- finally {
9932
- try {
9933
- if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
9934
- }
9935
- finally { if (e_1) throw e_1.error; }
9936
- }
9937
- var legend = "_Note: Each \u2588 represents ".concat(formatNumber(1 / scale), " ").concat(unitName, ", width of ").concat(valueHeader.toLowerCase(), " is ").concat(formatNumber(to - from), " ").concat(unitName, " = ").concat(width, " squares_");
9938
- return createMarkdownTable(table) + '\n\n' + legend;
9939
- }
9940
- /**
9941
- * TODO: Maybe use Mermain Gant Diagrams
9942
- * @see https://jojozhuang.github.io/tutorial/mermaid-cheat-sheet/
9943
- */
9944
-
9945
- /**
9946
- * Function escapeMarkdownBlock will escape markdown block if needed
9947
- * It is useful when you want have block in block
9948
- *
9949
- * @public exported from `@promptbook/markdown-utils`
9950
- */
9951
- function escapeMarkdownBlock(value) {
9952
- return value.replace(/```/g, '\\`\\`\\`');
9953
- }
9954
- /**
9955
- * TODO: [🏛] This can be part of markdown builder
9956
- */
9957
-
9958
- /**
9959
- * Default options for generating an execution report string
9960
- *
9961
- * @public exported from `@promptbook/core`
9962
- */
9963
- var ExecutionReportStringOptionsDefaults = {
9964
- taxRate: 0,
9965
- chartsWidth: 36,
9966
- };
9967
-
9968
- /**
9969
- * Count the duration of working time
9970
- *
9971
- * @private within the repository
9972
- */
9973
- function countWorkingDuration(items) {
9974
- var e_1, _a;
9975
- var steps = Array.from(new Set(items.flatMap(function (item) { return [item.from, item.to]; })));
9976
- steps.sort(function (a, b) { return a - b; });
9977
- var intervals = steps.map(function (step, index) { return [step, steps[index + 1] || 0]; }).slice(0, -1);
9978
- var duration = 0;
9979
- var _loop_1 = function (interval) {
9980
- var _b = __read(interval, 2), from = _b[0], to = _b[1];
9981
- if (items.some(function (item) { return item.from < to && item.to > from; })) {
9982
- duration += to - from;
9983
- }
9984
- };
9985
- try {
9986
- for (var intervals_1 = __values(intervals), intervals_1_1 = intervals_1.next(); !intervals_1_1.done; intervals_1_1 = intervals_1.next()) {
9987
- var interval = intervals_1_1.value;
9988
- _loop_1(interval);
9989
- }
9990
- }
9991
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
9992
- finally {
9993
- try {
9994
- if (intervals_1_1 && !intervals_1_1.done && (_a = intervals_1.return)) _a.call(intervals_1);
9995
- }
9996
- finally { if (e_1) throw e_1.error; }
9997
- }
9998
- return duration;
9999
- }
10000
-
10001
- /**
10002
- * Converts execution report from JSON to string format
10003
- *
10004
- * @public exported from `@promptbook/core`
10005
- */
10006
- function executionReportJsonToString(executionReportJson, options) {
10007
- var e_1, _a;
10008
- var _b, _c, _d, _e, _f, _g;
10009
- var _h = __assign(__assign({}, ExecutionReportStringOptionsDefaults), (options || {})), taxRate = _h.taxRate, chartsWidth = _h.chartsWidth;
10010
- var executionReportString = spaceTrim$1(function (block) { return "\n # ".concat(executionReportJson.title || 'Execution report', "\n\n ").concat(block(executionReportJson.description || ''), "\n "); });
10011
- var headerList = [];
10012
- if (executionReportJson.pipelineUrl) {
10013
- headerList.push("PIPELINE URL ".concat(executionReportJson.pipelineUrl));
10014
- }
10015
- headerList.push("PROMPTBOOK VERSION ".concat(executionReportJson.promptbookUsedVersion) +
10016
- (!executionReportJson.promptbookRequestedVersion
10017
- ? ''
10018
- : " *(requested ".concat(executionReportJson.promptbookRequestedVersion, ")*")));
10019
- if (executionReportJson.promptExecutions.length !== 0) {
10020
- // TODO: What if startedAt OR/AND completedAt is not defined?
10021
- var startedAt = moment(Math.min.apply(Math, __spreadArray([], __read(executionReportJson.promptExecutions
10022
- .filter(function (promptExecution) { var _a, _b; return (_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.start; })
10023
- .map(function (promptExecution) { return moment(promptExecution.result.timing.start).valueOf(); })), false)));
10024
- var completedAt = moment(Math.max.apply(Math, __spreadArray([], __read(executionReportJson.promptExecutions
10025
- .filter(function (promptExecution) { var _a, _b; return (_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.complete; })
10026
- .map(function (promptExecution) { return moment(promptExecution.result.timing.complete).valueOf(); })), false)));
10027
- var timingItems = executionReportJson.promptExecutions.map(function (promptExecution) {
10028
- var _a, _b, _c, _d;
10029
- return ({
10030
- title: promptExecution.prompt.title,
10031
- from: moment((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.start).valueOf() / 1000,
10032
- to: moment((_d = (_c = promptExecution.result) === null || _c === void 0 ? void 0 : _c.timing) === null || _d === void 0 ? void 0 : _d.complete).valueOf() / 1000,
10033
- });
10034
- });
10035
- var costItems = executionReportJson.promptExecutions
10036
- .filter(function (promptExecution) { var _a, _b; return typeof ((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) === 'number'; })
10037
- .map(function (promptExecution) {
10038
- var _a, _b;
10039
- return ({
10040
- title: promptExecution.prompt.title,
10041
- from: 0,
10042
- to: (((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price.value) || 0) /* <- TODO: look at uncertain numbers */ *
10043
- (1 + taxRate),
10044
- });
10045
- });
10046
- var duration = moment.duration(completedAt.diff(startedAt));
10047
- var llmDuration = moment.duration(countWorkingDuration(timingItems) * 1000);
10048
- var executionsWithKnownCost = executionReportJson.promptExecutions.filter(function (promptExecution) { var _a, _b; return (((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) || 'UNKNOWN') !== 'UNKNOWN'; });
10049
- var cost = executionsWithKnownCost.reduce(function (cost, promptExecution) {
10050
- return cost + (promptExecution.result.usage.price.value /* <- Look at uncertain number */ || 0);
10051
- }, 0);
10052
- headerList.push("STARTED AT ".concat(moment(startedAt).format("YYYY-MM-DD HH:mm:ss")));
10053
- headerList.push("COMPLETED AT ".concat(moment(completedAt).format("YYYY-MM-DD HH:mm:ss")));
10054
- headerList.push("TOTAL DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
10055
- headerList.push("TOTAL LLM DURATION ".concat(llmDuration.humanize(MOMENT_ARG_THRESHOLDS)));
10056
- headerList.push("TOTAL COST $".concat(formatNumber(cost * (1 + taxRate))) +
10057
- (executionsWithKnownCost.length === executionReportJson.promptExecutions.length
10058
- ? ''
10059
- : " *(Some cost is unknown)*") +
10060
- (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
10061
- executionReportString += '\n\n' + headerList.map(function (header) { return "- ".concat(header); }).join('\n');
10062
- executionReportString +=
10063
- '\n\n' +
10064
- '## 🗃 Index' +
10065
- '\n\n' +
10066
- executionReportJson.promptExecutions
10067
- .map(function (promptExecution) {
10068
- // TODO: Make some better system to convert hedings to links
10069
- var hash = normalizeToKebabCase(promptExecution.prompt.title);
10070
- if (/^\s*\p{Extended_Pictographic}/u.test(promptExecution.prompt.title)) {
10071
- hash = '-' + hash;
10072
- }
10073
- // TODO: Make working hash link for the template in md + pdf
10074
- return "- [".concat(promptExecution.prompt.title, "](#").concat(hash, ")");
10075
- })
10076
- .join('\n');
10077
- executionReportString +=
10078
- '\n\n' +
10079
- '## ⌚ Time chart' +
10080
- '\n\n' +
10081
- createMarkdownChart({
10082
- nameHeader: 'Template',
10083
- valueHeader: 'Timeline',
10084
- items: timingItems,
10085
- width: chartsWidth,
10086
- unitName: 'seconds',
10087
- });
10088
- executionReportString +=
10089
- '\n\n' +
10090
- '## 💸 Cost chart' +
10091
- '\n\n' +
10092
- createMarkdownChart({
10093
- nameHeader: 'Template',
10094
- valueHeader: 'Cost',
10095
- items: costItems,
10096
- width: chartsWidth,
10097
- unitName: 'USD',
10098
- });
10099
- }
10100
- else {
10101
- headerList.push("TOTAL COST $0 *(Nothing executed)*");
10102
- }
10103
- var _loop_1 = function (promptExecution) {
10104
- executionReportString += '\n\n\n\n' + "## ".concat(promptExecution.prompt.title);
10105
- var templateList = [];
10106
- // TODO: What if startedAt OR/AND completedAt is not defined?
10107
- var startedAt = moment((_c = (_b = promptExecution.result) === null || _b === void 0 ? void 0 : _b.timing) === null || _c === void 0 ? void 0 : _c.start);
10108
- var completedAt = moment((_e = (_d = promptExecution.result) === null || _d === void 0 ? void 0 : _d.timing) === null || _e === void 0 ? void 0 : _e.complete);
10109
- var duration = moment.duration(completedAt.diff(startedAt));
10110
- // Not need here:
10111
- // > templateList.push(`STARTED AT ${moment(startedAt).calendar()}`);
10112
- templateList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
10113
- if (typeof ((_g = (_f = promptExecution.result) === null || _f === void 0 ? void 0 : _f.usage) === null || _g === void 0 ? void 0 : _g.price) === 'number') {
10114
- templateList.push("COST $".concat(formatNumber(promptExecution.result.usage.price * (1 + taxRate))) +
10115
- (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
10116
- }
10117
- else {
10118
- templateList.push("COST UNKNOWN");
10119
- }
10120
- executionReportString += '\n\n' + templateList.map(function (header) { return "- ".concat(header); }).join('\n');
10121
- /*
10122
- - MODEL VARIANT ${promptExecution.prompt.modelRequirements.modelVariant}
10123
- - MODEL NAME \`${promptExecution.result?.model}\` (requested \`${
10124
- promptExecution.prompt.modelRequirements.modelName
10125
-
10126
- */
10127
- if (just(true)) {
10128
- executionReportString +=
10129
- '\n\n\n\n' +
10130
- spaceTrim$1(function (block) {
10131
- var _a;
10132
- return "\n\n ### Prompt\n\n ```\n ".concat(block(escapeMarkdownBlock(((_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.rawPromptContent) || promptExecution.prompt.content)), "\n ```\n\n ");
10133
- });
10134
- }
10135
- if (promptExecution.result && promptExecution.result.content) {
10136
- executionReportString += '\n\n\n\n' + '### Result' + '\n\n';
10137
- if (promptExecution.result === undefined) {
10138
- executionReportString += '*No result*';
10139
- }
10140
- else if (typeof promptExecution.result.content === 'string') {
10141
- executionReportString += spaceTrim$1(function (block) { return "\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.result.content)), "\n ```\n "); });
10142
- }
10143
- else {
10144
- executionReportString += embeddingVectorToString(promptExecution.result.content);
10145
- }
10146
- }
10147
- if (promptExecution.error && promptExecution.error.message) {
10148
- executionReportString +=
10149
- '\n\n\n\n' +
10150
- spaceTrim$1(function (block) { return "\n\n ### Error\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.error.message)), "\n ```\n\n "); });
10151
- }
10152
- };
10153
- try {
10154
- for (var _j = __values(executionReportJson.promptExecutions), _k = _j.next(); !_k.done; _k = _j.next()) {
10155
- var promptExecution = _k.value;
10156
- _loop_1(promptExecution);
10157
- }
10158
- }
10159
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
10160
- finally {
10161
- try {
10162
- if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
10163
- }
10164
- finally { if (e_1) throw e_1.error; }
10165
- }
10166
- executionReportString = prettifyMarkdown(executionReportString);
10167
- return executionReportString;
10168
- }
10169
- /**
10170
- * TODO: Add mermaid chart for every report
10171
- * TODO: [🧠] Allow to filter out some parts of the report by options
10172
- * TODO: [🧠] Should be in generated file GENERATOR_WARNING
10173
- */
10174
-
10175
- export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GenericFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SheetsFormfactorDefinition, TemplateTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
10251
+ export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GenericFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SectionTypes, SheetsFormfactorDefinition, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
10176
10252
  //# sourceMappingURL=index.es.js.map