@promptbook/pdf 0.75.0-1 → 0.75.0-4

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 (167) hide show
  1. package/README.md +28 -17
  2. package/esm/index.es.js +268 -249
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/{promptbook-collection → books}/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +28 -20
  6. package/esm/typings/src/_packages/types.index.d.ts +62 -52
  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 +3 -3
  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/{TEMPLATE/templateCommandParser.d.ts → SECTION/sectionCommandParser.d.ts} +6 -6
  28. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  29. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +17 -19
  30. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +1 -1
  31. package/esm/typings/src/commands/index.d.ts +4 -1
  32. package/esm/typings/src/config.d.ts +11 -3
  33. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
  34. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
  35. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +3 -3
  36. package/esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts +1 -1
  37. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +4 -4
  38. package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +15 -0
  39. package/esm/typings/src/conversion/utils/renameParameter.d.ts +3 -3
  40. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +3 -2
  41. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
  42. package/esm/typings/src/dialogs/simple-prompt/SimplePromptInterfaceTools.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/ScriptExecutionTools.d.ts +1 -1
  47. package/esm/typings/src/execution/createPipelineExecutor/{$OngoingTemplateResult.d.ts → $OngoingTaskResult.d.ts} +1 -1
  48. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +1 -1
  49. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +1 -1
  50. package/esm/typings/src/execution/createPipelineExecutor/{20-executeTemplate.d.ts → 20-executeTask.d.ts} +7 -7
  51. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -5
  52. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +1 -1
  53. package/esm/typings/src/execution/createPipelineExecutor/{getContextForTemplate.d.ts → getContextForTask.d.ts} +2 -2
  54. package/esm/typings/src/execution/createPipelineExecutor/{getExamplesForTemplate.d.ts → getExamplesForTask.d.ts} +2 -2
  55. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +27 -0
  56. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +30 -0
  57. package/esm/typings/src/{types → execution}/execution-report/ExecutionPromptReportJson.d.ts +2 -2
  58. package/esm/typings/src/{types → execution}/execution-report/ExecutionReportJson.d.ts +4 -4
  59. package/esm/typings/src/{types → execution}/execution-report/ExecutionReportStringOptions.d.ts +1 -1
  60. package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  61. package/esm/typings/src/execution/utils/usage-constants.d.ts +3 -0
  62. package/esm/typings/src/formats/index.d.ts +3 -0
  63. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +2 -2
  64. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +7 -1
  65. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +3 -0
  66. package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +45 -0
  67. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +14 -0
  68. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +3 -3
  69. package/esm/typings/src/formfactors/index.d.ts +85 -12
  70. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +14 -0
  71. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +13 -3
  72. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +13 -3
  73. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
  74. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +3 -0
  75. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +1 -0
  76. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +3 -0
  77. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
  78. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  79. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  80. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +3 -0
  81. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +1 -0
  82. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  83. package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +26 -0
  84. package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +14 -0
  85. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/getPipelineInterface.d.ts +3 -1
  86. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineImplementingInterface.d.ts +5 -1
  87. package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineInterfacesEqual.d.ts +2 -0
  88. package/esm/typings/src/{types/PipelineJson/TemplateJsonCommon.d.ts → pipeline/PipelineJson/CommonTaskJson.d.ts} +24 -24
  89. package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +13 -0
  90. package/esm/typings/src/{types → pipeline}/PipelineJson/Expectations.d.ts +2 -2
  91. package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgePieceJson.d.ts +7 -6
  92. package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgeSourceJson.d.ts +3 -3
  93. package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +98 -0
  94. package/esm/typings/src/{types → pipeline}/PipelineJson/PersonaJson.d.ts +5 -5
  95. package/esm/typings/src/{types → pipeline}/PipelineJson/PipelineJson.d.ts +11 -11
  96. package/esm/typings/src/{types → pipeline}/PipelineJson/PreparationJson.d.ts +1 -1
  97. package/esm/typings/src/{types/PipelineJson/PromptTemplateJson.d.ts → pipeline/PipelineJson/PromptTaskJson.d.ts} +8 -8
  98. package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +20 -0
  99. package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +13 -0
  100. package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +11 -0
  101. package/esm/typings/src/{types → pipeline}/PipelineString.d.ts +1 -1
  102. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +3 -3
  103. package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
  104. package/esm/typings/src/prepare/prepareTasks.d.ts +32 -0
  105. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -1
  106. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -1
  107. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +2 -2
  108. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  109. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +1 -1
  110. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
  111. package/esm/typings/src/scrapers/document/register-metadata.d.ts +3 -0
  112. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
  113. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
  114. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +3 -0
  115. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  116. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
  117. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +3 -0
  118. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -1
  119. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
  120. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +3 -0
  121. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +1 -1
  122. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
  123. package/esm/typings/src/scrapers/website/register-metadata.d.ts +3 -0
  124. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +1 -0
  125. package/esm/typings/src/types/Prompt.d.ts +4 -4
  126. package/esm/typings/src/types/SectionType.d.ts +21 -0
  127. package/esm/typings/src/types/TaskProgress.d.ts +2 -2
  128. package/esm/typings/src/types/TaskType.d.ts +15 -0
  129. package/esm/typings/src/types/typeAliasEmoji.d.ts +3 -0
  130. package/esm/typings/src/types/typeAliases.d.ts +2 -1
  131. package/esm/typings/src/utils/emojis.d.ts +1 -0
  132. package/esm/typings/src/utils/expectation-counters/constants.d.ts +1 -0
  133. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
  134. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
  135. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
  136. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
  137. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  138. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
  139. package/esm/typings/src/utils/expectation-counters/index.d.ts +3 -2
  140. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -0
  141. package/esm/typings/src/utils/organization/TODO_remove_as.d.ts +6 -0
  142. package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +2 -2
  143. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +1 -1
  144. package/esm/typings/src/version.d.ts +2 -1
  145. package/package.json +5 -4
  146. package/umd/index.umd.js +268 -249
  147. package/umd/index.umd.js.map +1 -1
  148. package/esm/typings/src/commands/TEMPLATE/TemplateCommand.d.ts +0 -11
  149. package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +0 -15
  150. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +0 -15
  151. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +0 -27
  152. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +0 -30
  153. package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +0 -15
  154. package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +0 -22
  155. package/esm/typings/src/pipeline/pipeline-interface/constants.d.ts +0 -9
  156. package/esm/typings/src/prepare/prepareTemplates.d.ts +0 -32
  157. package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +0 -13
  158. package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +0 -39
  159. package/esm/typings/src/types/PipelineJson/ScriptTemplateJson.d.ts +0 -20
  160. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +0 -13
  161. package/esm/typings/src/types/PipelineJson/TemplateJson.d.ts +0 -11
  162. /package/esm/typings/src/commands/{TEMPLATE/templateCommand.test.d.ts → SECTION/sectionCommand.test.d.ts} +0 -0
  163. /package/esm/typings/src/conversion/utils/{extractParameterNamesFromTemplate.test.d.ts → extractParameterNamesFromTask.test.d.ts} +0 -0
  164. /package/esm/typings/src/{types → execution}/execution-report/ExecutionReportString.d.ts +0 -0
  165. /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.d.ts +0 -0
  166. /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.test.d.ts +0 -0
  167. /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-3';
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:"./books/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:"./books/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:"./books/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:"./books/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';
@@ -250,7 +251,7 @@
250
251
  return isInput;
251
252
  })), _h = _g.next(); !_h.done; _h = _g.next()) {
252
253
  var parameter = _h.value;
253
- commands.push("INPUT PARAMETER ".concat(templateParameterJsonToString(parameter)));
254
+ commands.push("INPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
254
255
  }
255
256
  }
256
257
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -266,7 +267,7 @@
266
267
  return isOutput;
267
268
  })), _k = _j.next(); !_k.done; _k = _j.next()) {
268
269
  var parameter = _k.value;
269
- commands.push("OUTPUT PARAMETER ".concat(templateParameterJsonToString(parameter)));
270
+ commands.push("OUTPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
270
271
  }
271
272
  }
272
273
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -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 task = tasks_1_1.value;
284
285
  var
285
286
  /* Note: Not using:> name, */
286
- title_1 = template.title, description_1 = template.description,
287
+ title_1 = task.title, description_1 = task.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 = task.jokerParameterNames, taskType = task.taskType, content = task.content, postprocessing = task.postprocessingFunctionNames, expectations = task.expectations, format = task.format, resultingParameterName = task.resultingParameterName;
289
290
  pipelineString += '\n\n';
290
291
  pipelineString += "## ".concat(title_1);
291
292
  if (description_1) {
@@ -294,10 +295,11 @@
294
295
  }
295
296
  var commands_1 = [];
296
297
  var contentLanguage = 'text';
297
- if (templateType === 'PROMPT_TEMPLATE') {
298
- var modelRequirements = template.modelRequirements;
298
+ if (taskType === 'PROMPT_TASK') {
299
+ var modelRequirements = task.modelRequirements;
299
300
  var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
300
- commands_1.push("EXECUTE PROMPT TEMPLATE");
301
+ // Note: Do nothing, it is default
302
+ // commands.push(`PROMPT`);
301
303
  if (modelVariant) {
302
304
  commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
303
305
  }
@@ -305,21 +307,21 @@
305
307
  commands_1.push("MODEL NAME `".concat(modelName, "`"));
306
308
  }
307
309
  }
308
- else if (templateType === 'SIMPLE_TEMPLATE') {
310
+ else if (taskType === 'SIMPLE_TASK') {
309
311
  commands_1.push("SIMPLE TEMPLATE");
310
312
  // Note: Nothing special here
311
313
  }
312
- else if (templateType === 'SCRIPT_TEMPLATE') {
313
- commands_1.push("SCRIPT TEMPLATE");
314
- if (template.contentLanguage) {
315
- contentLanguage = template.contentLanguage;
314
+ else if (taskType === 'SCRIPT_TASK') {
315
+ commands_1.push("SCRIPT");
316
+ if (task.contentLanguage) {
317
+ contentLanguage = task.contentLanguage;
316
318
  }
317
319
  else {
318
320
  contentLanguage = '';
319
321
  }
320
322
  }
321
- else if (templateType === 'DIALOG_TEMPLATE') {
322
- commands_1.push("DIALOG TEMPLATE");
323
+ else if (taskType === 'DIALOG_TASK') {
324
+ commands_1.push("DIALOG");
323
325
  // Note: Nothing special here
324
326
  } // <- }else if([🅱]
325
327
  if (jokers) {
@@ -394,13 +396,13 @@
394
396
  pipelineString += '\n';
395
397
  pipelineString += '```';
396
398
  pipelineString += '\n\n';
397
- pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use templateParameterJsonToString
399
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
398
400
  }
399
401
  }
400
402
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
401
403
  finally {
402
404
  try {
403
- if (templates_1_1 && !templates_1_1.done && (_c = templates_1.return)) _c.call(templates_1);
405
+ if (tasks_1_1 && !tasks_1_1.done && (_c = tasks_1.return)) _c.call(tasks_1);
404
406
  }
405
407
  finally { if (e_3) throw e_3.error; }
406
408
  }
@@ -409,8 +411,8 @@
409
411
  /**
410
412
  * @private internal utility of `pipelineJsonToString`
411
413
  */
412
- function templateParameterJsonToString(templateParameterJson) {
413
- var name = templateParameterJson.name, description = templateParameterJson.description;
414
+ function taskParameterJsonToString(taskParameterJson) {
415
+ var name = taskParameterJson.name, description = taskParameterJson.description;
414
416
  var parameterString = "{".concat(name, "}");
415
417
  if (description) {
416
418
  parameterString = "".concat(parameterString, " ").concat(description);
@@ -418,7 +420,7 @@
418
420
  return parameterString;
419
421
  }
420
422
  /**
421
- * TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `templateParameterJsonToString` , use `stringifyCommand`
423
+ * TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `taskParameterJsonToString` , use `stringifyCommand`
422
424
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
423
425
  * TODO: [🏛] Maybe make some markdown builder
424
426
  * TODO: [🏛] Escape all
@@ -727,6 +729,7 @@
727
729
  true);
728
730
  /**
729
731
  * TODO: Extract `constants.ts` from `config.ts`
732
+ * Note: [💞] Ignore a discrepancy between file name and entity name
730
733
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
731
734
  */
732
735
 
@@ -982,9 +985,9 @@
982
985
  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
986
  }
984
987
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
985
- if (!Array.isArray(pipeline.templates)) {
988
+ if (!Array.isArray(pipeline.tasks)) {
986
989
  // 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 "); }));
990
+ 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
991
  }
989
992
  var _loop_1 = function (parameter) {
990
993
  if (parameter.isInput && parameter.isOutput) {
@@ -993,13 +996,12 @@
993
996
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
994
997
  if (!parameter.isInput &&
995
998
  !parameter.isOutput &&
996
- !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
999
+ !pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
997
1000
  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
1001
  }
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 "); }));
1002
+ // Note: Testing that parameter is either input or result of some task
1003
+ if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
1004
+ 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
1005
  }
1004
1006
  };
1005
1007
  try {
@@ -1016,7 +1018,7 @@
1016
1018
  }
1017
1019
  finally { if (e_1) throw e_1.error; }
1018
1020
  }
1019
- // Note: All input parameters are defined - so that they can be used as result of some template
1021
+ // Note: All input parameters are defined - so that they can be used as result of some task
1020
1022
  var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
1021
1023
  var isInput = _a.isInput;
1022
1024
  return isInput;
@@ -1024,27 +1026,27 @@
1024
1026
  var name = _a.name;
1025
1027
  return name;
1026
1028
  }));
1027
- var _loop_2 = function (template) {
1029
+ var _loop_2 = function (task) {
1028
1030
  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 "); }));
1031
+ if (definedParameters.has(task.resultingParameterName)) {
1032
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1031
1033
  }
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 "); }));
1034
+ if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
1035
+ 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
1036
  }
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 "); }));
1037
+ definedParameters.add(task.resultingParameterName);
1038
+ if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
1039
+ if (!task.format &&
1040
+ !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
1041
+ 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
1042
  }
1041
1043
  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 "); }));
1044
+ if (!task.dependentParameterNames.includes(joker)) {
1045
+ 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
1046
  }
1045
1047
  };
1046
1048
  try {
1047
- for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1049
+ for (var _k = (e_4 = void 0, __values(task.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
1048
1050
  var joker = _l.value;
1049
1051
  _loop_4(joker);
1050
1052
  }
@@ -1057,7 +1059,7 @@
1057
1059
  finally { if (e_4) throw e_4.error; }
1058
1060
  }
1059
1061
  }
1060
- if (template.expectations) {
1062
+ if (task.expectations) {
1061
1063
  var _loop_5 = function (unit, min, max) {
1062
1064
  if (min !== undefined && max !== undefined && min > max) {
1063
1065
  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 +1072,7 @@
1070
1072
  }
1071
1073
  };
1072
1074
  try {
1073
- for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1075
+ for (var _m = (e_5 = void 0, __values(Object.entries(task.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
1074
1076
  var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
1075
1077
  _loop_5(unit, min, max);
1076
1078
  }
@@ -1085,10 +1087,10 @@
1085
1087
  }
1086
1088
  };
1087
1089
  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);
1090
+ // Note: Checking each task individually
1091
+ for (var _f = __values(pipeline.tasks), _g = _f.next(); !_g.done; _g = _f.next()) {
1092
+ var task = _g.value;
1093
+ _loop_2(task);
1092
1094
  }
1093
1095
  }
1094
1096
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1122,20 +1124,20 @@
1122
1124
  }
1123
1125
  finally { if (e_3) throw e_3.error; }
1124
1126
  }
1125
- var unresovedTemplates = __spreadArray([], __read(pipeline.templates), false);
1127
+ var unresovedTasks = __spreadArray([], __read(pipeline.tasks), false);
1126
1128
  var loopLimit = LOOP_LIMIT;
1127
1129
  var _loop_3 = function () {
1128
1130
  if (loopLimit-- < 0) {
1129
1131
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
1130
1132
  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
1133
  }
1132
- var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
1133
- return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1134
+ var currentlyResovedTasks = unresovedTasks.filter(function (task) {
1135
+ return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
1134
1136
  });
1135
- if (currentlyResovedTemplates.length === 0) {
1137
+ if (currentlyResovedTasks.length === 0) {
1136
1138
  throw new PipelineLogicError(
1137
1139
  // TODO: [🐎] DRY
1138
- spaceTrim.spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates
1140
+ spaceTrim.spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks
1139
1141
  .map(function (_a) {
1140
1142
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
1141
1143
  return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
@@ -1154,13 +1156,13 @@
1154
1156
  .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1155
1157
  .join('\n')), "\n\n\n "); }));
1156
1158
  }
1157
- resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1159
+ resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTasks.map(function (_a) {
1158
1160
  var resultingParameterName = _a.resultingParameterName;
1159
1161
  return resultingParameterName;
1160
1162
  })), false);
1161
- unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
1163
+ unresovedTasks = unresovedTasks.filter(function (task) { return !currentlyResovedTasks.includes(task); });
1162
1164
  };
1163
- while (unresovedTemplates.length > 0) {
1165
+ while (unresovedTasks.length > 0) {
1164
1166
  _loop_3();
1165
1167
  }
1166
1168
  // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
@@ -1220,9 +1222,9 @@
1220
1222
  }(Error));
1221
1223
 
1222
1224
  /**
1223
- * Parses the template and returns the list of all parameter names
1225
+ * Parses the task and returns the list of all parameter names
1224
1226
  *
1225
- * @param template the template with parameters in {curly} braces
1227
+ * @param template the string template with parameters in {curly} braces
1226
1228
  * @returns the list of parameter names
1227
1229
  * @public exported from `@promptbook/utils`
1228
1230
  */
@@ -1253,18 +1255,18 @@
1253
1255
  * @public exported from `@promptbook/core`
1254
1256
  */
1255
1257
  function unpreparePipeline(pipeline) {
1256
- var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, templates = pipeline.templates;
1258
+ var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
1257
1259
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
1258
1260
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
1259
- templates = templates.map(function (template) {
1260
- var dependentParameterNames = template.dependentParameterNames;
1261
- var parameterNames = extractParameterNames(template.preparedContent || '');
1261
+ tasks = tasks.map(function (task) {
1262
+ var dependentParameterNames = task.dependentParameterNames;
1263
+ var parameterNames = extractParameterNames(task.preparedContent || '');
1262
1264
  dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
1263
- var templateUnprepared = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames });
1264
- delete templateUnprepared.preparedContent;
1265
- return templateUnprepared;
1265
+ var taskUnprepared = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames });
1266
+ delete taskUnprepared.preparedContent;
1267
+ return taskUnprepared;
1266
1268
  });
1267
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { templates: templates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1269
+ return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1268
1270
  }
1269
1271
  /**
1270
1272
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -1696,6 +1698,9 @@
1696
1698
  normalizedName = normalizedName.replace(/-$/, '');
1697
1699
  return normalizedName;
1698
1700
  }
1701
+ /**
1702
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1703
+ */
1699
1704
 
1700
1705
  /**
1701
1706
  * Removes emojis from a string and fix whitespaces
@@ -1881,6 +1886,9 @@
1881
1886
  UnexpectedError: UnexpectedError,
1882
1887
  // TODO: [🪑]> VersionMismatchError,
1883
1888
  };
1889
+ /**
1890
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1891
+ */
1884
1892
 
1885
1893
  /**
1886
1894
  * Deserializes the error object
@@ -1942,8 +1950,8 @@
1942
1950
  return false;
1943
1951
  }
1944
1952
  /*
1945
- TODO: [🧠][🍫] `templates` can not be determined if they are fully prepared SO ignoring them
1946
- > if (!pipeline.templates.every(({ preparedContent }) => preparedContent === undefined)) {
1953
+ TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
1954
+ > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
1947
1955
  > return false;
1948
1956
  > }
1949
1957
  */
@@ -1954,9 +1962,9 @@
1954
1962
  * TODO: [🐠] Maybe base this on `makeValidator`
1955
1963
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
1956
1964
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
1957
- * - [🏍] ? Is context in each template
1965
+ * - [🏍] ? Is context in each task
1958
1966
  * - [♨] Are examples prepared
1959
- * - [♨] Are templates prepared
1967
+ * - [♨] Are tasks prepared
1960
1968
  */
1961
1969
 
1962
1970
  /**
@@ -2104,6 +2112,9 @@
2104
2112
  pagesCount: { value: 0, isUncertain: true },
2105
2113
  },
2106
2114
  });
2115
+ /**
2116
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2117
+ */
2107
2118
 
2108
2119
  /**
2109
2120
  * @@@
@@ -3290,7 +3301,7 @@
3290
3301
  */
3291
3302
  function clonePipeline(pipeline) {
3292
3303
  // 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;
3304
+ 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
3305
  return {
3295
3306
  pipelineUrl: pipelineUrl,
3296
3307
  sourceFile: sourceFile,
@@ -3299,7 +3310,7 @@
3299
3310
  description: description,
3300
3311
  formfactorName: formfactorName,
3301
3312
  parameters: parameters,
3302
- templates: templates,
3313
+ tasks: tasks,
3303
3314
  knowledgeSources: knowledgeSources,
3304
3315
  knowledgePieces: knowledgePieces,
3305
3316
  personas: personas,
@@ -3315,20 +3326,20 @@
3315
3326
  *
3316
3327
  * @public exported from `@promptbook/core`
3317
3328
  */
3318
- function prepareTemplates(pipeline, tools, options) {
3329
+ function prepareTasks(pipeline, tools, options) {
3319
3330
  return __awaiter(this, void 0, void 0, function () {
3320
- var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
3331
+ var _a, maxParallelCount, tasks, knowledgePiecesCount, tasksPrepared;
3321
3332
  var _this = this;
3322
3333
  return __generator(this, function (_b) {
3323
3334
  switch (_b.label) {
3324
3335
  case 0:
3325
3336
  _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 () {
3329
- var dependentParameterNames, preparedContent, preparedTemplate;
3337
+ tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3338
+ tasksPrepared = new Array(tasks.length);
3339
+ return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (task, index) { return __awaiter(_this, void 0, void 0, function () {
3340
+ var dependentParameterNames, preparedContent, preparedTask;
3330
3341
  return __generator(this, function (_a) {
3331
- dependentParameterNames = template.dependentParameterNames;
3342
+ dependentParameterNames = task.dependentParameterNames;
3332
3343
  preparedContent = undefined;
3333
3344
  if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
3334
3345
  preparedContent = spaceTrim.spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
@@ -3337,22 +3348,22 @@
3337
3348
  'knowledge',
3338
3349
  ], false);
3339
3350
  }
3340
- preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
3341
- templatesPrepared[index] = preparedTemplate;
3351
+ preparedTask = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
3352
+ tasksPrepared[index] = preparedTask;
3342
3353
  return [2 /*return*/];
3343
3354
  });
3344
3355
  }); })];
3345
3356
  case 1:
3346
3357
  _b.sent();
3347
- return [2 /*return*/, { templatesPrepared: templatesPrepared }];
3358
+ return [2 /*return*/, { tasksPrepared: tasksPrepared }];
3348
3359
  }
3349
3360
  });
3350
3361
  });
3351
3362
  }
3352
3363
  /**
3353
- * TODO: [🧠] Add context to each template (if missing)
3354
- * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
3355
- * TODO: [♨][main] !!! Prepare index the examples and maybe templates
3364
+ * TODO: [🧠] Add context to each task (if missing)
3365
+ * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
3366
+ * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
3356
3367
  * TODO: Write tests for `preparePipeline`
3357
3368
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3358
3369
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -3369,12 +3380,12 @@
3369
3380
  */
3370
3381
  function preparePipeline(pipeline, tools, options) {
3371
3382
  return __awaiter(this, void 0, void 0, function () {
3372
- var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, templates,
3383
+ var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, tasks,
3373
3384
  /*
3374
3385
  <- TODO: [🧠][🪑] `promptbookVersion` */
3375
3386
  knowledgeSources /*
3376
3387
  <- TODO: [🧊] `knowledgePieces` */, personas /*
3377
- <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, templatesPrepared /* TODO: parameters: parametersPrepared*/;
3388
+ <- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
3378
3389
  var _this = this;
3379
3390
  return __generator(this, function (_c) {
3380
3391
  switch (_c.label) {
@@ -3383,7 +3394,7 @@
3383
3394
  return [2 /*return*/, pipeline];
3384
3395
  }
3385
3396
  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;
3397
+ parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3387
3398
  if (tools === undefined || tools.llm === undefined) {
3388
3399
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
3389
3400
  }
@@ -3426,9 +3437,9 @@
3426
3437
  case 2:
3427
3438
  partialknowledgePiecesPrepared = _c.sent();
3428
3439
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3429
- return [4 /*yield*/, prepareTemplates({
3440
+ return [4 /*yield*/, prepareTasks({
3430
3441
  parameters: parameters,
3431
- templates: templates,
3442
+ tasks: tasks,
3432
3443
  knowledgePiecesCount: knowledgePiecesPrepared.length,
3433
3444
  }, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), {
3434
3445
  rootDirname: rootDirname,
@@ -3436,12 +3447,12 @@
3436
3447
  isVerbose: isVerbose,
3437
3448
  })];
3438
3449
  case 3:
3439
- templatesPrepared = (_c.sent()).templatesPrepared;
3440
- // ----- /Templates preparation -----
3450
+ tasksPrepared = (_c.sent()).tasksPrepared;
3451
+ // ----- /Tasks preparation -----
3441
3452
  // Note: Count total usage
3442
3453
  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`
3454
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
3455
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3445
3456
  knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
3446
3457
  }
3447
3458
  });
@@ -3506,16 +3517,16 @@
3506
3517
  */
3507
3518
 
3508
3519
  /**
3509
- * Parses the template and returns the set of all used parameters
3520
+ * Parses the task and returns the set of all used parameters
3510
3521
  *
3511
- * @param template the template with used parameters
3522
+ * @param task the task with used parameters
3512
3523
  * @returns the set of parameter names
3513
3524
  * @throws {ParseError} if the script is invalid
3514
3525
  * @public exported from `@promptbook/utils`
3515
3526
  */
3516
- function extractParameterNamesFromTemplate(template) {
3527
+ function extractParameterNamesFromTask(task) {
3517
3528
  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;
3529
+ var title = task.title, description = task.description, taskType = task.taskType, content = task.content, preparedContent = task.preparedContent, jokerParameterNames = task.jokerParameterNames, foreach = task.foreach;
3519
3530
  var parameterNames = new Set();
3520
3531
  try {
3521
3532
  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 +3541,7 @@
3530
3541
  }
3531
3542
  finally { if (e_1) throw e_1.error; }
3532
3543
  }
3533
- if (templateType === 'SCRIPT_TEMPLATE') {
3544
+ if (taskType === 'SCRIPT_TASK') {
3534
3545
  try {
3535
3546
  for (var _g = __values(extractVariables(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
3536
3547
  var parameterName = _h.value;
@@ -3961,6 +3972,9 @@
3961
3972
  TextFormatDefinition,
3962
3973
  CsvFormatDefinition,
3963
3974
  ];
3975
+ /**
3976
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3977
+ */
3964
3978
 
3965
3979
  /**
3966
3980
  * Maps available parameters to expected parameters
@@ -4177,7 +4191,7 @@
4177
4191
  }
4178
4192
  finally { if (e_1) throw e_1.error; }
4179
4193
  }
4180
- var replacedTemplate = template;
4194
+ var replacedTemplates = template;
4181
4195
  var match;
4182
4196
  var loopLimit = LOOP_LIMIT;
4183
4197
  var _loop_1 = function () {
@@ -4206,24 +4220,24 @@
4206
4220
  .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
4207
4221
  .join('\n');
4208
4222
  }
4209
- replacedTemplate =
4210
- replacedTemplate.substring(0, match.index + precol.length) +
4223
+ replacedTemplates =
4224
+ replacedTemplates.substring(0, match.index + precol.length) +
4211
4225
  parameterValue +
4212
- replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
4226
+ replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
4213
4227
  };
4214
4228
  while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
4215
- .exec(replacedTemplate))) {
4229
+ .exec(replacedTemplates))) {
4216
4230
  _loop_1();
4217
4231
  }
4218
4232
  // [💫] Check if there are parameters that are not closed properly
4219
- if (/{\w+$/.test(replacedTemplate)) {
4233
+ if (/{\w+$/.test(replacedTemplates)) {
4220
4234
  throw new PipelineExecutionError('Parameter is not closed');
4221
4235
  }
4222
4236
  // [💫] Check if there are parameters that are not opened properly
4223
- if (/^\w+}/.test(replacedTemplate)) {
4237
+ if (/^\w+}/.test(replacedTemplates)) {
4224
4238
  throw new PipelineExecutionError('Parameter is not opened');
4225
4239
  }
4226
- return replacedTemplate;
4240
+ return replacedTemplates;
4227
4241
  }
4228
4242
 
4229
4243
  /**
@@ -4255,6 +4269,7 @@
4255
4269
  var LINES_PER_STANDARD_PAGE = 44;
4256
4270
  /**
4257
4271
  * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
4272
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4258
4273
  */
4259
4274
 
4260
4275
  /**
@@ -4334,6 +4349,7 @@
4334
4349
  };
4335
4350
  /**
4336
4351
  * TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
4352
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4337
4353
  */
4338
4354
 
4339
4355
  /**
@@ -4382,12 +4398,12 @@
4382
4398
  */
4383
4399
  function executeAttempts(options) {
4384
4400
  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;
4401
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTaskResult, _llms, llmTools, _loop_1, attempt, state_1;
4386
4402
  return __generator(this, function (_a) {
4387
4403
  switch (_a.label) {
4388
4404
  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 = {
4405
+ 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;
4406
+ $ongoingTaskResult = {
4391
4407
  $result: null,
4392
4408
  $resultString: null,
4393
4409
  $expectError: null,
@@ -4407,52 +4423,51 @@
4407
4423
  if (isJokerAttempt && !jokerParameterName) {
4408
4424
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
4409
4425
  }
4410
- $ongoingTemplateResult.$result = null;
4411
- $ongoingTemplateResult.$resultString = null;
4412
- $ongoingTemplateResult.$expectError = null;
4426
+ $ongoingTaskResult.$result = null;
4427
+ $ongoingTaskResult.$resultString = null;
4428
+ $ongoingTaskResult.$expectError = null;
4413
4429
  if (isJokerAttempt) {
4414
4430
  if (parameters[jokerParameterName] === undefined) {
4415
4431
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
4416
4432
  // <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
4417
4433
  }
4418
4434
  else {
4419
- $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
4435
+ $ongoingTaskResult.$resultString = parameters[jokerParameterName];
4420
4436
  }
4421
4437
  }
4422
4438
  _t.label = 1;
4423
4439
  case 1:
4424
4440
  _t.trys.push([1, 43, 44, 45]);
4425
4441
  if (!!isJokerAttempt) return [3 /*break*/, 25];
4426
- _b = template.templateType;
4442
+ _b = task.taskType;
4427
4443
  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];
4444
+ case 'SIMPLE_TASK': return [3 /*break*/, 2];
4445
+ case 'PROMPT_TASK': return [3 /*break*/, 3];
4446
+ case 'SCRIPT_TASK': return [3 /*break*/, 11];
4447
+ case 'DIALOG_TASK': return [3 /*break*/, 22];
4432
4448
  }
4433
4449
  return [3 /*break*/, 24];
4434
4450
  case 2:
4435
- $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
4451
+ $ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
4436
4452
  return [3 /*break*/, 25];
4437
4453
  case 3:
4438
- modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
4439
- $ongoingTemplateResult.$prompt = {
4440
- title: template.title,
4454
+ modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
4455
+ $ongoingTaskResult.$prompt = {
4456
+ title: task.title,
4441
4457
  pipelineUrl: "".concat(preparedPipeline.pipelineUrl
4442
4458
  ? 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
4459
+ : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(task.name
4460
+ // <- TODO: Here should be maybe also subformat index to distinguish between same task with different subformat values
4445
4461
  ),
4446
4462
  parameters: parameters,
4447
4463
  content: preparedContent,
4448
4464
  modelRequirements: modelRequirements,
4449
4465
  expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
4450
4466
  var name = _a.name;
4451
- return name === template.personaName;
4452
- }) ||
4453
- {})), template.expectations),
4454
- format: template.format,
4455
- postprocessingFunctionNames: template.postprocessingFunctionNames,
4467
+ return name === task.personaName;
4468
+ }) || {})), task.expectations),
4469
+ format: task.format,
4470
+ postprocessingFunctionNames: task.postprocessingFunctionNames,
4456
4471
  }; // <- TODO: Not very good type guard
4457
4472
  _c = modelRequirements.modelVariant;
4458
4473
  switch (_c) {
@@ -4462,36 +4477,35 @@
4462
4477
  }
4463
4478
  return [3 /*break*/, 9];
4464
4479
  case 4:
4465
- _d = $ongoingTemplateResult;
4480
+ _d = $ongoingTaskResult;
4466
4481
  return [4 /*yield*/, llmTools.callChatModel(
4467
4482
  // <- TODO: [🧁] Check that `callChatModel` is defined
4468
- $deepFreeze($ongoingTemplateResult.$prompt))];
4483
+ $deepFreeze($ongoingTaskResult.$prompt))];
4469
4484
  case 5:
4470
4485
  _d.$chatResult = _t.sent();
4471
4486
  // TODO: [🍬] Destroy chatThread
4472
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
4473
- $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
4487
+ $ongoingTaskResult.$result = $ongoingTaskResult.$chatResult;
4488
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$chatResult.content;
4474
4489
  return [3 /*break*/, 10];
4475
4490
  case 6:
4476
- _e = $ongoingTemplateResult;
4491
+ _e = $ongoingTaskResult;
4477
4492
  return [4 /*yield*/, llmTools.callCompletionModel(
4478
4493
  // <- TODO: [🧁] Check that `callCompletionModel` is defined
4479
- $deepFreeze($ongoingTemplateResult.$prompt))];
4494
+ $deepFreeze($ongoingTaskResult.$prompt))];
4480
4495
  case 7:
4481
4496
  _e.$completionResult = _t.sent();
4482
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
4483
- $ongoingTemplateResult.$resultString =
4484
- $ongoingTemplateResult.$completionResult.content;
4497
+ $ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
4498
+ $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
4485
4499
  return [3 /*break*/, 10];
4486
4500
  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 "); }));
4501
+ 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
4502
  case 10: return [3 /*break*/, 25];
4489
4503
  case 11:
4490
4504
  if (arrayableToArray(tools.script).length === 0) {
4491
4505
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
4492
4506
  }
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 "); }));
4507
+ if (!task.contentLanguage) {
4508
+ 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
4509
  }
4496
4510
  _t.label = 12;
4497
4511
  case 12:
@@ -4504,9 +4518,9 @@
4504
4518
  _t.label = 14;
4505
4519
  case 14:
4506
4520
  _t.trys.push([14, 16, , 17]);
4507
- _h = $ongoingTemplateResult;
4521
+ _h = $ongoingTaskResult;
4508
4522
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
4509
- scriptLanguage: template.contentLanguage,
4523
+ scriptLanguage: task.contentLanguage,
4510
4524
  script: preparedContent,
4511
4525
  parameters: parameters,
4512
4526
  }))];
@@ -4521,7 +4535,7 @@
4521
4535
  if (error_1 instanceof UnexpectedError) {
4522
4536
  throw error_1;
4523
4537
  }
4524
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
4538
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_1);
4525
4539
  return [3 /*break*/, 17];
4526
4540
  case 17:
4527
4541
  _g = _f.next();
@@ -4538,14 +4552,14 @@
4538
4552
  finally { if (e_1) throw e_1.error; }
4539
4553
  return [7 /*endfinally*/];
4540
4554
  case 21:
4541
- if ($ongoingTemplateResult.$resultString !== null) {
4555
+ if ($ongoingTaskResult.$resultString !== null) {
4542
4556
  return [3 /*break*/, 25];
4543
4557
  }
4544
- if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
4545
- throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
4558
+ if ($ongoingTaskResult.$scriptPipelineExecutionErrors.length === 1) {
4559
+ throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
4546
4560
  }
4547
4561
  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
4562
+ 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
4563
  .map(function (error) { return '- ' + error.message; })
4550
4564
  .join('\n\n')), "\n "); }));
4551
4565
  }
@@ -4553,27 +4567,27 @@
4553
4567
  if (tools.userInterface === undefined) {
4554
4568
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
4555
4569
  }
4556
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
4557
- _j = $ongoingTemplateResult;
4570
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
4571
+ _j = $ongoingTaskResult;
4558
4572
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
4559
- promptTitle: template.title,
4560
- promptMessage: replaceParameters(template.description || '', parameters),
4573
+ promptTitle: task.title,
4574
+ promptMessage: replaceParameters(task.description || '', parameters),
4561
4575
  defaultValue: replaceParameters(preparedContent, parameters),
4562
4576
  // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4563
4577
  placeholder: undefined,
4564
4578
  priority: priority,
4565
4579
  }))];
4566
4580
  case 23:
4567
- // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
4581
+ // TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
4568
4582
  _j.$resultString = _t.sent();
4569
4583
  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 "); }));
4584
+ case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4571
4585
  case 25:
4572
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
4586
+ if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
4573
4587
  _t.label = 26;
4574
4588
  case 26:
4575
4589
  _t.trys.push([26, 40, 41, 42]);
4576
- _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
4590
+ _k = (e_3 = void 0, __values(task.postprocessingFunctionNames)), _l = _k.next();
4577
4591
  _t.label = 27;
4578
4592
  case 27:
4579
4593
  if (!!_l.done) return [3 /*break*/, 39];
@@ -4590,13 +4604,13 @@
4590
4604
  _t.label = 30;
4591
4605
  case 30:
4592
4606
  _t.trys.push([30, 32, , 33]);
4593
- _p = $ongoingTemplateResult;
4607
+ _p = $ongoingTaskResult;
4594
4608
  return [4 /*yield*/, scriptTools.execute({
4595
4609
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
4596
4610
  script: "".concat(functionName, "(resultString)"),
4597
4611
  parameters: {
4598
- resultString: $ongoingTemplateResult.$resultString || '',
4599
- // Note: No ...parametersForTemplate, because working with result only
4612
+ resultString: $ongoingTaskResult.$resultString || '',
4613
+ // Note: No ...parametersForTask, because working with result only
4600
4614
  },
4601
4615
  })];
4602
4616
  case 31:
@@ -4612,7 +4626,7 @@
4612
4626
  throw error_2;
4613
4627
  }
4614
4628
  postprocessingError = error_2;
4615
- $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
4629
+ $ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_2);
4616
4630
  return [3 /*break*/, 33];
4617
4631
  case 33:
4618
4632
  _o = _m.next();
@@ -4649,12 +4663,12 @@
4649
4663
  return [7 /*endfinally*/];
4650
4664
  case 42:
4651
4665
  // TODO: [💝] Unite object for expecting amount and format
4652
- if (template.format) {
4653
- if (template.format === 'JSON') {
4654
- if (!isValidJsonString($ongoingTemplateResult.$resultString || '')) {
4666
+ if (task.format) {
4667
+ if (task.format === 'JSON') {
4668
+ if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
4655
4669
  // TODO: [🏢] Do more universally via `FormatDefinition`
4656
4670
  try {
4657
- $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
4671
+ $ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
4658
4672
  }
4659
4673
  catch (error) {
4660
4674
  throw new ExpectError(spaceTrim.spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
@@ -4663,12 +4677,12 @@
4663
4677
  }
4664
4678
  }
4665
4679
  else {
4666
- throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4680
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
4667
4681
  }
4668
4682
  }
4669
4683
  // TODO: [💝] Unite object for expecting amount and format
4670
- if (template.expectations) {
4671
- checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
4684
+ if (task.expectations) {
4685
+ checkExpectations(task.expectations, $ongoingTaskResult.$resultString || '');
4672
4686
  }
4673
4687
  return [2 /*return*/, "break-attempts"];
4674
4688
  case 43:
@@ -4676,38 +4690,38 @@
4676
4690
  if (!(error_3 instanceof ExpectError)) {
4677
4691
  throw error_3;
4678
4692
  }
4679
- $ongoingTemplateResult.$expectError = error_3;
4693
+ $ongoingTaskResult.$expectError = error_3;
4680
4694
  return [3 /*break*/, 45];
4681
4695
  case 44:
4682
4696
  if (!isJokerAttempt &&
4683
- template.templateType === 'PROMPT_TEMPLATE' &&
4684
- $ongoingTemplateResult.$prompt
4697
+ task.taskType === 'PROMPT_TASK' &&
4698
+ $ongoingTaskResult.$prompt
4685
4699
  // <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
4686
4700
  // In that case we don’t want to make a report about it because it’s not a llm execution error
4687
4701
  ) {
4688
- // TODO: [🧠] Maybe put other templateTypes into report
4702
+ // TODO: [🧠] Maybe put other taskTypes into report
4689
4703
  $executionReport.promptExecutions.push({
4690
- prompt: __assign({}, $ongoingTemplateResult.$prompt),
4691
- result: $ongoingTemplateResult.$result || undefined,
4692
- error: $ongoingTemplateResult.$expectError === null
4704
+ prompt: __assign({}, $ongoingTaskResult.$prompt),
4705
+ result: $ongoingTaskResult.$result || undefined,
4706
+ error: $ongoingTaskResult.$expectError === null
4693
4707
  ? undefined
4694
- : serializeError($ongoingTemplateResult.$expectError),
4708
+ : serializeError($ongoingTaskResult.$expectError),
4695
4709
  });
4696
4710
  }
4697
4711
  return [7 /*endfinally*/];
4698
4712
  case 45:
4699
- if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
4713
+ if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
4700
4714
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) {
4701
4715
  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) || '')
4716
+ 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
4717
  .split('\n')
4704
4718
  .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) || '')
4719
+ .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
4720
  .split('\n')
4707
4721
  .map(function (line) { return "> ".concat(line); })
4708
- .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
4722
+ .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTaskResult.$resultString === null
4709
4723
  ? 'null'
4710
- : $ongoingTemplateResult.$resultString
4724
+ : $ongoingTaskResult.$resultString
4711
4725
  .split('\n')
4712
4726
  .map(function (line) { return "> ".concat(line); })
4713
4727
  .join('\n')), "\n ---\n ");
@@ -4732,10 +4746,10 @@
4732
4746
  attempt++;
4733
4747
  return [3 /*break*/, 1];
4734
4748
  case 4:
4735
- if ($ongoingTemplateResult.$resultString === null) {
4749
+ if ($ongoingTaskResult.$resultString === null) {
4736
4750
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
4737
4751
  }
4738
- return [2 /*return*/, $ongoingTemplateResult.$resultString];
4752
+ return [2 /*return*/, $ongoingTaskResult.$resultString];
4739
4753
  }
4740
4754
  });
4741
4755
  });
@@ -4751,36 +4765,36 @@
4751
4765
  */
4752
4766
  function executeFormatSubvalues(options) {
4753
4767
  return __awaiter(this, void 0, void 0, function () {
4754
- var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
4768
+ var task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
4755
4769
  var _this = this;
4756
4770
  return __generator(this, function (_a) {
4757
4771
  switch (_a.label) {
4758
4772
  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) {
4773
+ task = options.task, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
4774
+ if (task.foreach === undefined) {
4761
4775
  return [2 /*return*/, /* not await */ executeAttempts(options)];
4762
4776
  }
4763
4777
  if (jokerParameterNames.length !== 0) {
4764
4778
  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
4779
  }
4766
- parameterValue = parameters[template.foreach.parameterName] || '';
4780
+ parameterValue = parameters[task.foreach.parameterName] || '';
4767
4781
  formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
4768
- return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(template.foreach.formatName);
4782
+ return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(task.foreach.formatName);
4769
4783
  });
4770
4784
  if (formatDefinition === undefined) {
4771
4785
  throw new UnexpectedError(
4772
4786
  // <- 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; })
4787
+ 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
4788
  .map(function (formatName) { return "- ".concat(formatName); })
4775
4789
  .join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
4776
4790
  }
4777
4791
  subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
4778
- return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(template.foreach.subformatName);
4792
+ return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(task.foreach.subformatName);
4779
4793
  });
4780
4794
  if (subvalueDefinition === undefined) {
4781
4795
  throw new UnexpectedError(
4782
4796
  // <- 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
4797
+ 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
4798
  .map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
4785
4799
  .map(function (subvalueName) { return "- ".concat(subvalueName); })
4786
4800
  .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 +4803,7 @@
4789
4803
  formatSettings = csvSettings;
4790
4804
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
4791
4805
  }
4792
- return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
4806
+ return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
4793
4807
  var mappedParameters, allSubparameters, subresultString;
4794
4808
  return __generator(this, function (_a) {
4795
4809
  switch (_a.label) {
@@ -4798,7 +4812,7 @@
4798
4812
  // TODO: When done [🐚] Report progress also for each subvalue here
4799
4813
  try {
4800
4814
  mappedParameters = mapAvailableToExpectedParameters({
4801
- expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
4815
+ expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
4802
4816
  availableParameters: subparameters,
4803
4817
  });
4804
4818
  }
@@ -4831,7 +4845,7 @@
4831
4845
  *
4832
4846
  * @private internal utility of `createPipelineExecutor`
4833
4847
  */
4834
- function getContextForTemplate(template) {
4848
+ function getContextForTask(task) {
4835
4849
  return __awaiter(this, void 0, void 0, function () {
4836
4850
  return __generator(this, function (_a) {
4837
4851
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
@@ -4844,15 +4858,10 @@
4844
4858
  *
4845
4859
  * @private internal utility of `createPipelineExecutor`
4846
4860
  */
4847
- function getKnowledgeForTemplate(options) {
4861
+ function getExamplesForTask(task) {
4848
4862
  return __awaiter(this, void 0, void 0, function () {
4849
- var preparedPipeline;
4850
4863
  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')];
4864
+ return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4856
4865
  });
4857
4866
  });
4858
4867
  }
@@ -4862,10 +4871,15 @@
4862
4871
  *
4863
4872
  * @private internal utility of `createPipelineExecutor`
4864
4873
  */
4865
- function getExamplesForTemplate(template) {
4874
+ function getKnowledgeForTask(options) {
4866
4875
  return __awaiter(this, void 0, void 0, function () {
4876
+ var preparedPipeline;
4867
4877
  return __generator(this, function (_a) {
4868
- return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4878
+ preparedPipeline = options.preparedPipeline, options.task;
4879
+ return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4880
+ var content = _a.content;
4881
+ return "- ".concat(content);
4882
+ }).join('\n')];
4869
4883
  });
4870
4884
  });
4871
4885
  }
@@ -4875,21 +4889,21 @@
4875
4889
  *
4876
4890
  * @private internal utility of `createPipelineExecutor`
4877
4891
  */
4878
- function getReservedParametersForTemplate(options) {
4892
+ function getReservedParametersForTask(options) {
4879
4893
  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;
4894
+ var preparedPipeline, task, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
4881
4895
  var e_1, _a;
4882
4896
  return __generator(this, function (_b) {
4883
4897
  switch (_b.label) {
4884
4898
  case 0:
4885
- preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
4886
- return [4 /*yield*/, getContextForTemplate()];
4899
+ preparedPipeline = options.preparedPipeline, task = options.task, pipelineIdentification = options.pipelineIdentification;
4900
+ return [4 /*yield*/, getContextForTask()];
4887
4901
  case 1:
4888
4902
  context = _b.sent();
4889
- return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
4903
+ return [4 /*yield*/, getKnowledgeForTask({ preparedPipeline: preparedPipeline, task: task })];
4890
4904
  case 2:
4891
4905
  knowledge = _b.sent();
4892
- return [4 /*yield*/, getExamplesForTemplate()];
4906
+ return [4 /*yield*/, getExamplesForTask()];
4893
4907
  case 3:
4894
4908
  examples = _b.sent();
4895
4909
  currentDate = new Date().toISOString();
@@ -4932,31 +4946,31 @@
4932
4946
  *
4933
4947
  * @private internal utility of `createPipelineExecutor`
4934
4948
  */
4935
- function executeTemplate(options) {
4949
+ function executeTask(options) {
4936
4950
  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;
4951
+ 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
4952
  var e_1, _g, _h;
4939
4953
  return __generator(this, function (_j) {
4940
4954
  switch (_j.label) {
4941
4955
  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);
4956
+ 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;
4957
+ name = "pipeline-executor-frame-".concat(currentTask.name);
4958
+ title = currentTask.title;
4959
+ priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
4946
4960
  return [4 /*yield*/, onProgress({
4947
4961
  name: name,
4948
4962
  title: title,
4949
4963
  isStarted: false,
4950
4964
  isDone: false,
4951
- templateType: currentTemplate.templateType,
4952
- parameterName: currentTemplate.resultingParameterName,
4965
+ taskType: currentTask.taskType,
4966
+ parameterName: currentTask.resultingParameterName,
4953
4967
  parameterValue: null,
4954
4968
  // <- [🍸]
4955
4969
  })];
4956
4970
  case 1:
4957
4971
  _j.sent();
4958
- usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
4959
- dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
4972
+ usedParameterNames = extractParameterNamesFromTask(currentTask);
4973
+ dependentParameterNames = new Set(currentTask.dependentParameterNames);
4960
4974
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4961
4975
  if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
4962
4976
  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 +4981,9 @@
4967
4981
  }
4968
4982
  _c = (_b = Object).freeze;
4969
4983
  _d = [{}];
4970
- return [4 /*yield*/, getReservedParametersForTemplate({
4984
+ return [4 /*yield*/, getReservedParametersForTask({
4971
4985
  preparedPipeline: preparedPipeline,
4972
- template: currentTemplate,
4986
+ task: currentTask,
4973
4987
  pipelineIdentification: pipelineIdentification,
4974
4988
  })];
4975
4989
  case 2:
@@ -4987,11 +5001,11 @@
4987
5001
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4988
5002
  // Houston, we have a problem
4989
5003
  // 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 "); }));
5004
+ 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
5005
  }
4992
5006
  };
4993
5007
  try {
4994
- // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
5008
+ // Note: [2] Check that all used parameters are defined and removing unused parameters for this task
4995
5009
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4996
5010
  for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4997
5011
  parameterName = _f.value;
@@ -5007,18 +5021,16 @@
5007
5021
  }
5008
5022
  // 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
5023
  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);
5024
+ maxAttempts = currentTask.taskType === 'DIALOG_TASK' ? Infinity : maxExecutionAttempts;
5025
+ jokerParameterNames = currentTask.jokerParameterNames || [];
5026
+ preparedContent = (currentTask.preparedContent || '{content}').split('{content}').join(currentTask.content);
5015
5027
  return [4 /*yield*/, executeFormatSubvalues({
5016
5028
  jokerParameterNames: jokerParameterNames,
5017
5029
  priority: priority,
5018
5030
  maxAttempts: maxAttempts,
5019
5031
  preparedContent: preparedContent,
5020
5032
  parameters: parameters,
5021
- template: currentTemplate,
5033
+ task: currentTask,
5022
5034
  preparedPipeline: preparedPipeline,
5023
5035
  tools: tools,
5024
5036
  $executionReport: $executionReport,
@@ -5031,15 +5043,15 @@
5031
5043
  title: title,
5032
5044
  isStarted: true,
5033
5045
  isDone: true,
5034
- templateType: currentTemplate.templateType,
5035
- parameterName: currentTemplate.resultingParameterName,
5046
+ taskType: currentTask.taskType,
5047
+ parameterName: currentTask.resultingParameterName,
5036
5048
  parameterValue: resultString,
5037
5049
  // <- [🍸]
5038
5050
  })];
5039
5051
  case 4:
5040
5052
  _j.sent();
5041
5053
  return [2 /*return*/, Object.freeze((_h = {},
5042
- _h[currentTemplate.resultingParameterName] =
5054
+ _h[currentTask.resultingParameterName] =
5043
5055
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
5044
5056
  resultString,
5045
5057
  _h))];
@@ -5101,7 +5113,7 @@
5101
5113
  */
5102
5114
  function executePipeline(options) {
5103
5115
  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;
5116
+ 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
5117
  var e_1, _f, e_2, _g;
5106
5118
  return __generator(this, function (_h) {
5107
5119
  switch (_h.label) {
@@ -5255,11 +5267,11 @@
5255
5267
  var name = _a.name;
5256
5268
  return name;
5257
5269
  });
5258
- unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.templates), false);
5270
+ unresovedTasks_1 = __spreadArray([], __read(preparedPipeline.tasks), false);
5259
5271
  resolving_1 = [];
5260
5272
  loopLimit = LOOP_LIMIT;
5261
5273
  _loop_2 = function () {
5262
- var currentTemplate, work_1;
5274
+ var currentTask, work_1;
5263
5275
  return __generator(this, function (_k) {
5264
5276
  switch (_k.label) {
5265
5277
  case 0:
@@ -5267,15 +5279,15 @@
5267
5279
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
5268
5280
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
5269
5281
  }
5270
- currentTemplate = unresovedTemplates_1.find(function (template) {
5271
- return template.dependentParameterNames.every(function (name) {
5282
+ currentTask = unresovedTasks_1.find(function (task) {
5283
+ return task.dependentParameterNames.every(function (name) {
5272
5284
  return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
5273
5285
  });
5274
5286
  });
5275
- if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
5287
+ if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
5276
5288
  throw new UnexpectedError(
5277
5289
  // 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
5290
+ 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
5291
  .map(function (_a) {
5280
5292
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
5281
5293
  return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
@@ -5294,14 +5306,14 @@
5294
5306
  .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5295
5307
  .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
5296
5308
  case 1:
5297
- if (!!currentTemplate) return [3 /*break*/, 3];
5309
+ if (!!currentTask) return [3 /*break*/, 3];
5298
5310
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
5299
5311
  case 2:
5300
5312
  /* [🤹‍♂️] */ _k.sent();
5301
5313
  return [3 /*break*/, 4];
5302
5314
  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) {
5315
+ unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
5316
+ work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
5305
5317
  if (isReturned) {
5306
5318
  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
5319
  .split('\n')
@@ -5311,16 +5323,16 @@
5311
5323
  if (onProgress) {
5312
5324
  onProgress(progress);
5313
5325
  }
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 "); }) }))
5326
+ }, $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
5327
  .then(function (newParametersToPass) {
5316
5328
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
5317
- resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
5329
+ resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
5318
5330
  })
5319
5331
  .then(function () {
5320
5332
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
5321
5333
  });
5322
5334
  // <- 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
5335
+ // 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
5336
  resolving_1.push(work_1);
5325
5337
  _k.label = 4;
5326
5338
  case 4: return [2 /*return*/];
@@ -5329,7 +5341,7 @@
5329
5341
  };
5330
5342
  _h.label = 21;
5331
5343
  case 21:
5332
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
5344
+ if (!(unresovedTasks_1.length > 0)) return [3 /*break*/, 23];
5333
5345
  return [5 /*yield**/, _loop_2()];
5334
5346
  case 22:
5335
5347
  _h.sent();
@@ -5487,6 +5499,9 @@
5487
5499
  * @public exported from `@promptbook/cli`
5488
5500
  */
5489
5501
  $scrapersMetadataRegister.register(markdownScraperMetadata);
5502
+ /**
5503
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5504
+ */
5490
5505
 
5491
5506
  /**
5492
5507
  * Scraper for markdown files
@@ -5681,6 +5696,9 @@
5681
5696
  * @public exported from `@promptbook/cli`
5682
5697
  */
5683
5698
  $scrapersMetadataRegister.register(pdfScraperMetadata);
5699
+ /**
5700
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5701
+ */
5684
5702
 
5685
5703
  /**
5686
5704
  * Scraper for .pdf files
@@ -5764,6 +5782,7 @@
5764
5782
  var _PdfScraperRegistration = $scrapersRegister.register(createPdfScraper);
5765
5783
  /**
5766
5784
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
5785
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5767
5786
  */
5768
5787
 
5769
5788
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;