@promptbook/openai 0.61.0-9 โ†’ 0.62.0-0

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 (372) hide show
  1. package/README.md +46 -5
  2. package/esm/index.es.js +238 -31
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +200 -30
  5. package/esm/typings/src/_packages/core.index.d.ts +9 -3
  6. package/esm/typings/src/_packages/execute-javascript.index.d.ts +1 -1
  7. package/esm/typings/src/_packages/node.index.d.ts +2 -1
  8. package/esm/typings/src/_packages/types.index.d.ts +12 -8
  9. package/esm/typings/src/_packages/utils.index.d.ts +11 -8
  10. package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -0
  11. package/esm/typings/src/cli/cli-commands/make.d.ts +3 -0
  12. package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -0
  13. package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
  14. package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
  15. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
  16. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
  17. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
  18. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
  19. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
  20. package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
  21. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
  22. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +42 -14
  23. package/esm/typings/src/config.d.ts +46 -1
  24. package/esm/typings/src/config.test.d.ts +4 -0
  25. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -2
  26. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
  27. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +6 -3
  28. package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
  29. package/{umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts โ†’ esm/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts} +2 -2
  30. package/esm/typings/src/conversion/utils/renameParameter.d.ts +3 -3
  31. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +14 -0
  32. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +12 -3
  33. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +10 -1
  34. package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
  35. package/esm/typings/src/errors/LimitReachedError.d.ts +7 -0
  36. package/esm/typings/src/errors/VersionMismatchError.d.ts +8 -0
  37. package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
  38. package/esm/typings/src/execution/LlmExecutionTools.d.ts +10 -8
  39. package/esm/typings/src/execution/PipelineExecutor.d.ts +48 -26
  40. package/esm/typings/src/execution/PromptResult.d.ts +39 -54
  41. package/esm/typings/src/execution/PromptResultUsage.d.ts +29 -0
  42. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +5 -4
  43. package/esm/typings/src/execution/UncertainNumber.d.ts +18 -0
  44. package/esm/typings/src/execution/UserInterfaceTools.d.ts +5 -5
  45. package/esm/typings/src/execution/createPipelineExecutor.d.ts +31 -3
  46. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
  47. package/esm/typings/src/execution/utils/addUsage.d.ts +58 -2
  48. package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
  49. package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  50. package/esm/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
  51. package/esm/typings/src/execution/utils/usageToHuman.d.ts +15 -0
  52. package/esm/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
  53. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  54. package/esm/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
  55. package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
  56. package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
  57. package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
  58. package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
  59. package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
  60. package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
  61. package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
  62. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -23
  63. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  64. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +8 -14
  65. package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +31 -0
  66. package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +11 -0
  67. package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +12 -0
  68. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
  69. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  70. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +19 -0
  71. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +14 -0
  72. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts +17 -0
  73. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +35 -0
  74. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
  75. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  76. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +3 -3
  77. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  78. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
  79. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
  80. package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  81. package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
  82. package/esm/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
  83. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
  84. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
  85. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
  86. package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +3 -0
  87. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
  88. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
  89. package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  90. package/esm/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  91. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
  92. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  93. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +10 -8
  94. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
  95. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
  96. package/esm/typings/src/personas/preparePersona.d.ts +15 -0
  97. package/esm/typings/src/prepare/PrepareOptions.d.ts +22 -0
  98. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +14 -0
  99. package/esm/typings/src/prepare/preparePipeline.d.ts +16 -0
  100. package/esm/typings/src/prepare/prepareTemplates.d.ts +31 -0
  101. package/esm/typings/src/prepare/unpreparePipeline.d.ts +11 -0
  102. package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
  103. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  104. package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
  105. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
  106. package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  107. package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
  108. package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
  109. package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  110. package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
  111. package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
  112. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
  113. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
  114. package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
  115. package/esm/typings/src/types/ModelRequirements.d.ts +71 -11
  116. package/esm/typings/src/types/ModelVariant.d.ts +14 -0
  117. package/esm/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
  118. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +70 -0
  119. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +27 -0
  120. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +10 -1
  121. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +41 -0
  122. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +31 -5
  123. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +22 -0
  124. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +8 -2
  125. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
  126. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +23 -4
  127. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +12 -2
  128. package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +7 -2
  129. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -2
  130. package/esm/typings/src/types/PipelineString.d.ts +1 -1
  131. package/esm/typings/src/types/Prompt.d.ts +54 -10
  132. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
  133. package/esm/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
  134. package/esm/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  135. package/esm/typings/src/types/typeAliases.d.ts +114 -15
  136. package/esm/typings/src/utils/FromtoItems.d.ts +3 -3
  137. package/esm/typings/src/utils/currentDate.d.ts +7 -0
  138. package/esm/typings/src/utils/deepClone.d.ts +9 -0
  139. package/esm/typings/src/utils/deepFreeze.d.ts +22 -0
  140. package/esm/typings/src/utils/emojis.d.ts +2 -2
  141. package/esm/typings/src/utils/{extractParameters.d.ts โ†’ extractParameterNames.d.ts} +2 -2
  142. package/esm/typings/src/utils/formatNumber.d.ts +1 -1
  143. package/esm/typings/src/utils/isRunningInWhatever.d.ts +3 -0
  144. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
  145. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
  146. package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  147. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  148. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
  149. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  150. package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
  151. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
  152. package/esm/typings/src/utils/organization/TODO_USE.d.ts +12 -0
  153. package/esm/typings/src/utils/organization/TODO_any.d.ts +6 -0
  154. package/esm/typings/src/utils/organization/TODO_object.d.ts +6 -0
  155. package/esm/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
  156. package/esm/typings/src/utils/organization/___.d.ts +6 -0
  157. package/{umd/typings/src/utils โ†’ esm/typings/src/utils/organization}/just.d.ts +5 -1
  158. package/esm/typings/src/utils/organization/keepUnused.d.ts +16 -0
  159. package/esm/typings/src/utils/organization/really_any.d.ts +6 -0
  160. package/esm/typings/src/utils/organization/really_unknown.d.ts +6 -0
  161. package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
  162. package/esm/typings/src/{execution/utils โ†’ utils}/replaceParameters.d.ts +2 -4
  163. package/esm/typings/src/utils/replaceParameters.test.d.ts +1 -0
  164. package/esm/typings/src/utils/sets/difference.d.ts +3 -0
  165. package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
  166. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
  167. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
  168. package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
  169. package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
  170. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  171. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
  172. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
  173. package/package.json +3 -3
  174. package/umd/index.umd.js +238 -31
  175. package/umd/index.umd.js.map +1 -1
  176. package/umd/typings/promptbook-collection/index.d.ts +200 -30
  177. package/umd/typings/src/_packages/core.index.d.ts +9 -3
  178. package/umd/typings/src/_packages/execute-javascript.index.d.ts +1 -1
  179. package/umd/typings/src/_packages/node.index.d.ts +2 -1
  180. package/umd/typings/src/_packages/types.index.d.ts +12 -8
  181. package/umd/typings/src/_packages/utils.index.d.ts +11 -8
  182. package/umd/typings/src/cli/cli-commands/hello.d.ts +3 -0
  183. package/umd/typings/src/cli/cli-commands/make.d.ts +3 -0
  184. package/umd/typings/src/cli/cli-commands/prettify.d.ts +3 -0
  185. package/umd/typings/src/cli/promptbookCli.d.ts +1 -0
  186. package/umd/typings/src/collection/PipelineCollection.d.ts +1 -1
  187. package/umd/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
  188. package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
  189. package/umd/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
  190. package/umd/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
  191. package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
  192. package/umd/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
  193. package/umd/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
  194. package/umd/typings/src/commands/_common/types/CommandParser.d.ts +42 -14
  195. package/umd/typings/src/config.d.ts +46 -1
  196. package/umd/typings/src/config.test.d.ts +4 -0
  197. package/umd/typings/src/conversion/pipelineJsonToString.d.ts +3 -2
  198. package/umd/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
  199. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +6 -3
  200. package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
  201. package/{esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts โ†’ umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts} +2 -2
  202. package/umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.test.d.ts +1 -0
  203. package/umd/typings/src/conversion/utils/renameParameter.d.ts +3 -3
  204. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +14 -0
  205. package/umd/typings/src/conversion/utils/stringifyPipelineJson.test.d.ts +1 -0
  206. package/umd/typings/src/conversion/validation/_importPipeline.d.ts +12 -3
  207. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +10 -1
  208. package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
  209. package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
  210. package/umd/typings/src/errors/VersionMismatchError.d.ts +8 -0
  211. package/umd/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
  212. package/umd/typings/src/execution/LlmExecutionTools.d.ts +10 -8
  213. package/umd/typings/src/execution/PipelineExecutor.d.ts +48 -26
  214. package/umd/typings/src/execution/PromptResult.d.ts +39 -54
  215. package/umd/typings/src/execution/PromptResultUsage.d.ts +29 -0
  216. package/umd/typings/src/execution/ScriptExecutionTools.d.ts +5 -4
  217. package/umd/typings/src/execution/UncertainNumber.d.ts +18 -0
  218. package/umd/typings/src/execution/UserInterfaceTools.d.ts +5 -5
  219. package/umd/typings/src/execution/createPipelineExecutor.d.ts +31 -3
  220. package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
  221. package/umd/typings/src/execution/utils/addUsage.d.ts +58 -2
  222. package/umd/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
  223. package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  224. package/umd/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
  225. package/umd/typings/src/execution/utils/usageToHuman.d.ts +15 -0
  226. package/umd/typings/src/execution/utils/usageToHuman.test.d.ts +1 -0
  227. package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
  228. package/umd/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  229. package/umd/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
  230. package/umd/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
  231. package/umd/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
  232. package/umd/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
  233. package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
  234. package/umd/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
  235. package/umd/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
  236. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
  237. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -0
  238. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -23
  239. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  240. package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +8 -14
  241. package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +31 -0
  242. package/umd/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +11 -0
  243. package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +12 -0
  244. package/umd/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
  245. package/umd/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  246. package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +19 -0
  247. package/umd/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +14 -0
  248. package/umd/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts +17 -0
  249. package/umd/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +35 -0
  250. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
  251. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  252. package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +3 -3
  253. package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  254. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
  255. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
  256. package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  257. package/umd/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
  258. package/umd/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
  259. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
  260. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
  261. package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
  262. package/umd/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +3 -0
  263. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
  264. package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
  265. package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  266. package/umd/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  267. package/umd/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
  268. package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  269. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +10 -8
  270. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
  271. package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
  272. package/umd/typings/src/personas/preparePersona.d.ts +15 -0
  273. package/umd/typings/src/personas/preparePersona.test.d.ts +1 -0
  274. package/umd/typings/src/prepare/PrepareOptions.d.ts +22 -0
  275. package/umd/typings/src/prepare/isPipelinePrepared.d.ts +14 -0
  276. package/umd/typings/src/prepare/isPipelinePrepared.test.d.ts +1 -0
  277. package/umd/typings/src/prepare/preparePipeline.d.ts +16 -0
  278. package/umd/typings/src/prepare/prepareTemplates.d.ts +31 -0
  279. package/umd/typings/src/prepare/unpreparePipeline.d.ts +11 -0
  280. package/umd/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
  281. package/umd/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  282. package/umd/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
  283. package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
  284. package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  285. package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
  286. package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
  287. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  288. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  289. package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
  290. package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
  291. package/umd/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
  292. package/umd/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
  293. package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
  294. package/umd/typings/src/types/ModelRequirements.d.ts +71 -11
  295. package/umd/typings/src/types/ModelVariant.d.ts +14 -0
  296. package/umd/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
  297. package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +70 -0
  298. package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +27 -0
  299. package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +10 -1
  300. package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +41 -0
  301. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +31 -5
  302. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +22 -0
  303. package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +8 -2
  304. package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
  305. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +23 -4
  306. package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +12 -2
  307. package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +7 -2
  308. package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -2
  309. package/umd/typings/src/types/PipelineString.d.ts +1 -1
  310. package/umd/typings/src/types/Prompt.d.ts +54 -10
  311. package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
  312. package/umd/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
  313. package/umd/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  314. package/umd/typings/src/types/typeAliases.d.ts +114 -15
  315. package/umd/typings/src/utils/FromtoItems.d.ts +3 -3
  316. package/umd/typings/src/utils/currentDate.d.ts +7 -0
  317. package/umd/typings/src/utils/deepClone.d.ts +9 -0
  318. package/umd/typings/src/utils/deepFreeze.d.ts +22 -0
  319. package/umd/typings/src/utils/emojis.d.ts +2 -2
  320. package/umd/typings/src/utils/{extractParameters.d.ts โ†’ extractParameterNames.d.ts} +2 -2
  321. package/umd/typings/src/utils/extractParameterNames.test.d.ts +1 -0
  322. package/umd/typings/src/utils/formatNumber.d.ts +1 -1
  323. package/umd/typings/src/utils/isRunningInWhatever.d.ts +3 -0
  324. package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
  325. package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
  326. package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  327. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  328. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
  329. package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  330. package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
  331. package/umd/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
  332. package/umd/typings/src/utils/organization/TODO_USE.d.ts +12 -0
  333. package/umd/typings/src/utils/organization/TODO_any.d.ts +6 -0
  334. package/umd/typings/src/utils/organization/TODO_object.d.ts +6 -0
  335. package/umd/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
  336. package/umd/typings/src/utils/organization/___.d.ts +6 -0
  337. package/{esm/typings/src/utils โ†’ umd/typings/src/utils/organization}/just.d.ts +5 -1
  338. package/umd/typings/src/utils/organization/keepUnused.d.ts +16 -0
  339. package/umd/typings/src/utils/organization/really_any.d.ts +6 -0
  340. package/umd/typings/src/utils/organization/really_unknown.d.ts +6 -0
  341. package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
  342. package/umd/typings/src/{execution/utils โ†’ utils}/replaceParameters.d.ts +2 -4
  343. package/umd/typings/src/utils/replaceParameters.test.d.ts +1 -0
  344. package/umd/typings/src/utils/sets/difference.d.ts +3 -0
  345. package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
  346. package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
  347. package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
  348. package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
  349. package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
  350. package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  351. package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
  352. package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
  353. package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  354. package/esm/typings/src/personas/personaToModelRequirements.d.ts +0 -6
  355. package/esm/typings/src/types/Parameters.d.ts +0 -14
  356. package/esm/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
  357. package/esm/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
  358. package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  359. package/umd/typings/src/personas/personaToModelRequirements.d.ts +0 -6
  360. package/umd/typings/src/types/Parameters.d.ts +0 -14
  361. package/umd/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
  362. package/umd/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
  363. /package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts โ†’ extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
  364. /package/esm/typings/src/{execution/addPromptResultUsage.test.d.ts โ†’ conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
  365. /package/esm/typings/src/execution/utils/{replaceParameters.test.d.ts โ†’ usageToHuman.test.d.ts} +0 -0
  366. /package/esm/typings/src/{utils/extractParameters.test.d.ts โ†’ knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts} +0 -0
  367. /package/{umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.test.d.ts โ†’ esm/typings/src/personas/preparePersona.test.d.ts} +0 -0
  368. /package/esm/typings/src/{utils/postprocessing โ†’ postprocessing/utils}/extractBlock.d.ts +0 -0
  369. /package/{umd/typings/src/execution/addPromptResultUsage.test.d.ts โ†’ esm/typings/src/prepare/isPipelinePrepared.test.d.ts} +0 -0
  370. /package/{umd/typings/src/execution/utils/replaceParameters.test.d.ts โ†’ esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts} +0 -0
  371. /package/{umd/typings/src/utils/extractParameters.test.d.ts โ†’ esm/typings/src/utils/extractParameterNames.test.d.ts} +0 -0
  372. /package/umd/typings/src/{utils/postprocessing โ†’ postprocessing/utils}/extractBlock.d.ts +0 -0
package/README.md CHANGED
@@ -43,7 +43,7 @@ import { OpenAiExecutionTools } from '@promptbook/openai';
43
43
  const collection = await createCollectionFromDirectory('./promptbook-collection');
44
44
 
45
45
  // โ–ถ Get single Pipeline
46
- const pipeline = await library.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
46
+ const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
47
47
 
48
48
  // โ–ถ Prepare tools
49
49
  const tools = {
@@ -71,6 +71,45 @@ const { isSuccessful, errors, outputParameters, executionReport } = result;
71
71
  console.info(outputParameters);
72
72
  ```
73
73
 
74
+ ## ๐Ÿง™โ€โ™‚๏ธ Connect to LLM providers automatically
75
+
76
+ You can just use `createLlmToolsFromEnv` function to create LLM tools from environment variables like `OPENAI_API_KEY` and `ANTHROPIC_CLAUDE_API_KEY` automatically.
77
+
78
+ ```typescript
79
+ import { createPipelineExecutor, createCollectionFromDirectory, assertsExecutionSuccessful } from '@promptbook/core';
80
+ import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
81
+ import { createLlmToolsFromEnv } from '@promptbook/node';
82
+
83
+ // โ–ถ Create whole pipeline collection
84
+ const collection = await createCollectionFromDirectory('./promptbook-collection');
85
+
86
+ // โ–ถ Get single Pipeline
87
+ const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
88
+
89
+ // โ–ถ Prepare multiple tools
90
+ const tools = {
91
+ // Note: ๐Ÿง™โ€โ™‚๏ธ Just call `createLlmToolsFromEnv` to automatically connect to all configured providers
92
+ llm: createLlmToolsFromEnv(),
93
+ script: [new JavascriptExecutionTools()],
94
+ };
95
+
96
+ // โ–ถ Create executor - the function that will execute the Pipeline
97
+ const pipelineExecutor = createPipelineExecutor({ pipeline, tools });
98
+
99
+ // โ–ถ Prepare input parameters
100
+ const inputParameters = { word: 'dog' };
101
+
102
+ // ๐Ÿš€โ–ถ Execute the Pipeline
103
+ const result = await pipelineExecutor(inputParameters);
104
+
105
+ // โ–ถ Fail if the execution was not successful
106
+ assertsExecutionSuccessful(result);
107
+
108
+ // โ–ถ Handle the result
109
+ const { isSuccessful, errors, outputParameters, executionReport } = result;
110
+ console.info(outputParameters);
111
+ ```
112
+
74
113
  ## ๐Ÿ’• Usage of multiple LLM providers
75
114
 
76
115
  You can use multiple LLM providers in one Promptbook execution. The best model will be chosen automatically according to the prompt and the model's capabilities.
@@ -80,12 +119,14 @@ import { createPipelineExecutor, assertsExecutionSuccessful } from '@promptbook/
80
119
  import { createCollectionFromDirectory } from '@promptbook/node';
81
120
  import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
82
121
  import { OpenAiExecutionTools } from '@promptbook/openai';
122
+ import { AnthropicClaudeExecutionTools } from '@promptbook/anthropic-claude';
123
+ import { AzureOpenAiExecutionTools } from '@promptbook/azure-openai';
83
124
 
84
125
  // โ–ถ Create whole pipeline collection
85
126
  const collection = await createCollectionFromDirectory('./promptbook-collection');
86
127
 
87
128
  // โ–ถ Get single Pipeline
88
- const pipeline = await library.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
129
+ const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
89
130
 
90
131
  // โ–ถ Prepare multiple tools
91
132
  const tools = {
@@ -186,7 +227,7 @@ File `write-website-content.ptbk.md`:
186
227
  > - PROMPTBOOK VERSION 0.0.1
187
228
  > - INPUTโ€ฏโ€ฏPARAM `{rawTitle}` Automatically suggested a site name or empty text
188
229
  > - INPUTโ€ฏโ€ฏPARAM `{rawAssigment}` Automatically generated site entry from image recognition
189
- > - OUTPUTโ€ฏPARAM `{content}` Web content
230
+ > - OUTPUTโ€ฏPARAM `{websiteContent}` Web content
190
231
  > - OUTPUTโ€ฏPARAM `{keywords}` Keywords
191
232
  >
192
233
  > ## ๐Ÿ‘ค Specifying the assigment
@@ -345,7 +386,7 @@ File `write-website-content.ptbk.md`:
345
386
  > {contentBody}
346
387
  > ```
347
388
  >
348
- > `-> {content}`
389
+ > `-> {websiteContent}`
349
390
 
350
391
 
351
392
 
@@ -385,7 +426,7 @@ flowchart LR
385
426
  templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
386
427
  templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
387
428
 
388
- templateCombineTheContent--"{content}"-->output
429
+ templateCombineTheContent--"{websiteContent}"-->output
389
430
  output((Output)):::output
390
431
 
391
432
  classDef input color: grey;
package/esm/index.es.js CHANGED
@@ -82,6 +82,18 @@ function __generator(thisArg, body) {
82
82
  }
83
83
  }
84
84
 
85
+ function __values(o) {
86
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
87
+ if (m) return m.call(o);
88
+ if (o && typeof o.length === "number") return {
89
+ next: function () {
90
+ if (o && i >= o.length) o = void 0;
91
+ return { value: o && o[i++], done: !o };
92
+ }
93
+ };
94
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
95
+ }
96
+
85
97
  function __read(o, n) {
86
98
  var m = typeof Symbol === "function" && o[Symbol.iterator];
87
99
  if (!m) return o;
@@ -97,12 +109,22 @@ function __read(o, n) {
97
109
  finally { if (e) throw e.error; }
98
110
  }
99
111
  return ar;
112
+ }
113
+
114
+ function __spreadArray(to, from, pack) {
115
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
116
+ if (ar || !(i in from)) {
117
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
118
+ ar[i] = from[i];
119
+ }
120
+ }
121
+ return to.concat(ar || Array.prototype.slice.call(from));
100
122
  }
101
123
 
102
124
  /**
103
125
  * Function computeUsage will create price per one token based on the string value found on openai page
104
126
  *
105
- * @private within the package, used only as internal helper for `OPENAI_MODELS`
127
+ * @private within the repository, used only as internal helper for `OPENAI_MODELS`
106
128
  */
107
129
  function computeUsage(value) {
108
130
  var _a = __read(value.split(' / '), 2), price = _a[0], tokens = _a[1];
@@ -456,6 +478,7 @@ var OPENAI_MODELS = [
456
478
  * @see /other/playground/playground.ts
457
479
  * TODO: [๐Ÿ“] Make better
458
480
  * TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
481
+ * TODO: [๐Ÿšธ] Not all models are compatible with JSON mode, add this information here and use it
459
482
  */
460
483
 
461
484
  /**
@@ -495,6 +518,168 @@ function getCurrentIsoDate() {
495
518
  return new Date().toISOString();
496
519
  }
497
520
 
521
+ /**
522
+ * @@@
523
+ *
524
+ * @returns The same object as the input, but deeply frozen
525
+ *
526
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
527
+ */
528
+ function deepFreeze(objectValue) {
529
+ var e_1, _a;
530
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
531
+ try {
532
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
533
+ var propertyName = propertyNames_1_1.value;
534
+ var value = objectValue[propertyName];
535
+ if (value && typeof value === 'object') {
536
+ deepFreeze(value);
537
+ }
538
+ }
539
+ }
540
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
541
+ finally {
542
+ try {
543
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
544
+ }
545
+ finally { if (e_1) throw e_1.error; }
546
+ }
547
+ return Object.freeze(objectValue);
548
+ }
549
+ /**
550
+ * TODO: [๐Ÿ”ผ] Export from `@promptbook/utils`
551
+ * TODO: [๐Ÿง ] Is there a way how to meaningfully test this utility
552
+ */
553
+
554
+ /**
555
+ * The maximum number of iterations for a loops
556
+ */
557
+ var LOOP_LIMIT = 1000;
558
+ /**
559
+ * Nonce which is used for replacing things in strings
560
+ */
561
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
562
+ /**
563
+ * The names of the parameters that are reserved for special purposes
564
+ */
565
+ deepFreeze([
566
+ 'content',
567
+ 'context',
568
+ 'knowledge',
569
+ 'samples',
570
+ 'modelName',
571
+ 'currentDate',
572
+ // <- TODO: Add more like 'date', 'modelName',...
573
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
574
+ ]);
575
+ /**
576
+ * @@@
577
+ */
578
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
579
+ /**
580
+ * @@@
581
+ */
582
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
583
+ /*
584
+ TODO: !!! Just testing false-negative detection of [๐ŸŸก][๐ŸŸข][๐Ÿ”ต][โšช] leak
585
+ */
586
+ // [๐ŸŸก][๐ŸŸข][๐Ÿ”ต][โšช]
587
+ /**
588
+ * TODO: [๐Ÿ”ผ] Export all to core
589
+ */
590
+
591
+ /**
592
+ * This error type indicates that some limit was reached
593
+ */
594
+ var LimitReachedError = /** @class */ (function (_super) {
595
+ __extends(LimitReachedError, _super);
596
+ function LimitReachedError(message) {
597
+ var _this = _super.call(this, message) || this;
598
+ _this.name = 'LimitReachedError';
599
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
600
+ return _this;
601
+ }
602
+ return LimitReachedError;
603
+ }(Error));
604
+
605
+ /**
606
+ * Replaces parameters in template with values from parameters object
607
+ *
608
+ * @param template the template with parameters in {curly} braces
609
+ * @param parameters the object with parameters
610
+ * @returns the template with replaced parameters
611
+ * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
612
+ */
613
+ function replaceParameters(template, parameters) {
614
+ var e_1, _a;
615
+ try {
616
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
617
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
618
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
619
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
620
+ }
621
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
622
+ // TODO: [๐Ÿต]
623
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
624
+ }
625
+ }
626
+ }
627
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
628
+ finally {
629
+ try {
630
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
631
+ }
632
+ finally { if (e_1) throw e_1.error; }
633
+ }
634
+ var replacedTemplate = template;
635
+ var match;
636
+ var loopLimit = LOOP_LIMIT;
637
+ var _loop_1 = function () {
638
+ if (loopLimit-- < 0) {
639
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
640
+ }
641
+ var precol = match.groups.precol;
642
+ var parameterName = match.groups.parameterName;
643
+ if (parameterName === '') {
644
+ return "continue";
645
+ }
646
+ if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
647
+ throw new PipelineExecutionError('Parameter is already opened or not closed');
648
+ }
649
+ if (parameters[parameterName] === undefined) {
650
+ throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
651
+ }
652
+ var parameterValue = parameters[parameterName];
653
+ if (parameterValue === undefined) {
654
+ throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
655
+ }
656
+ parameterValue = parameterValue.toString();
657
+ if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
658
+ parameterValue = parameterValue
659
+ .split('\n')
660
+ .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
661
+ .join('\n');
662
+ }
663
+ replacedTemplate =
664
+ replacedTemplate.substring(0, match.index + precol.length) +
665
+ parameterValue +
666
+ replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
667
+ };
668
+ while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
669
+ .exec(replacedTemplate))) {
670
+ _loop_1();
671
+ }
672
+ // [๐Ÿ’ซ] Check if there are parameters that are not closed properly
673
+ if (/{\w+$/.test(replacedTemplate)) {
674
+ throw new PipelineExecutionError('Parameter is not closed');
675
+ }
676
+ // [๐Ÿ’ซ] Check if there are parameters that are not opened properly
677
+ if (/^\w+}/.test(replacedTemplate)) {
678
+ throw new PipelineExecutionError('Parameter is not opened');
679
+ }
680
+ return replacedTemplate;
681
+ }
682
+
498
683
  /**
499
684
  * Counts number of characters in the text
500
685
  */
@@ -914,35 +1099,46 @@ var OpenAiExecutionTools = /** @class */ (function () {
914
1099
  */
915
1100
  OpenAiExecutionTools.prototype.callChatModel = function (prompt) {
916
1101
  return __awaiter(this, void 0, void 0, function () {
917
- var content, modelRequirements, expectFormat, model, modelSettings, rawRequest, start, complete, rawResponse, resultContent, usage;
1102
+ var content, parameters, modelRequirements, expectFormat, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
918
1103
  return __generator(this, function (_a) {
919
1104
  switch (_a.label) {
920
1105
  case 0:
921
1106
  if (this.options.isVerbose) {
922
1107
  console.info('๐Ÿ’ฌ OpenAI callChatModel call', { prompt: prompt });
923
1108
  }
924
- content = prompt.content, modelRequirements = prompt.modelRequirements, expectFormat = prompt.expectFormat;
1109
+ content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements, expectFormat = prompt.expectFormat;
925
1110
  // TODO: [โ˜‚] Use here more modelRequirements
926
1111
  if (modelRequirements.modelVariant !== 'CHAT') {
927
1112
  throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
928
1113
  }
929
- model = modelRequirements.modelName || this.getDefaultChatModel().modelName;
1114
+ modelName = modelRequirements.modelName || this.getDefaultChatModel().modelName;
930
1115
  modelSettings = {
931
- model: model,
1116
+ model: modelName,
932
1117
  max_tokens: modelRequirements.maxTokens,
933
- // <- TODO: Make some global max cap for maxTokens
1118
+ // <- TODO: [๐ŸŒพ] Make some global max cap for maxTokens
1119
+ temperature: modelRequirements.temperature,
1120
+ // <- TODO: [๐Ÿˆ] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
1121
+ // <- Note: [๐Ÿง†]
934
1122
  };
935
1123
  if (expectFormat === 'JSON') {
936
1124
  modelSettings.response_format = {
937
1125
  type: 'json_object',
938
1126
  };
939
1127
  }
940
- rawRequest = __assign(__assign({}, modelSettings), { messages: [
1128
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
1129
+ rawRequest = __assign(__assign({}, modelSettings), { messages: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
1130
+ ? []
1131
+ : [
1132
+ {
1133
+ role: 'system',
1134
+ content: modelRequirements.systemMessage,
1135
+ },
1136
+ ])), false), [
941
1137
  {
942
1138
  role: 'user',
943
- content: content,
1139
+ content: rawPromptContent,
944
1140
  },
945
- ], user: this.options.user });
1141
+ ], false), user: this.options.user });
946
1142
  start = getCurrentIsoDate();
947
1143
  if (this.options.isVerbose) {
948
1144
  console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
@@ -969,14 +1165,16 @@ var OpenAiExecutionTools = /** @class */ (function () {
969
1165
  }
970
1166
  return [2 /*return*/, {
971
1167
  content: resultContent,
972
- modelName: rawResponse.model || model,
1168
+ modelName: rawResponse.model || modelName,
973
1169
  timing: {
974
1170
  start: start,
975
1171
  complete: complete,
976
1172
  },
977
1173
  usage: usage,
1174
+ rawPromptContent: rawPromptContent,
1175
+ rawRequest: rawRequest,
978
1176
  rawResponse: rawResponse,
979
- // <- [๐Ÿคนโ€โ™‚๏ธ]
1177
+ // <- [๐Ÿ—ฏ]
980
1178
  }];
981
1179
  }
982
1180
  });
@@ -987,25 +1185,29 @@ var OpenAiExecutionTools = /** @class */ (function () {
987
1185
  */
988
1186
  OpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
989
1187
  return __awaiter(this, void 0, void 0, function () {
990
- var content, modelRequirements, model, modelSettings, rawRequest, start, complete, rawResponse, resultContent, usage;
1188
+ var content, parameters, modelRequirements, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
991
1189
  return __generator(this, function (_a) {
992
1190
  switch (_a.label) {
993
1191
  case 0:
994
1192
  if (this.options.isVerbose) {
995
1193
  console.info('๐Ÿ–‹ OpenAI callCompletionModel call', { prompt: prompt });
996
1194
  }
997
- content = prompt.content, modelRequirements = prompt.modelRequirements;
1195
+ content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
998
1196
  // TODO: [โ˜‚] Use here more modelRequirements
999
1197
  if (modelRequirements.modelVariant !== 'COMPLETION') {
1000
1198
  throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
1001
1199
  }
1002
- model = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
1200
+ modelName = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
1003
1201
  modelSettings = {
1004
- model: model,
1005
- max_tokens: modelRequirements.maxTokens || 2000, // <- Note: 2000 is for lagacy reasons
1006
- // <- TODO: Make some global max cap for maxTokens
1202
+ model: modelName,
1203
+ max_tokens: modelRequirements.maxTokens || 2000,
1204
+ // <- TODO: [๐ŸŒพ] Make some global max cap for maxTokens
1205
+ temperature: modelRequirements.temperature,
1206
+ // <- TODO: [๐Ÿˆ] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
1207
+ // <- Note: [๐Ÿง†]
1007
1208
  };
1008
- rawRequest = __assign(__assign({}, modelSettings), { prompt: content, user: this.options.user });
1209
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
1210
+ rawRequest = __assign(__assign({}, modelSettings), { prompt: rawPromptContent, user: this.options.user });
1009
1211
  start = getCurrentIsoDate();
1010
1212
  if (this.options.isVerbose) {
1011
1213
  console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
@@ -1029,14 +1231,16 @@ var OpenAiExecutionTools = /** @class */ (function () {
1029
1231
  usage = computeOpenaiUsage(content, resultContent || '', rawResponse);
1030
1232
  return [2 /*return*/, {
1031
1233
  content: resultContent,
1032
- modelName: rawResponse.model || model,
1234
+ modelName: rawResponse.model || modelName,
1033
1235
  timing: {
1034
1236
  start: start,
1035
1237
  complete: complete,
1036
1238
  },
1037
1239
  usage: usage,
1240
+ rawPromptContent: rawPromptContent,
1241
+ rawRequest: rawRequest,
1038
1242
  rawResponse: rawResponse,
1039
- // <- [๐Ÿคนโ€โ™‚๏ธ]
1243
+ // <- [๐Ÿ—ฏ]
1040
1244
  }];
1041
1245
  }
1042
1246
  });
@@ -1047,23 +1251,23 @@ var OpenAiExecutionTools = /** @class */ (function () {
1047
1251
  */
1048
1252
  OpenAiExecutionTools.prototype.callEmbeddingModel = function (prompt) {
1049
1253
  return __awaiter(this, void 0, void 0, function () {
1050
- var content, modelRequirements, model, rawRequest, start, complete, rawResponse, resultContent, usage;
1254
+ var content, parameters, modelRequirements, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
1051
1255
  return __generator(this, function (_a) {
1052
1256
  switch (_a.label) {
1053
1257
  case 0:
1054
1258
  if (this.options.isVerbose) {
1055
1259
  console.info('๐Ÿ–‹ OpenAI embedding call', { prompt: prompt });
1056
1260
  }
1057
- content = prompt.content, modelRequirements = prompt.modelRequirements;
1261
+ content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
1058
1262
  // TODO: [โ˜‚] Use here more modelRequirements
1059
1263
  if (modelRequirements.modelVariant !== 'EMBEDDING') {
1060
1264
  throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
1061
1265
  }
1062
- model = modelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
1266
+ modelName = modelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
1267
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
1063
1268
  rawRequest = {
1064
- input: content,
1065
- model: model,
1066
- // TODO: !!!! Test model 3 and dimensions
1269
+ input: rawPromptContent,
1270
+ model: modelName,
1067
1271
  };
1068
1272
  start = getCurrentIsoDate();
1069
1273
  if (this.options.isVerbose) {
@@ -1084,14 +1288,16 @@ var OpenAiExecutionTools = /** @class */ (function () {
1084
1288
  usage = computeOpenaiUsage(content, '', rawResponse);
1085
1289
  return [2 /*return*/, {
1086
1290
  content: resultContent,
1087
- modelName: rawResponse.model || model,
1291
+ modelName: rawResponse.model || modelName,
1088
1292
  timing: {
1089
1293
  start: start,
1090
1294
  complete: complete,
1091
1295
  },
1092
1296
  usage: usage,
1297
+ rawPromptContent: rawPromptContent,
1298
+ rawRequest: rawRequest,
1093
1299
  rawResponse: rawResponse,
1094
- // <- [๐Ÿคนโ€โ™‚๏ธ]
1300
+ // <- [๐Ÿ—ฏ]
1095
1301
  }];
1096
1302
  }
1097
1303
  });
@@ -1108,9 +1314,9 @@ var OpenAiExecutionTools = /** @class */ (function () {
1108
1314
  });
1109
1315
  if (model === undefined) {
1110
1316
  throw new UnexpectedError(spaceTrim$1(function (block) {
1111
- return "\n Cannot find model in OpenAI models with name ".concat(defaultModelName, " which should be used as default.\n\n Available models:\n ").concat(block(OPENAI_MODELS.map(function (_a) {
1317
+ return "\n Cannot find model in OpenAI models with name \"".concat(defaultModelName, "\" which should be used as default.\n\n Available models:\n ").concat(block(OPENAI_MODELS.map(function (_a) {
1112
1318
  var modelName = _a.modelName;
1113
- return "- ".concat(modelName);
1319
+ return "- \"".concat(modelName, "\"");
1114
1320
  }).join('\n')), "\n\n ");
1115
1321
  }));
1116
1322
  }
@@ -1154,12 +1360,13 @@ var OpenAiExecutionTools = /** @class */ (function () {
1154
1360
  * TODO: [๐Ÿง ][๐Ÿง™โ€โ™‚๏ธ] Maybe there can be some wizzard for thoose who want to use just OpenAI
1155
1361
  * TODO: Maybe Create some common util for callChatModel and callCompletionModel
1156
1362
  * TODO: Maybe make custom OpenaiError
1363
+ * TODO: [๐Ÿง ][๐Ÿˆ] Maybe use `isDeterministic` from options
1157
1364
  */
1158
1365
 
1159
1366
  /**
1160
1367
  * The version of the Promptbook library
1161
1368
  */
1162
- var PROMPTBOOK_VERSION = '0.61.0-8';
1369
+ var PROMPTBOOK_VERSION = '0.61.0';
1163
1370
  // TODO: !!!! List here all the versions and annotate + put into script
1164
1371
 
1165
1372
  export { OPENAI_MODELS, OpenAiExecutionTools, PROMPTBOOK_VERSION };