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