@promptbook/core 0.62.1 → 0.63.0-1

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 (332) hide show
  1. package/README.md +1 -1
  2. package/esm/index.es.js +533 -39
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/anthropic-claude.index.d.ts +3 -2
  5. package/esm/typings/src/_packages/azure-openai.index.d.ts +4 -2
  6. package/esm/typings/src/_packages/browser.index.d.ts +6 -0
  7. package/esm/typings/src/_packages/cli.index.d.ts +1 -7
  8. package/esm/typings/src/_packages/core.index.d.ts +87 -13
  9. package/esm/typings/src/_packages/execute-javascript.index.d.ts +5 -45
  10. package/esm/typings/src/_packages/fake-llm.index.d.ts +4 -5
  11. package/esm/typings/src/_packages/langtail.index.d.ts +4 -2
  12. package/esm/typings/src/_packages/markdown-utils.index.d.ts +23 -4
  13. package/esm/typings/src/_packages/node.index.d.ts +5 -2
  14. package/esm/typings/src/_packages/openai.index.d.ts +5 -2
  15. package/esm/typings/src/_packages/remote-client.index.d.ts +5 -2
  16. package/esm/typings/src/_packages/remote-server.index.d.ts +4 -2
  17. package/esm/typings/src/_packages/types.index.d.ts +441 -21
  18. package/esm/typings/src/_packages/utils.index.d.ts +84 -31
  19. package/esm/typings/src/cli/main.d.ts +12 -0
  20. package/esm/typings/src/collection/collectionToJson.d.ts +2 -0
  21. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -0
  22. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -0
  23. package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -0
  24. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  25. package/esm/typings/src/collection/constructors/createSubcollection.d.ts +1 -0
  26. package/esm/typings/src/commands/BLOCK/BlockTypes.d.ts +2 -0
  27. package/esm/typings/src/config.d.ts +27 -1
  28. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  29. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +6 -3
  30. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +4 -3
  31. package/esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts +2 -0
  32. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -0
  33. package/esm/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts +1 -0
  34. package/esm/typings/src/conversion/utils/extractVariables.d.ts +1 -0
  35. package/esm/typings/src/conversion/utils/renameParameter.d.ts +1 -0
  36. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +2 -0
  37. package/esm/typings/src/conversion/utils/titleToName.d.ts +6 -1
  38. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +1 -0
  39. package/esm/typings/src/errors/CollectionError.d.ts +2 -0
  40. package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +2 -0
  41. package/esm/typings/src/errors/LimitReachedError.d.ts +2 -0
  42. package/esm/typings/src/errors/NotFoundError.d.ts +2 -0
  43. package/esm/typings/src/errors/NotYetImplementedError.d.ts +2 -0
  44. package/esm/typings/src/errors/ParsingError.d.ts +2 -0
  45. package/esm/typings/src/errors/PipelineExecutionError.d.ts +2 -0
  46. package/esm/typings/src/errors/PipelineLogicError.d.ts +2 -0
  47. package/esm/typings/src/errors/ReferenceError.d.ts +2 -0
  48. package/esm/typings/src/errors/UnexpectedError.d.ts +2 -0
  49. package/esm/typings/src/errors/VersionMismatchError.d.ts +2 -0
  50. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -0
  51. package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -0
  52. package/esm/typings/src/execution/embeddingVectorToString.d.ts +2 -0
  53. package/esm/typings/src/execution/utils/addUsage.d.ts +3 -1
  54. package/esm/typings/src/execution/utils/checkExpectations.d.ts +2 -0
  55. package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -0
  56. package/esm/typings/src/execution/utils/usageToHuman.d.ts +2 -0
  57. package/esm/typings/src/execution/utils/usageToWorktime.d.ts +2 -0
  58. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -1
  59. package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +2 -0
  60. package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +2 -0
  61. package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +2 -0
  62. package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -1
  63. package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +10 -0
  64. package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +1 -1
  65. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +2 -0
  66. package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +4 -1
  67. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +1 -1
  68. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts +1 -1
  69. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -1
  70. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -0
  71. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -1
  72. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -0
  73. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +1 -0
  74. package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +2 -0
  75. package/esm/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +2 -0
  76. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -0
  77. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +2 -0
  78. package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +2 -0
  79. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -0
  80. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -0
  81. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  82. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
  83. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +2 -0
  84. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +7 -1
  85. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -0
  86. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  87. package/esm/typings/src/postprocessing/utils/extractBlock.d.ts +5 -0
  88. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -1
  89. package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
  90. package/esm/typings/src/prepare/prepareTemplates.d.ts +2 -1
  91. package/esm/typings/src/prepare/unpreparePipeline.d.ts +2 -1
  92. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +2 -0
  93. package/esm/typings/src/scripting/javascript/JavascriptExecutionTools.d.ts +1 -0
  94. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +51 -0
  95. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +0 -1
  96. package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +2 -1
  97. package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +0 -3
  98. package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +2 -1
  99. package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +2 -1
  100. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +2 -3
  101. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +2 -3
  102. package/esm/typings/src/types/ModelRequirements.d.ts +0 -1
  103. package/esm/typings/src/types/Prompt.d.ts +0 -1
  104. package/esm/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +4 -0
  105. package/esm/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -0
  106. package/esm/typings/src/types/typeAliases.d.ts +9 -2
  107. package/esm/typings/src/utils/currentDate.d.ts +1 -0
  108. package/esm/typings/src/utils/deepClone.d.ts +2 -1
  109. package/esm/typings/src/utils/deepFreeze.d.ts +1 -1
  110. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +2 -0
  111. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
  112. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
  113. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +2 -0
  114. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +4 -0
  115. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +2 -0
  116. package/esm/typings/src/utils/expectation-counters/index.d.ts +2 -0
  117. package/esm/typings/src/utils/extractParameterNames.d.ts +1 -0
  118. package/esm/typings/src/utils/isRunningInWhatever.d.ts +6 -3
  119. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +4 -1
  120. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  121. package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +4 -1
  122. package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +5 -0
  123. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  124. package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +2 -1
  125. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -0
  126. package/esm/typings/src/utils/markdown/flattenMarkdown.d.ts +3 -0
  127. package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +4 -0
  128. package/esm/typings/src/utils/markdown/removeContentComments.d.ts +1 -0
  129. package/esm/typings/src/utils/markdown/removeMarkdownFormatting.d.ts +1 -0
  130. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +3 -0
  131. package/esm/typings/src/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +2 -0
  132. package/esm/typings/src/utils/normalization/IKeywords.d.ts +3 -0
  133. package/esm/typings/src/utils/normalization/capitalize.d.ts +1 -0
  134. package/esm/typings/src/utils/normalization/decapitalize.d.ts +1 -0
  135. package/esm/typings/src/utils/normalization/isValidKeyword.d.ts +2 -0
  136. package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +8 -0
  137. package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +8 -0
  138. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +10 -0
  139. package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +9 -0
  140. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +10 -0
  141. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +11 -0
  142. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +9 -0
  143. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +1 -0
  144. package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +1 -0
  145. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +7 -0
  146. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +5 -0
  147. package/esm/typings/src/utils/parseNumber.d.ts +2 -1
  148. package/esm/typings/src/utils/random/randomSeed.d.ts +1 -0
  149. package/esm/typings/src/utils/removeEmojis.d.ts +1 -0
  150. package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
  151. package/esm/typings/src/utils/replaceParameters.d.ts +1 -0
  152. package/esm/typings/src/utils/sets/difference.d.ts +1 -0
  153. package/esm/typings/src/utils/sets/intersection.d.ts +1 -0
  154. package/esm/typings/src/utils/sets/union.d.ts +1 -0
  155. package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
  156. package/esm/typings/src/utils/trimEndOfCodeBlock.d.ts +2 -0
  157. package/esm/typings/src/utils/unwrapResult.d.ts +1 -0
  158. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +1 -0
  159. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +7 -0
  160. package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -0
  161. package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -0
  162. package/esm/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +2 -0
  163. package/esm/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +1 -0
  164. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -0
  165. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -0
  166. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
  167. package/package.json +1 -1
  168. package/umd/index.umd.js +556 -43
  169. package/umd/index.umd.js.map +1 -1
  170. package/umd/typings/src/_packages/anthropic-claude.index.d.ts +3 -2
  171. package/umd/typings/src/_packages/azure-openai.index.d.ts +4 -2
  172. package/umd/typings/src/_packages/browser.index.d.ts +6 -0
  173. package/umd/typings/src/_packages/cli.index.d.ts +1 -7
  174. package/umd/typings/src/_packages/core.index.d.ts +87 -13
  175. package/umd/typings/src/_packages/execute-javascript.index.d.ts +5 -45
  176. package/umd/typings/src/_packages/fake-llm.index.d.ts +4 -5
  177. package/umd/typings/src/_packages/langtail.index.d.ts +4 -2
  178. package/umd/typings/src/_packages/markdown-utils.index.d.ts +23 -4
  179. package/umd/typings/src/_packages/node.index.d.ts +5 -2
  180. package/umd/typings/src/_packages/openai.index.d.ts +5 -2
  181. package/umd/typings/src/_packages/remote-client.index.d.ts +5 -2
  182. package/umd/typings/src/_packages/remote-server.index.d.ts +4 -2
  183. package/umd/typings/src/_packages/types.index.d.ts +441 -21
  184. package/umd/typings/src/_packages/utils.index.d.ts +84 -31
  185. package/umd/typings/src/cli/main.d.ts +12 -0
  186. package/umd/typings/src/collection/collectionToJson.d.ts +2 -0
  187. package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -0
  188. package/umd/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -0
  189. package/umd/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -0
  190. package/umd/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  191. package/umd/typings/src/collection/constructors/createSubcollection.d.ts +1 -0
  192. package/umd/typings/src/commands/BLOCK/BlockTypes.d.ts +2 -0
  193. package/umd/typings/src/config.d.ts +27 -1
  194. package/umd/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  195. package/umd/typings/src/conversion/pipelineStringToJson.d.ts +6 -3
  196. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +4 -3
  197. package/umd/typings/src/conversion/prettify/prettifyPipelineString.d.ts +2 -0
  198. package/umd/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -0
  199. package/umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts +1 -0
  200. package/umd/typings/src/conversion/utils/extractVariables.d.ts +1 -0
  201. package/umd/typings/src/conversion/utils/renameParameter.d.ts +1 -0
  202. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +2 -0
  203. package/umd/typings/src/conversion/utils/titleToName.d.ts +6 -1
  204. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +1 -0
  205. package/umd/typings/src/errors/CollectionError.d.ts +2 -0
  206. package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +2 -0
  207. package/umd/typings/src/errors/LimitReachedError.d.ts +2 -0
  208. package/umd/typings/src/errors/NotFoundError.d.ts +2 -0
  209. package/umd/typings/src/errors/NotYetImplementedError.d.ts +2 -0
  210. package/umd/typings/src/errors/ParsingError.d.ts +2 -0
  211. package/umd/typings/src/errors/PipelineExecutionError.d.ts +2 -0
  212. package/umd/typings/src/errors/PipelineLogicError.d.ts +2 -0
  213. package/umd/typings/src/errors/ReferenceError.d.ts +2 -0
  214. package/umd/typings/src/errors/UnexpectedError.d.ts +2 -0
  215. package/umd/typings/src/errors/VersionMismatchError.d.ts +2 -0
  216. package/umd/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -0
  217. package/umd/typings/src/execution/createPipelineExecutor.d.ts +1 -0
  218. package/umd/typings/src/execution/embeddingVectorToString.d.ts +2 -0
  219. package/umd/typings/src/execution/utils/addUsage.d.ts +3 -1
  220. package/umd/typings/src/execution/utils/checkExpectations.d.ts +2 -0
  221. package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -0
  222. package/umd/typings/src/execution/utils/usageToHuman.d.ts +2 -0
  223. package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -0
  224. package/umd/typings/src/formats/_common/FormatDefinition.d.ts +2 -1
  225. package/umd/typings/src/formats/json/utils/isValidJsonString.d.ts +2 -0
  226. package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +2 -0
  227. package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +2 -0
  228. package/umd/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -1
  229. package/umd/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +10 -0
  230. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +1 -1
  231. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +2 -0
  232. package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +4 -1
  233. package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +1 -1
  234. package/umd/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts +1 -1
  235. package/umd/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -1
  236. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -0
  237. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -1
  238. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -0
  239. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +1 -0
  240. package/umd/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +2 -0
  241. package/umd/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +2 -0
  242. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -0
  243. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +2 -0
  244. package/umd/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +2 -0
  245. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -0
  246. package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -0
  247. package/umd/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  248. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
  249. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +2 -0
  250. package/umd/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +7 -1
  251. package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -0
  252. package/umd/typings/src/personas/preparePersona.d.ts +1 -1
  253. package/umd/typings/src/postprocessing/utils/extractBlock.d.ts +5 -0
  254. package/umd/typings/src/prepare/isPipelinePrepared.d.ts +2 -1
  255. package/umd/typings/src/prepare/preparePipeline.d.ts +1 -1
  256. package/umd/typings/src/prepare/prepareTemplates.d.ts +2 -1
  257. package/umd/typings/src/prepare/unpreparePipeline.d.ts +2 -1
  258. package/umd/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +2 -0
  259. package/umd/typings/src/scripting/javascript/JavascriptExecutionTools.d.ts +1 -0
  260. package/umd/typings/src/scripting/javascript/postprocessing-functions.d.ts +51 -0
  261. package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +0 -1
  262. package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +2 -1
  263. package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +0 -3
  264. package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +2 -1
  265. package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +2 -1
  266. package/umd/typings/src/storage/memory/MemoryStorage.d.ts +2 -3
  267. package/umd/typings/src/storage/utils/PrefixStorage.d.ts +2 -3
  268. package/umd/typings/src/types/ModelRequirements.d.ts +0 -1
  269. package/umd/typings/src/types/Prompt.d.ts +0 -1
  270. package/umd/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +4 -0
  271. package/umd/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -0
  272. package/umd/typings/src/types/typeAliases.d.ts +9 -2
  273. package/umd/typings/src/utils/currentDate.d.ts +1 -0
  274. package/umd/typings/src/utils/deepClone.d.ts +2 -1
  275. package/umd/typings/src/utils/deepFreeze.d.ts +1 -1
  276. package/umd/typings/src/utils/expectation-counters/countCharacters.d.ts +2 -0
  277. package/umd/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
  278. package/umd/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
  279. package/umd/typings/src/utils/expectation-counters/countParagraphs.d.ts +2 -0
  280. package/umd/typings/src/utils/expectation-counters/countSentences.d.ts +4 -0
  281. package/umd/typings/src/utils/expectation-counters/countWords.d.ts +2 -0
  282. package/umd/typings/src/utils/expectation-counters/index.d.ts +2 -0
  283. package/umd/typings/src/utils/extractParameterNames.d.ts +1 -0
  284. package/umd/typings/src/utils/isRunningInWhatever.d.ts +6 -3
  285. package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +4 -1
  286. package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  287. package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +4 -1
  288. package/umd/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +5 -0
  289. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  290. package/umd/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +2 -1
  291. package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -0
  292. package/umd/typings/src/utils/markdown/flattenMarkdown.d.ts +3 -0
  293. package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +4 -0
  294. package/umd/typings/src/utils/markdown/removeContentComments.d.ts +1 -0
  295. package/umd/typings/src/utils/markdown/removeMarkdownFormatting.d.ts +1 -0
  296. package/umd/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +3 -0
  297. package/umd/typings/src/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +2 -0
  298. package/umd/typings/src/utils/normalization/IKeywords.d.ts +3 -0
  299. package/umd/typings/src/utils/normalization/capitalize.d.ts +1 -0
  300. package/umd/typings/src/utils/normalization/decapitalize.d.ts +1 -0
  301. package/umd/typings/src/utils/normalization/isValidKeyword.d.ts +2 -0
  302. package/umd/typings/src/utils/normalization/nameToUriPart.d.ts +8 -0
  303. package/umd/typings/src/utils/normalization/nameToUriParts.d.ts +8 -0
  304. package/umd/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +10 -0
  305. package/umd/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +9 -0
  306. package/umd/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +10 -0
  307. package/umd/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +11 -0
  308. package/umd/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +9 -0
  309. package/umd/typings/src/utils/normalization/parseKeywords.d.ts +1 -0
  310. package/umd/typings/src/utils/normalization/parseKeywordsFromString.d.ts +1 -0
  311. package/umd/typings/src/utils/normalization/removeDiacritics.d.ts +7 -0
  312. package/umd/typings/src/utils/normalization/searchKeywords.d.ts +5 -0
  313. package/umd/typings/src/utils/parseNumber.d.ts +2 -1
  314. package/umd/typings/src/utils/random/randomSeed.d.ts +1 -0
  315. package/umd/typings/src/utils/removeEmojis.d.ts +1 -0
  316. package/umd/typings/src/utils/removeQuotes.d.ts +1 -0
  317. package/umd/typings/src/utils/replaceParameters.d.ts +1 -0
  318. package/umd/typings/src/utils/sets/difference.d.ts +1 -0
  319. package/umd/typings/src/utils/sets/intersection.d.ts +1 -0
  320. package/umd/typings/src/utils/sets/union.d.ts +1 -0
  321. package/umd/typings/src/utils/trimCodeBlock.d.ts +1 -0
  322. package/umd/typings/src/utils/trimEndOfCodeBlock.d.ts +2 -0
  323. package/umd/typings/src/utils/unwrapResult.d.ts +1 -0
  324. package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +1 -0
  325. package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +7 -0
  326. package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -0
  327. package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -0
  328. package/umd/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +2 -0
  329. package/umd/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +1 -0
  330. package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -0
  331. package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -0
  332. package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
package/umd/index.umd.js CHANGED
@@ -1,15 +1,23 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('moment')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'moment'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.moment));
5
- })(this, (function (exports, spaceTrim, prettier, parserHtml, moment) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('moment')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'moment'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.moment));
5
+ })(this, (function (exports, spaceTrim, prettier, parserHtml, hexEncoder, sha256, moment) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
10
10
  var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
11
+ var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
12
+ var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
11
13
  var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
12
14
 
15
+ /**
16
+ * The version of the Promptbook library
17
+ */
18
+ var PROMPTBOOK_VERSION = '0.63.0-0';
19
+ // TODO: !!!! List here all the versions and annotate + put into script
20
+
13
21
  /*! *****************************************************************************
14
22
  Copyright (c) Microsoft Corporation.
15
23
 
@@ -133,6 +141,8 @@
133
141
  * Converts PipelineCollection to serialized JSON
134
142
  *
135
143
  * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
144
+ *
145
+ * @public exported from `@promptbook/core`
136
146
  */
137
147
  function collectionToJson(collection) {
138
148
  return __awaiter(this, void 0, void 0, function () {
@@ -191,6 +201,7 @@
191
201
  /**
192
202
  * Makes first letter of a string uppercase
193
203
  *
204
+ * @public exported from `@promptbook/utils`
194
205
  */
195
206
  function capitalize(word) {
196
207
  return word.substring(0, 1).toUpperCase() + word.substring(1);
@@ -201,6 +212,7 @@
201
212
  *
202
213
  * @param pipelineJson Promptbook in JSON format (.ptbk.json)
203
214
  * @returns Promptbook in string format (.ptbk.md)
215
+ * @public exported from `@promptbook/core`
204
216
  */
205
217
  function pipelineJsonToString(pipelineJson) {
206
218
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
@@ -431,6 +443,7 @@
431
443
  * @@@
432
444
  *
433
445
  * @returns The same object as the input, but deeply frozen
446
+ * @public exported from `@promptbook/utils`
434
447
  *
435
448
  * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
436
449
  */
@@ -438,7 +451,6 @@
438
451
  return deepFreeze(objectValue);
439
452
  }
440
453
  /**
441
- * TODO: [🔼] Export from `@promptbook/utils`
442
454
  * TODO: [🧠] Is there a way how to meaningfully test this utility
443
455
  */
444
456
 
@@ -464,22 +476,62 @@
464
476
 
465
477
  /**
466
478
  * The maximum number of iterations for a loops
479
+ *
480
+ * @private within the repository - too low-level in comparison to other `MAX_...`
467
481
  */
468
482
  var LOOP_LIMIT = 1000;
469
483
  /**
470
484
  * The maximum number of (LLM) tasks running in parallel
485
+ *
486
+ * @public exported from `@promptbook/core`
471
487
  */
472
488
  var MAX_PARALLEL_COUNT = 5;
473
489
  /**
474
490
  * The maximum number of attempts to execute LLM task before giving up
491
+ *
492
+ * @public exported from `@promptbook/core`
475
493
  */
476
494
  var MAX_EXECUTION_ATTEMPTS = 3;
495
+ /**
496
+ * The maximum length of the (generated) filename
497
+ *
498
+ * @public exported from `@promptbook/core`
499
+ */
500
+ var MAX_FILENAME_LENGTH = 30;
501
+ /**
502
+ * @@@
503
+ * TODO: [🐝] !!! Use
504
+ *
505
+ * @public exported from `@promptbook/core`
506
+ */
507
+ var MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
508
+ /**
509
+ * @@@
510
+ * TODO: [🐝] !!! Use
511
+ *
512
+ * @public exported from `@promptbook/core`
513
+ */
514
+ var MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
515
+ /**
516
+ * Where to store the cache of executions for promptbook CLI
517
+ *
518
+ * @public exported from `@promptbook/core`
519
+ */
520
+ var EXECUTIONS_CACHE_DIRNAME = '/.promptbook/executions-cache';
521
+ /**
522
+ * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
523
+ *
524
+ * @public exported from `@promptbook/core`
525
+ */
526
+ var PIPELINE_COLLECTION_BASE_FILENAME = "index";
477
527
  /**
478
528
  * Nonce which is used for replacing things in strings
479
529
  */
480
530
  var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
481
531
  /**
482
532
  * The names of the parameters that are reserved for special purposes
533
+ *
534
+ * @public exported from `@promptbook/core`
483
535
  */
484
536
  var RESERVED_PARAMETER_NAMES = deepFreeze([
485
537
  'content',
@@ -493,10 +545,14 @@
493
545
  ]);
494
546
  /**
495
547
  * @@@
548
+ *
549
+ * @private within the repository
496
550
  */
497
551
  var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
498
552
  /**
499
553
  * @@@
554
+ *
555
+ * @private within the repository
500
556
  */
501
557
  var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
502
558
  /*
@@ -504,11 +560,13 @@
504
560
  */
505
561
  // [🟡][🟢][🔵][⚪]
506
562
  /**
507
- * TODO: [🔼] Export all to core
563
+ * TODO: !!!!!! Check that all @private contains some normalized explanation
508
564
  */
509
565
 
510
566
  /**
511
567
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
568
+ *
569
+ * @public exported from `@promptbook/core`
512
570
  */
513
571
  var ParsingError = /** @class */ (function (_super) {
514
572
  __extends(ParsingError, _super);
@@ -523,6 +581,8 @@
523
581
 
524
582
  /**
525
583
  * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
584
+ *
585
+ * @public exported from `@promptbook/core`
526
586
  */
527
587
  var PipelineLogicError = /** @class */ (function (_super) {
528
588
  __extends(PipelineLogicError, _super);
@@ -537,6 +597,8 @@
537
597
 
538
598
  /**
539
599
  * This error type indicates that the error should not happen and its last check before crashing with some other error
600
+ *
601
+ * @public exported from `@promptbook/core`
540
602
  */
541
603
  var UnexpectedError = /** @class */ (function (_super) {
542
604
  __extends(UnexpectedError, _super);
@@ -555,6 +617,8 @@
555
617
  * Note: There are two simmilar functions:
556
618
  * - `isValidSemanticVersion` which tests any semantic version
557
619
  * - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
620
+ *
621
+ * @public exported from `@promptbook/utils`
558
622
  */
559
623
  function isValidSemanticVersion(version) {
560
624
  if (typeof version !== 'string') {
@@ -575,6 +639,8 @@
575
639
  * Note: There are two simmilar functions:
576
640
  * - `isValidSemanticVersion` which tests any semantic version
577
641
  * - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
642
+ *
643
+ * @public exported from `@promptbook/utils`
578
644
  */
579
645
  function isValidPromptbookVersion(version) {
580
646
  if (!isValidSemanticVersion(version)) {
@@ -593,6 +659,8 @@
593
659
  * Note: There are two simmilar functions:
594
660
  * - `isUrlOnPrivateNetwork` which tests full URL
595
661
  * - `isHostnameOnPrivateNetwork` *(this one)* which tests just hostname
662
+ *
663
+ * @public exported from `@promptbook/utils`
596
664
  */
597
665
  function isHostnameOnPrivateNetwork(hostname) {
598
666
  if (hostname === 'example.com' ||
@@ -627,6 +695,7 @@
627
695
  *
628
696
  * @param {string} ipAddress - The IP address to check.
629
697
  * @returns {boolean} Returns true if the IP address is reserved for private networks or localhost, otherwise false.
698
+ * @public exported from `@promptbook/utils`
630
699
  */
631
700
  function isUrlOnPrivateNetwork(url) {
632
701
  if (typeof url === 'string') {
@@ -642,6 +711,8 @@
642
711
  * Note: There are two simmilar functions:
643
712
  * - `isValidUrl` which tests any URL
644
713
  * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
714
+ *
715
+ * @public exported from `@promptbook/utils`
645
716
  */
646
717
  function isValidUrl(url) {
647
718
  if (typeof url !== 'string') {
@@ -668,6 +739,8 @@
668
739
  * Note: There are two simmilar functions:
669
740
  * - `isValidUrl` which tests any URL
670
741
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
742
+ *
743
+ * @public exported from `@promptbook/utils`
671
744
  */
672
745
  function isValidPipelineUrl(url) {
673
746
  if (!isValidUrl(url)) {
@@ -705,6 +778,7 @@
705
778
  * @param pipeline valid or invalid PipelineJson
706
779
  * @returns the same pipeline if it is logically valid
707
780
  * @throws {PipelineLogicError} on logical error in the pipeline
781
+ * @public exported from `@promptbook/core`
708
782
  */
709
783
  function validatePipeline(pipeline) {
710
784
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
@@ -934,6 +1008,8 @@
934
1008
 
935
1009
  /**
936
1010
  * This error indicates that promptbook not found in the collection
1011
+ *
1012
+ * @public exported from `@promptbook/core`
937
1013
  */
938
1014
  var NotFoundError = /** @class */ (function (_super) {
939
1015
  __extends(NotFoundError, _super);
@@ -948,6 +1024,8 @@
948
1024
 
949
1025
  /**
950
1026
  * This error indicates errors in referencing promptbooks between each other
1027
+ *
1028
+ * @public exported from `@promptbook/core`
951
1029
  */
952
1030
  var ReferenceError$1 = /** @class */ (function (_super) {
953
1031
  __extends(ReferenceError, _super);
@@ -965,6 +1043,7 @@
965
1043
  *
966
1044
  * @param template the template with parameters in {curly} braces
967
1045
  * @returns the list of parameter names
1046
+ * @public exported from `@promptbook/utils`
968
1047
  */
969
1048
  function extractParameterNames(template) {
970
1049
  var e_1, _a;
@@ -989,6 +1068,8 @@
989
1068
 
990
1069
  /**
991
1070
  * Unprepare just strips the preparation data of the pipeline
1071
+ *
1072
+ * @public exported from `@promptbook/core`
992
1073
  */
993
1074
  function unpreparePipeline(pipeline) {
994
1075
  var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, promptTemplates = pipeline.promptTemplates;
@@ -1005,7 +1086,6 @@
1005
1086
  return __assign(__assign({}, pipeline), { promptTemplates: promptTemplates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
1006
1087
  }
1007
1088
  /**
1008
- * TODO: [🔼] !!! Export via `@promptbook/core`
1009
1089
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
1010
1090
  * TODO: Write tests for `preparePipeline`
1011
1091
  * TODO: [🍙] Make some standart order of json properties
@@ -1107,6 +1187,7 @@
1107
1187
  *
1108
1188
  * @param promptbookSources
1109
1189
  * @returns PipelineCollection
1190
+ * @public exported from `@promptbook/core`
1110
1191
  */
1111
1192
  function createCollectionFromJson() {
1112
1193
  var promptbooks = [];
@@ -1134,6 +1215,7 @@
1134
1215
  * @param promptbookSourcesPromiseOrFactory
1135
1216
  * @returns PipelineCollection
1136
1217
  * @deprecated Do not use, it will became internal tool for other constructor functions
1218
+ * @public exported from `@promptbook/core`
1137
1219
  */
1138
1220
  function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
1139
1221
  var collection = null;
@@ -1204,8 +1286,8 @@
1204
1286
 
1205
1287
  /**
1206
1288
  * Constructs Promptbook from remote Promptbase URL
1207
-
1208
1289
  * @returns PipelineCollection
1290
+ * @public exported from `@promptbook/core`
1209
1291
  */
1210
1292
  function createCollectionFromUrl(url, options) {
1211
1293
  return __awaiter(this, void 0, void 0, function () {
@@ -1245,6 +1327,7 @@
1245
1327
  *
1246
1328
  * @param promptbookSources
1247
1329
  * @returns PipelineCollection
1330
+ * @public exported from `@promptbook/core`
1248
1331
  */
1249
1332
  function createSubcollection(collection, predicate) {
1250
1333
  function listPipelines() {
@@ -1320,6 +1403,7 @@
1320
1403
  * Block type describes the way how the block is blockd
1321
1404
  *
1322
1405
  * @see https://github.com/webgptorg/promptbook#block-type
1406
+ * @public exported from `@promptbook/core`
1323
1407
  */
1324
1408
  var BlockTypes = [
1325
1409
  'PROMPT_TEMPLATE',
@@ -1335,6 +1419,8 @@
1335
1419
 
1336
1420
  /**
1337
1421
  * @@@
1422
+ *
1423
+ * @public exported from `@promptbook/utils`
1338
1424
  */
1339
1425
  function deepClone(objectValue) {
1340
1426
  return JSON.parse(JSON.stringify(objectValue));
@@ -1351,14 +1437,13 @@
1351
1437
  */
1352
1438
  }
1353
1439
  /**
1354
- * TODO: [🔼] Export from `@promptbook/utils`
1355
1440
  * TODO: [🧠] Is there a way how to meaningfully test this utility
1356
1441
  */
1357
1442
 
1358
1443
  /**
1359
1444
  * @@@
1360
1445
  *
1361
- * TODO: [🔼] Export with addUsage
1446
+ * @public exported from `@promptbook/core`
1362
1447
  */
1363
1448
  var ZERO_USAGE = deepFreeze({
1364
1449
  price: { value: 0 },
@@ -1385,6 +1470,8 @@
1385
1470
  * Function `addUsage` will add multiple usages into one
1386
1471
  *
1387
1472
  * Note: If you provide 0 values, it returns ZERO_USAGE
1473
+ *
1474
+ * @public exported from `@promptbook/core`
1388
1475
  */
1389
1476
  function addUsage() {
1390
1477
  var usageItems = [];
@@ -1457,6 +1544,7 @@
1457
1544
  * @param array - Array to iterate over
1458
1545
  * @param options - Options for the function
1459
1546
  * @param callbackfunction - Function to call for each item
1547
+ * @public exported from `@promptbook/utils`
1460
1548
  */
1461
1549
  function forEachAsync(array, options, callbackfunction) {
1462
1550
  return __awaiter(this, void 0, void 0, function () {
@@ -1525,7 +1613,7 @@
1525
1613
  });
1526
1614
  }
1527
1615
 
1528
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.62.0",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.62.0",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.62.0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.62.0",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.62.0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.62.0",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.62.0",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.62.0",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1616
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.0-0",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-0",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.63.0-0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-0",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.63.0-0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-0",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.63.0-0",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-0",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1529
1617
 
1530
1618
  var defaultDiacriticsRemovalMap = [
1531
1619
  {
@@ -1743,6 +1831,8 @@
1743
1831
  * > "ě" => "e"
1744
1832
  * > "Ă" => "A"
1745
1833
  * > ...
1834
+ *
1835
+ * @public exported from `@promptbook/utils`
1746
1836
  */
1747
1837
  var DIACRITIC_VARIANTS_LETTERS = {};
1748
1838
  // tslint:disable-next-line: prefer-for-of
@@ -1770,7 +1860,11 @@
1770
1860
  */
1771
1861
 
1772
1862
  /**
1863
+ * @@@
1773
1864
  *
1865
+ * @param input @@@
1866
+ * @returns @@@
1867
+ * @public exported from `@promptbook/utils`
1774
1868
  */
1775
1869
  function removeDiacritics(input) {
1776
1870
  /*eslint no-control-regex: "off"*/
@@ -1778,7 +1872,19 @@
1778
1872
  return DIACRITIC_VARIANTS_LETTERS[a] || a;
1779
1873
  });
1780
1874
  }
1875
+ /**
1876
+ * TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
1877
+ */
1781
1878
 
1879
+ /**
1880
+ * @@@
1881
+ *
1882
+ * @param text @@@
1883
+ * @returns @@@
1884
+ * @example 'hello-world'
1885
+ * @example 'i-love-promptbook'
1886
+ * @public exported from `@promptbook/utils`
1887
+ */
1782
1888
  function normalizeToKebabCase(text) {
1783
1889
  var e_1, _a;
1784
1890
  text = removeDiacritics(text);
@@ -1838,6 +1944,7 @@
1838
1944
  *
1839
1945
  * @param text with emojis
1840
1946
  * @returns text without emojis
1947
+ * @public exported from `@promptbook/utils`
1841
1948
  */
1842
1949
  function removeEmojis(text) {
1843
1950
  // Replace emojis (and also ZWJ sequence) with hyphens
@@ -1849,7 +1956,12 @@
1849
1956
  }
1850
1957
 
1851
1958
  /**
1852
- * Function normalizes title to name which can be used as identifier
1959
+ * @@@
1960
+ *
1961
+ * @param value @@@
1962
+ * @returns @@@
1963
+ * @example @@@
1964
+ * @public exported from `@promptbook/utils`
1853
1965
  */
1854
1966
  function titleToName(value) {
1855
1967
  if (value.startsWith('http://') || value.startsWith('https://')) {
@@ -1868,6 +1980,8 @@
1868
1980
 
1869
1981
  /**
1870
1982
  * This error indicates errors during the execution of the pipeline
1983
+ *
1984
+ * @public exported from `@promptbook/core`
1871
1985
  */
1872
1986
  var PipelineExecutionError = /** @class */ (function (_super) {
1873
1987
  __extends(PipelineExecutionError, _super);
@@ -1885,6 +1999,7 @@
1885
1999
  *
1886
2000
  * @param executionResult - The partial result of the promptnook execution
1887
2001
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
2002
+ * @public exported from `@promptbook/core`
1888
2003
  */
1889
2004
  function assertsExecutionSuccessful(executionResult) {
1890
2005
  var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
@@ -1915,6 +2030,7 @@
1915
2030
  * @param script from which to extract the variables
1916
2031
  * @returns the list of variable names
1917
2032
  * @throws {ParsingError} if the script is invalid
2033
+ * @public exported from `@promptbook/utils`
1918
2034
  */
1919
2035
  function extractVariables(script) {
1920
2036
  var variables = new Set();
@@ -1963,6 +2079,7 @@
1963
2079
  * @param promptTemplate the template with used parameters
1964
2080
  * @returns the set of parameter names
1965
2081
  * @throws {ParsingError} if the script is invalid
2082
+ * @public exported from `@promptbook/utils`
1966
2083
  */
1967
2084
  function extractParameterNamesFromPromptTemplate(promptTemplate) {
1968
2085
  var e_1, _a, e_2, _b, e_3, _c;
@@ -2036,6 +2153,8 @@
2036
2153
 
2037
2154
  /**
2038
2155
  * Function isValidJsonString will tell you if the string is valid JSON or not
2156
+ *
2157
+ * @public exported from `@promptbook/utils`
2039
2158
  */
2040
2159
  function isValidJsonString(value /* <- [👨‍⚖️] */) {
2041
2160
  try {
@@ -2262,6 +2381,8 @@
2262
2381
  *
2263
2382
  *
2264
2383
  * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
2384
+ *
2385
+ * @public exported from `@promptbook/core`
2265
2386
  */
2266
2387
  function joinLlmExecutionTools() {
2267
2388
  var llmExecutionTools = [];
@@ -2301,6 +2422,8 @@
2301
2422
 
2302
2423
  /**
2303
2424
  * Determine if the pipeline is fully prepared
2425
+ *
2426
+ * @public exported from `@promptbook/core`
2304
2427
  */
2305
2428
  function isPipelinePrepared(pipeline) {
2306
2429
  // Note: Ignoring `pipeline.preparations` @@@
@@ -2321,7 +2444,6 @@
2321
2444
  }
2322
2445
  /**
2323
2446
  * TODO: [🐠] Maybe base this on `makeValidator`
2324
- * TODO: [🔼] Export via core or utils
2325
2447
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2326
2448
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2327
2449
  * - [🏍] ? Is context in each template
@@ -2367,6 +2489,8 @@
2367
2489
 
2368
2490
  /**
2369
2491
  * This error type indicates that some limit was reached
2492
+ *
2493
+ * @public exported from `@promptbook/core`
2370
2494
  */
2371
2495
  var LimitReachedError = /** @class */ (function (_super) {
2372
2496
  __extends(LimitReachedError, _super);
@@ -2386,6 +2510,7 @@
2386
2510
  * @param parameters the object with parameters
2387
2511
  * @returns the template with replaced parameters
2388
2512
  * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
2513
+ * @public exported from `@promptbook/utils`
2389
2514
  */
2390
2515
  function replaceParameters(template, parameters) {
2391
2516
  var e_1, _a;
@@ -2461,6 +2586,7 @@
2461
2586
  * Create difference set of two sets.
2462
2587
  *
2463
2588
  * @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
2589
+ * @public exported from `@promptbook/utils`
2464
2590
  */
2465
2591
  function difference(a, b, isEqual) {
2466
2592
  var e_1, _a;
@@ -2494,6 +2620,7 @@
2494
2620
  * Creates a new set with all elements that are present in either set
2495
2621
  *
2496
2622
  * @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
2623
+ * @public exported from `@promptbook/utils`
2497
2624
  */
2498
2625
  function union() {
2499
2626
  var e_1, _a, e_2, _b;
@@ -2530,14 +2657,10 @@
2530
2657
  return union;
2531
2658
  }
2532
2659
 
2533
- /**
2534
- * The version of the Promptbook library
2535
- */
2536
- var PROMPTBOOK_VERSION = '0.62.0';
2537
- // TODO: !!!! List here all the versions and annotate + put into script
2538
-
2539
2660
  /**
2540
2661
  * Counts number of characters in the text
2662
+ *
2663
+ * @public exported from `@promptbook/utils`
2541
2664
  */
2542
2665
  function countCharacters(text) {
2543
2666
  // Remove null characters
@@ -2551,6 +2674,8 @@
2551
2674
 
2552
2675
  /**
2553
2676
  * Counts number of lines in the text
2677
+ *
2678
+ * @public exported from `@promptbook/utils`
2554
2679
  */
2555
2680
  function countLines(text) {
2556
2681
  if (text === '') {
@@ -2561,6 +2686,8 @@
2561
2686
 
2562
2687
  /**
2563
2688
  * Counts number of pages in the text
2689
+ *
2690
+ * @public exported from `@promptbook/utils`
2564
2691
  */
2565
2692
  function countPages(text) {
2566
2693
  var sentencesPerPage = 5; // Assuming each page has 5 sentences
@@ -2571,6 +2698,8 @@
2571
2698
 
2572
2699
  /**
2573
2700
  * Counts number of paragraphs in the text
2701
+ *
2702
+ * @public exported from `@promptbook/utils`
2574
2703
  */
2575
2704
  function countParagraphs(text) {
2576
2705
  return text.split(/\n\s*\n/).filter(function (paragraph) { return paragraph.trim() !== ''; }).length;
@@ -2578,12 +2707,16 @@
2578
2707
 
2579
2708
  /**
2580
2709
  * Split text into sentences
2710
+ *
2711
+ * @public exported from `@promptbook/utils`
2581
2712
  */
2582
2713
  function splitIntoSentences(text) {
2583
2714
  return text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
2584
2715
  }
2585
2716
  /**
2586
2717
  * Counts number of sentences in the text
2718
+ *
2719
+ * @public exported from `@promptbook/utils`
2587
2720
  */
2588
2721
  function countSentences(text) {
2589
2722
  return splitIntoSentences(text).length;
@@ -2591,6 +2724,8 @@
2591
2724
 
2592
2725
  /**
2593
2726
  * Counts number of words in the text
2727
+ *
2728
+ * @public exported from `@promptbook/utils`
2594
2729
  */
2595
2730
  function countWords(text) {
2596
2731
  text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
@@ -2600,6 +2735,8 @@
2600
2735
 
2601
2736
  /**
2602
2737
  * Index of all counter functions
2738
+ *
2739
+ * @public exported from `@promptbook/utils`
2603
2740
  */
2604
2741
  var CountUtils = {
2605
2742
  CHARACTERS: countCharacters,
@@ -2619,6 +2756,7 @@
2619
2756
  *
2620
2757
  * @throws {ExpectError} if the expectations are not met
2621
2758
  * @returns {void} Nothing
2759
+ * @public exported from `@promptbook/core`
2622
2760
  */
2623
2761
  function checkExpectations(expectations, value) {
2624
2762
  var e_1, _a;
@@ -2650,6 +2788,7 @@
2650
2788
  * - `isPassingExpectations` which returns a boolean
2651
2789
  *
2652
2790
  * @returns {boolean} True if the expectations are met
2791
+ * @public exported from `@promptbook/core`
2653
2792
  */
2654
2793
  function isPassingExpectations(expectations, value) {
2655
2794
  try {
@@ -2672,6 +2811,7 @@
2672
2811
  *
2673
2812
  * @returns The executor function
2674
2813
  * @throws {PipelineLogicError} on logical error in the pipeline
2814
+ * @public exported from `@promptbook/core`
2675
2815
  */
2676
2816
  function createPipelineExecutor(options) {
2677
2817
  var _this = this;
@@ -3460,6 +3600,8 @@
3460
3600
 
3461
3601
  /**
3462
3602
  * @@@
3603
+ *
3604
+ * @public exported from `@promptbook/core`
3463
3605
  */
3464
3606
  function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3465
3607
  return __awaiter(this, void 0, void 0, function () {
@@ -3595,6 +3737,7 @@
3595
3737
  * Prepares the knowle
3596
3738
  *
3597
3739
  * @see https://github.com/webgptorg/promptbook/discussions/41
3740
+ * @public exported from `@promptbook/core`
3598
3741
  */
3599
3742
  function prepareKnowledgePieces(knowledgeSources, options) {
3600
3743
  return __awaiter(this, void 0, void 0, function () {
@@ -3609,7 +3752,7 @@
3609
3752
  var partialPieces, pieces;
3610
3753
  return __generator(this, function (_a) {
3611
3754
  switch (_a.label) {
3612
- case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.source, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is
3755
+ case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.source, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
3613
3756
  options)];
3614
3757
  case 1:
3615
3758
  partialPieces = _a.sent();
@@ -3647,7 +3790,6 @@
3647
3790
  > ):
3648
3791
  */
3649
3792
  /**
3650
- * TODO: [🐝][🔼] !!! Export via `@promptbook/core`
3651
3793
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
3652
3794
  * Put `knowledgePieces` into `PrepareKnowledgeOptions`
3653
3795
  * TODO: [🪂] More than max things can run in parallel by acident [1,[2a,2b,_],[3a,3b,_]]
@@ -3661,6 +3803,7 @@
3661
3803
  *
3662
3804
  * @param llmTools LLM tools to be intercepted with usage counting
3663
3805
  * @returns LLM tools with same functionality with added total cost counting
3806
+ * @public exported from `@promptbook/core`
3664
3807
  */
3665
3808
  function countTotalUsage(llmTools) {
3666
3809
  var _this = this;
@@ -3728,7 +3871,6 @@
3728
3871
  return proxyTools;
3729
3872
  }
3730
3873
  /**
3731
- * TODO: [🔼] !!! Export via `@promptbookcore/`
3732
3874
  * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
3733
3875
  * TODO: [🧠] Is there some meaningfull way how to test this util
3734
3876
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
@@ -3740,6 +3882,7 @@
3740
3882
  * Prepares the persona for the pipeline
3741
3883
  *
3742
3884
  * @see https://github.com/webgptorg/promptbook/discussions/22
3885
+ * @public exported from `@promptbook/core`
3743
3886
  */
3744
3887
  function preparePersona(personaDescription, options) {
3745
3888
  return __awaiter(this, void 0, void 0, function () {
@@ -3794,7 +3937,6 @@
3794
3937
  });
3795
3938
  }
3796
3939
  /**
3797
- * TODO: [🔼] !!! Export via `@promptbook/core`
3798
3940
  * TODO: [🏢] !! Check validity of `modelName` in pipeline
3799
3941
  * TODO: [🏢] !! Check validity of `systemMessage` in pipeline
3800
3942
  * TODO: [🏢] !! Check validity of `temperature` in pipeline
@@ -3802,6 +3944,8 @@
3802
3944
 
3803
3945
  /**
3804
3946
  * @@@
3947
+ *
3948
+ * @public exported from `@promptbook/core`
3805
3949
  */
3806
3950
  function prepareTemplates(pipeline, options) {
3807
3951
  return __awaiter(this, void 0, void 0, function () {
@@ -3843,7 +3987,6 @@
3843
3987
  * TODO: [🧠] Add context to each template (if missing)
3844
3988
  * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
3845
3989
  * TODO: [♨] !!! Prepare index the samples and maybe templates
3846
- * TODO: [🔼] !!! Export via `@promptbook/core`
3847
3990
  * TODO: Write tests for `preparePipeline`
3848
3991
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3849
3992
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -3856,6 +3999,7 @@
3856
3999
  *
3857
4000
  * Note: This function does not validate logic of the pipeline
3858
4001
  * Note: This function acts as part of compilation process
4002
+ * @public exported from `@promptbook/core`
3859
4003
  */
3860
4004
  function preparePipeline(pipeline, options) {
3861
4005
  return __awaiter(this, void 0, void 0, function () {
@@ -3932,7 +4076,6 @@
3932
4076
  });
3933
4077
  }
3934
4078
  /**
3935
- * TODO: [🔼] !!! Export via `@promptbook/core`
3936
4079
  * TODO: Write tests for `preparePipeline`
3937
4080
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3938
4081
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -3943,6 +4086,7 @@
3943
4086
  * Tests if given string is valid URL.
3944
4087
  *
3945
4088
  * Note: This does not check if the file exists only if the path is valid
4089
+ * @public exported from `@promptbook/utils`
3946
4090
  */
3947
4091
  function isValidFilePath(filePath) {
3948
4092
  if (typeof filePath !== 'string') {
@@ -4125,6 +4269,7 @@
4125
4269
  *
4126
4270
  * @param {string} str - The string to remove Markdown tags from.
4127
4271
  * @returns {string} The input string with all Markdown tags removed.
4272
+ * @public exported from `@promptbook/markdown-utils`
4128
4273
  */
4129
4274
  function removeMarkdownFormatting(str) {
4130
4275
  // Remove bold formatting
@@ -4136,6 +4281,15 @@
4136
4281
  return str;
4137
4282
  }
4138
4283
 
4284
+ /**
4285
+ * @@@
4286
+ *
4287
+ * @param text @@@
4288
+ * @returns @@@
4289
+ * @example 'HELLO_WORLD'
4290
+ * @example 'I_LOVE_PROMPTBOOK'
4291
+ * @public exported from `@promptbook/utils`
4292
+ */
4139
4293
  function normalizeTo_SCREAMING_CASE(text) {
4140
4294
  var e_1, _a;
4141
4295
  var charType;
@@ -4303,7 +4457,7 @@
4303
4457
  * @returns parsed number
4304
4458
  * @throws {ParsingError} if the value is not a number
4305
4459
  *
4306
- * @private within the parseCommand
4460
+ * @public exported from `@promptbook/utils`
4307
4461
  */
4308
4462
  function parseNumber(value) {
4309
4463
  var originalValue = value;
@@ -4359,6 +4513,7 @@
4359
4513
  }
4360
4514
  /**
4361
4515
  * TODO: Maybe use sth. like safe-eval in fraction/calculation case @see https://www.npmjs.com/package/safe-eval
4516
+ * TODO: [🧠][🌻] Maybe export through `@promptbook/markdown-utils` not `@promptbook/utils`
4362
4517
  */
4363
4518
 
4364
4519
  /**
@@ -4670,6 +4825,13 @@
4670
4825
  },
4671
4826
  };
4672
4827
 
4828
+ /**
4829
+ * @@@
4830
+ *
4831
+ * @param javascriptName @@@
4832
+ * @returns @@@
4833
+ * @public exported from `@promptbook/utils`
4834
+ */
4673
4835
  function isValidJavascriptName(javascriptName) {
4674
4836
  if (typeof javascriptName !== 'string') {
4675
4837
  return false;
@@ -5142,6 +5304,8 @@
5142
5304
 
5143
5305
  /**
5144
5306
  * This error type indicates that some part of the code is not implemented yet
5307
+ *
5308
+ * @public exported from `@promptbook/core`
5145
5309
  */
5146
5310
  var NotYetImplementedError = /** @class */ (function (_super) {
5147
5311
  __extends(NotYetImplementedError, _super);
@@ -5168,7 +5332,8 @@
5168
5332
  * Note: It can not work with html syntax and comments
5169
5333
  *
5170
5334
  * @param markdown any valid markdown
5171
- * @returns
5335
+ * @returns @@@
5336
+ * @public exported from `@promptbook/markdown-utils`
5172
5337
  */
5173
5338
  function extractAllListItemsFromMarkdown(markdown) {
5174
5339
  var e_1, _a;
@@ -5208,7 +5373,7 @@
5208
5373
  *
5209
5374
  * @param markdown any valid markdown
5210
5375
  * @returns code blocks with language and content
5211
- *
5376
+ * @public exported from `@promptbook/markdown-utils`
5212
5377
  */
5213
5378
  function extractAllBlocksFromMarkdown(markdown) {
5214
5379
  var e_1, _a;
@@ -5285,6 +5450,7 @@
5285
5450
  *
5286
5451
  * @param markdown any valid markdown
5287
5452
  * @returns code block with language and content
5453
+ * @public exported from `@promptbook/markdown-utils`
5288
5454
  */
5289
5455
  function extractOneBlockFromMarkdown(markdown) {
5290
5456
  var codeBlocks = extractAllBlocksFromMarkdown(markdown);
@@ -5299,6 +5465,8 @@
5299
5465
 
5300
5466
  /**
5301
5467
  * Parses markdown section to title its level and content
5468
+ *
5469
+ * @public exported from `@promptbook/markdown-utils`
5302
5470
  */
5303
5471
  function parseMarkdownSection(value) {
5304
5472
  var _a, _b;
@@ -5323,6 +5491,8 @@
5323
5491
 
5324
5492
  /**
5325
5493
  * Splits the markdown into sections by headings
5494
+ *
5495
+ * @public exported from `@promptbook/markdown-utils`
5326
5496
  */
5327
5497
  function splitMarkdownIntoSections(markdown) {
5328
5498
  var e_1, _a;
@@ -5384,6 +5554,7 @@
5384
5554
  return sections;
5385
5555
  }
5386
5556
  /**
5557
+ * TODO: [🏛] This can be part of markdown builder
5387
5558
  * Note: [🕞] In past (commit 42086e1603cbed506482997c00a8ee979af0a247) there was much more
5388
5559
  * sophisticated implementation of this function through parsing markdown into JSON structure
5389
5560
  * and flattening the actual structure
@@ -5395,6 +5566,8 @@
5395
5566
  *
5396
5567
  * - It always have h1 - if there is no h1 in the markdown, it will be added "# Untitled"
5397
5568
  * - All other headings are normalized to h2
5569
+ *
5570
+ * @public exported from `@promptbook/markdown-utils`
5398
5571
  */
5399
5572
  function flattenMarkdown(markdown) {
5400
5573
  var e_1, _a;
@@ -5430,6 +5603,7 @@
5430
5603
  return spaceTrim__default["default"](flattenedMarkdown);
5431
5604
  }
5432
5605
  /**
5606
+ * TODO: [🏛] This can be part of markdown builder
5433
5607
  * Note: [🕞] In past (commit 42086e1603cbed506482997c00a8ee979af0a247) there was much more
5434
5608
  * sophisticated implementation of this function through parsing markdown into JSON structure
5435
5609
  * and flattening the actual structure
@@ -5441,6 +5615,7 @@
5441
5615
  *
5442
5616
  * @param {string} content - The string to remove comments from.
5443
5617
  * @returns {string} The input string with all comments removed.
5618
+ * @public exported from `@promptbook/markdown-utils`
5444
5619
  */
5445
5620
  function removeContentComments(content) {
5446
5621
  return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
@@ -5454,12 +5629,13 @@
5454
5629
  * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
5455
5630
  * - `preparePipeline` - just one step in the compilation process
5456
5631
  *
5632
+ * Note: This function does not validate logic of the pipeline only the syntax
5633
+ * Note: This function acts as compilation process
5634
+ *
5457
5635
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
5458
5636
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
5459
5637
  * @throws {ParsingError} if the promptbook string is not valid
5460
- *
5461
- * Note: This function does not validate logic of the pipeline only the syntax
5462
- * Note: This function acts as compilation process
5638
+ * @public exported from `@promptbook/core`
5463
5639
  */
5464
5640
  function pipelineStringToJsonSync(pipelineString) {
5465
5641
  var e_1, _a, e_2, _b;
@@ -5852,13 +6028,14 @@
5852
6028
  * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
5853
6029
  * - `preparePipeline` - just one step in the compilation process
5854
6030
  *
6031
+ * Note: This function does not validate logic of the pipeline only the syntax
6032
+ * Note: This function acts as compilation process
6033
+ *
5855
6034
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
5856
6035
  * @param options - Options and tools for the compilation
5857
6036
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
5858
6037
  * @throws {ParsingError} if the promptbook string is not valid
5859
- *
5860
- * Note: This function does not validate logic of the pipeline only the syntax
5861
- * Note: This function acts as compilation process
6038
+ * @public exported from `@promptbook/core`
5862
6039
  */
5863
6040
  function pipelineStringToJson(pipelineString, options) {
5864
6041
  if (options === void 0) { options = { llmTools: null }; }
@@ -5887,7 +6064,7 @@
5887
6064
  /**
5888
6065
  * Add or modify an auto-generated section in a markdown file
5889
6066
  *
5890
- * @private within the repository
6067
+ * @public exported from `@promptbook/markdown-utils`
5891
6068
  */
5892
6069
  function addAutoGeneratedSection(content, options) {
5893
6070
  var sectionName = options.sectionName, sectionContent = options.sectionContent;
@@ -5907,7 +6084,20 @@
5907
6084
  var _a = __read(placeForSection, 1), heading = _a[0];
5908
6085
  return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
5909
6086
  }
6087
+ /**
6088
+ * TODO: [🏛] This can be part of markdown builder
6089
+ */
5910
6090
 
6091
+ /**
6092
+ * @@@
6093
+ *
6094
+ * @param text @@@
6095
+ * @param _isFirstLetterCapital @@@
6096
+ * @returns @@@
6097
+ * @example 'helloWorld'
6098
+ * @example 'iLovePromptbook'
6099
+ * @public exported from `@promptbook/utils`
6100
+ */
5911
6101
  function normalizeTo_camelCase(text, _isFirstLetterCapital) {
5912
6102
  var e_1, _a;
5913
6103
  if (_isFirstLetterCapital === void 0) { _isFirstLetterCapital = false; }
@@ -5966,6 +6156,8 @@
5966
6156
  * Creates a Mermaid graph based on the promptbook
5967
6157
  *
5968
6158
  * Note: The result is not wrapped in a Markdown code block
6159
+ *
6160
+ * @public exported from `@promptbook/utils`
5969
6161
  */
5970
6162
  function renderPromptbookMermaid(pipelineJson, options) {
5971
6163
  var _a = (options || {}).linkPromptTemplate, linkPromptTemplate = _a === void 0 ? function () { return null; } : _a;
@@ -6022,6 +6214,8 @@
6022
6214
 
6023
6215
  /**
6024
6216
  * Prettyfies Promptbook string and adds Mermaid graph
6217
+ *
6218
+ * @public exported from `@promptbook/core`
6025
6219
  */
6026
6220
  function prettifyPipelineString(pipelineString, options) {
6027
6221
  return __awaiter(this, void 0, void 0, function () {
@@ -6064,6 +6258,8 @@
6064
6258
  *
6065
6259
  * Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
6066
6260
  * Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
6261
+ *
6262
+ * @public exported from `@promptbook/core`
6067
6263
  */
6068
6264
  function stringifyPipelineJson(pipeline) {
6069
6265
  var pipelineJsonStringified = JSON.stringify(pipeline, null, 4);
@@ -6083,6 +6279,8 @@
6083
6279
 
6084
6280
  /**
6085
6281
  * This error indicates that the pipeline collection cannot be propperly loaded
6282
+ *
6283
+ * @public exported from `@promptbook/core`
6086
6284
  */
6087
6285
  var CollectionError = /** @class */ (function (_super) {
6088
6286
  __extends(CollectionError, _super);
@@ -6095,8 +6293,26 @@
6095
6293
  return CollectionError;
6096
6294
  }(Error));
6097
6295
 
6296
+ /**
6297
+ * This error type indicates that you try to use a feature that is not available in the current environment
6298
+ *
6299
+ * @public exported from `@promptbook/core`
6300
+ */
6301
+ var EnvironmentMismatchError = /** @class */ (function (_super) {
6302
+ __extends(EnvironmentMismatchError, _super);
6303
+ function EnvironmentMismatchError(message) {
6304
+ var _this = _super.call(this, message) || this;
6305
+ _this.name = 'EnvironmentMismatchError';
6306
+ Object.setPrototypeOf(_this, EnvironmentMismatchError.prototype);
6307
+ return _this;
6308
+ }
6309
+ return EnvironmentMismatchError;
6310
+ }(Error));
6311
+
6098
6312
  /**
6099
6313
  * This error type indicates that the version of the pipeline is not matching the expected version
6314
+ *
6315
+ * @public exported from `@promptbook/core`
6100
6316
  */
6101
6317
  var VersionMismatchError = /** @class */ (function (_super) {
6102
6318
  __extends(VersionMismatchError, _super);
@@ -6111,6 +6327,8 @@
6111
6327
 
6112
6328
  /**
6113
6329
  * Pretty print an embedding vector for logging
6330
+ *
6331
+ * @public exported from `@promptbook/core`
6114
6332
  */
6115
6333
  function embeddingVectorToString(embeddingVector) {
6116
6334
  var vectorLength = Math.pow(embeddingVector.reduce(function (acc, val) { return acc + Math.pow(val, 2); }, 0), 0.5);
@@ -6123,6 +6341,8 @@
6123
6341
  * Note: This is an estimate based of theese sources:
6124
6342
  * - https://jecas.cz/doba-cteni
6125
6343
  * - https://www.originalnitonery.cz/blog/psani-vsemi-deseti-se-muzete-naucit-i-sami-doma
6344
+ *
6345
+ * @public exported from `@promptbook/core`
6126
6346
  */
6127
6347
  function usageToWorktime(usage) {
6128
6348
  var value = usage.input.wordsCount.value / (200 /* words per minute */ * 60) +
@@ -6137,6 +6357,8 @@
6137
6357
 
6138
6358
  /**
6139
6359
  * Function `usageToHuman` will take usage and convert it to human readable report
6360
+ *
6361
+ * @public exported from `@promptbook/core`
6140
6362
  */
6141
6363
  function usageToHuman(usage) {
6142
6364
  var report = 'Usage:';
@@ -6161,6 +6383,8 @@
6161
6383
  /**
6162
6384
  * Delagates the user interaction to a async callback function
6163
6385
  * You need to provide your own implementation of this callback function and its bind to UI.
6386
+ *
6387
+ * @public exported from `@promptbook/core`
6164
6388
  */
6165
6389
  var CallbackInterfaceTools = /** @class */ (function () {
6166
6390
  function CallbackInterfaceTools(options) {
@@ -6193,6 +6417,8 @@
6193
6417
  *
6194
6418
  * Warning: It is used for testing and mocking
6195
6419
  * **NOT intended to use in the production** due to its synchronous nature.
6420
+ *
6421
+ * @public exported from `@promptbook/core`
6196
6422
  */
6197
6423
  var SimplePromptInterfaceTools = /** @class */ (function () {
6198
6424
  function SimplePromptInterfaceTools(options) {
@@ -6224,12 +6450,260 @@
6224
6450
  */
6225
6451
 
6226
6452
  /**
6227
- * Default options for generating an execution report string
6453
+ * Stores
6454
+ *
6455
+ * @public exported from `@promptbook/core`
6228
6456
  */
6229
- var ExecutionReportStringOptionsDefaults = {
6230
- taxRate: 0,
6231
- chartsWidth: 36,
6232
- };
6457
+ var MemoryStorage = /** @class */ (function () {
6458
+ function MemoryStorage() {
6459
+ this.storage = {};
6460
+ }
6461
+ Object.defineProperty(MemoryStorage.prototype, "length", {
6462
+ /**
6463
+ * Returns the number of key/value pairs currently present in the list associated with the object.
6464
+ */
6465
+ get: function () {
6466
+ return Object.keys(this.storage).length;
6467
+ },
6468
+ enumerable: false,
6469
+ configurable: true
6470
+ });
6471
+ /**
6472
+ * Empties the list associated with the object of all key/value pairs, if there are any.
6473
+ */
6474
+ MemoryStorage.prototype.clear = function () {
6475
+ this.storage = {};
6476
+ };
6477
+ /**
6478
+ * Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
6479
+ */
6480
+ MemoryStorage.prototype.getItem = function (key) {
6481
+ return this.storage[key] || null;
6482
+ };
6483
+ /**
6484
+ * Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
6485
+ */
6486
+ MemoryStorage.prototype.key = function (index) {
6487
+ return Object.keys(this.storage)[index] || null;
6488
+ };
6489
+ /**
6490
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
6491
+ */
6492
+ MemoryStorage.prototype.setItem = function (key, value) {
6493
+ this.storage[key] = value;
6494
+ };
6495
+ /**
6496
+ * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
6497
+ */
6498
+ MemoryStorage.prototype.removeItem = function (key) {
6499
+ delete this.storage[key];
6500
+ };
6501
+ return MemoryStorage;
6502
+ }());
6503
+
6504
+ /**
6505
+ * Simple wrapper `new Date().toISOString()`
6506
+ *
6507
+ * @returns string_date branded type
6508
+ * @public exported from `@promptbook/utils`
6509
+ */
6510
+ function $currentDate() {
6511
+ return new Date().toISOString();
6512
+ }
6513
+
6514
+ /**
6515
+ * Intercepts LLM tools and counts total usage of the tools
6516
+ *
6517
+ * Note: It can take extended `LlmExecutionTools` and cache the
6518
+ *
6519
+ * @param llmTools LLM tools to be intercepted with usage counting, it can contain extra methods like `totalUsage`
6520
+ * @returns LLM tools with same functionality with added total cost counting
6521
+ * @public exported from `@promptbook/core`
6522
+ */
6523
+ function cacheLlmTools(llmTools, options) {
6524
+ var _this = this;
6525
+ if (options === void 0) { options = {}; }
6526
+ var _a = options.storage, storage = _a === void 0 ? new MemoryStorage() : _a, _b = options.isReloaded, isReloaded = _b === void 0 ? false : _b;
6527
+ var proxyTools = __assign(__assign({}, llmTools), {
6528
+ // <- Note: [🥫]
6529
+ get title() {
6530
+ // TODO: [🧠] Maybe put here some suffix
6531
+ return llmTools.title;
6532
+ },
6533
+ get description() {
6534
+ // TODO: [🧠] Maybe put here some suffix
6535
+ return llmTools.description;
6536
+ }, listModels: function () {
6537
+ // TODO: [🧠] Should be model listing also cached?
6538
+ return /* not await */ llmTools.listModels();
6539
+ } });
6540
+ var callCommonModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
6541
+ var key, cacheItem, _a, promptResult, _b;
6542
+ return __generator(this, function (_c) {
6543
+ switch (_c.label) {
6544
+ case 0:
6545
+ key = titleToName(prompt.title.substring(0, MAX_FILENAME_LENGTH - 10) +
6546
+ '-' +
6547
+ sha256__default["default"](hexEncoder__default["default"].parse(JSON.stringify(prompt.parameters))).toString( /* hex */));
6548
+ if (!!isReloaded) return [3 /*break*/, 2];
6549
+ return [4 /*yield*/, storage.getItem(key)];
6550
+ case 1:
6551
+ _a = _c.sent();
6552
+ return [3 /*break*/, 3];
6553
+ case 2:
6554
+ _a = null;
6555
+ _c.label = 3;
6556
+ case 3:
6557
+ cacheItem = _a;
6558
+ if (cacheItem) {
6559
+ return [2 /*return*/, cacheItem.promptResult];
6560
+ }
6561
+ _b = prompt.modelRequirements.modelVariant;
6562
+ switch (_b) {
6563
+ case 'CHAT': return [3 /*break*/, 4];
6564
+ case 'COMPLETION': return [3 /*break*/, 6];
6565
+ case 'EMBEDDING': return [3 /*break*/, 8];
6566
+ }
6567
+ return [3 /*break*/, 10];
6568
+ case 4: return [4 /*yield*/, llmTools.callChatModel(prompt)];
6569
+ case 5:
6570
+ promptResult = _c.sent();
6571
+ return [3 /*break*/, 11];
6572
+ case 6: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
6573
+ case 7:
6574
+ promptResult = _c.sent();
6575
+ return [3 /*break*/, 11];
6576
+ case 8: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
6577
+ case 9:
6578
+ promptResult = _c.sent();
6579
+ return [3 /*break*/, 11];
6580
+ case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
6581
+ case 11: return [4 /*yield*/, storage.setItem(key, {
6582
+ date: $currentDate(),
6583
+ promptbookVersion: PROMPTBOOK_VERSION,
6584
+ prompt: prompt,
6585
+ promptResult: promptResult,
6586
+ })];
6587
+ case 12:
6588
+ _c.sent();
6589
+ return [2 /*return*/, promptResult];
6590
+ }
6591
+ });
6592
+ }); };
6593
+ if (llmTools.callChatModel !== undefined) {
6594
+ proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
6595
+ return __generator(this, function (_a) {
6596
+ return [2 /*return*/, /* not await */ callCommonModel(prompt)];
6597
+ });
6598
+ }); };
6599
+ }
6600
+ if (llmTools.callCompletionModel !== undefined) {
6601
+ proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
6602
+ return __generator(this, function (_a) {
6603
+ return [2 /*return*/, /* not await */ callCommonModel(prompt)];
6604
+ });
6605
+ }); };
6606
+ }
6607
+ if (llmTools.callEmbeddingModel !== undefined) {
6608
+ proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
6609
+ return __generator(this, function (_a) {
6610
+ return [2 /*return*/, /* not await */ callCommonModel(prompt)];
6611
+ });
6612
+ }); };
6613
+ }
6614
+ // <- Note: [🤖]
6615
+ return proxyTools;
6616
+ }
6617
+ /**
6618
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
6619
+ * TODO: [🧠] Is there some meaningfull way how to test this util
6620
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
6621
+ * @@@ write discussion about this and storages
6622
+ * @@@ write how to combine multiple interceptors
6623
+ */
6624
+
6625
+ /**
6626
+ * @@@
6627
+ *
6628
+ * @public exported from `@promptbook/core`
6629
+ */
6630
+ function limitTotalUsage(llmTools, options) {
6631
+ var _this = this;
6632
+ if (options === void 0) { options = {}; }
6633
+ var _a = options.maxTotalUsage, maxTotalUsage = _a === void 0 ? ZERO_USAGE : _a, _b = options.storage, storage = _b === void 0 ? new MemoryStorage() : _b;
6634
+ TODO_USE(storage);
6635
+ var proxyTools = countTotalUsage(llmTools);
6636
+ if (maxTotalUsage.price.value !== 0) {
6637
+ throw new NotYetImplementedError('`limitTotalUsage` is not yet implemented for non-zero price');
6638
+ // TODO: "Cannot call `callChatModel` because the total cost limit is reached"
6639
+ }
6640
+ if (proxyTools.callChatModel !== undefined) {
6641
+ proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
6642
+ return __generator(this, function (_a) {
6643
+ TODO_USE(prompt);
6644
+ throw new LimitReachedError('Cannot call `callChatModel` because you are not allowed to spend any cost');
6645
+ });
6646
+ }); };
6647
+ }
6648
+ if (proxyTools.callCompletionModel !== undefined) {
6649
+ proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
6650
+ return __generator(this, function (_a) {
6651
+ TODO_USE(prompt);
6652
+ throw new LimitReachedError('Cannot call `callCompletionModel` because you are not allowed to spend any cost');
6653
+ });
6654
+ }); };
6655
+ }
6656
+ if (proxyTools.callEmbeddingModel !== undefined) {
6657
+ proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
6658
+ return __generator(this, function (_a) {
6659
+ TODO_USE(prompt);
6660
+ throw new LimitReachedError('Cannot call `callEmbeddingModel` because you are not allowed to spend any cost');
6661
+ });
6662
+ }); };
6663
+ }
6664
+ // <- Note: [🤖]
6665
+ return proxyTools;
6666
+ }
6667
+ /**
6668
+ * TODO: Maybe internally use `countTotalUsage`
6669
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
6670
+ * TODO: [🧠] Is there some meaningfull way how to test this util
6671
+ * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
6672
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
6673
+ */
6674
+
6675
+ /**
6676
+ * This class behaves like LocalStorage but separates keys by prefix
6677
+ *
6678
+ * @public exported from `@promptbook/core`
6679
+ */
6680
+ var PrefixStorage = /** @class */ (function () {
6681
+ function PrefixStorage(baseStorage, keyPrefix, separator) {
6682
+ if (separator === void 0) { separator = '_'; }
6683
+ this.baseStorage = baseStorage;
6684
+ this.keyPrefix = keyPrefix;
6685
+ this.separator = separator;
6686
+ }
6687
+ /**
6688
+ * Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
6689
+ */
6690
+ PrefixStorage.prototype.getItem = function (key) {
6691
+ return this.baseStorage.getItem(this.keyPrefix + this.separator + key);
6692
+ };
6693
+ /**
6694
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
6695
+ */
6696
+ PrefixStorage.prototype.setItem = function (key, value) {
6697
+ return this.baseStorage.setItem(this.keyPrefix + this.separator + key, value);
6698
+ };
6699
+ /**
6700
+ * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
6701
+ */
6702
+ PrefixStorage.prototype.removeItem = function (key) {
6703
+ this.baseStorage.removeItem(this.keyPrefix + this.separator + key);
6704
+ };
6705
+ return PrefixStorage;
6706
+ }());
6233
6707
 
6234
6708
  /**
6235
6709
  * Format either small or big number
@@ -6254,7 +6728,7 @@
6254
6728
  /**
6255
6729
  * Create a markdown table from a 2D array of strings
6256
6730
  *
6257
- * @private within the repository
6731
+ * @public exported from `@promptbook/markdown-utils`
6258
6732
  */
6259
6733
  function createMarkdownTable(table) {
6260
6734
  var columnWidths = table.reduce(function (widths, row) {
@@ -6278,11 +6752,14 @@
6278
6752
  });
6279
6753
  return __spreadArray([header, separator], __read(rows), false).join('\n');
6280
6754
  }
6755
+ /**
6756
+ * TODO: [🏛] This can be part of markdown builder
6757
+ */
6281
6758
 
6282
6759
  /**
6283
6760
  * Function createMarkdownChart will draw a chart in markdown from ⬛+🟦 tiles
6284
6761
  *
6285
- * @private within the repository
6762
+ * @public exported from `@promptbook/markdown-utils`
6286
6763
  */
6287
6764
  function createMarkdownChart(options) {
6288
6765
  var e_1, _a;
@@ -6318,10 +6795,25 @@
6318
6795
  /**
6319
6796
  * Function escapeMarkdownBlock will escape markdown block if needed
6320
6797
  * It is useful when you want have block in block
6798
+ *
6799
+ * @public exported from `@promptbook/markdown-utils`
6321
6800
  */
6322
6801
  function escapeMarkdownBlock(value) {
6323
6802
  return value.replace(/```/g, '\\`\\`\\`');
6324
6803
  }
6804
+ /**
6805
+ * TODO: [🏛] This can be part of markdown builder
6806
+ */
6807
+
6808
+ /**
6809
+ * Default options for generating an execution report string
6810
+ *
6811
+ * @public exported from `@promptbook/core`
6812
+ */
6813
+ var ExecutionReportStringOptionsDefaults = {
6814
+ taxRate: 0,
6815
+ chartsWidth: 36,
6816
+ };
6325
6817
 
6326
6818
  /**
6327
6819
  * The thresholds for the relative time in the `moment` NPM package.
@@ -6367,6 +6859,8 @@
6367
6859
 
6368
6860
  /**
6369
6861
  * Converts execution report from JSON to string format
6862
+ *
6863
+ * @public exported from `@promptbook/core`
6370
6864
  */
6371
6865
  function executionReportJsonToString(executionReportJson, options) {
6372
6866
  var e_1, _a;
@@ -6539,22 +7033,36 @@
6539
7033
  exports.BlockTypes = BlockTypes;
6540
7034
  exports.CallbackInterfaceTools = CallbackInterfaceTools;
6541
7035
  exports.CollectionError = CollectionError;
7036
+ exports.EXECUTIONS_CACHE_DIRNAME = EXECUTIONS_CACHE_DIRNAME;
7037
+ exports.EnvironmentMismatchError = EnvironmentMismatchError;
6542
7038
  exports.ExecutionReportStringOptionsDefaults = ExecutionReportStringOptionsDefaults;
6543
- exports.ExpectError = ExpectError;
7039
+ exports.LimitReachedError = LimitReachedError;
7040
+ exports.MAX_EXECUTION_ATTEMPTS = MAX_EXECUTION_ATTEMPTS;
7041
+ exports.MAX_FILENAME_LENGTH = MAX_FILENAME_LENGTH;
7042
+ exports.MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH;
7043
+ exports.MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL;
7044
+ exports.MAX_PARALLEL_COUNT = MAX_PARALLEL_COUNT;
7045
+ exports.MemoryStorage = MemoryStorage;
6544
7046
  exports.NotFoundError = NotFoundError;
7047
+ exports.NotYetImplementedError = NotYetImplementedError;
7048
+ exports.PIPELINE_COLLECTION_BASE_FILENAME = PIPELINE_COLLECTION_BASE_FILENAME;
6545
7049
  exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
6546
7050
  exports.ParsingError = ParsingError;
6547
7051
  exports.PipelineExecutionError = PipelineExecutionError;
6548
7052
  exports.PipelineLogicError = PipelineLogicError;
7053
+ exports.PrefixStorage = PrefixStorage;
6549
7054
  exports.RESERVED_PARAMETER_NAMES = RESERVED_PARAMETER_NAMES;
6550
7055
  exports.ReferenceError = ReferenceError$1;
6551
7056
  exports.SimplePromptInterfaceTools = SimplePromptInterfaceTools;
6552
7057
  exports.UnexpectedError = UnexpectedError;
6553
7058
  exports.VersionMismatchError = VersionMismatchError;
7059
+ exports.ZERO_USAGE = ZERO_USAGE;
6554
7060
  exports.addUsage = addUsage;
6555
7061
  exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
7062
+ exports.cacheLlmTools = cacheLlmTools;
6556
7063
  exports.checkExpectations = checkExpectations;
6557
7064
  exports.collectionToJson = collectionToJson;
7065
+ exports.countTotalUsage = countTotalUsage;
6558
7066
  exports.createCollectionFromJson = createCollectionFromJson;
6559
7067
  exports.createCollectionFromPromise = createCollectionFromPromise;
6560
7068
  exports.createCollectionFromUrl = createCollectionFromUrl;
@@ -6563,12 +7071,17 @@
6563
7071
  exports.embeddingVectorToString = embeddingVectorToString;
6564
7072
  exports.executionReportJsonToString = executionReportJsonToString;
6565
7073
  exports.isPassingExpectations = isPassingExpectations;
7074
+ exports.isPipelinePrepared = isPipelinePrepared;
6566
7075
  exports.joinLlmExecutionTools = joinLlmExecutionTools;
7076
+ exports.limitTotalUsage = limitTotalUsage;
6567
7077
  exports.pipelineJsonToString = pipelineJsonToString;
6568
7078
  exports.pipelineStringToJson = pipelineStringToJson;
6569
7079
  exports.pipelineStringToJsonSync = pipelineStringToJsonSync;
6570
7080
  exports.prepareKnowledgeFromMarkdown = prepareKnowledgeFromMarkdown;
7081
+ exports.prepareKnowledgePieces = prepareKnowledgePieces;
7082
+ exports.preparePersona = preparePersona;
6571
7083
  exports.preparePipeline = preparePipeline;
7084
+ exports.prepareTemplates = prepareTemplates;
6572
7085
  exports.prettifyPipelineString = prettifyPipelineString;
6573
7086
  exports.stringifyPipelineJson = stringifyPipelineJson;
6574
7087
  exports.unpreparePipeline = unpreparePipeline;