@promptbook/pdf 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 +236 -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 +236 -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
@@ -20,9 +20,10 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  *
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
23
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-1';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
+ * Note: [💞] Ignore a discrepancy between file name and entity name
26
27
  */
27
28
 
28
29
  /*! *****************************************************************************
@@ -173,7 +174,7 @@ var NotYetImplementedError = /** @class */ (function (_super) {
173
174
  function TODO_USE() {
174
175
  }
175
176
 
176
- 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"}];
177
+ 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"}];
177
178
 
178
179
  /**
179
180
  * Prettify the html code
@@ -227,7 +228,7 @@ function capitalize(word) {
227
228
  */
228
229
  function pipelineJsonToString(pipelineJson) {
229
230
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
230
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
231
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, tasks = pipelineJson.tasks;
231
232
  var pipelineString = "# ".concat(title);
232
233
  if (description) {
233
234
  pipelineString += '\n\n';
@@ -277,13 +278,13 @@ function pipelineJsonToString(pipelineJson) {
277
278
  pipelineString += '\n\n';
278
279
  pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
279
280
  try {
280
- for (var templates_1 = __values(templates), templates_1_1 = templates_1.next(); !templates_1_1.done; templates_1_1 = templates_1.next()) {
281
- var template = templates_1_1.value;
281
+ for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
282
+ var template = tasks_1_1.value;
282
283
  var
283
284
  /* Note: Not using:> name, */
284
285
  title_1 = template.title, description_1 = template.description,
285
286
  /* Note: dependentParameterNames, */
286
- jokers = template.jokerParameterNames, templateType = template.templateType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
287
+ jokers = template.jokerParameterNames, taskType = template.taskType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
287
288
  pipelineString += '\n\n';
288
289
  pipelineString += "## ".concat(title_1);
289
290
  if (description_1) {
@@ -292,7 +293,7 @@ function pipelineJsonToString(pipelineJson) {
292
293
  }
293
294
  var commands_1 = [];
294
295
  var contentLanguage = 'text';
295
- if (templateType === 'PROMPT_TEMPLATE') {
296
+ if (taskType === 'PROMPT_TASK') {
296
297
  var modelRequirements = template.modelRequirements;
297
298
  var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
298
299
  commands_1.push("EXECUTE PROMPT TEMPLATE");
@@ -303,11 +304,11 @@ function pipelineJsonToString(pipelineJson) {
303
304
  commands_1.push("MODEL NAME `".concat(modelName, "`"));
304
305
  }
305
306
  }
306
- else if (templateType === 'SIMPLE_TEMPLATE') {
307
+ else if (taskType === 'SIMPLE_TASK') {
307
308
  commands_1.push("SIMPLE TEMPLATE");
308
309
  // Note: Nothing special here
309
310
  }
310
- else if (templateType === 'SCRIPT_TEMPLATE') {
311
+ else if (taskType === 'SCRIPT_TASK') {
311
312
  commands_1.push("SCRIPT TEMPLATE");
312
313
  if (template.contentLanguage) {
313
314
  contentLanguage = template.contentLanguage;
@@ -316,7 +317,7 @@ function pipelineJsonToString(pipelineJson) {
316
317
  contentLanguage = '';
317
318
  }
318
319
  }
319
- else if (templateType === 'DIALOG_TEMPLATE') {
320
+ else if (taskType === 'DIALOG_TASK') {
320
321
  commands_1.push("DIALOG TEMPLATE");
321
322
  // Note: Nothing special here
322
323
  } // <- }else if([🅱]
@@ -398,7 +399,7 @@ function pipelineJsonToString(pipelineJson) {
398
399
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
399
400
  finally {
400
401
  try {
401
- if (templates_1_1 && !templates_1_1.done && (_c = templates_1.return)) _c.call(templates_1);
402
+ if (tasks_1_1 && !tasks_1_1.done && (_c = tasks_1.return)) _c.call(tasks_1);
402
403
  }
403
404
  finally { if (e_3) throw e_3.error; }
404
405
  }
@@ -725,6 +726,7 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
725
726
  true);
726
727
  /**
727
728
  * TODO: Extract `constants.ts` from `config.ts`
729
+ * Note: [💞] Ignore a discrepancy between file name and entity name
728
730
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
729
731
  */
730
732
 
@@ -980,9 +982,9 @@ function validatePipelineCore(pipeline) {
980
982
  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 "); }));
981
983
  }
982
984
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
983
- if (!Array.isArray(pipeline.templates)) {
985
+ if (!Array.isArray(pipeline.tasks)) {
984
986
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
985
- 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 "); }));
987
+ 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 "); }));
986
988
  }
987
989
  var _loop_1 = function (parameter) {
988
990
  if (parameter.isInput && parameter.isOutput) {
@@ -991,13 +993,12 @@ function validatePipelineCore(pipeline) {
991
993
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
992
994
  if (!parameter.isInput &&
993
995
  !parameter.isOutput &&
994
- !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
996
+ !pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
995
997
  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 "); }));
996
998
  }
997
- // Note: Testing that parameter is either input or result of some template
998
- if (!parameter.isInput &&
999
- !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
1000
- 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 "); }));
999
+ // Note: Testing that parameter is either input or result of some task
1000
+ if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
1001
+ 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 "); }));
1001
1002
  }
1002
1003
  };
1003
1004
  try {
@@ -1014,7 +1015,7 @@ function validatePipelineCore(pipeline) {
1014
1015
  }
1015
1016
  finally { if (e_1) throw e_1.error; }
1016
1017
  }
1017
- // Note: All input parameters are defined - so that they can be used as result of some template
1018
+ // Note: All input parameters are defined - so that they can be used as result of some task
1018
1019
  var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
1019
1020
  var isInput = _a.isInput;
1020
1021
  return isInput;
@@ -1022,27 +1023,27 @@ function validatePipelineCore(pipeline) {
1022
1023
  var name = _a.name;
1023
1024
  return name;
1024
1025
  }));
1025
- var _loop_2 = function (template) {
1026
+ var _loop_2 = function (task) {
1026
1027
  var e_4, _h, e_5, _j;
1027
- if (definedParameters.has(template.resultingParameterName)) {
1028
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1028
+ if (definedParameters.has(task.resultingParameterName)) {
1029
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1029
1030
  }
1030
- if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1031
- 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 "); }));
1031
+ if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
1032
+ 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 "); }));
1032
1033
  }
1033
- definedParameters.add(template.resultingParameterName);
1034
- if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
1035
- if (!template.format &&
1036
- !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1037
- 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 "); }));
1034
+ definedParameters.add(task.resultingParameterName);
1035
+ if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
1036
+ if (!task.format &&
1037
+ !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1038
+ 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 "); }));
1038
1039
  }
1039
1040
  var _loop_4 = function (joker) {
1040
- if (!template.dependentParameterNames.includes(joker)) {
1041
- 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 "); }));
1041
+ if (!task.dependentParameterNames.includes(joker)) {
1042
+ 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 "); }));
1042
1043
  }
1043
1044
  };
1044
1045
  try {
1045
- for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1046
+ for (var _k = (e_4 = void 0, __values(task.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1046
1047
  var joker = _l.value;
1047
1048
  _loop_4(joker);
1048
1049
  }
@@ -1055,7 +1056,7 @@ function validatePipelineCore(pipeline) {
1055
1056
  finally { if (e_4) throw e_4.error; }
1056
1057
  }
1057
1058
  }
1058
- if (template.expectations) {
1059
+ if (task.expectations) {
1059
1060
  var _loop_5 = function (unit, min, max) {
1060
1061
  if (min !== undefined && max !== undefined && min > max) {
1061
1062
  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 "); }));
@@ -1068,7 +1069,7 @@ function validatePipelineCore(pipeline) {
1068
1069
  }
1069
1070
  };
1070
1071
  try {
1071
- for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1072
+ for (var _m = (e_5 = void 0, __values(Object.entries(task.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1072
1073
  var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
1073
1074
  _loop_5(unit, min, max);
1074
1075
  }
@@ -1083,10 +1084,10 @@ function validatePipelineCore(pipeline) {
1083
1084
  }
1084
1085
  };
1085
1086
  try {
1086
- // Note: Checking each template individually
1087
- for (var _f = __values(pipeline.templates), _g = _f.next(); !_g.done; _g = _f.next()) {
1088
- var template = _g.value;
1089
- _loop_2(template);
1087
+ // Note: Checking each task individually
1088
+ for (var _f = __values(pipeline.tasks), _g = _f.next(); !_g.done; _g = _f.next()) {
1089
+ var task = _g.value;
1090
+ _loop_2(task);
1090
1091
  }
1091
1092
  }
1092
1093
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1120,15 +1121,15 @@ function validatePipelineCore(pipeline) {
1120
1121
  }
1121
1122
  finally { if (e_3) throw e_3.error; }
1122
1123
  }
1123
- var unresovedTemplates = __spreadArray([], __read(pipeline.templates), false);
1124
+ var unresovedTemplates = __spreadArray([], __read(pipeline.tasks), false);
1124
1125
  var loopLimit = LOOP_LIMIT;
1125
1126
  var _loop_3 = function () {
1126
1127
  if (loopLimit-- < 0) {
1127
1128
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1128
1129
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
1129
1130
  }
1130
- var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1131
- return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1131
+ var currentlyResovedTemplates = unresovedTemplates.filter(function (task) {
1132
+ return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1132
1133
  });
1133
1134
  if (currentlyResovedTemplates.length === 0) {
1134
1135
  throw new PipelineLogicError(
@@ -1156,7 +1157,7 @@ function validatePipelineCore(pipeline) {
1156
1157
  var resultingParameterName = _a.resultingParameterName;
1157
1158
  return resultingParameterName;
1158
1159
  })), false);
1159
- unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
1160
+ unresovedTemplates = unresovedTemplates.filter(function (task) { return !currentlyResovedTemplates.includes(task); });
1160
1161
  };
1161
1162
  while (unresovedTemplates.length > 0) {
1162
1163
  _loop_3();
@@ -1218,9 +1219,9 @@ var PipelineUrlError = /** @class */ (function (_super) {
1218
1219
  }(Error));
1219
1220
 
1220
1221
  /**
1221
- * Parses the template and returns the list of all parameter names
1222
+ * Parses the task and returns the list of all parameter names
1222
1223
  *
1223
- * @param template the template with parameters in {curly} braces
1224
+ * @param template the task with parameters in {curly} braces
1224
1225
  * @returns the list of parameter names
1225
1226
  * @public exported from `@promptbook/utils`
1226
1227
  */
@@ -1251,10 +1252,10 @@ function extractParameterNames(template) {
1251
1252
  * @public exported from `@promptbook/core`
1252
1253
  */
1253
1254
  function unpreparePipeline(pipeline) {
1254
- var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, templates = pipeline.templates;
1255
+ var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
1255
1256
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
1256
1257
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
1257
- templates = templates.map(function (template) {
1258
+ tasks = tasks.map(function (template) {
1258
1259
  var dependentParameterNames = template.dependentParameterNames;
1259
1260
  var parameterNames = extractParameterNames(template.preparedContent || '');
1260
1261
  dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
@@ -1262,7 +1263,7 @@ function unpreparePipeline(pipeline) {
1262
1263
  delete templateUnprepared.preparedContent;
1263
1264
  return templateUnprepared;
1264
1265
  });
1265
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { templates: templates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1266
+ return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1266
1267
  }
1267
1268
  /**
1268
1269
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -1694,6 +1695,9 @@ function normalizeToKebabCase(text) {
1694
1695
  normalizedName = normalizedName.replace(/-$/, '');
1695
1696
  return normalizedName;
1696
1697
  }
1698
+ /**
1699
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1700
+ */
1697
1701
 
1698
1702
  /**
1699
1703
  * Removes emojis from a string and fix whitespaces
@@ -1879,6 +1883,9 @@ var ERRORS = {
1879
1883
  UnexpectedError: UnexpectedError,
1880
1884
  // TODO: [🪑]> VersionMismatchError,
1881
1885
  };
1886
+ /**
1887
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1888
+ */
1882
1889
 
1883
1890
  /**
1884
1891
  * Deserializes the error object
@@ -1940,8 +1947,8 @@ function isPipelinePrepared(pipeline) {
1940
1947
  return false;
1941
1948
  }
1942
1949
  /*
1943
- TODO: [🧠][🍫] `templates` can not be determined if they are fully prepared SO ignoring them
1944
- > if (!pipeline.templates.every(({ preparedContent }) => preparedContent === undefined)) {
1950
+ TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
1951
+ > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
1945
1952
  > return false;
1946
1953
  > }
1947
1954
  */
@@ -1954,7 +1961,7 @@ function isPipelinePrepared(pipeline) {
1954
1961
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
1955
1962
  * - [🏍] ? Is context in each template
1956
1963
  * - [♨] Are examples prepared
1957
- * - [♨] Are templates prepared
1964
+ * - [♨] Are tasks prepared
1958
1965
  */
1959
1966
 
1960
1967
  /**
@@ -2102,6 +2109,9 @@ $deepFreeze({
2102
2109
  pagesCount: { value: 0, isUncertain: true },
2103
2110
  },
2104
2111
  });
2112
+ /**
2113
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2114
+ */
2105
2115
 
2106
2116
  /**
2107
2117
  * @@@
@@ -3288,7 +3298,7 @@ TODO: [🧊] This is how it can look in future
3288
3298
  */
3289
3299
  function clonePipeline(pipeline) {
3290
3300
  // Note: Not using spread operator (...) because @@@
3291
- 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;
3301
+ 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;
3292
3302
  return {
3293
3303
  pipelineUrl: pipelineUrl,
3294
3304
  sourceFile: sourceFile,
@@ -3297,7 +3307,7 @@ function clonePipeline(pipeline) {
3297
3307
  description: description,
3298
3308
  formfactorName: formfactorName,
3299
3309
  parameters: parameters,
3300
- templates: templates,
3310
+ tasks: tasks,
3301
3311
  knowledgeSources: knowledgeSources,
3302
3312
  knowledgePieces: knowledgePieces,
3303
3313
  personas: personas,
@@ -3313,17 +3323,17 @@ function clonePipeline(pipeline) {
3313
3323
  *
3314
3324
  * @public exported from `@promptbook/core`
3315
3325
  */
3316
- function prepareTemplates(pipeline, tools, options) {
3326
+ function prepareTasks(pipeline, tools, options) {
3317
3327
  return __awaiter(this, void 0, void 0, function () {
3318
- var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
3328
+ var _a, maxParallelCount, tasks, knowledgePiecesCount, tasksPrepared;
3319
3329
  var _this = this;
3320
3330
  return __generator(this, function (_b) {
3321
3331
  switch (_b.label) {
3322
3332
  case 0:
3323
3333
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
3324
- templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3325
- templatesPrepared = new Array(templates.length);
3326
- 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 () {
3334
+ tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3335
+ tasksPrepared = new Array(tasks.length);
3336
+ 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 () {
3327
3337
  var dependentParameterNames, preparedContent, preparedTemplate;
3328
3338
  return __generator(this, function (_a) {
3329
3339
  dependentParameterNames = template.dependentParameterNames;
@@ -3336,13 +3346,13 @@ function prepareTemplates(pipeline, tools, options) {
3336
3346
  ], false);
3337
3347
  }
3338
3348
  preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
3339
- templatesPrepared[index] = preparedTemplate;
3349
+ tasksPrepared[index] = preparedTemplate;
3340
3350
  return [2 /*return*/];
3341
3351
  });
3342
3352
  }); })];
3343
3353
  case 1:
3344
3354
  _b.sent();
3345
- return [2 /*return*/, { templatesPrepared: templatesPrepared }];
3355
+ return [2 /*return*/, { tasksPrepared: tasksPrepared }];
3346
3356
  }
3347
3357
  });
3348
3358
  });
@@ -3350,7 +3360,7 @@ function prepareTemplates(pipeline, tools, options) {
3350
3360
  /**
3351
3361
  * TODO: [🧠] Add context to each template (if missing)
3352
3362
  * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
3353
- * TODO: [♨][main] !!! Prepare index the examples and maybe templates
3363
+ * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
3354
3364
  * TODO: Write tests for `preparePipeline`
3355
3365
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3356
3366
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -3367,12 +3377,12 @@ function prepareTemplates(pipeline, tools, options) {
3367
3377
  */
3368
3378
  function preparePipeline(pipeline, tools, options) {
3369
3379
  return __awaiter(this, void 0, void 0, function () {
3370
- var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, templates,
3380
+ var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, tasks,
3371
3381
  /*
3372
3382
  <- TODO: [🧠][🪑] `promptbookVersion` */
3373
3383
  knowledgeSources /*
3374
3384
  <- TODO: [🧊] `knowledgePieces` */, personas /*
3375
- <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, templatesPrepared /* TODO: parameters: parametersPrepared*/;
3385
+ <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
3376
3386
  var _this = this;
3377
3387
  return __generator(this, function (_c) {
3378
3388
  switch (_c.label) {
@@ -3381,7 +3391,7 @@ function preparePipeline(pipeline, tools, options) {
3381
3391
  return [2 /*return*/, pipeline];
3382
3392
  }
3383
3393
  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;
3384
- parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3394
+ parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3385
3395
  if (tools === undefined || tools.llm === undefined) {
3386
3396
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
3387
3397
  }
@@ -3424,9 +3434,9 @@ function preparePipeline(pipeline, tools, options) {
3424
3434
  case 2:
3425
3435
  partialknowledgePiecesPrepared = _c.sent();
3426
3436
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3427
- return [4 /*yield*/, prepareTemplates({
3437
+ return [4 /*yield*/, prepareTasks({
3428
3438
  parameters: parameters,
3429
- templates: templates,
3439
+ tasks: tasks,
3430
3440
  knowledgePiecesCount: knowledgePiecesPrepared.length,
3431
3441
  }, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), {
3432
3442
  rootDirname: rootDirname,
@@ -3434,12 +3444,12 @@ function preparePipeline(pipeline, tools, options) {
3434
3444
  isVerbose: isVerbose,
3435
3445
  })];
3436
3446
  case 3:
3437
- templatesPrepared = (_c.sent()).templatesPrepared;
3447
+ tasksPrepared = (_c.sent()).tasksPrepared;
3438
3448
  // ----- /Templates preparation -----
3439
3449
  // Note: Count total usage
3440
3450
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
3441
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
3442
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
3451
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
3452
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3443
3453
  knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
3444
3454
  }
3445
3455
  });
@@ -3511,9 +3521,9 @@ function extractVariables(script) {
3511
3521
  * @throws {ParseError} if the script is invalid
3512
3522
  * @public exported from `@promptbook/utils`
3513
3523
  */
3514
- function extractParameterNamesFromTemplate(template) {
3524
+ function extractParameterNamesFromTask(template) {
3515
3525
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
3516
- var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
3526
+ var title = template.title, description = template.description, taskType = template.taskType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
3517
3527
  var parameterNames = new Set();
3518
3528
  try {
3519
3529
  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()) {
@@ -3528,7 +3538,7 @@ function extractParameterNamesFromTemplate(template) {
3528
3538
  }
3529
3539
  finally { if (e_1) throw e_1.error; }
3530
3540
  }
3531
- if (templateType === 'SCRIPT_TEMPLATE') {
3541
+ if (taskType === 'SCRIPT_TASK') {
3532
3542
  try {
3533
3543
  for (var _g = __values(extractVariables(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
3534
3544
  var parameterName = _h.value;
@@ -3959,6 +3969,9 @@ var FORMAT_DEFINITIONS = [
3959
3969
  TextFormatDefinition,
3960
3970
  CsvFormatDefinition,
3961
3971
  ];
3972
+ /**
3973
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3974
+ */
3962
3975
 
3963
3976
  /**
3964
3977
  * Maps available parameters to expected parameters
@@ -4175,7 +4188,7 @@ function replaceParameters(template, parameters) {
4175
4188
  }
4176
4189
  finally { if (e_1) throw e_1.error; }
4177
4190
  }
4178
- var replacedTemplate = template;
4191
+ var replacedTemplates = template;
4179
4192
  var match;
4180
4193
  var loopLimit = LOOP_LIMIT;
4181
4194
  var _loop_1 = function () {
@@ -4204,24 +4217,24 @@ function replaceParameters(template, parameters) {
4204
4217
  .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
4205
4218
  .join('\n');
4206
4219
  }
4207
- replacedTemplate =
4208
- replacedTemplate.substring(0, match.index + precol.length) +
4220
+ replacedTemplates =
4221
+ replacedTemplates.substring(0, match.index + precol.length) +
4209
4222
  parameterValue +
4210
- replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
4223
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
4211
4224
  };
4212
4225
  while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
4213
- .exec(replacedTemplate))) {
4226
+ .exec(replacedTemplates))) {
4214
4227
  _loop_1();
4215
4228
  }
4216
4229
  // [💫] Check if there are parameters that are not closed properly
4217
- if (/{\w+$/.test(replacedTemplate)) {
4230
+ if (/{\w+$/.test(replacedTemplates)) {
4218
4231
  throw new PipelineExecutionError('Parameter is not closed');
4219
4232
  }
4220
4233
  // [💫] Check if there are parameters that are not opened properly
4221
- if (/^\w+}/.test(replacedTemplate)) {
4234
+ if (/^\w+}/.test(replacedTemplates)) {
4222
4235
  throw new PipelineExecutionError('Parameter is not opened');
4223
4236
  }
4224
- return replacedTemplate;
4237
+ return replacedTemplates;
4225
4238
  }
4226
4239
 
4227
4240
  /**
@@ -4253,6 +4266,7 @@ var CHARACTERS_PER_STANDARD_LINE = 63;
4253
4266
  var LINES_PER_STANDARD_PAGE = 44;
4254
4267
  /**
4255
4268
  * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
4269
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4256
4270
  */
4257
4271
 
4258
4272
  /**
@@ -4332,6 +4346,7 @@ var CountUtils = {
4332
4346
  };
4333
4347
  /**
4334
4348
  * TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
4349
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4335
4350
  */
4336
4351
 
4337
4352
  /**
@@ -4380,12 +4395,12 @@ function checkExpectations(expectations, value) {
4380
4395
  */
4381
4396
  function executeAttempts(options) {
4382
4397
  return __awaiter(this, void 0, void 0, function () {
4383
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
4398
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTaskResult, _llms, llmTools, _loop_1, attempt, state_1;
4384
4399
  return __generator(this, function (_a) {
4385
4400
  switch (_a.label) {
4386
4401
  case 0:
4387
- 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;
4388
- $ongoingTemplateResult = {
4402
+ 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;
4403
+ $ongoingTaskResult = {
4389
4404
  $result: null,
4390
4405
  $resultString: null,
4391
4406
  $expectError: null,
@@ -4405,52 +4420,51 @@ function executeAttempts(options) {
4405
4420
  if (isJokerAttempt && !jokerParameterName) {
4406
4421
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
4407
4422
  }
4408
- $ongoingTemplateResult.$result = null;
4409
- $ongoingTemplateResult.$resultString = null;
4410
- $ongoingTemplateResult.$expectError = null;
4423
+ $ongoingTaskResult.$result = null;
4424
+ $ongoingTaskResult.$resultString = null;
4425
+ $ongoingTaskResult.$expectError = null;
4411
4426
  if (isJokerAttempt) {
4412
4427
  if (parameters[jokerParameterName] === undefined) {
4413
4428
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
4414
4429
  // <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
4415
4430
  }
4416
4431
  else {
4417
- $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
4432
+ $ongoingTaskResult.$resultString = parameters[jokerParameterName];
4418
4433
  }
4419
4434
  }
4420
4435
  _t.label = 1;
4421
4436
  case 1:
4422
4437
  _t.trys.push([1, 43, 44, 45]);
4423
4438
  if (!!isJokerAttempt) return [3 /*break*/, 25];
4424
- _b = template.templateType;
4439
+ _b = task.taskType;
4425
4440
  switch (_b) {
4426
- case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
4427
- case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
4428
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
4429
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
4441
+ case 'SIMPLE_TASK': return [3 /*break*/, 2];
4442
+ case 'PROMPT_TASK': return [3 /*break*/, 3];
4443
+ case 'SCRIPT_TASK': return [3 /*break*/, 11];
4444
+ case 'DIALOG_TASK': return [3 /*break*/, 22];
4430
4445
  }
4431
4446
  return [3 /*break*/, 24];
4432
4447
  case 2:
4433
- $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
4448
+ $ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
4434
4449
  return [3 /*break*/, 25];
4435
4450
  case 3:
4436
- modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
4437
- $ongoingTemplateResult.$prompt = {
4438
- title: template.title,
4451
+ modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
4452
+ $ongoingTaskResult.$prompt = {
4453
+ title: task.title,
4439
4454
  pipelineUrl: "".concat(preparedPipeline.pipelineUrl
4440
4455
  ? preparedPipeline.pipelineUrl
4441
- : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
4442
- // <- TODO: Here should be maybe also subformat index to distinguish between same template with different subformat values
4456
+ : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(task.name
4457
+ // <- TODO: Here should be maybe also subformat index to distinguish between same task with different subformat values
4443
4458
  ),
4444
4459
  parameters: parameters,
4445
4460
  content: preparedContent,
4446
4461
  modelRequirements: modelRequirements,
4447
4462
  expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
4448
4463
  var name = _a.name;
4449
- return name === template.personaName;
4450
- }) ||
4451
- {})), template.expectations),
4452
- format: template.format,
4453
- postprocessingFunctionNames: template.postprocessingFunctionNames,
4464
+ return name === task.personaName;
4465
+ }) || {})), task.expectations),
4466
+ format: task.format,
4467
+ postprocessingFunctionNames: task.postprocessingFunctionNames,
4454
4468
  }; // <- TODO: Not very good type guard
4455
4469
  _c = modelRequirements.modelVariant;
4456
4470
  switch (_c) {
@@ -4460,36 +4474,35 @@ function executeAttempts(options) {
4460
4474
  }
4461
4475
  return [3 /*break*/, 9];
4462
4476
  case 4:
4463
- _d = $ongoingTemplateResult;
4477
+ _d = $ongoingTaskResult;
4464
4478
  return [4 /*yield*/, llmTools.callChatModel(
4465
4479
  // <- TODO: [🧁] Check that `callChatModel` is defined
4466
- $deepFreeze($ongoingTemplateResult.$prompt))];
4480
+ $deepFreeze($ongoingTaskResult.$prompt))];
4467
4481
  case 5:
4468
4482
  _d.$chatResult = _t.sent();
4469
4483
  // TODO: [🍬] Destroy chatThread
4470
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
4471
- $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
4484
+ $ongoingTaskResult.$result = $ongoingTaskResult.$chatResult;
4485
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$chatResult.content;
4472
4486
  return [3 /*break*/, 10];
4473
4487
  case 6:
4474
- _e = $ongoingTemplateResult;
4488
+ _e = $ongoingTaskResult;
4475
4489
  return [4 /*yield*/, llmTools.callCompletionModel(
4476
4490
  // <- TODO: [🧁] Check that `callCompletionModel` is defined
4477
- $deepFreeze($ongoingTemplateResult.$prompt))];
4491
+ $deepFreeze($ongoingTaskResult.$prompt))];
4478
4492
  case 7:
4479
4493
  _e.$completionResult = _t.sent();
4480
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
4481
- $ongoingTemplateResult.$resultString =
4482
- $ongoingTemplateResult.$completionResult.content;
4494
+ $ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
4495
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
4483
4496
  return [3 /*break*/, 10];
4484
4497
  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 "); }));
4485
- case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4498
+ case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(task.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4486
4499
  case 10: return [3 /*break*/, 25];
4487
4500
  case 11:
4488
4501
  if (arrayableToArray(tools.script).length === 0) {
4489
4502
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
4490
4503
  }
4491
- if (!template.contentLanguage) {
4492
- 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 "); }));
4504
+ if (!task.contentLanguage) {
4505
+ 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 "); }));
4493
4506
  }
4494
4507
  _t.label = 12;
4495
4508
  case 12:
@@ -4502,9 +4515,9 @@ function executeAttempts(options) {
4502
4515
  _t.label = 14;
4503
4516
  case 14:
4504
4517
  _t.trys.push([14, 16, , 17]);
4505
- _h = $ongoingTemplateResult;
4518
+ _h = $ongoingTaskResult;
4506
4519
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
4507
- scriptLanguage: template.contentLanguage,
4520
+ scriptLanguage: task.contentLanguage,
4508
4521
  script: preparedContent,
4509
4522
  parameters: parameters,
4510
4523
  }))];
@@ -4519,7 +4532,7 @@ function executeAttempts(options) {
4519
4532
  if (error_1 instanceof UnexpectedError) {
4520
4533
  throw error_1;
4521
4534
  }
4522
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
4535
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_1);
4523
4536
  return [3 /*break*/, 17];
4524
4537
  case 17:
4525
4538
  _g = _f.next();
@@ -4536,14 +4549,14 @@ function executeAttempts(options) {
4536
4549
  finally { if (e_1) throw e_1.error; }
4537
4550
  return [7 /*endfinally*/];
4538
4551
  case 21:
4539
- if ($ongoingTemplateResult.$resultString !== null) {
4552
+ if ($ongoingTaskResult.$resultString !== null) {
4540
4553
  return [3 /*break*/, 25];
4541
4554
  }
4542
- if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
4543
- throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
4555
+ if ($ongoingTaskResult.$scriptPipelineExecutionErrors.length === 1) {
4556
+ throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
4544
4557
  }
4545
4558
  else {
4546
- 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
4559
+ 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
4547
4560
  .map(function (error) { return '- ' + error.message; })
4548
4561
  .join('\n\n')), "\n "); }));
4549
4562
  }
@@ -4551,27 +4564,27 @@ function executeAttempts(options) {
4551
4564
  if (tools.userInterface === undefined) {
4552
4565
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
4553
4566
  }
4554
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
4555
- _j = $ongoingTemplateResult;
4567
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
4568
+ _j = $ongoingTaskResult;
4556
4569
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
4557
- promptTitle: template.title,
4558
- promptMessage: replaceParameters(template.description || '', parameters),
4570
+ promptTitle: task.title,
4571
+ promptMessage: replaceParameters(task.description || '', parameters),
4559
4572
  defaultValue: replaceParameters(preparedContent, parameters),
4560
4573
  // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4561
4574
  placeholder: undefined,
4562
4575
  priority: priority,
4563
4576
  }))];
4564
4577
  case 23:
4565
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
4578
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
4566
4579
  _j.$resultString = _t.sent();
4567
4580
  return [3 /*break*/, 25];
4568
- case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4581
+ case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4569
4582
  case 25:
4570
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
4583
+ if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
4571
4584
  _t.label = 26;
4572
4585
  case 26:
4573
4586
  _t.trys.push([26, 40, 41, 42]);
4574
- _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
4587
+ _k = (e_3 = void 0, __values(task.postprocessingFunctionNames)), _l = _k.next();
4575
4588
  _t.label = 27;
4576
4589
  case 27:
4577
4590
  if (!!_l.done) return [3 /*break*/, 39];
@@ -4588,13 +4601,13 @@ function executeAttempts(options) {
4588
4601
  _t.label = 30;
4589
4602
  case 30:
4590
4603
  _t.trys.push([30, 32, , 33]);
4591
- _p = $ongoingTemplateResult;
4604
+ _p = $ongoingTaskResult;
4592
4605
  return [4 /*yield*/, scriptTools.execute({
4593
4606
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
4594
4607
  script: "".concat(functionName, "(resultString)"),
4595
4608
  parameters: {
4596
- resultString: $ongoingTemplateResult.$resultString || '',
4597
- // Note: No ...parametersForTemplate, because working with result only
4609
+ resultString: $ongoingTaskResult.$resultString || '',
4610
+ // Note: No ...parametersForTask, because working with result only
4598
4611
  },
4599
4612
  })];
4600
4613
  case 31:
@@ -4610,7 +4623,7 @@ function executeAttempts(options) {
4610
4623
  throw error_2;
4611
4624
  }
4612
4625
  postprocessingError = error_2;
4613
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
4626
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_2);
4614
4627
  return [3 /*break*/, 33];
4615
4628
  case 33:
4616
4629
  _o = _m.next();
@@ -4647,12 +4660,12 @@ function executeAttempts(options) {
4647
4660
  return [7 /*endfinally*/];
4648
4661
  case 42:
4649
4662
  // TODO: [💝] Unite object for expecting amount and format
4650
- if (template.format) {
4651
- if (template.format === 'JSON') {
4652
- if (!isValidJsonString($ongoingTemplateResult.$resultString || '')) {
4663
+ if (task.format) {
4664
+ if (task.format === 'JSON') {
4665
+ if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
4653
4666
  // TODO: [🏢] Do more universally via `FormatDefinition`
4654
4667
  try {
4655
- $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
4668
+ $ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
4656
4669
  }
4657
4670
  catch (error) {
4658
4671
  throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
@@ -4661,12 +4674,12 @@ function executeAttempts(options) {
4661
4674
  }
4662
4675
  }
4663
4676
  else {
4664
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4677
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4665
4678
  }
4666
4679
  }
4667
4680
  // TODO: [💝] Unite object for expecting amount and format
4668
- if (template.expectations) {
4669
- checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
4681
+ if (task.expectations) {
4682
+ checkExpectations(task.expectations, $ongoingTaskResult.$resultString || '');
4670
4683
  }
4671
4684
  return [2 /*return*/, "break-attempts"];
4672
4685
  case 43:
@@ -4674,38 +4687,38 @@ function executeAttempts(options) {
4674
4687
  if (!(error_3 instanceof ExpectError)) {
4675
4688
  throw error_3;
4676
4689
  }
4677
- $ongoingTemplateResult.$expectError = error_3;
4690
+ $ongoingTaskResult.$expectError = error_3;
4678
4691
  return [3 /*break*/, 45];
4679
4692
  case 44:
4680
4693
  if (!isJokerAttempt &&
4681
- template.templateType === 'PROMPT_TEMPLATE' &&
4682
- $ongoingTemplateResult.$prompt
4694
+ task.taskType === 'PROMPT_TASK' &&
4695
+ $ongoingTaskResult.$prompt
4683
4696
  // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
4684
4697
  // In that case we don’t want to make a report about it because it’s not a llm execution error
4685
4698
  ) {
4686
- // TODO: [🧠] Maybe put other templateTypes into report
4699
+ // TODO: [🧠] Maybe put other taskTypes into report
4687
4700
  $executionReport.promptExecutions.push({
4688
- prompt: __assign({}, $ongoingTemplateResult.$prompt),
4689
- result: $ongoingTemplateResult.$result || undefined,
4690
- error: $ongoingTemplateResult.$expectError === null
4701
+ prompt: __assign({}, $ongoingTaskResult.$prompt),
4702
+ result: $ongoingTaskResult.$result || undefined,
4703
+ error: $ongoingTaskResult.$expectError === null
4691
4704
  ? undefined
4692
- : serializeError($ongoingTemplateResult.$expectError),
4705
+ : serializeError($ongoingTaskResult.$expectError),
4693
4706
  });
4694
4707
  }
4695
4708
  return [7 /*endfinally*/];
4696
4709
  case 45:
4697
- if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
4710
+ if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
4698
4711
  throw new PipelineExecutionError(spaceTrim(function (block) {
4699
4712
  var _a, _b, _c;
4700
- 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) || '')
4713
+ 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) || '')
4701
4714
  .split('\n')
4702
4715
  .map(function (line) { return "> ".concat(line); })
4703
- .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) || '')
4716
+ .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) || '')
4704
4717
  .split('\n')
4705
4718
  .map(function (line) { return "> ".concat(line); })
4706
- .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
4719
+ .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTaskResult.$resultString === null
4707
4720
  ? 'null'
4708
- : $ongoingTemplateResult.$resultString
4721
+ : $ongoingTaskResult.$resultString
4709
4722
  .split('\n')
4710
4723
  .map(function (line) { return "> ".concat(line); })
4711
4724
  .join('\n')), "\n ---\n ");
@@ -4730,10 +4743,10 @@ function executeAttempts(options) {
4730
4743
  attempt++;
4731
4744
  return [3 /*break*/, 1];
4732
4745
  case 4:
4733
- if ($ongoingTemplateResult.$resultString === null) {
4746
+ if ($ongoingTaskResult.$resultString === null) {
4734
4747
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
4735
4748
  }
4736
- return [2 /*return*/, $ongoingTemplateResult.$resultString];
4749
+ return [2 /*return*/, $ongoingTaskResult.$resultString];
4737
4750
  }
4738
4751
  });
4739
4752
  });
@@ -4749,36 +4762,36 @@ function executeAttempts(options) {
4749
4762
  */
4750
4763
  function executeFormatSubvalues(options) {
4751
4764
  return __awaiter(this, void 0, void 0, function () {
4752
- var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
4765
+ var task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
4753
4766
  var _this = this;
4754
4767
  return __generator(this, function (_a) {
4755
4768
  switch (_a.label) {
4756
4769
  case 0:
4757
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
4758
- if (template.foreach === undefined) {
4770
+ task = options.task, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
4771
+ if (task.foreach === undefined) {
4759
4772
  return [2 /*return*/, /* not await */ executeAttempts(options)];
4760
4773
  }
4761
4774
  if (jokerParameterNames.length !== 0) {
4762
4775
  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 "); }));
4763
4776
  }
4764
- parameterValue = parameters[template.foreach.parameterName] || '';
4777
+ parameterValue = parameters[task.foreach.parameterName] || '';
4765
4778
  formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
4766
- return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(template.foreach.formatName);
4779
+ return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(task.foreach.formatName);
4767
4780
  });
4768
4781
  if (formatDefinition === undefined) {
4769
4782
  throw new UnexpectedError(
4770
4783
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
4771
- 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; })
4784
+ 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; })
4772
4785
  .map(function (formatName) { return "- ".concat(formatName); })
4773
4786
  .join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
4774
4787
  }
4775
4788
  subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
4776
- return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(template.foreach.subformatName);
4789
+ return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(task.foreach.subformatName);
4777
4790
  });
4778
4791
  if (subvalueDefinition === undefined) {
4779
4792
  throw new UnexpectedError(
4780
4793
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
4781
- 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
4794
+ 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
4782
4795
  .map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
4783
4796
  .map(function (subvalueName) { return "- ".concat(subvalueName); })
4784
4797
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -4787,7 +4800,7 @@ function executeFormatSubvalues(options) {
4787
4800
  formatSettings = csvSettings;
4788
4801
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
4789
4802
  }
4790
- return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
4803
+ return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
4791
4804
  var mappedParameters, allSubparameters, subresultString;
4792
4805
  return __generator(this, function (_a) {
4793
4806
  switch (_a.label) {
@@ -4796,7 +4809,7 @@ function executeFormatSubvalues(options) {
4796
4809
  // TODO: When done [🐚] Report progress also for each subvalue here
4797
4810
  try {
4798
4811
  mappedParameters = mapAvailableToExpectedParameters({
4799
- expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
4812
+ expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
4800
4813
  availableParameters: subparameters,
4801
4814
  });
4802
4815
  }
@@ -4829,7 +4842,7 @@ function executeFormatSubvalues(options) {
4829
4842
  *
4830
4843
  * @private internal utility of `createPipelineExecutor`
4831
4844
  */
4832
- function getContextForTemplate(template) {
4845
+ function getContextForTask(task) {
4833
4846
  return __awaiter(this, void 0, void 0, function () {
4834
4847
  return __generator(this, function (_a) {
4835
4848
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
@@ -4842,15 +4855,10 @@ function getContextForTemplate(template) {
4842
4855
  *
4843
4856
  * @private internal utility of `createPipelineExecutor`
4844
4857
  */
4845
- function getKnowledgeForTemplate(options) {
4858
+ function getExamplesForTask(task) {
4846
4859
  return __awaiter(this, void 0, void 0, function () {
4847
- var preparedPipeline;
4848
4860
  return __generator(this, function (_a) {
4849
- preparedPipeline = options.preparedPipeline, options.template;
4850
- return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4851
- var content = _a.content;
4852
- return "- ".concat(content);
4853
- }).join('\n')];
4861
+ return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4854
4862
  });
4855
4863
  });
4856
4864
  }
@@ -4860,10 +4868,15 @@ function getKnowledgeForTemplate(options) {
4860
4868
  *
4861
4869
  * @private internal utility of `createPipelineExecutor`
4862
4870
  */
4863
- function getExamplesForTemplate(template) {
4871
+ function getKnowledgeForTask(options) {
4864
4872
  return __awaiter(this, void 0, void 0, function () {
4873
+ var preparedPipeline;
4865
4874
  return __generator(this, function (_a) {
4866
- return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4875
+ preparedPipeline = options.preparedPipeline, options.task;
4876
+ return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4877
+ var content = _a.content;
4878
+ return "- ".concat(content);
4879
+ }).join('\n')];
4867
4880
  });
4868
4881
  });
4869
4882
  }
@@ -4873,21 +4886,21 @@ function getExamplesForTemplate(template) {
4873
4886
  *
4874
4887
  * @private internal utility of `createPipelineExecutor`
4875
4888
  */
4876
- function getReservedParametersForTemplate(options) {
4889
+ function getReservedParametersForTask(options) {
4877
4890
  return __awaiter(this, void 0, void 0, function () {
4878
- var preparedPipeline, template, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
4891
+ var preparedPipeline, task, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
4879
4892
  var e_1, _a;
4880
4893
  return __generator(this, function (_b) {
4881
4894
  switch (_b.label) {
4882
4895
  case 0:
4883
- preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
4884
- return [4 /*yield*/, getContextForTemplate()];
4896
+ preparedPipeline = options.preparedPipeline, task = options.task, pipelineIdentification = options.pipelineIdentification;
4897
+ return [4 /*yield*/, getContextForTask()];
4885
4898
  case 1:
4886
4899
  context = _b.sent();
4887
- return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
4900
+ return [4 /*yield*/, getKnowledgeForTask({ preparedPipeline: preparedPipeline, task: task })];
4888
4901
  case 2:
4889
4902
  knowledge = _b.sent();
4890
- return [4 /*yield*/, getExamplesForTemplate()];
4903
+ return [4 /*yield*/, getExamplesForTask()];
4891
4904
  case 3:
4892
4905
  examples = _b.sent();
4893
4906
  currentDate = new Date().toISOString();
@@ -4930,31 +4943,31 @@ function getReservedParametersForTemplate(options) {
4930
4943
  *
4931
4944
  * @private internal utility of `createPipelineExecutor`
4932
4945
  */
4933
- function executeTemplate(options) {
4946
+ function executeTask(options) {
4934
4947
  return __awaiter(this, void 0, void 0, function () {
4935
- 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;
4948
+ 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;
4936
4949
  var e_1, _g, _h;
4937
4950
  return __generator(this, function (_j) {
4938
4951
  switch (_j.label) {
4939
4952
  case 0:
4940
- 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;
4941
- name = "pipeline-executor-frame-".concat(currentTemplate.name);
4942
- title = currentTemplate.title;
4943
- priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
4953
+ 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;
4954
+ name = "pipeline-executor-frame-".concat(currentTask.name);
4955
+ title = currentTask.title;
4956
+ priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
4944
4957
  return [4 /*yield*/, onProgress({
4945
4958
  name: name,
4946
4959
  title: title,
4947
4960
  isStarted: false,
4948
4961
  isDone: false,
4949
- templateType: currentTemplate.templateType,
4950
- parameterName: currentTemplate.resultingParameterName,
4962
+ taskType: currentTask.taskType,
4963
+ parameterName: currentTask.resultingParameterName,
4951
4964
  parameterValue: null,
4952
4965
  // <- [🍸]
4953
4966
  })];
4954
4967
  case 1:
4955
4968
  _j.sent();
4956
- usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
4957
- dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
4969
+ usedParameterNames = extractParameterNamesFromTask(currentTask);
4970
+ dependentParameterNames = new Set(currentTask.dependentParameterNames);
4958
4971
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4959
4972
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
4960
4973
  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)
@@ -4965,9 +4978,9 @@ function executeTemplate(options) {
4965
4978
  }
4966
4979
  _c = (_b = Object).freeze;
4967
4980
  _d = [{}];
4968
- return [4 /*yield*/, getReservedParametersForTemplate({
4981
+ return [4 /*yield*/, getReservedParametersForTask({
4969
4982
  preparedPipeline: preparedPipeline,
4970
- template: currentTemplate,
4983
+ task: currentTask,
4971
4984
  pipelineIdentification: pipelineIdentification,
4972
4985
  })];
4973
4986
  case 2:
@@ -4985,11 +4998,11 @@ function executeTemplate(options) {
4985
4998
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4986
4999
  // Houston, we have a problem
4987
5000
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
4988
- 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 "); }));
5001
+ 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 "); }));
4989
5002
  }
4990
5003
  };
4991
5004
  try {
4992
- // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
5005
+ // Note: [2] Check that all used parameters are defined and removing unused parameters for this task
4993
5006
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4994
5007
  for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4995
5008
  parameterName = _f.value;
@@ -5005,18 +5018,16 @@ function executeTemplate(options) {
5005
5018
  }
5006
5019
  // 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
5007
5020
  Object.freeze(parameters);
5008
- maxAttempts = currentTemplate.templateType === 'DIALOG_TEMPLATE' ? Infinity : maxExecutionAttempts;
5009
- jokerParameterNames = currentTemplate.jokerParameterNames || [];
5010
- preparedContent = (currentTemplate.preparedContent || '{content}')
5011
- .split('{content}')
5012
- .join(currentTemplate.content);
5021
+ maxAttempts = currentTask.taskType === 'DIALOG_TASK' ? Infinity : maxExecutionAttempts;
5022
+ jokerParameterNames = currentTask.jokerParameterNames || [];
5023
+ preparedContent = (currentTask.preparedContent || '{content}').split('{content}').join(currentTask.content);
5013
5024
  return [4 /*yield*/, executeFormatSubvalues({
5014
5025
  jokerParameterNames: jokerParameterNames,
5015
5026
  priority: priority,
5016
5027
  maxAttempts: maxAttempts,
5017
5028
  preparedContent: preparedContent,
5018
5029
  parameters: parameters,
5019
- template: currentTemplate,
5030
+ task: currentTask,
5020
5031
  preparedPipeline: preparedPipeline,
5021
5032
  tools: tools,
5022
5033
  $executionReport: $executionReport,
@@ -5029,15 +5040,15 @@ function executeTemplate(options) {
5029
5040
  title: title,
5030
5041
  isStarted: true,
5031
5042
  isDone: true,
5032
- templateType: currentTemplate.templateType,
5033
- parameterName: currentTemplate.resultingParameterName,
5043
+ taskType: currentTask.taskType,
5044
+ parameterName: currentTask.resultingParameterName,
5034
5045
  parameterValue: resultString,
5035
5046
  // <- [🍸]
5036
5047
  })];
5037
5048
  case 4:
5038
5049
  _j.sent();
5039
5050
  return [2 /*return*/, Object.freeze((_h = {},
5040
- _h[currentTemplate.resultingParameterName] =
5051
+ _h[currentTask.resultingParameterName] =
5041
5052
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
5042
5053
  resultString,
5043
5054
  _h))];
@@ -5099,7 +5110,7 @@ function filterJustOutputParameters(options) {
5099
5110
  */
5100
5111
  function executePipeline(options) {
5101
5112
  return __awaiter(this, void 0, void 0, function () {
5102
- 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;
5113
+ 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;
5103
5114
  var e_1, _f, e_2, _g;
5104
5115
  return __generator(this, function (_h) {
5105
5116
  switch (_h.label) {
@@ -5253,11 +5264,11 @@ function executePipeline(options) {
5253
5264
  var name = _a.name;
5254
5265
  return name;
5255
5266
  });
5256
- unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.templates), false);
5267
+ unresovedTasks_1 = __spreadArray([], __read(preparedPipeline.tasks), false);
5257
5268
  resolving_1 = [];
5258
5269
  loopLimit = LOOP_LIMIT;
5259
5270
  _loop_2 = function () {
5260
- var currentTemplate, work_1;
5271
+ var currentTask, work_1;
5261
5272
  return __generator(this, function (_k) {
5262
5273
  switch (_k.label) {
5263
5274
  case 0:
@@ -5265,15 +5276,15 @@ function executePipeline(options) {
5265
5276
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
5266
5277
  throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
5267
5278
  }
5268
- currentTemplate = unresovedTemplates_1.find(function (template) {
5269
- return template.dependentParameterNames.every(function (name) {
5279
+ currentTask = unresovedTasks_1.find(function (task) {
5280
+ return task.dependentParameterNames.every(function (name) {
5270
5281
  return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
5271
5282
  });
5272
5283
  });
5273
- if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
5284
+ if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
5274
5285
  throw new UnexpectedError(
5275
5286
  // TODO: [🐎] DRY
5276
- 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
5287
+ 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
5277
5288
  .map(function (_a) {
5278
5289
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
5279
5290
  return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
@@ -5292,14 +5303,14 @@ function executePipeline(options) {
5292
5303
  .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5293
5304
  .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
5294
5305
  case 1:
5295
- if (!!currentTemplate) return [3 /*break*/, 3];
5306
+ if (!!currentTask) return [3 /*break*/, 3];
5296
5307
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
5297
5308
  case 2:
5298
5309
  /* [🤹‍♂️] */ _k.sent();
5299
5310
  return [3 /*break*/, 4];
5300
5311
  case 3:
5301
- unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
5302
- work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
5312
+ unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
5313
+ work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
5303
5314
  if (isReturned) {
5304
5315
  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)
5305
5316
  .split('\n')
@@ -5309,16 +5320,16 @@ function executePipeline(options) {
5309
5320
  if (onProgress) {
5310
5321
  onProgress(progress);
5311
5322
  }
5312
- }, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
5323
+ }, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
5313
5324
  .then(function (newParametersToPass) {
5314
5325
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
5315
- resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
5326
+ resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
5316
5327
  })
5317
5328
  .then(function () {
5318
5329
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
5319
5330
  });
5320
5331
  // <- Note: Errors are catched here [3]
5321
- // 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
5332
+ // 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
5322
5333
  resolving_1.push(work_1);
5323
5334
  _k.label = 4;
5324
5335
  case 4: return [2 /*return*/];
@@ -5327,7 +5338,7 @@ function executePipeline(options) {
5327
5338
  };
5328
5339
  _h.label = 21;
5329
5340
  case 21:
5330
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
5341
+ if (!(unresovedTasks_1.length > 0)) return [3 /*break*/, 23];
5331
5342
  return [5 /*yield**/, _loop_2()];
5332
5343
  case 22:
5333
5344
  _h.sent();
@@ -5485,6 +5496,9 @@ var markdownScraperMetadata = $deepFreeze({
5485
5496
  * @public exported from `@promptbook/cli`
5486
5497
  */
5487
5498
  $scrapersMetadataRegister.register(markdownScraperMetadata);
5499
+ /**
5500
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5501
+ */
5488
5502
 
5489
5503
  /**
5490
5504
  * Scraper for markdown files
@@ -5679,6 +5693,9 @@ var pdfScraperMetadata = $deepFreeze({
5679
5693
  * @public exported from `@promptbook/cli`
5680
5694
  */
5681
5695
  $scrapersMetadataRegister.register(pdfScraperMetadata);
5696
+ /**
5697
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5698
+ */
5682
5699
 
5683
5700
  /**
5684
5701
  * Scraper for .pdf files
@@ -5762,6 +5779,7 @@ var createPdfScraper = Object.assign(function (tools, options) {
5762
5779
  var _PdfScraperRegistration = $scrapersRegister.register(createPdfScraper);
5763
5780
  /**
5764
5781
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
5782
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5765
5783
  */
5766
5784
 
5767
5785
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, PdfScraper, _PdfScraperRegistration, createPdfScraper };