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