@promptbook/legacy-documents 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 +239 -218
  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 +5 -4
  140. package/umd/index.umd.js +239 -218
  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
@@ -23,9 +23,10 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
23
23
  *
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-1';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
+ * Note: [💞] Ignore a discrepancy between file name and entity name
29
30
  */
30
31
 
31
32
  /*! *****************************************************************************
@@ -463,6 +464,7 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
463
464
  true);
464
465
  /**
465
466
  * TODO: Extract `constants.ts` from `config.ts`
467
+ * Note: [💞] Ignore a discrepancy between file name and entity name
466
468
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
467
469
  */
468
470
 
@@ -1079,6 +1081,9 @@ function normalizeToKebabCase(text) {
1079
1081
  normalizedName = normalizedName.replace(/-$/, '');
1080
1082
  return normalizedName;
1081
1083
  }
1084
+ /**
1085
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1086
+ */
1082
1087
 
1083
1088
  /**
1084
1089
  * Removes emojis from a string and fix whitespaces
@@ -1226,7 +1231,7 @@ function getScraperIntermediateSource(source, options) {
1226
1231
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
1227
1232
  */
1228
1233
 
1229
- 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"}];
1234
+ 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"}];
1230
1235
 
1231
1236
  /**
1232
1237
  * Prettify the html code
@@ -1280,7 +1285,7 @@ function capitalize(word) {
1280
1285
  */
1281
1286
  function pipelineJsonToString(pipelineJson) {
1282
1287
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
1283
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
1288
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, tasks = pipelineJson.tasks;
1284
1289
  var pipelineString = "# ".concat(title);
1285
1290
  if (description) {
1286
1291
  pipelineString += '\n\n';
@@ -1330,13 +1335,13 @@ function pipelineJsonToString(pipelineJson) {
1330
1335
  pipelineString += '\n\n';
1331
1336
  pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
1332
1337
  try {
1333
- for (var templates_1 = __values(templates), templates_1_1 = templates_1.next(); !templates_1_1.done; templates_1_1 = templates_1.next()) {
1334
- var template = templates_1_1.value;
1338
+ for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
1339
+ var template = tasks_1_1.value;
1335
1340
  var
1336
1341
  /* Note: Not using:> name, */
1337
1342
  title_1 = template.title, description_1 = template.description,
1338
1343
  /* Note: dependentParameterNames, */
1339
- jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
1344
+ jokers = template.jokerParameterNames, taskType = template.taskType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
1340
1345
  pipelineString += '\n\n';
1341
1346
  pipelineString += "## ".concat(title_1);
1342
1347
  if (description_1) {
@@ -1345,7 +1350,7 @@ function pipelineJsonToString(pipelineJson) {
1345
1350
  }
1346
1351
  var commands_1 = [];
1347
1352
  var contentLanguage = 'text';
1348
- if (templateType === 'PROMPT_TEMPLATE') {
1353
+ if (taskType === 'PROMPT_TASK') {
1349
1354
  var modelRequirements = template.modelRequirements;
1350
1355
  var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
1351
1356
  commands_1.push("EXECUTE PROMPT TEMPLATE");
@@ -1356,11 +1361,11 @@ function pipelineJsonToString(pipelineJson) {
1356
1361
  commands_1.push("MODEL NAME `".concat(modelName, "`"));
1357
1362
  }
1358
1363
  }
1359
- else if (templateType === 'SIMPLE_TEMPLATE') {
1364
+ else if (taskType === 'SIMPLE_TASK') {
1360
1365
  commands_1.push("SIMPLE TEMPLATE");
1361
1366
  // Note: Nothing special here
1362
1367
  }
1363
- else if (templateType === 'SCRIPT_TEMPLATE') {
1368
+ else if (taskType === 'SCRIPT_TASK') {
1364
1369
  commands_1.push("SCRIPT TEMPLATE");
1365
1370
  if (template.contentLanguage) {
1366
1371
  contentLanguage = template.contentLanguage;
@@ -1369,7 +1374,7 @@ function pipelineJsonToString(pipelineJson) {
1369
1374
  contentLanguage = '';
1370
1375
  }
1371
1376
  }
1372
- else if (templateType === 'DIALOG_TEMPLATE') {
1377
+ else if (taskType === 'DIALOG_TASK') {
1373
1378
  commands_1.push("DIALOG TEMPLATE");
1374
1379
  // Note: Nothing special here
1375
1380
  } // <- }else if([🅱]
@@ -1451,7 +1456,7 @@ function pipelineJsonToString(pipelineJson) {
1451
1456
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
1452
1457
  finally {
1453
1458
  try {
1454
- if (templates_1_1 && !templates_1_1.done && (_c = templates_1.return)) _c.call(templates_1);
1459
+ if (tasks_1_1 && !tasks_1_1.done && (_c = tasks_1.return)) _c.call(tasks_1);
1455
1460
  }
1456
1461
  finally { if (e_3) throw e_3.error; }
1457
1462
  }
@@ -1699,9 +1704,9 @@ function validatePipelineCore(pipeline) {
1699
1704
  throw new ParseError(spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.parameters` expected to be an array, but got ".concat(typeof pipeline.parameters, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1700
1705
  }
1701
1706
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1702
- if (!Array.isArray(pipeline.templates)) {
1707
+ if (!Array.isArray(pipeline.tasks)) {
1703
1708
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
1704
- throw new ParseError(spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.templates` expected to be an array, but got ".concat(typeof pipeline.templates, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1709
+ throw new ParseError(spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.tasks` expected to be an array, but got ".concat(typeof pipeline.tasks, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
1705
1710
  }
1706
1711
  var _loop_1 = function (parameter) {
1707
1712
  if (parameter.isInput && parameter.isOutput) {
@@ -1710,13 +1715,12 @@ function validatePipelineCore(pipeline) {
1710
1715
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
1711
1716
  if (!parameter.isInput &&
1712
1717
  !parameter.isOutput &&
1713
- !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
1718
+ !pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
1714
1719
  throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
1715
1720
  }
1716
- // Note: Testing that parameter is either input or result of some template
1717
- if (!parameter.isInput &&
1718
- !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
1719
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add template that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1721
+ // Note: Testing that parameter is either input or result of some task
1722
+ if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
1723
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add task that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1720
1724
  }
1721
1725
  };
1722
1726
  try {
@@ -1733,7 +1737,7 @@ function validatePipelineCore(pipeline) {
1733
1737
  }
1734
1738
  finally { if (e_1) throw e_1.error; }
1735
1739
  }
1736
- // Note: All input parameters are defined - so that they can be used as result of some template
1740
+ // Note: All input parameters are defined - so that they can be used as result of some task
1737
1741
  var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
1738
1742
  var isInput = _a.isInput;
1739
1743
  return isInput;
@@ -1741,27 +1745,27 @@ function validatePipelineCore(pipeline) {
1741
1745
  var name = _a.name;
1742
1746
  return name;
1743
1747
  }));
1744
- var _loop_2 = function (template) {
1748
+ var _loop_2 = function (task) {
1745
1749
  var e_4, _h, e_5, _j;
1746
- if (definedParameters.has(template.resultingParameterName)) {
1747
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1750
+ if (definedParameters.has(task.resultingParameterName)) {
1751
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1748
1752
  }
1749
- if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1750
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
1753
+ if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
1754
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter name {".concat(task.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
1751
1755
  }
1752
- definedParameters.add(template.resultingParameterName);
1753
- if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
1754
- if (!template.format &&
1755
- !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1756
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
1756
+ definedParameters.add(task.resultingParameterName);
1757
+ if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
1758
+ if (!task.format &&
1759
+ !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1760
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Joker parameters are used for {".concat(task.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
1757
1761
  }
1758
1762
  var _loop_4 = function (joker) {
1759
- if (!template.dependentParameterNames.includes(joker)) {
1760
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1763
+ if (!task.dependentParameterNames.includes(joker)) {
1764
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(task.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1761
1765
  }
1762
1766
  };
1763
1767
  try {
1764
- for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1768
+ for (var _k = (e_4 = void 0, __values(task.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1765
1769
  var joker = _l.value;
1766
1770
  _loop_4(joker);
1767
1771
  }
@@ -1774,7 +1778,7 @@ function validatePipelineCore(pipeline) {
1774
1778
  finally { if (e_4) throw e_4.error; }
1775
1779
  }
1776
1780
  }
1777
- if (template.expectations) {
1781
+ if (task.expectations) {
1778
1782
  var _loop_5 = function (unit, min, max) {
1779
1783
  if (min !== undefined && max !== undefined && min > max) {
1780
1784
  throw new PipelineLogicError(spaceTrim(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -1787,7 +1791,7 @@ function validatePipelineCore(pipeline) {
1787
1791
  }
1788
1792
  };
1789
1793
  try {
1790
- for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1794
+ for (var _m = (e_5 = void 0, __values(Object.entries(task.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1791
1795
  var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
1792
1796
  _loop_5(unit, min, max);
1793
1797
  }
@@ -1802,10 +1806,10 @@ function validatePipelineCore(pipeline) {
1802
1806
  }
1803
1807
  };
1804
1808
  try {
1805
- // Note: Checking each template individually
1806
- for (var _f = __values(pipeline.templates), _g = _f.next(); !_g.done; _g = _f.next()) {
1807
- var template = _g.value;
1808
- _loop_2(template);
1809
+ // Note: Checking each task individually
1810
+ for (var _f = __values(pipeline.tasks), _g = _f.next(); !_g.done; _g = _f.next()) {
1811
+ var task = _g.value;
1812
+ _loop_2(task);
1809
1813
  }
1810
1814
  }
1811
1815
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1839,15 +1843,15 @@ function validatePipelineCore(pipeline) {
1839
1843
  }
1840
1844
  finally { if (e_3) throw e_3.error; }
1841
1845
  }
1842
- var unresovedTemplates = __spreadArray([], __read(pipeline.templates), false);
1846
+ var unresovedTemplates = __spreadArray([], __read(pipeline.tasks), false);
1843
1847
  var loopLimit = LOOP_LIMIT;
1844
1848
  var _loop_3 = function () {
1845
1849
  if (loopLimit-- < 0) {
1846
1850
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1847
1851
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
1848
1852
  }
1849
- var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1850
- return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1853
+ var currentlyResovedTemplates = unresovedTemplates.filter(function (task) {
1854
+ return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1851
1855
  });
1852
1856
  if (currentlyResovedTemplates.length === 0) {
1853
1857
  throw new PipelineLogicError(
@@ -1875,7 +1879,7 @@ function validatePipelineCore(pipeline) {
1875
1879
  var resultingParameterName = _a.resultingParameterName;
1876
1880
  return resultingParameterName;
1877
1881
  })), false);
1878
- unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
1882
+ unresovedTemplates = unresovedTemplates.filter(function (task) { return !currentlyResovedTemplates.includes(task); });
1879
1883
  };
1880
1884
  while (unresovedTemplates.length > 0) {
1881
1885
  _loop_3();
@@ -1937,9 +1941,9 @@ var PipelineUrlError = /** @class */ (function (_super) {
1937
1941
  }(Error));
1938
1942
 
1939
1943
  /**
1940
- * Parses the template and returns the list of all parameter names
1944
+ * Parses the task and returns the list of all parameter names
1941
1945
  *
1942
- * @param template the template with parameters in {curly} braces
1946
+ * @param template the task with parameters in {curly} braces
1943
1947
  * @returns the list of parameter names
1944
1948
  * @public exported from `@promptbook/utils`
1945
1949
  */
@@ -1970,10 +1974,10 @@ function extractParameterNames(template) {
1970
1974
  * @public exported from `@promptbook/core`
1971
1975
  */
1972
1976
  function unpreparePipeline(pipeline) {
1973
- var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, templates = pipeline.templates;
1977
+ var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
1974
1978
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
1975
1979
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
1976
- templates = templates.map(function (template) {
1980
+ tasks = tasks.map(function (template) {
1977
1981
  var dependentParameterNames = template.dependentParameterNames;
1978
1982
  var parameterNames = extractParameterNames(template.preparedContent || '');
1979
1983
  dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
@@ -1981,7 +1985,7 @@ function unpreparePipeline(pipeline) {
1981
1985
  delete templateUnprepared.preparedContent;
1982
1986
  return templateUnprepared;
1983
1987
  });
1984
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { templates: templates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1988
+ return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1985
1989
  }
1986
1990
  /**
1987
1991
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -2196,6 +2200,9 @@ var ERRORS = {
2196
2200
  UnexpectedError: UnexpectedError,
2197
2201
  // TODO: [🪑]> VersionMismatchError,
2198
2202
  };
2203
+ /**
2204
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2205
+ */
2199
2206
 
2200
2207
  /**
2201
2208
  * Deserializes the error object
@@ -2257,8 +2264,8 @@ function isPipelinePrepared(pipeline) {
2257
2264
  return false;
2258
2265
  }
2259
2266
  /*
2260
- TODO: [🧠][🍫] `templates` can not be determined if they are fully prepared SO ignoring them
2261
- > if (!pipeline.templates.every(({ preparedContent }) => preparedContent === undefined)) {
2267
+ TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
2268
+ > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
2262
2269
  > return false;
2263
2270
  > }
2264
2271
  */
@@ -2271,7 +2278,7 @@ function isPipelinePrepared(pipeline) {
2271
2278
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2272
2279
  * - [🏍] ? Is context in each template
2273
2280
  * - [♨] Are examples prepared
2274
- * - [♨] Are templates prepared
2281
+ * - [♨] Are tasks prepared
2275
2282
  */
2276
2283
 
2277
2284
  /**
@@ -2419,6 +2426,9 @@ $deepFreeze({
2419
2426
  pagesCount: { value: 0, isUncertain: true },
2420
2427
  },
2421
2428
  });
2429
+ /**
2430
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2431
+ */
2422
2432
 
2423
2433
  /**
2424
2434
  * @@@
@@ -3543,7 +3553,7 @@ TODO: [🧊] This is how it can look in future
3543
3553
  */
3544
3554
  function clonePipeline(pipeline) {
3545
3555
  // Note: Not using spread operator (...) because @@@
3546
- 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;
3556
+ 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;
3547
3557
  return {
3548
3558
  pipelineUrl: pipelineUrl,
3549
3559
  sourceFile: sourceFile,
@@ -3552,7 +3562,7 @@ function clonePipeline(pipeline) {
3552
3562
  description: description,
3553
3563
  formfactorName: formfactorName,
3554
3564
  parameters: parameters,
3555
- templates: templates,
3565
+ tasks: tasks,
3556
3566
  knowledgeSources: knowledgeSources,
3557
3567
  knowledgePieces: knowledgePieces,
3558
3568
  personas: personas,
@@ -3568,17 +3578,17 @@ function clonePipeline(pipeline) {
3568
3578
  *
3569
3579
  * @public exported from `@promptbook/core`
3570
3580
  */
3571
- function prepareTemplates(pipeline, tools, options) {
3581
+ function prepareTasks(pipeline, tools, options) {
3572
3582
  return __awaiter(this, void 0, void 0, function () {
3573
- var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
3583
+ var _a, maxParallelCount, tasks, knowledgePiecesCount, tasksPrepared;
3574
3584
  var _this = this;
3575
3585
  return __generator(this, function (_b) {
3576
3586
  switch (_b.label) {
3577
3587
  case 0:
3578
3588
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
3579
- templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3580
- templatesPrepared = new Array(templates.length);
3581
- 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 () {
3589
+ tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3590
+ tasksPrepared = new Array(tasks.length);
3591
+ 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 () {
3582
3592
  var dependentParameterNames, preparedContent, preparedTemplate;
3583
3593
  return __generator(this, function (_a) {
3584
3594
  dependentParameterNames = template.dependentParameterNames;
@@ -3591,13 +3601,13 @@ function prepareTemplates(pipeline, tools, options) {
3591
3601
  ], false);
3592
3602
  }
3593
3603
  preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
3594
- templatesPrepared[index] = preparedTemplate;
3604
+ tasksPrepared[index] = preparedTemplate;
3595
3605
  return [2 /*return*/];
3596
3606
  });
3597
3607
  }); })];
3598
3608
  case 1:
3599
3609
  _b.sent();
3600
- return [2 /*return*/, { templatesPrepared: templatesPrepared }];
3610
+ return [2 /*return*/, { tasksPrepared: tasksPrepared }];
3601
3611
  }
3602
3612
  });
3603
3613
  });
@@ -3605,7 +3615,7 @@ function prepareTemplates(pipeline, tools, options) {
3605
3615
  /**
3606
3616
  * TODO: [🧠] Add context to each template (if missing)
3607
3617
  * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
3608
- * TODO: [♨][main] !!! Prepare index the examples and maybe templates
3618
+ * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
3609
3619
  * TODO: Write tests for `preparePipeline`
3610
3620
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3611
3621
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -3622,12 +3632,12 @@ function prepareTemplates(pipeline, tools, options) {
3622
3632
  */
3623
3633
  function preparePipeline(pipeline, tools, options) {
3624
3634
  return __awaiter(this, void 0, void 0, function () {
3625
- var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, templates,
3635
+ var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, tasks,
3626
3636
  /*
3627
3637
  <- TODO: [🧠][🪑] `promptbookVersion` */
3628
3638
  knowledgeSources /*
3629
3639
  <- TODO: [🧊] `knowledgePieces` */, personas /*
3630
- <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, templatesPrepared /* TODO: parameters: parametersPrepared*/;
3640
+ <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
3631
3641
  var _this = this;
3632
3642
  return __generator(this, function (_c) {
3633
3643
  switch (_c.label) {
@@ -3636,7 +3646,7 @@ function preparePipeline(pipeline, tools, options) {
3636
3646
  return [2 /*return*/, pipeline];
3637
3647
  }
3638
3648
  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;
3639
- parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3649
+ parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3640
3650
  if (tools === undefined || tools.llm === undefined) {
3641
3651
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
3642
3652
  }
@@ -3679,9 +3689,9 @@ function preparePipeline(pipeline, tools, options) {
3679
3689
  case 2:
3680
3690
  partialknowledgePiecesPrepared = _c.sent();
3681
3691
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3682
- return [4 /*yield*/, prepareTemplates({
3692
+ return [4 /*yield*/, prepareTasks({
3683
3693
  parameters: parameters,
3684
- templates: templates,
3694
+ tasks: tasks,
3685
3695
  knowledgePiecesCount: knowledgePiecesPrepared.length,
3686
3696
  }, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), {
3687
3697
  rootDirname: rootDirname,
@@ -3689,12 +3699,12 @@ function preparePipeline(pipeline, tools, options) {
3689
3699
  isVerbose: isVerbose,
3690
3700
  })];
3691
3701
  case 3:
3692
- templatesPrepared = (_c.sent()).templatesPrepared;
3702
+ tasksPrepared = (_c.sent()).tasksPrepared;
3693
3703
  // ----- /Templates preparation -----
3694
3704
  // Note: Count total usage
3695
3705
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
3696
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
3697
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
3706
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
3707
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3698
3708
  knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
3699
3709
  }
3700
3710
  });
@@ -3766,9 +3776,9 @@ function extractVariables(script) {
3766
3776
  * @throws {ParseError} if the script is invalid
3767
3777
  * @public exported from `@promptbook/utils`
3768
3778
  */
3769
- function extractParameterNamesFromTemplate(template) {
3779
+ function extractParameterNamesFromTask(template) {
3770
3780
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
3771
- var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
3781
+ var title = template.title, description = template.description, taskType = template.taskType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
3772
3782
  var parameterNames = new Set();
3773
3783
  try {
3774
3784
  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()) {
@@ -3783,7 +3793,7 @@ function extractParameterNamesFromTemplate(template) {
3783
3793
  }
3784
3794
  finally { if (e_1) throw e_1.error; }
3785
3795
  }
3786
- if (templateType === 'SCRIPT_TEMPLATE') {
3796
+ if (taskType === 'SCRIPT_TASK') {
3787
3797
  try {
3788
3798
  for (var _g = __values(extractVariables(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
3789
3799
  var parameterName = _h.value;
@@ -4214,6 +4224,9 @@ var FORMAT_DEFINITIONS = [
4214
4224
  TextFormatDefinition,
4215
4225
  CsvFormatDefinition,
4216
4226
  ];
4227
+ /**
4228
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4229
+ */
4217
4230
 
4218
4231
  /**
4219
4232
  * Maps available parameters to expected parameters
@@ -4430,7 +4443,7 @@ function replaceParameters(template, parameters) {
4430
4443
  }
4431
4444
  finally { if (e_1) throw e_1.error; }
4432
4445
  }
4433
- var replacedTemplate = template;
4446
+ var replacedTemplates = template;
4434
4447
  var match;
4435
4448
  var loopLimit = LOOP_LIMIT;
4436
4449
  var _loop_1 = function () {
@@ -4459,24 +4472,24 @@ function replaceParameters(template, parameters) {
4459
4472
  .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
4460
4473
  .join('\n');
4461
4474
  }
4462
- replacedTemplate =
4463
- replacedTemplate.substring(0, match.index + precol.length) +
4475
+ replacedTemplates =
4476
+ replacedTemplates.substring(0, match.index + precol.length) +
4464
4477
  parameterValue +
4465
- replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
4478
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
4466
4479
  };
4467
4480
  while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
4468
- .exec(replacedTemplate))) {
4481
+ .exec(replacedTemplates))) {
4469
4482
  _loop_1();
4470
4483
  }
4471
4484
  // [💫] Check if there are parameters that are not closed properly
4472
- if (/{\w+$/.test(replacedTemplate)) {
4485
+ if (/{\w+$/.test(replacedTemplates)) {
4473
4486
  throw new PipelineExecutionError('Parameter is not closed');
4474
4487
  }
4475
4488
  // [💫] Check if there are parameters that are not opened properly
4476
- if (/^\w+}/.test(replacedTemplate)) {
4489
+ if (/^\w+}/.test(replacedTemplates)) {
4477
4490
  throw new PipelineExecutionError('Parameter is not opened');
4478
4491
  }
4479
- return replacedTemplate;
4492
+ return replacedTemplates;
4480
4493
  }
4481
4494
 
4482
4495
  /**
@@ -4508,6 +4521,7 @@ var CHARACTERS_PER_STANDARD_LINE = 63;
4508
4521
  var LINES_PER_STANDARD_PAGE = 44;
4509
4522
  /**
4510
4523
  * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
4524
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4511
4525
  */
4512
4526
 
4513
4527
  /**
@@ -4587,6 +4601,7 @@ var CountUtils = {
4587
4601
  };
4588
4602
  /**
4589
4603
  * TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
4604
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4590
4605
  */
4591
4606
 
4592
4607
  /**
@@ -4635,12 +4650,12 @@ function checkExpectations(expectations, value) {
4635
4650
  */
4636
4651
  function executeAttempts(options) {
4637
4652
  return __awaiter(this, void 0, void 0, function () {
4638
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
4653
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTaskResult, _llms, llmTools, _loop_1, attempt, state_1;
4639
4654
  return __generator(this, function (_a) {
4640
4655
  switch (_a.label) {
4641
4656
  case 0:
4642
- 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;
4643
- $ongoingTemplateResult = {
4657
+ 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;
4658
+ $ongoingTaskResult = {
4644
4659
  $result: null,
4645
4660
  $resultString: null,
4646
4661
  $expectError: null,
@@ -4660,52 +4675,51 @@ function executeAttempts(options) {
4660
4675
  if (isJokerAttempt && !jokerParameterName) {
4661
4676
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
4662
4677
  }
4663
- $ongoingTemplateResult.$result = null;
4664
- $ongoingTemplateResult.$resultString = null;
4665
- $ongoingTemplateResult.$expectError = null;
4678
+ $ongoingTaskResult.$result = null;
4679
+ $ongoingTaskResult.$resultString = null;
4680
+ $ongoingTaskResult.$expectError = null;
4666
4681
  if (isJokerAttempt) {
4667
4682
  if (parameters[jokerParameterName] === undefined) {
4668
4683
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
4669
4684
  // <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
4670
4685
  }
4671
4686
  else {
4672
- $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
4687
+ $ongoingTaskResult.$resultString = parameters[jokerParameterName];
4673
4688
  }
4674
4689
  }
4675
4690
  _t.label = 1;
4676
4691
  case 1:
4677
4692
  _t.trys.push([1, 43, 44, 45]);
4678
4693
  if (!!isJokerAttempt) return [3 /*break*/, 25];
4679
- _b = template.templateType;
4694
+ _b = task.taskType;
4680
4695
  switch (_b) {
4681
- case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
4682
- case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
4683
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
4684
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
4696
+ case 'SIMPLE_TASK': return [3 /*break*/, 2];
4697
+ case 'PROMPT_TASK': return [3 /*break*/, 3];
4698
+ case 'SCRIPT_TASK': return [3 /*break*/, 11];
4699
+ case 'DIALOG_TASK': return [3 /*break*/, 22];
4685
4700
  }
4686
4701
  return [3 /*break*/, 24];
4687
4702
  case 2:
4688
- $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
4703
+ $ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
4689
4704
  return [3 /*break*/, 25];
4690
4705
  case 3:
4691
- modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
4692
- $ongoingTemplateResult.$prompt = {
4693
- title: template.title,
4706
+ modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
4707
+ $ongoingTaskResult.$prompt = {
4708
+ title: task.title,
4694
4709
  pipelineUrl: "".concat(preparedPipeline.pipelineUrl
4695
4710
  ? preparedPipeline.pipelineUrl
4696
- : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
4697
- // <- TODO: Here should be maybe also subformat index to distinguish between same template with different subformat values
4711
+ : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(task.name
4712
+ // <- TODO: Here should be maybe also subformat index to distinguish between same task with different subformat values
4698
4713
  ),
4699
4714
  parameters: parameters,
4700
4715
  content: preparedContent,
4701
4716
  modelRequirements: modelRequirements,
4702
4717
  expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
4703
4718
  var name = _a.name;
4704
- return name === template.personaName;
4705
- }) ||
4706
- {})), template.expectations),
4707
- format: template.format,
4708
- postprocessingFunctionNames: template.postprocessingFunctionNames,
4719
+ return name === task.personaName;
4720
+ }) || {})), task.expectations),
4721
+ format: task.format,
4722
+ postprocessingFunctionNames: task.postprocessingFunctionNames,
4709
4723
  }; // <- TODO: Not very good type guard
4710
4724
  _c = modelRequirements.modelVariant;
4711
4725
  switch (_c) {
@@ -4715,36 +4729,35 @@ function executeAttempts(options) {
4715
4729
  }
4716
4730
  return [3 /*break*/, 9];
4717
4731
  case 4:
4718
- _d = $ongoingTemplateResult;
4732
+ _d = $ongoingTaskResult;
4719
4733
  return [4 /*yield*/, llmTools.callChatModel(
4720
4734
  // <- TODO: [🧁] Check that `callChatModel` is defined
4721
- $deepFreeze($ongoingTemplateResult.$prompt))];
4735
+ $deepFreeze($ongoingTaskResult.$prompt))];
4722
4736
  case 5:
4723
4737
  _d.$chatResult = _t.sent();
4724
4738
  // TODO: [🍬] Destroy chatThread
4725
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
4726
- $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
4739
+ $ongoingTaskResult.$result = $ongoingTaskResult.$chatResult;
4740
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$chatResult.content;
4727
4741
  return [3 /*break*/, 10];
4728
4742
  case 6:
4729
- _e = $ongoingTemplateResult;
4743
+ _e = $ongoingTaskResult;
4730
4744
  return [4 /*yield*/, llmTools.callCompletionModel(
4731
4745
  // <- TODO: [🧁] Check that `callCompletionModel` is defined
4732
- $deepFreeze($ongoingTemplateResult.$prompt))];
4746
+ $deepFreeze($ongoingTaskResult.$prompt))];
4733
4747
  case 7:
4734
4748
  _e.$completionResult = _t.sent();
4735
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
4736
- $ongoingTemplateResult.$resultString =
4737
- $ongoingTemplateResult.$completionResult.content;
4749
+ $ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
4750
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
4738
4751
  return [3 /*break*/, 10];
4739
4752
  case 8: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Embedding model can not be used in pipeline\n\n This should be catched during parsing\n\n ".concat(block(pipelineIdentification), "\n\n "); }));
4740
- case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4753
+ case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(task.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4741
4754
  case 10: return [3 /*break*/, 25];
4742
4755
  case 11:
4743
4756
  if (arrayableToArray(tools.script).length === 0) {
4744
4757
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
4745
4758
  }
4746
- if (!template.contentLanguage) {
4747
- throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4759
+ if (!task.contentLanguage) {
4760
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TASK \"".concat(task.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4748
4761
  }
4749
4762
  _t.label = 12;
4750
4763
  case 12:
@@ -4757,9 +4770,9 @@ function executeAttempts(options) {
4757
4770
  _t.label = 14;
4758
4771
  case 14:
4759
4772
  _t.trys.push([14, 16, , 17]);
4760
- _h = $ongoingTemplateResult;
4773
+ _h = $ongoingTaskResult;
4761
4774
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
4762
- scriptLanguage: template.contentLanguage,
4775
+ scriptLanguage: task.contentLanguage,
4763
4776
  script: preparedContent,
4764
4777
  parameters: parameters,
4765
4778
  }))];
@@ -4774,7 +4787,7 @@ function executeAttempts(options) {
4774
4787
  if (error_1 instanceof UnexpectedError) {
4775
4788
  throw error_1;
4776
4789
  }
4777
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
4790
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_1);
4778
4791
  return [3 /*break*/, 17];
4779
4792
  case 17:
4780
4793
  _g = _f.next();
@@ -4791,14 +4804,14 @@ function executeAttempts(options) {
4791
4804
  finally { if (e_1) throw e_1.error; }
4792
4805
  return [7 /*endfinally*/];
4793
4806
  case 21:
4794
- if ($ongoingTemplateResult.$resultString !== null) {
4807
+ if ($ongoingTaskResult.$resultString !== null) {
4795
4808
  return [3 /*break*/, 25];
4796
4809
  }
4797
- if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
4798
- throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
4810
+ if ($ongoingTaskResult.$scriptPipelineExecutionErrors.length === 1) {
4811
+ throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
4799
4812
  }
4800
4813
  else {
4801
- throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
4814
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTaskResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTaskResult.$scriptPipelineExecutionErrors
4802
4815
  .map(function (error) { return '- ' + error.message; })
4803
4816
  .join('\n\n')), "\n "); }));
4804
4817
  }
@@ -4806,27 +4819,27 @@ function executeAttempts(options) {
4806
4819
  if (tools.userInterface === undefined) {
4807
4820
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
4808
4821
  }
4809
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
4810
- _j = $ongoingTemplateResult;
4822
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
4823
+ _j = $ongoingTaskResult;
4811
4824
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
4812
- promptTitle: template.title,
4813
- promptMessage: replaceParameters(template.description || '', parameters),
4825
+ promptTitle: task.title,
4826
+ promptMessage: replaceParameters(task.description || '', parameters),
4814
4827
  defaultValue: replaceParameters(preparedContent, parameters),
4815
4828
  // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4816
4829
  placeholder: undefined,
4817
4830
  priority: priority,
4818
4831
  }))];
4819
4832
  case 23:
4820
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
4833
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
4821
4834
  _j.$resultString = _t.sent();
4822
4835
  return [3 /*break*/, 25];
4823
- case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4836
+ case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4824
4837
  case 25:
4825
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
4838
+ if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
4826
4839
  _t.label = 26;
4827
4840
  case 26:
4828
4841
  _t.trys.push([26, 40, 41, 42]);
4829
- _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
4842
+ _k = (e_3 = void 0, __values(task.postprocessingFunctionNames)), _l = _k.next();
4830
4843
  _t.label = 27;
4831
4844
  case 27:
4832
4845
  if (!!_l.done) return [3 /*break*/, 39];
@@ -4843,13 +4856,13 @@ function executeAttempts(options) {
4843
4856
  _t.label = 30;
4844
4857
  case 30:
4845
4858
  _t.trys.push([30, 32, , 33]);
4846
- _p = $ongoingTemplateResult;
4859
+ _p = $ongoingTaskResult;
4847
4860
  return [4 /*yield*/, scriptTools.execute({
4848
4861
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
4849
4862
  script: "".concat(functionName, "(resultString)"),
4850
4863
  parameters: {
4851
- resultString: $ongoingTemplateResult.$resultString || '',
4852
- // Note: No ...parametersForTemplate, because working with result only
4864
+ resultString: $ongoingTaskResult.$resultString || '',
4865
+ // Note: No ...parametersForTask, because working with result only
4853
4866
  },
4854
4867
  })];
4855
4868
  case 31:
@@ -4865,7 +4878,7 @@ function executeAttempts(options) {
4865
4878
  throw error_2;
4866
4879
  }
4867
4880
  postprocessingError = error_2;
4868
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
4881
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_2);
4869
4882
  return [3 /*break*/, 33];
4870
4883
  case 33:
4871
4884
  _o = _m.next();
@@ -4902,12 +4915,12 @@ function executeAttempts(options) {
4902
4915
  return [7 /*endfinally*/];
4903
4916
  case 42:
4904
4917
  // TODO: [💝] Unite object for expecting amount and format
4905
- if (template.format) {
4906
- if (template.format === 'JSON') {
4907
- if (!isValidJsonString($ongoingTemplateResult.$resultString || '')) {
4918
+ if (task.format) {
4919
+ if (task.format === 'JSON') {
4920
+ if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
4908
4921
  // TODO: [🏢] Do more universally via `FormatDefinition`
4909
4922
  try {
4910
- $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
4923
+ $ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
4911
4924
  }
4912
4925
  catch (error) {
4913
4926
  throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
@@ -4916,12 +4929,12 @@ function executeAttempts(options) {
4916
4929
  }
4917
4930
  }
4918
4931
  else {
4919
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4932
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4920
4933
  }
4921
4934
  }
4922
4935
  // TODO: [💝] Unite object for expecting amount and format
4923
- if (template.expectations) {
4924
- checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
4936
+ if (task.expectations) {
4937
+ checkExpectations(task.expectations, $ongoingTaskResult.$resultString || '');
4925
4938
  }
4926
4939
  return [2 /*return*/, "break-attempts"];
4927
4940
  case 43:
@@ -4929,38 +4942,38 @@ function executeAttempts(options) {
4929
4942
  if (!(error_3 instanceof ExpectError)) {
4930
4943
  throw error_3;
4931
4944
  }
4932
- $ongoingTemplateResult.$expectError = error_3;
4945
+ $ongoingTaskResult.$expectError = error_3;
4933
4946
  return [3 /*break*/, 45];
4934
4947
  case 44:
4935
4948
  if (!isJokerAttempt &&
4936
- template.templateType === 'PROMPT_TEMPLATE' &&
4937
- $ongoingTemplateResult.$prompt
4949
+ task.taskType === 'PROMPT_TASK' &&
4950
+ $ongoingTaskResult.$prompt
4938
4951
  // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
4939
4952
  // In that case we don’t want to make a report about it because it’s not a llm execution error
4940
4953
  ) {
4941
- // TODO: [🧠] Maybe put other templateTypes into report
4954
+ // TODO: [🧠] Maybe put other taskTypes into report
4942
4955
  $executionReport.promptExecutions.push({
4943
- prompt: __assign({}, $ongoingTemplateResult.$prompt),
4944
- result: $ongoingTemplateResult.$result || undefined,
4945
- error: $ongoingTemplateResult.$expectError === null
4956
+ prompt: __assign({}, $ongoingTaskResult.$prompt),
4957
+ result: $ongoingTaskResult.$result || undefined,
4958
+ error: $ongoingTaskResult.$expectError === null
4946
4959
  ? undefined
4947
- : serializeError($ongoingTemplateResult.$expectError),
4960
+ : serializeError($ongoingTaskResult.$expectError),
4948
4961
  });
4949
4962
  }
4950
4963
  return [7 /*endfinally*/];
4951
4964
  case 45:
4952
- if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
4965
+ if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
4953
4966
  throw new PipelineExecutionError(spaceTrim(function (block) {
4954
4967
  var _a, _b, _c;
4955
- 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) || '')
4968
+ 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) || '')
4956
4969
  .split('\n')
4957
4970
  .map(function (line) { return "> ".concat(line); })
4958
- .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) || '')
4971
+ .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) || '')
4959
4972
  .split('\n')
4960
4973
  .map(function (line) { return "> ".concat(line); })
4961
- .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
4974
+ .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTaskResult.$resultString === null
4962
4975
  ? 'null'
4963
- : $ongoingTemplateResult.$resultString
4976
+ : $ongoingTaskResult.$resultString
4964
4977
  .split('\n')
4965
4978
  .map(function (line) { return "> ".concat(line); })
4966
4979
  .join('\n')), "\n ---\n ");
@@ -4985,10 +4998,10 @@ function executeAttempts(options) {
4985
4998
  attempt++;
4986
4999
  return [3 /*break*/, 1];
4987
5000
  case 4:
4988
- if ($ongoingTemplateResult.$resultString === null) {
5001
+ if ($ongoingTaskResult.$resultString === null) {
4989
5002
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
4990
5003
  }
4991
- return [2 /*return*/, $ongoingTemplateResult.$resultString];
5004
+ return [2 /*return*/, $ongoingTaskResult.$resultString];
4992
5005
  }
4993
5006
  });
4994
5007
  });
@@ -5004,36 +5017,36 @@ function executeAttempts(options) {
5004
5017
  */
5005
5018
  function executeFormatSubvalues(options) {
5006
5019
  return __awaiter(this, void 0, void 0, function () {
5007
- var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
5020
+ var task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
5008
5021
  var _this = this;
5009
5022
  return __generator(this, function (_a) {
5010
5023
  switch (_a.label) {
5011
5024
  case 0:
5012
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
5013
- if (template.foreach === undefined) {
5025
+ task = options.task, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
5026
+ if (task.foreach === undefined) {
5014
5027
  return [2 /*return*/, /* not await */ executeAttempts(options)];
5015
5028
  }
5016
5029
  if (jokerParameterNames.length !== 0) {
5017
5030
  throw new UnexpectedError(spaceTrim$1(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 "); }));
5018
5031
  }
5019
- parameterValue = parameters[template.foreach.parameterName] || '';
5032
+ parameterValue = parameters[task.foreach.parameterName] || '';
5020
5033
  formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
5021
- return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(template.foreach.formatName);
5034
+ return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(task.foreach.formatName);
5022
5035
  });
5023
5036
  if (formatDefinition === undefined) {
5024
5037
  throw new UnexpectedError(
5025
5038
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
5026
- spaceTrim$1(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; })
5039
+ spaceTrim$1(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; })
5027
5040
  .map(function (formatName) { return "- ".concat(formatName); })
5028
5041
  .join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
5029
5042
  }
5030
5043
  subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
5031
- return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(template.foreach.subformatName);
5044
+ return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(task.foreach.subformatName);
5032
5045
  });
5033
5046
  if (subvalueDefinition === undefined) {
5034
5047
  throw new UnexpectedError(
5035
5048
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
5036
- spaceTrim$1(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
5049
+ spaceTrim$1(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
5037
5050
  .map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
5038
5051
  .map(function (subvalueName) { return "- ".concat(subvalueName); })
5039
5052
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -5042,7 +5055,7 @@ function executeFormatSubvalues(options) {
5042
5055
  formatSettings = csvSettings;
5043
5056
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
5044
5057
  }
5045
- return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
5058
+ return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
5046
5059
  var mappedParameters, allSubparameters, subresultString;
5047
5060
  return __generator(this, function (_a) {
5048
5061
  switch (_a.label) {
@@ -5051,7 +5064,7 @@ function executeFormatSubvalues(options) {
5051
5064
  // TODO: When done [🐚] Report progress also for each subvalue here
5052
5065
  try {
5053
5066
  mappedParameters = mapAvailableToExpectedParameters({
5054
- expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
5067
+ expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
5055
5068
  availableParameters: subparameters,
5056
5069
  });
5057
5070
  }
@@ -5084,7 +5097,7 @@ function executeFormatSubvalues(options) {
5084
5097
  *
5085
5098
  * @private internal utility of `createPipelineExecutor`
5086
5099
  */
5087
- function getContextForTemplate(template) {
5100
+ function getContextForTask(task) {
5088
5101
  return __awaiter(this, void 0, void 0, function () {
5089
5102
  return __generator(this, function (_a) {
5090
5103
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
@@ -5097,15 +5110,10 @@ function getContextForTemplate(template) {
5097
5110
  *
5098
5111
  * @private internal utility of `createPipelineExecutor`
5099
5112
  */
5100
- function getKnowledgeForTemplate(options) {
5113
+ function getExamplesForTask(task) {
5101
5114
  return __awaiter(this, void 0, void 0, function () {
5102
- var preparedPipeline;
5103
5115
  return __generator(this, function (_a) {
5104
- preparedPipeline = options.preparedPipeline, options.template;
5105
- return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
5106
- var content = _a.content;
5107
- return "- ".concat(content);
5108
- }).join('\n')];
5116
+ return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
5109
5117
  });
5110
5118
  });
5111
5119
  }
@@ -5115,10 +5123,15 @@ function getKnowledgeForTemplate(options) {
5115
5123
  *
5116
5124
  * @private internal utility of `createPipelineExecutor`
5117
5125
  */
5118
- function getExamplesForTemplate(template) {
5126
+ function getKnowledgeForTask(options) {
5119
5127
  return __awaiter(this, void 0, void 0, function () {
5128
+ var preparedPipeline;
5120
5129
  return __generator(this, function (_a) {
5121
- return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
5130
+ preparedPipeline = options.preparedPipeline, options.task;
5131
+ return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
5132
+ var content = _a.content;
5133
+ return "- ".concat(content);
5134
+ }).join('\n')];
5122
5135
  });
5123
5136
  });
5124
5137
  }
@@ -5128,21 +5141,21 @@ function getExamplesForTemplate(template) {
5128
5141
  *
5129
5142
  * @private internal utility of `createPipelineExecutor`
5130
5143
  */
5131
- function getReservedParametersForTemplate(options) {
5144
+ function getReservedParametersForTask(options) {
5132
5145
  return __awaiter(this, void 0, void 0, function () {
5133
- var preparedPipeline, template, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
5146
+ var preparedPipeline, task, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
5134
5147
  var e_1, _a;
5135
5148
  return __generator(this, function (_b) {
5136
5149
  switch (_b.label) {
5137
5150
  case 0:
5138
- preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
5139
- return [4 /*yield*/, getContextForTemplate()];
5151
+ preparedPipeline = options.preparedPipeline, task = options.task, pipelineIdentification = options.pipelineIdentification;
5152
+ return [4 /*yield*/, getContextForTask()];
5140
5153
  case 1:
5141
5154
  context = _b.sent();
5142
- return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
5155
+ return [4 /*yield*/, getKnowledgeForTask({ preparedPipeline: preparedPipeline, task: task })];
5143
5156
  case 2:
5144
5157
  knowledge = _b.sent();
5145
- return [4 /*yield*/, getExamplesForTemplate()];
5158
+ return [4 /*yield*/, getExamplesForTask()];
5146
5159
  case 3:
5147
5160
  examples = _b.sent();
5148
5161
  currentDate = new Date().toISOString();
@@ -5185,31 +5198,31 @@ function getReservedParametersForTemplate(options) {
5185
5198
  *
5186
5199
  * @private internal utility of `createPipelineExecutor`
5187
5200
  */
5188
- function executeTemplate(options) {
5201
+ function executeTask(options) {
5189
5202
  return __awaiter(this, void 0, void 0, function () {
5190
- 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;
5203
+ 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;
5191
5204
  var e_1, _g, _h;
5192
5205
  return __generator(this, function (_j) {
5193
5206
  switch (_j.label) {
5194
5207
  case 0:
5195
- 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;
5196
- name = "pipeline-executor-frame-".concat(currentTemplate.name);
5197
- title = currentTemplate.title;
5198
- priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
5208
+ 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;
5209
+ name = "pipeline-executor-frame-".concat(currentTask.name);
5210
+ title = currentTask.title;
5211
+ priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5199
5212
  return [4 /*yield*/, onProgress({
5200
5213
  name: name,
5201
5214
  title: title,
5202
5215
  isStarted: false,
5203
5216
  isDone: false,
5204
- templateType: currentTemplate.templateType,
5205
- parameterName: currentTemplate.resultingParameterName,
5217
+ taskType: currentTask.taskType,
5218
+ parameterName: currentTask.resultingParameterName,
5206
5219
  parameterValue: null,
5207
5220
  // <- [🍸]
5208
5221
  })];
5209
5222
  case 1:
5210
5223
  _j.sent();
5211
- usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
5212
- dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
5224
+ usedParameterNames = extractParameterNamesFromTask(currentTask);
5225
+ dependentParameterNames = new Set(currentTask.dependentParameterNames);
5213
5226
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
5214
5227
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
5215
5228
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Dependent parameters are not consistent with used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames)
@@ -5220,9 +5233,9 @@ function executeTemplate(options) {
5220
5233
  }
5221
5234
  _c = (_b = Object).freeze;
5222
5235
  _d = [{}];
5223
- return [4 /*yield*/, getReservedParametersForTemplate({
5236
+ return [4 /*yield*/, getReservedParametersForTask({
5224
5237
  preparedPipeline: preparedPipeline,
5225
- template: currentTemplate,
5238
+ task: currentTask,
5226
5239
  pipelineIdentification: pipelineIdentification,
5227
5240
  })];
5228
5241
  case 2:
@@ -5240,11 +5253,11 @@ function executeTemplate(options) {
5240
5253
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
5241
5254
  // Houston, we have a problem
5242
5255
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
5243
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
5256
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in task \"").concat(currentTask.title || currentTask.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
5244
5257
  }
5245
5258
  };
5246
5259
  try {
5247
- // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
5260
+ // Note: [2] Check that all used parameters are defined and removing unused parameters for this task
5248
5261
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
5249
5262
  for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
5250
5263
  parameterName = _f.value;
@@ -5260,18 +5273,16 @@ function executeTemplate(options) {
5260
5273
  }
5261
5274
  // 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
5262
5275
  Object.freeze(parameters);
5263
- maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
5264
- jokerParameterNames = currentTemplate.jokerParameterNames || [];
5265
- preparedContent = (currentTemplate.preparedContent || '{content}')
5266
- .split('{content}')
5267
- .join(currentTemplate.content);
5276
+ maxAttempts = currentTask.taskType === 'DIALOG_TASK' ? Infinity : maxExecutionAttempts;
5277
+ jokerParameterNames = currentTask.jokerParameterNames || [];
5278
+ preparedContent = (currentTask.preparedContent || '{content}').split('{content}').join(currentTask.content);
5268
5279
  return [4 /*yield*/, executeFormatSubvalues({
5269
5280
  jokerParameterNames: jokerParameterNames,
5270
5281
  priority: priority,
5271
5282
  maxAttempts: maxAttempts,
5272
5283
  preparedContent: preparedContent,
5273
5284
  parameters: parameters,
5274
- template: currentTemplate,
5285
+ task: currentTask,
5275
5286
  preparedPipeline: preparedPipeline,
5276
5287
  tools: tools,
5277
5288
  $executionReport: $executionReport,
@@ -5284,15 +5295,15 @@ function executeTemplate(options) {
5284
5295
  title: title,
5285
5296
  isStarted: true,
5286
5297
  isDone: true,
5287
- templateType: currentTemplate.templateType,
5288
- parameterName: currentTemplate.resultingParameterName,
5298
+ taskType: currentTask.taskType,
5299
+ parameterName: currentTask.resultingParameterName,
5289
5300
  parameterValue: resultString,
5290
5301
  // <- [🍸]
5291
5302
  })];
5292
5303
  case 4:
5293
5304
  _j.sent();
5294
5305
  return [2 /*return*/, Object.freeze((_h = {},
5295
- _h[currentTemplate.resultingParameterName] =
5306
+ _h[currentTask.resultingParameterName] =
5296
5307
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
5297
5308
  resultString,
5298
5309
  _h))];
@@ -5354,7 +5365,7 @@ function filterJustOutputParameters(options) {
5354
5365
  */
5355
5366
  function executePipeline(options) {
5356
5367
  return __awaiter(this, void 0, void 0, function () {
5357
- 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;
5368
+ 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;
5358
5369
  var e_1, _f, e_2, _g;
5359
5370
  return __generator(this, function (_h) {
5360
5371
  switch (_h.label) {
@@ -5508,11 +5519,11 @@ function executePipeline(options) {
5508
5519
  var name = _a.name;
5509
5520
  return name;
5510
5521
  });
5511
- unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.templates), false);
5522
+ unresovedTasks_1 = __spreadArray([], __read(preparedPipeline.tasks), false);
5512
5523
  resolving_1 = [];
5513
5524
  loopLimit = LOOP_LIMIT;
5514
5525
  _loop_2 = function () {
5515
- var currentTemplate, work_1;
5526
+ var currentTask, work_1;
5516
5527
  return __generator(this, function (_k) {
5517
5528
  switch (_k.label) {
5518
5529
  case 0:
@@ -5520,15 +5531,15 @@ function executePipeline(options) {
5520
5531
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
5521
5532
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
5522
5533
  }
5523
- currentTemplate = unresovedTemplates_1.find(function (template) {
5524
- return template.dependentParameterNames.every(function (name) {
5534
+ currentTask = unresovedTasks_1.find(function (task) {
5535
+ return task.dependentParameterNames.every(function (name) {
5525
5536
  return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
5526
5537
  });
5527
5538
  });
5528
- if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
5539
+ if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
5529
5540
  throw new UnexpectedError(
5530
5541
  // TODO: [🐎] DRY
5531
- spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates_1
5542
+ spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks_1
5532
5543
  .map(function (_a) {
5533
5544
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
5534
5545
  return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
@@ -5547,14 +5558,14 @@ function executePipeline(options) {
5547
5558
  .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5548
5559
  .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
5549
5560
  case 1:
5550
- if (!!currentTemplate) return [3 /*break*/, 3];
5561
+ if (!!currentTask) return [3 /*break*/, 3];
5551
5562
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
5552
5563
  case 2:
5553
5564
  /* [🤹‍♂️] */ _k.sent();
5554
5565
  return [3 /*break*/, 4];
5555
5566
  case 3:
5556
- unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
5557
- work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
5567
+ unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
5568
+ work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
5558
5569
  if (isReturned) {
5559
5570
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
5560
5571
  .split('\n')
@@ -5564,16 +5575,16 @@ function executePipeline(options) {
5564
5575
  if (onProgress) {
5565
5576
  onProgress(progress);
5566
5577
  }
5567
- }, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
5578
+ }, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
5568
5579
  .then(function (newParametersToPass) {
5569
5580
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
5570
- resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
5581
+ resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
5571
5582
  })
5572
5583
  .then(function () {
5573
5584
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
5574
5585
  });
5575
5586
  // <- Note: Errors are catched here [3]
5576
- // 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
5587
+ // 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
5577
5588
  resolving_1.push(work_1);
5578
5589
  _k.label = 4;
5579
5590
  case 4: return [2 /*return*/];
@@ -5582,7 +5593,7 @@ function executePipeline(options) {
5582
5593
  };
5583
5594
  _h.label = 21;
5584
5595
  case 21:
5585
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
5596
+ if (!(unresovedTasks_1.length > 0)) return [3 /*break*/, 23];
5586
5597
  return [5 /*yield**/, _loop_2()];
5587
5598
  case 22:
5588
5599
  _h.sent();
@@ -5740,6 +5751,9 @@ var markdownScraperMetadata = $deepFreeze({
5740
5751
  * @public exported from `@promptbook/cli`
5741
5752
  */
5742
5753
  $scrapersMetadataRegister.register(markdownScraperMetadata);
5754
+ /**
5755
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5756
+ */
5743
5757
 
5744
5758
  /**
5745
5759
  * Scraper for markdown files
@@ -5934,6 +5948,9 @@ var documentScraperMetadata = $deepFreeze({
5934
5948
  * @public exported from `@promptbook/cli`
5935
5949
  */
5936
5950
  $scrapersMetadataRegister.register(documentScraperMetadata);
5951
+ /**
5952
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5953
+ */
5937
5954
 
5938
5955
  /**
5939
5956
  * Scraper of .docx and .odt files
@@ -6098,6 +6115,9 @@ var legacyDocumentScraperMetadata = $deepFreeze({
6098
6115
  * @public exported from `@promptbook/cli`
6099
6116
  */
6100
6117
  $scrapersMetadataRegister.register(legacyDocumentScraperMetadata);
6118
+ /**
6119
+ * Note: [💞] Ignore a discrepancy between file name and entity name
6120
+ */
6101
6121
 
6102
6122
  /**
6103
6123
  * Scraper for old document files (like .doc and .rtf)
@@ -6267,6 +6287,7 @@ var createLegacyDocumentScraper = Object.assign(function (tools, options) {
6267
6287
  var _LegacyDocumentScraperRegistration = $scrapersRegister.register(createLegacyDocumentScraper);
6268
6288
  /**
6269
6289
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
6290
+ * Note: [💞] Ignore a discrepancy between file name and entity name
6270
6291
  */
6271
6292
 
6272
6293
  export { BOOK_LANGUAGE_VERSION, LegacyDocumentScraper, PROMPTBOOK_ENGINE_VERSION, _LegacyDocumentScraperRegistration, createLegacyDocumentScraper };