@promptbook/node 0.59.0 → 0.60.0-3

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 (206) hide show
  1. package/README.md +2 -2
  2. package/esm/index.es.js +279 -280
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +23 -23
  5. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +11 -11
  7. package/esm/typings/src/_packages/utils.index.d.ts +9 -11
  8. package/esm/typings/src/config.d.ts +1 -1
  9. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +12 -0
  10. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +32 -0
  11. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +23 -0
  12. package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +1 -1
  13. package/{umd/typings/src/conversion/prettify/prettifyPromptbookString.d.ts → esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts} +2 -2
  14. package/esm/typings/src/conversion/prettify/{renderPromptbookMermaid.d.ts → renderPipelineMermaidOptions.d.ts} +4 -4
  15. package/esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
  16. package/esm/typings/src/conversion/utils/extractVariables.d.ts +1 -1
  17. package/esm/typings/src/conversion/utils/parseCommand.d.ts +2 -2
  18. package/esm/typings/src/conversion/utils/parseNumber.d.ts +1 -1
  19. package/esm/typings/src/conversion/utils/renameParameter.d.ts +4 -4
  20. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +13 -0
  21. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +27 -0
  22. package/{umd/typings/src/errors/PromptbookLibraryError.d.ts → esm/typings/src/errors/CollectionError.d.ts} +2 -2
  23. package/esm/typings/src/errors/{PromptbookExecutionError.d.ts → ExecutionError.d.ts} +2 -2
  24. package/{umd/typings/src/errors/PromptbookNotFoundError.d.ts → esm/typings/src/errors/NotFoundError.d.ts} +2 -2
  25. package/{umd/typings/src/errors/PromptbookLogicError.d.ts → esm/typings/src/errors/PipelineLogicError.d.ts} +2 -2
  26. package/{umd/typings/src/errors/PromptbookReferenceError.d.ts → esm/typings/src/errors/ReferenceError.d.ts} +2 -2
  27. package/esm/typings/src/errors/{PromptbookSyntaxError.d.ts → SyntaxError.d.ts} +2 -2
  28. package/esm/typings/src/errors/TemplateError.d.ts +1 -1
  29. package/esm/typings/src/errors/_ExpectError.d.ts +2 -2
  30. package/esm/typings/src/execution/ExecutionTools.d.ts +1 -1
  31. package/esm/typings/src/execution/LlmExecutionTools.d.ts +4 -4
  32. package/esm/typings/src/execution/PromptResult.d.ts +1 -1
  33. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -1
  34. package/esm/typings/src/execution/createPromptbookExecutor.d.ts +3 -3
  35. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -1
  36. package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  37. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  38. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
  39. package/esm/typings/src/library/PipelineCollection.d.ts +25 -0
  40. package/esm/typings/src/library/{SimplePromptbookLibrary.d.ts → SimplePipelineCollection.d.ts} +11 -11
  41. package/{umd/typings/src/library/constructors/createLibraryFromDirectory.d.ts → esm/typings/src/library/constructors/createCollectionFromDirectory.d.ts} +5 -5
  42. package/esm/typings/src/library/constructors/createCollectionFromJson.d.ts +12 -0
  43. package/esm/typings/src/library/constructors/createCollectionFromPromise.d.ts +22 -0
  44. package/esm/typings/src/library/constructors/{createLibraryFromUrl.d.ts → createCollectionFromUrl.d.ts} +5 -5
  45. package/esm/typings/src/library/constructors/createSubcollection.d.ts +12 -0
  46. package/esm/typings/src/library/libraryToJson.d.ts +5 -5
  47. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -3
  48. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -3
  49. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -2
  50. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +3 -3
  51. package/esm/typings/src/llm-providers/mocked/fakeTextToExpectations.d.ts +1 -1
  52. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -3
  53. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
  54. package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  55. package/esm/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  56. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +3 -3
  57. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +2 -2
  58. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  59. package/esm/typings/src/types/Command.d.ts +4 -4
  60. package/esm/typings/src/types/Parameters.d.ts +1 -1
  61. package/esm/typings/src/types/{PromptbookJson/PromptbookJson.d.ts → PipelineJson/PipelineJson.d.ts} +4 -4
  62. package/{umd/typings/src/types/PromptbookString.d.ts → esm/typings/src/types/PipelineString.d.ts} +3 -3
  63. package/esm/typings/src/types/Prompt.d.ts +3 -3
  64. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +2 -2
  65. package/esm/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  66. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  67. package/esm/typings/src/utils/emojis.d.ts +2 -2
  68. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
  69. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
  70. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
  71. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
  72. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  73. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
  74. package/esm/typings/src/utils/expectation-counters/index.d.ts +2 -2
  75. package/esm/typings/src/utils/formatNumber.d.ts +1 -1
  76. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -1
  77. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  78. package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  79. package/esm/typings/src/utils/markdown-json/MarkdownStructure.d.ts +1 -1
  80. package/esm/typings/src/utils/markdown-json/countMarkdownStructureDeepness.d.ts +1 -1
  81. package/esm/typings/src/utils/markdown-json/markdownToMarkdownStructure.d.ts +1 -1
  82. package/package.json +3 -3
  83. package/umd/index.umd.js +279 -280
  84. package/umd/index.umd.js.map +1 -1
  85. package/umd/typings/src/_packages/core.index.d.ts +23 -23
  86. package/umd/typings/src/_packages/node.index.d.ts +2 -2
  87. package/umd/typings/src/_packages/types.index.d.ts +11 -11
  88. package/umd/typings/src/_packages/utils.index.d.ts +9 -11
  89. package/umd/typings/src/config.d.ts +1 -1
  90. package/umd/typings/src/conversion/pipelineJsonToString.d.ts +12 -0
  91. package/umd/typings/src/conversion/pipelineStringToJson.d.ts +32 -0
  92. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +23 -0
  93. package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +1 -1
  94. package/{esm/typings/src/conversion/prettify/prettifyPromptbookString.d.ts → umd/typings/src/conversion/prettify/prettifyPipelineString.d.ts} +2 -2
  95. package/umd/typings/src/conversion/prettify/{renderPromptbookMermaid.d.ts → renderPipelineMermaidOptions.d.ts} +4 -4
  96. package/umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
  97. package/umd/typings/src/conversion/utils/extractVariables.d.ts +1 -1
  98. package/umd/typings/src/conversion/utils/parseCommand.d.ts +2 -2
  99. package/umd/typings/src/conversion/utils/parseNumber.d.ts +1 -1
  100. package/umd/typings/src/conversion/utils/renameParameter.d.ts +4 -4
  101. package/umd/typings/src/conversion/validation/_importPipeline.d.ts +13 -0
  102. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +27 -0
  103. package/{esm/typings/src/errors/PromptbookLibraryError.d.ts → umd/typings/src/errors/CollectionError.d.ts} +2 -2
  104. package/umd/typings/src/errors/{PromptbookExecutionError.d.ts → ExecutionError.d.ts} +2 -2
  105. package/{esm/typings/src/errors/PromptbookNotFoundError.d.ts → umd/typings/src/errors/NotFoundError.d.ts} +2 -2
  106. package/{esm/typings/src/errors/PromptbookLogicError.d.ts → umd/typings/src/errors/PipelineLogicError.d.ts} +2 -2
  107. package/{esm/typings/src/errors/PromptbookReferenceError.d.ts → umd/typings/src/errors/ReferenceError.d.ts} +2 -2
  108. package/umd/typings/src/errors/{PromptbookSyntaxError.d.ts → SyntaxError.d.ts} +2 -2
  109. package/umd/typings/src/errors/TemplateError.d.ts +1 -1
  110. package/umd/typings/src/errors/_ExpectError.d.ts +2 -2
  111. package/umd/typings/src/execution/ExecutionTools.d.ts +1 -1
  112. package/umd/typings/src/execution/LlmExecutionTools.d.ts +4 -4
  113. package/umd/typings/src/execution/PromptResult.d.ts +1 -1
  114. package/umd/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -1
  115. package/umd/typings/src/execution/createPromptbookExecutor.d.ts +3 -3
  116. package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -1
  117. package/umd/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  118. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  119. package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
  120. package/umd/typings/src/library/PipelineCollection.d.ts +25 -0
  121. package/umd/typings/src/library/{SimplePromptbookLibrary.d.ts → SimplePipelineCollection.d.ts} +11 -11
  122. package/{esm/typings/src/library/constructors/createLibraryFromDirectory.d.ts → umd/typings/src/library/constructors/createCollectionFromDirectory.d.ts} +5 -5
  123. package/umd/typings/src/library/constructors/createCollectionFromJson.d.ts +12 -0
  124. package/umd/typings/src/library/constructors/createCollectionFromPromise.d.ts +22 -0
  125. package/umd/typings/src/library/constructors/{createLibraryFromUrl.d.ts → createCollectionFromUrl.d.ts} +5 -5
  126. package/umd/typings/src/library/constructors/createSubcollection.d.ts +12 -0
  127. package/umd/typings/src/library/libraryToJson.d.ts +5 -5
  128. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -3
  129. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -3
  130. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -2
  131. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +3 -3
  132. package/umd/typings/src/llm-providers/mocked/fakeTextToExpectations.d.ts +1 -1
  133. package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -3
  134. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
  135. package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  136. package/umd/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  137. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +3 -3
  138. package/umd/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +2 -2
  139. package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  140. package/umd/typings/src/types/Command.d.ts +4 -4
  141. package/umd/typings/src/types/Parameters.d.ts +1 -1
  142. package/umd/typings/src/types/{PromptbookJson/PromptbookJson.d.ts → PipelineJson/PipelineJson.d.ts} +4 -4
  143. package/{esm/typings/src/types/PromptbookString.d.ts → umd/typings/src/types/PipelineString.d.ts} +3 -3
  144. package/umd/typings/src/types/Prompt.d.ts +3 -3
  145. package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +2 -2
  146. package/umd/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  147. package/umd/typings/src/types/typeAliases.d.ts +2 -2
  148. package/umd/typings/src/utils/emojis.d.ts +2 -2
  149. package/umd/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
  150. package/umd/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
  151. package/umd/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
  152. package/umd/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
  153. package/umd/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  154. package/umd/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
  155. package/umd/typings/src/utils/expectation-counters/index.d.ts +2 -2
  156. package/umd/typings/src/utils/formatNumber.d.ts +1 -1
  157. package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -1
  158. package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  159. package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  160. package/umd/typings/src/utils/markdown-json/MarkdownStructure.d.ts +1 -1
  161. package/umd/typings/src/utils/markdown-json/countMarkdownStructureDeepness.d.ts +1 -1
  162. package/umd/typings/src/utils/markdown-json/markdownToMarkdownStructure.d.ts +1 -1
  163. package/esm/typings/src/conversion/promptbookJsonToString.d.ts +0 -12
  164. package/esm/typings/src/conversion/promptbookStringToJson.d.ts +0 -32
  165. package/esm/typings/src/conversion/promptbookStringToJsonSync.d.ts +0 -23
  166. package/esm/typings/src/conversion/validation/_importPromptbook.d.ts +0 -13
  167. package/esm/typings/src/conversion/validation/validatePromptbook.d.ts +0 -27
  168. package/esm/typings/src/library/PromptbookLibrary.d.ts +0 -25
  169. package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +0 -12
  170. package/esm/typings/src/library/constructors/createLibraryFromPromise.d.ts +0 -22
  171. package/esm/typings/src/library/constructors/createSublibrary.d.ts +0 -12
  172. package/umd/typings/src/conversion/promptbookJsonToString.d.ts +0 -12
  173. package/umd/typings/src/conversion/promptbookStringToJson.d.ts +0 -32
  174. package/umd/typings/src/conversion/promptbookStringToJsonSync.d.ts +0 -23
  175. package/umd/typings/src/conversion/validation/_importPromptbook.d.ts +0 -13
  176. package/umd/typings/src/conversion/validation/validatePromptbook.d.ts +0 -27
  177. package/umd/typings/src/library/PromptbookLibrary.d.ts +0 -25
  178. package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +0 -12
  179. package/umd/typings/src/library/constructors/createLibraryFromPromise.d.ts +0 -22
  180. package/umd/typings/src/library/constructors/createSublibrary.d.ts +0 -12
  181. /package/esm/typings/{promptbook-library → promptbook-collection}/index.d.ts +0 -0
  182. /package/esm/typings/src/conversion/{promptbookStringToJson.test.d.ts → pipelineStringToJson.test.d.ts} +0 -0
  183. /package/esm/typings/src/conversion/{promptbookStringToJsonSync.test.d.ts → pipelineStringToJsonSync.test.d.ts} +0 -0
  184. /package/esm/typings/src/conversion/validation/{promptbookStringToJson-syntaxErrors.test.d.ts → pipelineStringToJson-syntaxErrors.test.d.ts} +0 -0
  185. /package/esm/typings/src/conversion/validation/{validatePromptbook-logicErrors.test.d.ts → validatePipeline-logicErrors.test.d.ts} +0 -0
  186. /package/esm/typings/src/conversion/validation/{validatePromptbook.test.d.ts → validatePipeline.test.d.ts} +0 -0
  187. /package/esm/typings/src/library/constructors/{createLibraryFromDirectory.test.d.ts → createCollectionFromDirectory.test.d.ts} +0 -0
  188. /package/esm/typings/src/library/constructors/{createLibraryFromJson.test.d.ts → createCollectionFromJson.test.d.ts} +0 -0
  189. /package/esm/typings/src/library/constructors/{createLibraryFromPromise.test.d.ts → createCollectionFromPromise.test.d.ts} +0 -0
  190. /package/esm/typings/src/types/{PromptbookJson → PipelineJson}/KnowledgeJson.d.ts +0 -0
  191. /package/esm/typings/src/types/{PromptbookJson → PipelineJson}/MaterialKnowledgePieceJson.d.ts +0 -0
  192. /package/esm/typings/src/types/{PromptbookJson → PipelineJson}/PromptTemplateJson.d.ts +0 -0
  193. /package/esm/typings/src/types/{PromptbookJson → PipelineJson}/PromptTemplateParameterJson.d.ts +0 -0
  194. /package/umd/typings/{promptbook-library → promptbook-collection}/index.d.ts +0 -0
  195. /package/umd/typings/src/conversion/{promptbookStringToJson.test.d.ts → pipelineStringToJson.test.d.ts} +0 -0
  196. /package/umd/typings/src/conversion/{promptbookStringToJsonSync.test.d.ts → pipelineStringToJsonSync.test.d.ts} +0 -0
  197. /package/umd/typings/src/conversion/validation/{promptbookStringToJson-syntaxErrors.test.d.ts → pipelineStringToJson-syntaxErrors.test.d.ts} +0 -0
  198. /package/umd/typings/src/conversion/validation/{validatePromptbook-logicErrors.test.d.ts → validatePipeline-logicErrors.test.d.ts} +0 -0
  199. /package/umd/typings/src/conversion/validation/{validatePromptbook.test.d.ts → validatePipeline.test.d.ts} +0 -0
  200. /package/umd/typings/src/library/constructors/{createLibraryFromDirectory.test.d.ts → createCollectionFromDirectory.test.d.ts} +0 -0
  201. /package/umd/typings/src/library/constructors/{createLibraryFromJson.test.d.ts → createCollectionFromJson.test.d.ts} +0 -0
  202. /package/umd/typings/src/library/constructors/{createLibraryFromPromise.test.d.ts → createCollectionFromPromise.test.d.ts} +0 -0
  203. /package/umd/typings/src/types/{PromptbookJson → PipelineJson}/KnowledgeJson.d.ts +0 -0
  204. /package/umd/typings/src/types/{PromptbookJson → PipelineJson}/MaterialKnowledgePieceJson.d.ts +0 -0
  205. /package/umd/typings/src/types/{PromptbookJson → PipelineJson}/PromptTemplateJson.d.ts +0 -0
  206. /package/umd/typings/src/types/{PromptbookJson → PipelineJson}/PromptTemplateParameterJson.d.ts +0 -0
package/umd/index.umd.js CHANGED
@@ -134,31 +134,31 @@
134
134
  */
135
135
  var LOOP_LIMIT = 1000;
136
136
  /**
137
- * The name of the builded promptbook library made by CLI `promptbook make` and for lookup in `createLibraryFromDirectory`
137
+ * The name of the builded promptbook library made by CLI `promptbook make` and for lookup in `createCollectionFromDirectory`
138
138
  */
139
139
  var PROMPTBOOK_MAKED_BASE_FILENAME = "index";
140
140
 
141
- var promptbookLibrary = [{title:"Prepare Keywords",promptbookUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.59.0-36",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-36",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
141
+ var PipelineCollection = [{title:"Prepare Keywords",promptbookUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.60.0-2",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.60.0-2",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
142
142
 
143
143
  /**
144
144
  * This error indicates errors during the execution of the promptbook
145
145
  */
146
- var PromptbookExecutionError = /** @class */ (function (_super) {
147
- __extends(PromptbookExecutionError, _super);
148
- function PromptbookExecutionError(message) {
146
+ var ExecutionError = /** @class */ (function (_super) {
147
+ __extends(ExecutionError, _super);
148
+ function ExecutionError(message) {
149
149
  var _this = _super.call(this, message) || this;
150
- _this.name = 'PromptbookExecutionError';
151
- Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
150
+ _this.name = 'ExecutionError';
151
+ Object.setPrototypeOf(_this, ExecutionError.prototype);
152
152
  return _this;
153
153
  }
154
- return PromptbookExecutionError;
154
+ return ExecutionError;
155
155
  }(Error));
156
156
 
157
157
  /**
158
158
  * Asserts that the execution of a promptnook is successful
159
159
  *
160
160
  * @param executionResult - The partial result of the promptnook execution
161
- * @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
161
+ * @throws {ExecutionError} If the execution is not successful or if multiple errors occurred
162
162
  */
163
163
  function assertsExecutionSuccessful(executionResult) {
164
164
  var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
@@ -166,13 +166,13 @@
166
166
  return;
167
167
  }
168
168
  if (errors.length === 0) {
169
- throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
169
+ throw new ExecutionError("Promptnook Execution failed because of unknown reason");
170
170
  }
171
171
  else if (errors.length === 1) {
172
172
  throw errors[0];
173
173
  }
174
174
  else {
175
- throw new PromptbookExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
175
+ throw new ExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
176
176
  }
177
177
  }
178
178
  /**
@@ -182,29 +182,29 @@
182
182
  /**
183
183
  * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
184
184
  */
185
- var PromptbookLogicError = /** @class */ (function (_super) {
186
- __extends(PromptbookLogicError, _super);
187
- function PromptbookLogicError(message) {
185
+ var PipelineLogicError = /** @class */ (function (_super) {
186
+ __extends(PipelineLogicError, _super);
187
+ function PipelineLogicError(message) {
188
188
  var _this = _super.call(this, message) || this;
189
- _this.name = 'PromptbookLogicError';
190
- Object.setPrototypeOf(_this, PromptbookLogicError.prototype);
189
+ _this.name = 'PipelineLogicError';
190
+ Object.setPrototypeOf(_this, PipelineLogicError.prototype);
191
191
  return _this;
192
192
  }
193
- return PromptbookLogicError;
193
+ return PipelineLogicError;
194
194
  }(Error));
195
195
 
196
196
  /**
197
197
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
198
198
  */
199
- var PromptbookSyntaxError = /** @class */ (function (_super) {
200
- __extends(PromptbookSyntaxError, _super);
201
- function PromptbookSyntaxError(message) {
199
+ var SyntaxError = /** @class */ (function (_super) {
200
+ __extends(SyntaxError, _super);
201
+ function SyntaxError(message) {
202
202
  var _this = _super.call(this, message) || this;
203
- _this.name = 'PromptbookSyntaxError';
204
- Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
203
+ _this.name = 'SyntaxError';
204
+ Object.setPrototypeOf(_this, SyntaxError.prototype);
205
205
  return _this;
206
206
  }
207
- return PromptbookSyntaxError;
207
+ return SyntaxError;
208
208
  }(Error));
209
209
 
210
210
  /**
@@ -247,7 +247,7 @@
247
247
  }
248
248
 
249
249
  /**
250
- * Validates PromptbookJson if it is logically valid
250
+ * Validates PipelineJson if it is logically valid
251
251
  *
252
252
  * It checks:
253
253
  * - if it has correct parameters dependency
@@ -256,48 +256,48 @@
256
256
  * - if it is valid json
257
257
  * - if it is meaningful
258
258
  *
259
- * @param promptbook valid or invalid PromptbookJson
260
- * @returns the same promptbook if it is logically valid
261
- * @throws {PromptbookLogicError} on logical error in the promptbook
259
+ * @param pipeline valid or invalid PipelineJson
260
+ * @returns the same pipeline if it is logically valid
261
+ * @throws {PipelineLogicError} on logical error in the pipeline
262
262
  */
263
- function validatePromptbook(promptbook) {
263
+ function validatePipeline(pipeline) {
264
264
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
265
265
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
266
- if (promptbook.promptbookUrl !== undefined) {
267
- if (!isValidUrl(promptbook.promptbookUrl)) {
266
+ if (pipeline.promptbookUrl !== undefined) {
267
+ if (!isValidUrl(pipeline.promptbookUrl)) {
268
268
  // TODO: This should be maybe the syntax error detected during parsing
269
- throw new PromptbookLogicError("Invalid promptbook URL \"".concat(promptbook.promptbookUrl, "\""));
269
+ throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.promptbookUrl, "\""));
270
270
  }
271
271
  }
272
272
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
273
- if (!Array.isArray(promptbook.parameters)) {
273
+ if (!Array.isArray(pipeline.parameters)) {
274
274
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
275
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.parameters expected to be an array, but got ".concat(typeof promptbook.parameters, "\n ")));
275
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.parameters expected to be an array, but got ".concat(typeof pipeline.parameters, "\n ")));
276
276
  }
277
277
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
278
- if (!Array.isArray(promptbook.promptTemplates)) {
278
+ if (!Array.isArray(pipeline.promptTemplates)) {
279
279
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
280
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.promptTemplates expected to be an array, but got ".concat(typeof promptbook.promptTemplates, "\n ")));
280
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.promptTemplates expected to be an array, but got ".concat(typeof pipeline.promptTemplates, "\n ")));
281
281
  }
282
282
  var _loop_1 = function (parameter) {
283
283
  if (parameter.isInput && parameter.isOutput) {
284
- throw new PromptbookLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
284
+ throw new PipelineLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
285
285
  }
286
286
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
287
287
  if (!parameter.isInput &&
288
288
  !parameter.isOutput &&
289
- !promptbook.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
290
- throw new PromptbookLogicError(spaceTrim.spaceTrim("\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 ")));
289
+ !pipeline.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
290
+ throw new PipelineLogicError(spaceTrim.spaceTrim("\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 ")));
291
291
  }
292
292
  // Note: Testing that parameter is either input or result of some template
293
293
  if (!parameter.isInput &&
294
- !promptbook.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
295
- throw new PromptbookLogicError(spaceTrim.spaceTrim("\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ")));
294
+ !pipeline.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
295
+ throw new PipelineLogicError(spaceTrim.spaceTrim("\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ")));
296
296
  }
297
297
  };
298
298
  try {
299
299
  // Note: Check each parameter individually
300
- for (var _e = __values(promptbook.parameters), _f = _e.next(); !_f.done; _f = _e.next()) {
300
+ for (var _e = __values(pipeline.parameters), _f = _e.next(); !_f.done; _f = _e.next()) {
301
301
  var parameter = _f.value;
302
302
  _loop_1(parameter);
303
303
  }
@@ -310,7 +310,7 @@
310
310
  finally { if (e_1) throw e_1.error; }
311
311
  }
312
312
  // Note: Check each template individually
313
- var definedParameters = new Set(promptbook.parameters.filter(function (_a) {
313
+ var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
314
314
  var isInput = _a.isInput;
315
315
  return isInput;
316
316
  }).map(function (_a) {
@@ -318,25 +318,25 @@
318
318
  return name;
319
319
  }));
320
320
  try {
321
- for (var _g = __values(promptbook.promptTemplates), _h = _g.next(); !_h.done; _h = _g.next()) {
321
+ for (var _g = __values(pipeline.promptTemplates), _h = _g.next(); !_h.done; _h = _g.next()) {
322
322
  var template = _h.value;
323
323
  if (definedParameters.has(template.resultingParameterName)) {
324
- throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
324
+ throw new PipelineLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
325
325
  }
326
326
  definedParameters.add(template.resultingParameterName);
327
327
  if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
328
- throw new PromptbookLogicError(spaceTrim.spaceTrim("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
328
+ throw new PipelineLogicError(spaceTrim.spaceTrim("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
329
329
  }
330
330
  if (template.jokers && template.jokers.length > 0) {
331
331
  if (!template.expectFormat &&
332
332
  !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
333
- throw new PromptbookLogicError("Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined"));
333
+ throw new PipelineLogicError("Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined"));
334
334
  }
335
335
  try {
336
336
  for (var _j = (e_3 = void 0, __values(template.jokers)), _k = _j.next(); !_k.done; _k = _j.next()) {
337
337
  var joker = _k.value;
338
338
  if (!template.dependentParameterNames.includes(joker)) {
339
- throw new PromptbookLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
339
+ throw new PipelineLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
340
340
  }
341
341
  }
342
342
  }
@@ -353,13 +353,13 @@
353
353
  for (var _l = (e_4 = void 0, __values(Object.entries(template.expectations))), _m = _l.next(); !_m.done; _m = _l.next()) {
354
354
  var _o = __read(_m.value, 2), unit = _o[0], _p = _o[1], min = _p.min, max = _p.max;
355
355
  if (min !== undefined && max !== undefined && min > max) {
356
- throw new PromptbookLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
356
+ throw new PipelineLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
357
357
  }
358
358
  if (min !== undefined && min < 0) {
359
- throw new PromptbookLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
359
+ throw new PipelineLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
360
360
  }
361
361
  if (max !== undefined && max <= 0) {
362
- throw new PromptbookLogicError("Max expectation of ".concat(unit, " must be positive"));
362
+ throw new PipelineLogicError("Max expectation of ".concat(unit, " must be positive"));
363
363
  }
364
364
  }
365
365
  }
@@ -381,7 +381,7 @@
381
381
  finally { if (e_2) throw e_2.error; }
382
382
  }
383
383
  // Note: Detect circular dependencies
384
- var resovedParameters = promptbook.parameters
384
+ var resovedParameters = pipeline.parameters
385
385
  .filter(function (_a) {
386
386
  var isInput = _a.isInput;
387
387
  return isInput;
@@ -390,17 +390,17 @@
390
390
  var name = _a.name;
391
391
  return name;
392
392
  });
393
- var unresovedTemplates = __spreadArray([], __read(promptbook.promptTemplates), false);
393
+ var unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
394
394
  var loopLimit = LOOP_LIMIT;
395
395
  var _loop_2 = function () {
396
396
  if (loopLimit-- < 0) {
397
- throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
397
+ throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
398
398
  }
399
399
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
400
400
  return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
401
401
  });
402
402
  if (currentlyResovedTemplates.length === 0) {
403
- throw new PromptbookLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Can not resolve some parameters\n It may be circular dependencies\n\n Can not resolve:\n ".concat(block(unresovedTemplates
403
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Can not resolve some parameters\n It may be circular dependencies\n\n Can not resolve:\n ".concat(block(unresovedTemplates
404
404
  .map(function (_a) {
405
405
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
406
406
  return "- {".concat(resultingParameterName, "} depends on ").concat(dependentParameterNames
@@ -418,25 +418,25 @@
418
418
  while (unresovedTemplates.length > 0) {
419
419
  _loop_2();
420
420
  }
421
- return promptbook;
421
+ return pipeline;
422
422
  }
423
423
  /**
424
424
  * TODO: [🧠] Work with promptbookVersion
425
425
  * TODO: Use here some json-schema, Zod or something similar and change it to:
426
426
  * > /**
427
- * > * Validates PromptbookJson if it is logically valid.
427
+ * > * Validates PipelineJson if it is logically valid.
428
428
  * > *
429
429
  * > * It checks:
430
430
  * > * - it has a valid structure
431
431
  * > * - ...
432
- * > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
432
+ * > ex port function validatePipeline(promptbook: unknown): asserts promptbook is PipelineJson {
433
433
  */
434
434
 
435
435
  /**
436
436
  * This error occurs when some expectation is not met in the execution of the pipeline
437
437
  *
438
- * @private Always catched and rethrown as `PromptbookExecutionError`
439
- * Note: This is a kindof subtype of PromptbookExecutionError
438
+ * @private Always catched and rethrown as `ExecutionError`
439
+ * Note: This is a kindof subtype of ExecutionError
440
440
  */
441
441
  var ExpectError = /** @class */ (function (_super) {
442
442
  __extends(ExpectError, _super);
@@ -471,7 +471,7 @@
471
471
  /**
472
472
  * The version of the Promptbook library
473
473
  */
474
- var PROMPTBOOK_VERSION = '0.59.0-36';
474
+ var PROMPTBOOK_VERSION = '0.60.0-2';
475
475
 
476
476
  /**
477
477
  * Function `addUsage` will add multiple usages into one
@@ -929,7 +929,7 @@
929
929
  /**
930
930
  * This error occurs during the parameter replacement in the template
931
931
  *
932
- * Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
932
+ * Note: This is a kindof subtype of ExecutionError because it occurs during the execution of the pipeline
933
933
  */
934
934
  var TemplateError = /** @class */ (function (_super) {
935
935
  __extends(TemplateError, _super);
@@ -1006,13 +1006,13 @@
1006
1006
  * Creates executor function from promptbook and execution tools.
1007
1007
  *
1008
1008
  * @returns The executor function
1009
- * @throws {PromptbookLogicError} on logical error in the promptbook
1009
+ * @throws {PipelineLogicError} on logical error in the promptbook
1010
1010
  */
1011
1011
  function createPromptbookExecutor(options) {
1012
1012
  var _this = this;
1013
1013
  var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
1014
1014
  var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
1015
- validatePromptbook(promptbook);
1015
+ validatePipeline(promptbook);
1016
1016
  var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
1017
1017
  function executeSingleTemplate(currentTemplate) {
1018
1018
  return __awaiter(this, void 0, void 0, function () {
@@ -1059,7 +1059,7 @@
1059
1059
  expectError = null;
1060
1060
  if (isJokerAttempt) {
1061
1061
  if (typeof parametersToPass[joker] === 'undefined') {
1062
- throw new PromptbookExecutionError("Joker parameter {".concat(joker, "} not defined"));
1062
+ throw new ExecutionError("Joker parameter {".concat(joker, "} not defined"));
1063
1063
  }
1064
1064
  resultString = parametersToPass[joker];
1065
1065
  }
@@ -1139,13 +1139,13 @@
1139
1139
  return [7 /*endfinally*/];
1140
1140
  case 10:
1141
1141
  if (errors.length === 0) {
1142
- throw new PromptbookExecutionError('Postprocessing in LlmExecutionTools failed because no ScriptExecutionTools were provided');
1142
+ throw new ExecutionError('Postprocessing in LlmExecutionTools failed because no ScriptExecutionTools were provided');
1143
1143
  }
1144
1144
  else if (errors.length === 1) {
1145
1145
  throw errors[0];
1146
1146
  }
1147
1147
  else {
1148
- throw new PromptbookExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Postprocessing in LlmExecutionTools failed ".concat(errors.length, "x\n\n ").concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n\n')), "\n "); }));
1148
+ throw new ExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Postprocessing in LlmExecutionTools failed ".concat(errors.length, "x\n\n ").concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n\n')), "\n "); }));
1149
1149
  }
1150
1150
  }
1151
1151
  });
@@ -1157,27 +1157,27 @@
1157
1157
  case 'COMPLETION': return [3 /*break*/, 9];
1158
1158
  }
1159
1159
  return [3 /*break*/, 11];
1160
- case 7: return [4 /*yield*/, tools.llm.gptChat(prompt)];
1160
+ case 7: return [4 /*yield*/, tools.llm.callChatModel(prompt)];
1161
1161
  case 8:
1162
1162
  chatThread = _o.sent();
1163
1163
  // TODO: [🍬] Destroy chatThread
1164
1164
  result = chatThread;
1165
1165
  resultString = chatThread.content;
1166
1166
  return [3 /*break*/, 12];
1167
- case 9: return [4 /*yield*/, tools.llm.gptComplete(prompt)];
1167
+ case 9: return [4 /*yield*/, tools.llm.callCompletionModel(prompt)];
1168
1168
  case 10:
1169
1169
  completionResult = _o.sent();
1170
1170
  result = completionResult;
1171
1171
  resultString = completionResult.content;
1172
1172
  return [3 /*break*/, 12];
1173
- case 11: throw new PromptbookExecutionError("Unknown model variant \"".concat(currentTemplate.modelRequirements.modelVariant, "\""));
1173
+ case 11: throw new ExecutionError("Unknown model variant \"".concat(currentTemplate.modelRequirements.modelVariant, "\""));
1174
1174
  case 12: return [3 /*break*/, 27];
1175
1175
  case 13:
1176
1176
  if (tools.script.length === 0) {
1177
- throw new PromptbookExecutionError('No script execution tools are available');
1177
+ throw new ExecutionError('No script execution tools are available');
1178
1178
  }
1179
1179
  if (!currentTemplate.contentLanguage) {
1180
- throw new PromptbookExecutionError("Script language is not defined for prompt template \"".concat(currentTemplate.name, "\""));
1180
+ throw new ExecutionError("Script language is not defined for prompt template \"".concat(currentTemplate.name, "\""));
1181
1181
  }
1182
1182
  // TODO: DRY [1]
1183
1183
  scriptExecutionErrors = [];
@@ -1229,13 +1229,13 @@
1229
1229
  throw scriptExecutionErrors[0];
1230
1230
  }
1231
1231
  else {
1232
- throw new PromptbookExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script execution failed ".concat(scriptExecutionErrors.length, " times\n\n ").concat(block(scriptExecutionErrors
1232
+ throw new ExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script execution failed ".concat(scriptExecutionErrors.length, " times\n\n ").concat(block(scriptExecutionErrors
1233
1233
  .map(function (error) { return '- ' + error.message; })
1234
1234
  .join('\n\n')), "\n "); }));
1235
1235
  }
1236
1236
  case 24:
1237
1237
  if (tools.userInterface === undefined) {
1238
- throw new PromptbookExecutionError('User interface tools are not available');
1238
+ throw new ExecutionError('User interface tools are not available');
1239
1239
  }
1240
1240
  return [4 /*yield*/, tools.userInterface.promptDialog({
1241
1241
  promptTitle: currentTemplate.title,
@@ -1249,7 +1249,7 @@
1249
1249
  // TODO: [🌹] When making next attempt for `PROMPT DIALOG`, preserve the previous user input
1250
1250
  resultString = _o.sent();
1251
1251
  return [3 /*break*/, 27];
1252
- case 26: throw new PromptbookExecutionError(
1252
+ case 26: throw new ExecutionError(
1253
1253
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1254
1254
  "Unknown execution type \"".concat(currentTemplate.executionType, "\""));
1255
1255
  case 27:
@@ -1374,7 +1374,7 @@
1374
1374
  return [7 /*endfinally*/];
1375
1375
  case 47:
1376
1376
  if (expectError !== null && attempt === maxAttempts - 1) {
1377
- throw new PromptbookExecutionError(spaceTrim.spaceTrim(function (block) { return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ---\n Last error ").concat((expectError === null || expectError === void 0 ? void 0 : expectError.name) || '', ":\n ").concat(block((expectError === null || expectError === void 0 ? void 0 : expectError.message) || ''), "\n\n Last result:\n ").concat(resultString, "\n ---\n "); }));
1377
+ throw new ExecutionError(spaceTrim.spaceTrim(function (block) { return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ---\n Last error ").concat((expectError === null || expectError === void 0 ? void 0 : expectError.name) || '', ":\n ").concat(block((expectError === null || expectError === void 0 ? void 0 : expectError.message) || ''), "\n\n Last result:\n ").concat(resultString, "\n ---\n "); }));
1378
1378
  }
1379
1379
  _o.label = 48;
1380
1380
  case 48:
@@ -1443,7 +1443,7 @@
1443
1443
  return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
1444
1444
  });
1445
1445
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
1446
- throw new UnexpectedError(spaceTrim.spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
1446
+ throw new UnexpectedError(spaceTrim.spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePipeline\n "));
1447
1447
  case 1:
1448
1448
  if (!!currentTemplate) return [3 /*break*/, 3];
1449
1449
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -1576,16 +1576,16 @@
1576
1576
  /**
1577
1577
  * Converts promptbook in JSON format to string format
1578
1578
  *
1579
- * @param promptbookJson Promptbook in JSON format (.ptbk.json)
1579
+ * @param pipelineJson Promptbook in JSON format (.ptbk.json)
1580
1580
  * @returns Promptbook in string format (.ptbk.md)
1581
1581
  */
1582
- function promptbookJsonToString(promptbookJson) {
1582
+ function pipelineJsonToString(pipelineJson) {
1583
1583
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
1584
- var title = promptbookJson.title, promptbookUrl = promptbookJson.promptbookUrl, promptbookVersion = promptbookJson.promptbookVersion, description = promptbookJson.description, parameters = promptbookJson.parameters, promptTemplates = promptbookJson.promptTemplates;
1585
- var promptbookString = "# ".concat(title);
1584
+ var title = pipelineJson.title, promptbookUrl = pipelineJson.promptbookUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, promptTemplates = pipelineJson.promptTemplates;
1585
+ var pipelineString = "# ".concat(title);
1586
1586
  if (description) {
1587
- promptbookString += '\n\n';
1588
- promptbookString += description;
1587
+ pipelineString += '\n\n';
1588
+ pipelineString += description;
1589
1589
  }
1590
1590
  // TODO:> const commands: Array<Command>
1591
1591
  var commands = [];
@@ -1593,7 +1593,7 @@
1593
1593
  commands.push("PROMPTBOOK URL ".concat(promptbookUrl));
1594
1594
  }
1595
1595
  commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
1596
- promptbookString = prettifyMarkdown(promptbookString);
1596
+ pipelineString = prettifyMarkdown(pipelineString);
1597
1597
  try {
1598
1598
  for (var _g = __values(parameters.filter(function (_a) {
1599
1599
  var isInput = _a.isInput;
@@ -1626,8 +1626,8 @@
1626
1626
  }
1627
1627
  finally { if (e_2) throw e_2.error; }
1628
1628
  }
1629
- promptbookString += '\n\n';
1630
- promptbookString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
1629
+ pipelineString += '\n\n';
1630
+ pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
1631
1631
  try {
1632
1632
  for (var promptTemplates_1 = __values(promptTemplates), promptTemplates_1_1 = promptTemplates_1.next(); !promptTemplates_1_1.done; promptTemplates_1_1 = promptTemplates_1.next()) {
1633
1633
  var promptTemplate = promptTemplates_1_1.value;
@@ -1636,11 +1636,11 @@
1636
1636
  title_1 = promptTemplate.title, description_1 = promptTemplate.description,
1637
1637
  /* Note: dependentParameterNames, */
1638
1638
  jokers = promptTemplate.jokers, executionType = promptTemplate.executionType, content = promptTemplate.content, postprocessing = promptTemplate.postprocessing, expectations = promptTemplate.expectations, expectFormat = promptTemplate.expectFormat, resultingParameterName = promptTemplate.resultingParameterName;
1639
- promptbookString += '\n\n';
1640
- promptbookString += "## ".concat(title_1);
1639
+ pipelineString += '\n\n';
1640
+ pipelineString += "## ".concat(title_1);
1641
1641
  if (description_1) {
1642
- promptbookString += '\n\n';
1643
- promptbookString += description_1;
1642
+ pipelineString += '\n\n';
1643
+ pipelineString += description_1;
1644
1644
  }
1645
1645
  // TODO:> const commands: Array<Command>
1646
1646
  var commands_1 = [];
@@ -1734,18 +1734,18 @@
1734
1734
  commands_1.push("EXPECT JSON");
1735
1735
  }
1736
1736
  } /* not else */
1737
- promptbookString += '\n\n';
1738
- promptbookString += commands_1.map(function (command) { return "- ".concat(command); }).join('\n');
1739
- promptbookString += '\n\n';
1740
- promptbookString += '```' + contentLanguage;
1741
- promptbookString += '\n';
1742
- promptbookString += spaceTrim__default["default"](content);
1737
+ pipelineString += '\n\n';
1738
+ pipelineString += commands_1.map(function (command) { return "- ".concat(command); }).join('\n');
1739
+ pipelineString += '\n\n';
1740
+ pipelineString += '```' + contentLanguage;
1741
+ pipelineString += '\n';
1742
+ pipelineString += spaceTrim__default["default"](content);
1743
1743
  // <- TODO: !!! Escape
1744
1744
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
1745
- promptbookString += '\n';
1746
- promptbookString += '```';
1747
- promptbookString += '\n\n';
1748
- promptbookString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
1745
+ pipelineString += '\n';
1746
+ pipelineString += '```';
1747
+ pipelineString += '\n\n';
1748
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
1749
1749
  }
1750
1750
  }
1751
1751
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -1755,10 +1755,10 @@
1755
1755
  }
1756
1756
  finally { if (e_3) throw e_3.error; }
1757
1757
  }
1758
- return promptbookString;
1758
+ return pipelineString;
1759
1759
  }
1760
1760
  /**
1761
- * @private internal util of promptbookJsonToString
1761
+ * @private internal util of pipelineJsonToString
1762
1762
  */
1763
1763
  function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
1764
1764
  var name = promptTemplateParameterJson.name, description = promptTemplateParameterJson.description;
@@ -1775,49 +1775,49 @@
1775
1775
  /**
1776
1776
  * This error indicates that promptbook not found in the library
1777
1777
  */
1778
- var PromptbookNotFoundError = /** @class */ (function (_super) {
1779
- __extends(PromptbookNotFoundError, _super);
1780
- function PromptbookNotFoundError(message) {
1778
+ var NotFoundError = /** @class */ (function (_super) {
1779
+ __extends(NotFoundError, _super);
1780
+ function NotFoundError(message) {
1781
1781
  var _this = _super.call(this, message) || this;
1782
- _this.name = 'PromptbookNotFoundError';
1783
- Object.setPrototypeOf(_this, PromptbookNotFoundError.prototype);
1782
+ _this.name = 'NotFoundError';
1783
+ Object.setPrototypeOf(_this, NotFoundError.prototype);
1784
1784
  return _this;
1785
1785
  }
1786
- return PromptbookNotFoundError;
1786
+ return NotFoundError;
1787
1787
  }(Error));
1788
1788
 
1789
1789
  /**
1790
1790
  * This error indicates errors in referencing promptbooks between each other
1791
1791
  */
1792
- var PromptbookReferenceError = /** @class */ (function (_super) {
1793
- __extends(PromptbookReferenceError, _super);
1794
- function PromptbookReferenceError(message) {
1792
+ var ReferenceError$1 = /** @class */ (function (_super) {
1793
+ __extends(ReferenceError, _super);
1794
+ function ReferenceError(message) {
1795
1795
  var _this = _super.call(this, message) || this;
1796
- _this.name = 'PromptbookReferenceError';
1797
- Object.setPrototypeOf(_this, PromptbookReferenceError.prototype);
1796
+ _this.name = 'ReferenceError';
1797
+ Object.setPrototypeOf(_this, ReferenceError.prototype);
1798
1798
  return _this;
1799
1799
  }
1800
- return PromptbookReferenceError;
1800
+ return ReferenceError;
1801
1801
  }(Error));
1802
1802
 
1803
1803
  /**
1804
1804
  * Library of promptbooks that groups together promptbooks for an application.
1805
1805
  * This implementation is a very thin wrapper around the Array / Map of promptbooks.
1806
1806
  *
1807
- * @private use `createLibraryFromJson` instead
1808
- * @see https://github.com/webgptorg/promptbook#promptbook-library
1807
+ * @private use `createCollectionFromJson` instead
1808
+ * @see https://github.com/webgptorg/promptbook#promptbook-collection
1809
1809
  */
1810
- var SimplePromptbookLibrary = /** @class */ (function () {
1810
+ var SimplePipelineCollection = /** @class */ (function () {
1811
1811
  /**
1812
1812
  * Constructs a promptbook library from promptbooks
1813
1813
  *
1814
1814
  * @param promptbooks !!!
1815
1815
  *
1816
- * @private Use instead `createLibraryFromJson`
1816
+ * @private Use instead `createCollectionFromJson`
1817
1817
  * Note: During the construction logic of all promptbooks are validated
1818
- * Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
1818
+ * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
1819
1819
  */
1820
- function SimplePromptbookLibrary() {
1820
+ function SimplePipelineCollection() {
1821
1821
  var e_1, _a;
1822
1822
  var promptbooks = [];
1823
1823
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1828,14 +1828,13 @@
1828
1828
  for (var promptbooks_1 = __values(promptbooks), promptbooks_1_1 = promptbooks_1.next(); !promptbooks_1_1.done; promptbooks_1_1 = promptbooks_1.next()) {
1829
1829
  var promptbook = promptbooks_1_1.value;
1830
1830
  if (promptbook.promptbookUrl === undefined) {
1831
- throw new PromptbookReferenceError(spaceTrim.spaceTrim("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
1831
+ throw new ReferenceError$1(spaceTrim.spaceTrim("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
1832
1832
  }
1833
- validatePromptbook(promptbook);
1833
+ validatePipeline(promptbook);
1834
1834
  // Note: [🦄]
1835
1835
  if (this.library.has(promptbook.promptbookUrl) &&
1836
- promptbookJsonToString(promptbook) !==
1837
- promptbookJsonToString(this.library.get(promptbook.promptbookUrl))) {
1838
- throw new PromptbookReferenceError(spaceTrim.spaceTrim("\n Promptbook with URL \"".concat(promptbook.promptbookUrl, "\" is already in the library\n\n Note: Promptbooks with the same URL are not allowed\n Note: Automatically check whether the promptbooks are the same BUT they are DIFFERENT\n\n ")));
1836
+ pipelineJsonToString(promptbook) !== pipelineJsonToString(this.library.get(promptbook.promptbookUrl))) {
1837
+ throw new ReferenceError$1(spaceTrim.spaceTrim("\n Promptbook with URL \"".concat(promptbook.promptbookUrl, "\" is already in the library\n\n Note: Promptbooks with the same URL are not allowed\n Note: Automatically check whether the promptbooks are the same BUT they are DIFFERENT\n\n ")));
1839
1838
  }
1840
1839
  this.library.set(promptbook.promptbookUrl, promptbook);
1841
1840
  }
@@ -1851,7 +1850,7 @@
1851
1850
  /**
1852
1851
  * Gets all promptbooks in the library
1853
1852
  */
1854
- SimplePromptbookLibrary.prototype.listPromptbooks = function () {
1853
+ SimplePipelineCollection.prototype.listPipelines = function () {
1855
1854
  return Array.from(this.library.keys());
1856
1855
  };
1857
1856
  /**
@@ -1859,14 +1858,14 @@
1859
1858
  *
1860
1859
  * Note: This is not a direct fetching from the URL, but a lookup in the library
1861
1860
  */
1862
- SimplePromptbookLibrary.prototype.getPromptbookByUrl = function (url) {
1861
+ SimplePipelineCollection.prototype.getPipelineByUrl = function (url) {
1863
1862
  var _this = this;
1864
1863
  var promptbook = this.library.get(url);
1865
1864
  if (!promptbook) {
1866
- if (this.listPromptbooks().length === 0) {
1867
- throw new PromptbookNotFoundError(spaceTrim.spaceTrim("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
1865
+ if (this.listPipelines().length === 0) {
1866
+ throw new NotFoundError(spaceTrim.spaceTrim("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
1868
1867
  }
1869
- throw new PromptbookNotFoundError(spaceTrim.spaceTrim(function (block) { return "\n Promptbook with url \"".concat(url, "\" not found\n\n Available promptbooks:\n ").concat(block(_this.listPromptbooks()
1868
+ throw new NotFoundError(spaceTrim.spaceTrim(function (block) { return "\n Promptbook with url \"".concat(url, "\" not found\n\n Available promptbooks:\n ").concat(block(_this.listPipelines()
1870
1869
  .map(function (promptbookUrl) { return "- ".concat(promptbookUrl); })
1871
1870
  .join('\n')), "\n\n "); }));
1872
1871
  }
@@ -1875,27 +1874,27 @@
1875
1874
  /**
1876
1875
  * Checks whether given prompt was defined in any promptbook in the library
1877
1876
  */
1878
- SimplePromptbookLibrary.prototype.isResponsibleForPrompt = function (prompt) {
1877
+ SimplePipelineCollection.prototype.isResponsibleForPrompt = function (prompt) {
1879
1878
  return true;
1880
1879
  };
1881
- return SimplePromptbookLibrary;
1880
+ return SimplePipelineCollection;
1882
1881
  }());
1883
1882
 
1884
1883
  /**
1885
- * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
1884
+ * Creates PipelineCollection from array of PipelineJson or PipelineString
1886
1885
  *
1887
- * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
1886
+ * Note: Functions `libraryToJson` and `createCollectionFromJson` are complementary
1888
1887
  * Note: During the construction syntax and logic of all sources are validated
1889
1888
  *
1890
1889
  * @param promptbookSources
1891
- * @returns PromptbookLibrary
1890
+ * @returns PipelineCollection
1892
1891
  */
1893
- function createLibraryFromJson() {
1892
+ function createCollectionFromJson() {
1894
1893
  var promptbooks = [];
1895
1894
  for (var _i = 0; _i < arguments.length; _i++) {
1896
1895
  promptbooks[_i] = arguments[_i];
1897
1896
  }
1898
- return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
1897
+ return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
1899
1898
  }
1900
1899
 
1901
1900
  /* tslint:disable */
@@ -1961,8 +1960,8 @@
1961
1960
  switch (_b.label) {
1962
1961
  case 0:
1963
1962
  content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
1964
- library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
1965
- return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
1963
+ library = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
1964
+ return [4 /*yield*/, library.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
1966
1965
  case 1:
1967
1966
  prepareKnowledgeFromMarkdownPromptbook = _b.sent();
1968
1967
  prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
@@ -1974,7 +1973,7 @@
1974
1973
  ],
1975
1974
  },
1976
1975
  });
1977
- return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
1976
+ return [4 /*yield*/, library.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
1978
1977
  case 2:
1979
1978
  prepareKeywordsPromptbook = _b.sent();
1980
1979
  prepareKeywordsExecutor = createPromptbookExecutor({
@@ -2063,7 +2062,7 @@
2063
2062
  /**
2064
2063
  * Computes the deepness of the markdown structure.
2065
2064
  *
2066
- * @private within the library
2065
+ * @private within the package
2067
2066
  */
2068
2067
  function countMarkdownStructureDeepness(markdownStructure) {
2069
2068
  var e_1, _a;
@@ -2093,7 +2092,7 @@
2093
2092
  * @param markdown The markdown string to parse.
2094
2093
  * @returns The MarkdownStructure object.
2095
2094
  *
2096
- * @private within the library
2095
+ * @private within the package
2097
2096
  */
2098
2097
  function markdownToMarkdownStructure(markdown) {
2099
2098
  var e_1, _a;
@@ -2368,7 +2367,7 @@
2368
2367
  *
2369
2368
  * @param script from which to extract the variables
2370
2369
  * @returns the list of variable names
2371
- * @throws {PromptbookSyntaxError} if the script is invalid
2370
+ * @throws {SyntaxError} if the script is invalid
2372
2371
  */
2373
2372
  function extractVariables(script) {
2374
2373
  var variables = new Set();
@@ -2404,7 +2403,7 @@
2404
2403
  if (!(error instanceof Error)) {
2405
2404
  throw error;
2406
2405
  }
2407
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.name), ": ").concat(block(error.message), "\n "); }));
2406
+ throw new SyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.name), ": ").concat(block(error.message), "\n "); }));
2408
2407
  }
2409
2408
  return variables;
2410
2409
  }
@@ -2417,7 +2416,7 @@
2417
2416
  *
2418
2417
  * @param promptTemplate the template with used parameters
2419
2418
  * @returns the set of parameter names
2420
- * @throws {PromptbookSyntaxError} if the script is invalid
2419
+ * @throws {SyntaxError} if the script is invalid
2421
2420
  */
2422
2421
  function extractParametersFromPromptTemplate(promptTemplate) {
2423
2422
  var e_1, _a, e_2, _b;
@@ -2456,6 +2455,45 @@
2456
2455
  * TODO: [🔣] If script require contentLanguage
2457
2456
  */
2458
2457
 
2458
+ /**
2459
+ * Execution type describes the way how the block is executed
2460
+ *
2461
+ * @see https://github.com/webgptorg/promptbook#execution-type
2462
+ */
2463
+ var ExecutionTypes = [
2464
+ 'PROMPT_TEMPLATE',
2465
+ 'SIMPLE_TEMPLATE',
2466
+ 'SCRIPT',
2467
+ 'PROMPT_DIALOG',
2468
+ // <- [🥻] Insert here when making new command
2469
+ ];
2470
+
2471
+ /**
2472
+ * Units of text measurement
2473
+ */
2474
+ var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
2475
+ /**
2476
+ * TODO: [💝] Unite object for expecting amount and format - remove expectFormat
2477
+ * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
2478
+ * TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
2479
+ */
2480
+
2481
+ /**
2482
+ * Removes Markdown formatting tags from a string.
2483
+ *
2484
+ * @param {string} str - The string to remove Markdown tags from.
2485
+ * @returns {string} The input string with all Markdown tags removed.
2486
+ */
2487
+ function removeMarkdownFormatting(str) {
2488
+ // Remove bold formatting
2489
+ str = str.replace(/\*\*(.*?)\*\*/g, '$1');
2490
+ // Remove italic formatting
2491
+ str = str.replace(/\*(.*?)\*/g, '$1');
2492
+ // Remove code formatting
2493
+ str = str.replace(/`(.*?)`/g, '$1');
2494
+ return str;
2495
+ }
2496
+
2459
2497
  /* tslint:disable */
2460
2498
  /*
2461
2499
  TODO: Tests
@@ -2520,45 +2558,6 @@
2520
2558
  * TODO: [🌺] Use some intermediate util splitWords
2521
2559
  */
2522
2560
 
2523
- /**
2524
- * Execution type describes the way how the block is executed
2525
- *
2526
- * @see https://github.com/webgptorg/promptbook#execution-type
2527
- */
2528
- var ExecutionTypes = [
2529
- 'PROMPT_TEMPLATE',
2530
- 'SIMPLE_TEMPLATE',
2531
- 'SCRIPT',
2532
- 'PROMPT_DIALOG',
2533
- // <- [🥻] Insert here when making new command
2534
- ];
2535
-
2536
- /**
2537
- * Units of text measurement
2538
- */
2539
- var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
2540
- /**
2541
- * TODO: [💝] Unite object for expecting amount and format - remove expectFormat
2542
- * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
2543
- * TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
2544
- */
2545
-
2546
- /**
2547
- * Removes Markdown formatting tags from a string.
2548
- *
2549
- * @param {string} str - The string to remove Markdown tags from.
2550
- * @returns {string} The input string with all Markdown tags removed.
2551
- */
2552
- function removeMarkdownFormatting(str) {
2553
- // Remove bold formatting
2554
- str = str.replace(/\*\*(.*?)\*\*/g, '$1');
2555
- // Remove italic formatting
2556
- str = str.replace(/\*(.*?)\*/g, '$1');
2557
- // Remove code formatting
2558
- str = str.replace(/`(.*?)`/g, '$1');
2559
- return str;
2560
- }
2561
-
2562
2561
  /**
2563
2562
  * Function parseNumber will parse number from string
2564
2563
  *
@@ -2566,7 +2565,7 @@
2566
2565
  * Note: it also works only with decimal numbers
2567
2566
  *
2568
2567
  * @returns parsed number
2569
- * @throws {PromptbookSyntaxError} if the value is not a number
2568
+ * @throws {SyntaxError} if the value is not a number
2570
2569
  *
2571
2570
  * @private within the parseCommand
2572
2571
  */
@@ -2602,7 +2601,7 @@
2602
2601
  var numerator = parseNumber(numerator_);
2603
2602
  var denominator = parseNumber(denominator_);
2604
2603
  if (denominator === 0) {
2605
- throw new PromptbookSyntaxError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
2604
+ throw new SyntaxError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
2606
2605
  }
2607
2606
  return numerator / denominator;
2608
2607
  }
@@ -2614,11 +2613,11 @@
2614
2613
  return parseNumber(significand) * Math.pow(10, parseNumber(exponent));
2615
2614
  }
2616
2615
  if (!/^[0-9.]+$/.test(value) || value.split('.').length > 2) {
2617
- throw new PromptbookSyntaxError("Unable to parse number from \"".concat(originalValue, "\""));
2616
+ throw new SyntaxError("Unable to parse number from \"".concat(originalValue, "\""));
2618
2617
  }
2619
2618
  var num = parseFloat(value);
2620
2619
  if (isNaN(num)) {
2621
- throw new PromptbookSyntaxError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
2620
+ throw new SyntaxError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
2622
2621
  }
2623
2622
  return num;
2624
2623
  }
@@ -2630,14 +2629,14 @@
2630
2629
  * Parses one line of ul/ol to command
2631
2630
  *
2632
2631
  * @returns parsed command object
2633
- * @throws {PromptbookSyntaxError} if the command is invalid
2632
+ * @throws {SyntaxError} if the command is invalid
2634
2633
  *
2635
- * @private within the promptbookStringToJson
2634
+ * @private within the pipelineStringToJson
2636
2635
  */
2637
2636
  function parseCommand(listItem) {
2638
2637
  var e_1, _a;
2639
2638
  if (listItem.includes('\n') || listItem.includes('\r')) {
2640
- throw new PromptbookSyntaxError('Command can not contain new line characters:');
2639
+ throw new SyntaxError('Command can not contain new line characters:');
2641
2640
  }
2642
2641
  var type = listItem.trim();
2643
2642
  type = type.split('`').join('');
@@ -2664,15 +2663,15 @@
2664
2663
  type.startsWith('PROMPTBOOKURL') ||
2665
2664
  type.startsWith('HTTPS')) {
2666
2665
  if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
2667
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
2666
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
2668
2667
  }
2669
2668
  var promptbookUrlString = listItemParts.pop();
2670
2669
  var promptbookUrl = new URL(promptbookUrlString);
2671
2670
  if (promptbookUrl.protocol !== 'https:') {
2672
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
2671
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
2673
2672
  }
2674
2673
  if (promptbookUrl.hash !== '') {
2675
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
2674
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
2676
2675
  }
2677
2676
  return {
2678
2677
  type: 'PROMPTBOOK_URL',
@@ -2681,7 +2680,7 @@
2681
2680
  }
2682
2681
  else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
2683
2682
  if (listItemParts.length !== 2) {
2684
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
2683
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
2685
2684
  }
2686
2685
  var promptbookVersion = listItemParts.pop();
2687
2686
  // TODO: Validate version
@@ -2696,7 +2695,7 @@
2696
2695
  type.startsWith('SIMPLE_TEMPLATE')) {
2697
2696
  var executionTypes = ExecutionTypes.filter(function (executionType) { return type.includes(executionType); });
2698
2697
  if (executionTypes.length !== 1) {
2699
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type in command:\n\n - ".concat(listItem, "\n\n Supported execution types are:\n ").concat(block(ExecutionTypes.join(', ')), "\n "); }));
2698
+ throw new SyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type in command:\n\n - ".concat(listItem, "\n\n Supported execution types are:\n ").concat(block(ExecutionTypes.join(', ')), "\n "); }));
2700
2699
  }
2701
2700
  return {
2702
2701
  type: 'EXECUTE',
@@ -2721,7 +2720,7 @@
2721
2720
  };
2722
2721
  }
2723
2722
  else {
2724
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant in command:\n\n - ".concat(listItem, "\n\n Supported variants are:\n ").concat(block(['CHAT', 'COMPLETION'].join(', ')), "\n "); }));
2723
+ throw new SyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant in command:\n\n - ".concat(listItem, "\n\n Supported variants are:\n ").concat(block(['CHAT', 'COMPLETION'].join(', ')), "\n "); }));
2725
2724
  }
2726
2725
  }
2727
2726
  if (type.startsWith('MODEL_NAME')) {
@@ -2732,7 +2731,7 @@
2732
2731
  };
2733
2732
  }
2734
2733
  else {
2735
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model key in command:\n\n - ".concat(listItem, "\n\n Supported model keys are:\n ").concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
2734
+ throw new SyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model key in command:\n\n - ".concat(listItem, "\n\n Supported model keys are:\n ").concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
2736
2735
  }
2737
2736
  }
2738
2737
  else if (type.startsWith('PARAM') ||
@@ -2742,12 +2741,12 @@
2742
2741
  listItem.startsWith('> {') /* <- Note: This is a bit hack to parse return parameters defined at the end of each section */) {
2743
2742
  var parametersMatch = listItem.match(/\{(?<parameterName>[a-z0-9_]+)\}[^\S\r\n]*(?<parameterDescription>.*)$/im);
2744
2743
  if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
2745
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
2744
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
2746
2745
  }
2747
2746
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2748
2747
  var _b = parametersMatch.groups, parameterName = _b.parameterName, parameterDescription = _b.parameterDescription;
2749
2748
  if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
2750
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
2749
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
2751
2750
  }
2752
2751
  var isInput = type.startsWith('INPUT');
2753
2752
  var isOutput = type.startsWith('OUTPUT');
@@ -2765,11 +2764,11 @@
2765
2764
  }
2766
2765
  else if (type.startsWith('JOKER')) {
2767
2766
  if (listItemParts.length !== 2) {
2768
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
2767
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
2769
2768
  }
2770
2769
  var parametersMatch = (listItemParts.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
2771
2770
  if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
2772
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
2771
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
2773
2772
  }
2774
2773
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2775
2774
  var parameterName = parametersMatch.groups.parameterName;
@@ -2780,7 +2779,7 @@
2780
2779
  }
2781
2780
  else if (type.startsWith('POSTPROCESS') || type.startsWith('POST_PROCESS')) {
2782
2781
  if (listItemParts.length !== 2) {
2783
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
2782
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
2784
2783
  }
2785
2784
  var functionName = listItemParts.pop();
2786
2785
  return {
@@ -2810,15 +2809,15 @@
2810
2809
  sign = 'MAXIMUM';
2811
2810
  }
2812
2811
  else {
2813
- throw new PromptbookSyntaxError("Invalid sign \"".concat(signRaw, "\", expected EXACTLY, MIN or MAX"));
2812
+ throw new SyntaxError("Invalid sign \"".concat(signRaw, "\", expected EXACTLY, MIN or MAX"));
2814
2813
  }
2815
2814
  var amountRaw = listItemParts.shift();
2816
2815
  var amount = parseNumber(amountRaw);
2817
2816
  if (amount < 0) {
2818
- throw new PromptbookSyntaxError('Amount must be positive number or zero');
2817
+ throw new SyntaxError('Amount must be positive number or zero');
2819
2818
  }
2820
2819
  if (amount !== Math.floor(amount)) {
2821
- throw new PromptbookSyntaxError('Amount must be whole number');
2820
+ throw new SyntaxError('Amount must be whole number');
2822
2821
  }
2823
2822
  var unitRaw = listItemParts.shift();
2824
2823
  var unit = undefined;
@@ -2833,7 +2832,7 @@
2833
2832
  if (new RegExp("^".concat(existingUnitText.toLowerCase())).test(unitRaw.toLowerCase()) ||
2834
2833
  new RegExp("^".concat(unitRaw.toLowerCase())).test(existingUnitText.toLowerCase())) {
2835
2834
  if (unit !== undefined) {
2836
- throw new PromptbookSyntaxError("Ambiguous unit \"".concat(unitRaw, "\""));
2835
+ throw new SyntaxError("Ambiguous unit \"".concat(unitRaw, "\""));
2837
2836
  }
2838
2837
  unit = existingUnit;
2839
2838
  }
@@ -2847,7 +2846,7 @@
2847
2846
  finally { if (e_1) throw e_1.error; }
2848
2847
  }
2849
2848
  if (unit === undefined) {
2850
- throw new PromptbookSyntaxError("Invalid unit \"".concat(unitRaw, "\""));
2849
+ throw new SyntaxError("Invalid unit \"".concat(unitRaw, "\""));
2851
2850
  }
2852
2851
  return {
2853
2852
  type: 'EXPECT_AMOUNT',
@@ -2860,7 +2859,7 @@
2860
2859
  if (!(error instanceof Error)) {
2861
2860
  throw error;
2862
2861
  }
2863
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid EXPECT command; ".concat(error.message, ":\n\n - ").concat(listItem, "\n ")));
2862
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid EXPECT command; ".concat(error.message, ":\n\n - ").concat(listItem, "\n ")));
2864
2863
  }
2865
2864
  /*
2866
2865
  } else if (type.startsWith('__________________')) {
@@ -2868,7 +2867,7 @@
2868
2867
  */
2869
2868
  }
2870
2869
  else {
2871
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PROMPTBOOK_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
2870
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PROMPTBOOK_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
2872
2871
  }
2873
2872
  }
2874
2873
 
@@ -2901,20 +2900,20 @@
2901
2900
  * Compile promptbook from string (markdown) format to JSON format synchronously
2902
2901
  *
2903
2902
  * Note: There are two similar functions:
2904
- * - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
2905
- * - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
2903
+ * - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
2904
+ * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
2906
2905
  *
2907
- * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
2906
+ * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
2908
2907
  * @param options - Options and tools for the compilation
2909
2908
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
2910
- * @throws {PromptbookSyntaxError} if the promptbook string is not valid
2909
+ * @throws {SyntaxError} if the promptbook string is not valid
2911
2910
  *
2912
2911
  * Note: This function does not validate logic of the pipeline only the syntax
2913
2912
  * Note: This function acts as compilation process
2914
2913
  */
2915
- function promptbookStringToJsonSync(promptbookString) {
2914
+ function pipelineStringToJsonSync(pipelineString) {
2916
2915
  var e_1, _a, e_2, _b;
2917
- var promptbookJson = {
2916
+ var pipelineJson = {
2918
2917
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2919
2918
  title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
2920
2919
  promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
@@ -2926,19 +2925,19 @@
2926
2925
  };
2927
2926
  // =============================================================
2928
2927
  // Note: 1️⃣ Normalization of the PROMPTBOOK string
2929
- promptbookString = removeContentComments(promptbookString);
2930
- promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
2931
- promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
2928
+ pipelineString = removeContentComments(pipelineString);
2929
+ pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
2930
+ pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
2932
2931
  // =============================================================
2933
2932
  ///Note: 2️⃣ Function for adding parameters
2934
2933
  var addParam = function (parameterCommand) {
2935
2934
  var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
2936
- var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
2935
+ var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
2937
2936
  if (existingParameter &&
2938
2937
  existingParameter.description &&
2939
2938
  existingParameter.description !== parameterDescription &&
2940
2939
  parameterDescription) {
2941
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
2940
+ throw new SyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
2942
2941
  }
2943
2942
  if (existingParameter) {
2944
2943
  if (parameterDescription) {
@@ -2946,7 +2945,7 @@
2946
2945
  }
2947
2946
  }
2948
2947
  else {
2949
- promptbookJson.parameters.push({
2948
+ pipelineJson.parameters.push({
2950
2949
  name: parameterName,
2951
2950
  description: parameterDescription || undefined,
2952
2951
  isInput: isInput,
@@ -2955,13 +2954,13 @@
2955
2954
  }
2956
2955
  };
2957
2956
  // =============================================================
2958
- // Note: 3️⃣ Parse the dynamic part - the template pipeline
2959
- var markdownStructure = markdownToMarkdownStructure(promptbookString);
2957
+ // Note: 3️⃣ Parse the dynamic part - the pipeline
2958
+ var markdownStructure = markdownToMarkdownStructure(pipelineString);
2960
2959
  var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
2961
2960
  if (markdownStructureDeepness !== 2) {
2962
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
2961
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
2963
2962
  }
2964
- promptbookJson.title = markdownStructure.title;
2963
+ pipelineJson.title = markdownStructure.title;
2965
2964
  // TODO: [1] DRY description
2966
2965
  var description = markdownStructure.content;
2967
2966
  // Note: Remove codeblocks
@@ -2972,7 +2971,7 @@
2972
2971
  if (description === '') {
2973
2972
  description = undefined;
2974
2973
  }
2975
- promptbookJson.description = description;
2974
+ pipelineJson.description = description;
2976
2975
  var defaultModelRequirements = {};
2977
2976
  var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
2978
2977
  try {
@@ -2981,10 +2980,10 @@
2981
2980
  var command = parseCommand(listItem);
2982
2981
  switch (command.type) {
2983
2982
  case 'PROMPTBOOK_URL':
2984
- promptbookJson.promptbookUrl = command.promptbookUrl.href;
2983
+ pipelineJson.promptbookUrl = command.promptbookUrl.href;
2985
2984
  break;
2986
2985
  case 'PROMPTBOOK_VERSION':
2987
- promptbookJson.promptbookVersion = command.promptbookVersion;
2986
+ pipelineJson.promptbookVersion = command.promptbookVersion;
2988
2987
  break;
2989
2988
  case 'MODEL':
2990
2989
  defaultModelRequirements[command.key] = command.value;
@@ -2993,7 +2992,7 @@
2993
2992
  addParam(command);
2994
2993
  break;
2995
2994
  default:
2996
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
2995
+ throw new SyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
2997
2996
  }
2998
2997
  }
2999
2998
  }
@@ -3027,7 +3026,7 @@
3027
3026
  break;
3028
3027
  case 'EXECUTE':
3029
3028
  if (isExecutionTypeChanged) {
3030
- throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
3029
+ throw new SyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
3031
3030
  }
3032
3031
  executionType = command.executionType;
3033
3032
  isExecutionTypeChanged = true;
@@ -3048,25 +3047,25 @@
3048
3047
  expectAmount[unit] = expectAmount[unit] || {};
3049
3048
  if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
3050
3049
  if (expectAmount[unit].min !== undefined) {
3051
- throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3050
+ throw new SyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3052
3051
  }
3053
3052
  expectAmount[unit].min = command.amount;
3054
3053
  } /* not else */
3055
3054
  if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
3056
3055
  if (expectAmount[unit].max !== undefined) {
3057
- throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3056
+ throw new SyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3058
3057
  }
3059
3058
  expectAmount[unit].max = command.amount;
3060
3059
  }
3061
3060
  break;
3062
3061
  case 'EXPECT_FORMAT':
3063
3062
  if (expectFormat !== undefined && command.format !== expectFormat) {
3064
- throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
3063
+ throw new SyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
3065
3064
  }
3066
3065
  expectFormat = command.format;
3067
3066
  break;
3068
3067
  default:
3069
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
3068
+ throw new SyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
3070
3069
  }
3071
3070
  }
3072
3071
  }
@@ -3080,16 +3079,16 @@
3080
3079
  var _f = extractOneBlockFromMarkdown(section.content), language = _f.language, content = _f.content;
3081
3080
  if (executionType === 'SCRIPT') {
3082
3081
  if (!language) {
3083
- throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
3082
+ throw new SyntaxError('You must specify the language of the script in the prompt template');
3084
3083
  }
3085
3084
  else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
3086
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
3085
+ throw new SyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
3087
3086
  }
3088
3087
  }
3089
3088
  var lastLine = section.content.split('\n').pop();
3090
3089
  var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
3091
3090
  if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
3092
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
3091
+ throw new SyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
3093
3092
  // TODO: Show code of invalid sections each time + DRY
3094
3093
  section.content
3095
3094
  .split('\n')
@@ -3139,7 +3138,7 @@
3139
3138
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3140
3139
  delete template.modelRequirements;
3141
3140
  }
3142
- promptbookJson.promptTemplates.push(template);
3141
+ pipelineJson.promptTemplates.push(template);
3143
3142
  };
3144
3143
  try {
3145
3144
  for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
@@ -3155,7 +3154,7 @@
3155
3154
  finally { if (e_2) throw e_2.error; }
3156
3155
  }
3157
3156
  // =============================================================
3158
- return promptbookJson;
3157
+ return pipelineJson;
3159
3158
  }
3160
3159
  /**
3161
3160
  * TODO: Report here line/column of error
@@ -3167,21 +3166,21 @@
3167
3166
  * Compile promptbook from string (markdown) format to JSON format
3168
3167
  *
3169
3168
  * Note: There are two similar functions:
3170
- * - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
3171
- * - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
3169
+ * - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
3170
+ * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
3172
3171
  *
3173
- * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
3172
+ * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
3174
3173
  * @param options - Options and tools for the compilation
3175
3174
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
3176
- * @throws {PromptbookSyntaxError} if the promptbook string is not valid
3175
+ * @throws {SyntaxError} if the promptbook string is not valid
3177
3176
  *
3178
3177
  * Note: This function does not validate logic of the pipeline only the syntax
3179
3178
  * Note: This function acts as compilation process
3180
3179
  */
3181
- function promptbookStringToJson(promptbookString, options) {
3180
+ function pipelineStringToJson(pipelineString, options) {
3182
3181
  if (options === void 0) { options = {}; }
3183
3182
  return __awaiter(this, void 0, void 0, function () {
3184
- var llmTools, knowledge, promptbookJson;
3183
+ var llmTools, knowledge, pipelineJson;
3185
3184
  return __generator(this, function (_a) {
3186
3185
  switch (_a.label) {
3187
3186
  case 0:
@@ -3196,8 +3195,8 @@
3196
3195
  console.info('!!!! knowledge', knowledge);
3197
3196
  _a.label = 2;
3198
3197
  case 2:
3199
- promptbookJson = promptbookStringToJsonSync(promptbookString);
3200
- return [2 /*return*/, promptbookJson];
3198
+ pipelineJson = pipelineStringToJsonSync(pipelineString);
3199
+ return [2 /*return*/, pipelineJson];
3201
3200
  }
3202
3201
  });
3203
3202
  });
@@ -3209,15 +3208,15 @@
3209
3208
  /**
3210
3209
  * This error indicates that the promptbook library cannot be propperly loaded
3211
3210
  */
3212
- var PromptbookLibraryError = /** @class */ (function (_super) {
3213
- __extends(PromptbookLibraryError, _super);
3214
- function PromptbookLibraryError(message) {
3211
+ var CollectionError = /** @class */ (function (_super) {
3212
+ __extends(CollectionError, _super);
3213
+ function CollectionError(message) {
3215
3214
  var _this = _super.call(this, message) || this;
3216
- _this.name = 'PromptbookLibraryError';
3217
- Object.setPrototypeOf(_this, PromptbookLibraryError.prototype);
3215
+ _this.name = 'CollectionError';
3216
+ Object.setPrototypeOf(_this, CollectionError.prototype);
3218
3217
  return _this;
3219
3218
  }
3220
- return PromptbookLibraryError;
3219
+ return CollectionError;
3221
3220
  }(Error));
3222
3221
 
3223
3222
  /**
@@ -3236,23 +3235,23 @@
3236
3235
  /**
3237
3236
  * Constructs Promptbook from async sources
3238
3237
  * It can be one of the following:
3239
- * - Promise of array of PromptbookJson or PromptbookString
3240
- * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
3238
+ * - Promise of array of PipelineJson or PipelineString
3239
+ * - Factory function that returns Promise of array of PipelineJson or PipelineString
3241
3240
  *
3242
3241
  * Note: This is useful as internal tool for other constructor functions like
3243
- * `createLibraryFromUrl` or `createLibraryFromDirectory`
3242
+ * `createCollectionFromUrl` or `createCollectionFromDirectory`
3244
3243
  * Consider using those functions instead of this one
3245
3244
  *
3246
3245
  * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
3247
- * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
3246
+ * when error occurs in given promise or factory function, it is thrown during `listPipelines` or `getPipelineByUrl` call
3248
3247
  *
3249
- * Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
3248
+ * Note: Consider using `createCollectionFromDirectory` or `createCollectionFromUrl`
3250
3249
  *
3251
3250
  * @param promptbookSourcesPromiseOrFactory
3252
- * @returns PromptbookLibrary
3251
+ * @returns PipelineCollection
3253
3252
  * @deprecated Do not use, it will became internal tool for other constructor functions
3254
3253
  */
3255
- function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3254
+ function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
3256
3255
  var library;
3257
3256
  function forSources() {
3258
3257
  return __awaiter(this, void 0, void 0, function () {
@@ -3267,32 +3266,32 @@
3267
3266
  return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
3268
3267
  case 1:
3269
3268
  promptbookSources = _a.sent();
3270
- library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3269
+ library = createCollectionFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3271
3270
  return [2 /*return*/];
3272
3271
  }
3273
3272
  });
3274
3273
  });
3275
3274
  }
3276
- function listPromptbooks() {
3275
+ function listPipelines() {
3277
3276
  return __awaiter(this, void 0, void 0, function () {
3278
3277
  return __generator(this, function (_a) {
3279
3278
  switch (_a.label) {
3280
3279
  case 0: return [4 /*yield*/, forSources()];
3281
3280
  case 1:
3282
3281
  _a.sent();
3283
- return [2 /*return*/, /* not await */ library.listPromptbooks()];
3282
+ return [2 /*return*/, /* not await */ library.listPipelines()];
3284
3283
  }
3285
3284
  });
3286
3285
  });
3287
3286
  }
3288
- function getPromptbookByUrl(url) {
3287
+ function getPipelineByUrl(url) {
3289
3288
  return __awaiter(this, void 0, void 0, function () {
3290
3289
  return __generator(this, function (_a) {
3291
3290
  switch (_a.label) {
3292
3291
  case 0: return [4 /*yield*/, forSources()];
3293
3292
  case 1:
3294
3293
  _a.sent();
3295
- return [2 /*return*/, /* not await */ library.getPromptbookByUrl(url)];
3294
+ return [2 /*return*/, /* not await */ library.getPipelineByUrl(url)];
3296
3295
  }
3297
3296
  });
3298
3297
  });
@@ -3310,8 +3309,8 @@
3310
3309
  });
3311
3310
  }
3312
3311
  return {
3313
- listPromptbooks: listPromptbooks,
3314
- getPromptbookByUrl: getPromptbookByUrl,
3312
+ listPipelines: listPipelines,
3313
+ getPipelineByUrl: getPipelineByUrl,
3315
3314
  isResponsibleForPrompt: isResponsibleForPrompt,
3316
3315
  };
3317
3316
  }
@@ -3323,9 +3322,9 @@
3323
3322
  *
3324
3323
  * @param path - path to the directory with promptbooks
3325
3324
  * @param options - Misc options for the library
3326
- * @returns PromptbookLibrary
3325
+ * @returns PipelineCollection
3327
3326
  */
3328
- function createLibraryFromDirectory(path$1, options) {
3327
+ function createCollectionFromDirectory(path$1, options) {
3329
3328
  return __awaiter(this, void 0, void 0, function () {
3330
3329
  var makedLibraryFilePath, makedLibraryFileExists, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, library;
3331
3330
  var _this = this;
@@ -3333,7 +3332,7 @@
3333
3332
  switch (_f.label) {
3334
3333
  case 0:
3335
3334
  if (!isRunningInNode()) {
3336
- throw new Error('Function `createLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
3335
+ throw new Error('Function `createCollectionFromDirectory` can only be run in Node.js environment because it reads the file system.');
3337
3336
  }
3338
3337
  makedLibraryFilePath = path.join(path$1, "".concat(PROMPTBOOK_MAKED_BASE_FILENAME, ".json"));
3339
3338
  return [4 /*yield*/, promises.access(makedLibraryFilePath, promises.constants.R_OK)
@@ -3349,7 +3348,7 @@
3349
3348
  // TODO: !! Implement;
3350
3349
  }
3351
3350
  _a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? false : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashOnError, isCrashOnError = _e === void 0 ? true : _e;
3352
- library = createLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3351
+ library = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3353
3352
  var fileNames, promptbooks, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
3354
3353
  var e_1, _a;
3355
3354
  return __generator(this, function (_b) {
@@ -3363,7 +3362,7 @@
3363
3362
  fileNames = _b.sent();
3364
3363
  promptbooks = [];
3365
3364
  _loop_1 = function (fileName) {
3366
- var promptbook, promptbookString, _c, _d, error_1, wrappedErrorMessage;
3365
+ var promptbook, pipelineString, _c, _d, error_1, wrappedErrorMessage;
3367
3366
  return __generator(this, function (_e) {
3368
3367
  switch (_e.label) {
3369
3368
  case 0:
@@ -3372,8 +3371,8 @@
3372
3371
  if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/, 3];
3373
3372
  return [4 /*yield*/, promises.readFile(fileName, 'utf8')];
3374
3373
  case 1:
3375
- promptbookString = (_e.sent());
3376
- return [4 /*yield*/, promptbookStringToJson(promptbookString)];
3374
+ pipelineString = (_e.sent());
3375
+ return [4 /*yield*/, pipelineStringToJson(pipelineString)];
3377
3376
  case 2:
3378
3377
  promptbook = _e.sent();
3379
3378
  return [3 /*break*/, 6];
@@ -3408,9 +3407,9 @@
3408
3407
  if (!isCrashOnError) {
3409
3408
  // Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
3410
3409
  // But be handled in current try-catch block
3411
- validatePromptbook(promptbook);
3410
+ validatePipeline(promptbook);
3412
3411
  }
3413
- // Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePromptbookLibrary
3412
+ // Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePipelineCollection
3414
3413
  promptbooks.push(promptbook);
3415
3414
  }
3416
3415
  }
@@ -3422,7 +3421,7 @@
3422
3421
  }
3423
3422
  wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n Error during loading promptbook from file ".concat(fileName.split('\\').join('/'), ":\n\n ").concat(block(error_1.message), "\n\n "); });
3424
3423
  if (isCrashOnError) {
3425
- throw new PromptbookLibraryError(wrappedErrorMessage);
3424
+ throw new CollectionError(wrappedErrorMessage);
3426
3425
  }
3427
3426
  console.error(wrappedErrorMessage);
3428
3427
  return [3 /*break*/, 8];
@@ -3461,7 +3460,7 @@
3461
3460
  });
3462
3461
  }); });
3463
3462
  if (!(isLazyLoaded === false)) return [3 /*break*/, 3];
3464
- return [4 /*yield*/, library.listPromptbooks()];
3463
+ return [4 /*yield*/, library.listPipelines()];
3465
3464
  case 2:
3466
3465
  _f.sent();
3467
3466
  _f.label = 3;
@@ -3476,7 +3475,7 @@
3476
3475
  * @param path
3477
3476
  * @param isRecursive
3478
3477
  * @returns List of all files in the directory
3479
- * @private internal function for `createLibraryFromDirectory`
3478
+ * @private internal function for `createCollectionFromDirectory`
3480
3479
  */
3481
3480
  function listAllFiles(path$1, isRecursive) {
3482
3481
  return __awaiter(this, void 0, void 0, function () {
@@ -3534,7 +3533,7 @@
3534
3533
  */
3535
3534
 
3536
3535
  exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
3537
- exports.createLibraryFromDirectory = createLibraryFromDirectory;
3536
+ exports.createCollectionFromDirectory = createCollectionFromDirectory;
3538
3537
 
3539
3538
  Object.defineProperty(exports, '__esModule', { value: true });
3540
3539