@promptbook/azure-openai 0.61.0-9 โ†’ 0.61.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 (366) hide show
  1. package/README.md +8 -6
  2. package/esm/index.es.js +256 -27
  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 +7 -2
  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 +1 -1
  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 +30 -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/usageToWorktime.d.ts +2 -2
  52. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  53. package/esm/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
  54. package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
  55. package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
  56. package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
  57. package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
  58. package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
  59. package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
  60. package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
  61. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -23
  62. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  63. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +8 -14
  64. package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +30 -0
  65. package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
  66. package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +11 -0
  67. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
  68. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  69. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +16 -0
  70. package/esm/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
  71. package/esm/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
  72. package/esm/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
  73. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
  74. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  75. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +3 -3
  76. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  77. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
  78. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
  79. package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  80. package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
  81. package/esm/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
  82. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
  83. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
  84. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
  85. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
  86. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
  87. package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  88. package/esm/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  89. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
  90. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  91. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +10 -8
  92. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
  93. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
  94. package/esm/typings/src/personas/preparePersona.d.ts +15 -0
  95. package/esm/typings/src/prepare/PrepareOptions.d.ts +22 -0
  96. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +14 -0
  97. package/esm/typings/src/prepare/preparePipeline.d.ts +17 -0
  98. package/esm/typings/src/prepare/prepareTemplates.d.ts +31 -0
  99. package/esm/typings/src/prepare/unpreparePipeline.d.ts +11 -0
  100. package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
  101. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  102. package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
  103. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
  104. package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  105. package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
  106. package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
  107. package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  108. package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
  109. package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
  110. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
  111. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
  112. package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
  113. package/esm/typings/src/types/ModelRequirements.d.ts +71 -11
  114. package/esm/typings/src/types/ModelVariant.d.ts +14 -0
  115. package/esm/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
  116. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +70 -0
  117. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +27 -0
  118. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +10 -1
  119. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +41 -0
  120. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +31 -5
  121. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +22 -0
  122. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +8 -2
  123. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
  124. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +23 -4
  125. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +12 -2
  126. package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +7 -2
  127. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -2
  128. package/esm/typings/src/types/PipelineString.d.ts +1 -1
  129. package/esm/typings/src/types/Prompt.d.ts +54 -10
  130. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
  131. package/esm/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
  132. package/esm/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  133. package/esm/typings/src/types/typeAliases.d.ts +114 -15
  134. package/esm/typings/src/utils/FromtoItems.d.ts +3 -3
  135. package/esm/typings/src/utils/currentDate.d.ts +7 -0
  136. package/esm/typings/src/utils/deepClone.d.ts +9 -0
  137. package/esm/typings/src/utils/deepFreeze.d.ts +22 -0
  138. package/esm/typings/src/utils/emojis.d.ts +2 -2
  139. package/esm/typings/src/utils/{extractParameters.d.ts โ†’ extractParameterNames.d.ts} +2 -2
  140. package/esm/typings/src/utils/formatNumber.d.ts +1 -1
  141. package/esm/typings/src/utils/isRunningInWhatever.d.ts +3 -0
  142. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
  143. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
  144. package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  145. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
  146. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  147. package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
  148. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
  149. package/esm/typings/src/utils/organization/TODO_USE.d.ts +12 -0
  150. package/esm/typings/src/utils/organization/TODO_any.d.ts +6 -0
  151. package/esm/typings/src/utils/organization/TODO_object.d.ts +6 -0
  152. package/esm/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
  153. package/esm/typings/src/utils/organization/___.d.ts +6 -0
  154. package/{umd/typings/src/utils โ†’ esm/typings/src/utils/organization}/just.d.ts +5 -1
  155. package/esm/typings/src/utils/organization/keepUnused.d.ts +16 -0
  156. package/esm/typings/src/utils/organization/really_any.d.ts +6 -0
  157. package/esm/typings/src/utils/organization/really_unknown.d.ts +6 -0
  158. package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
  159. package/esm/typings/src/{execution/utils โ†’ utils}/replaceParameters.d.ts +2 -4
  160. package/esm/typings/src/utils/replaceParameters.test.d.ts +1 -0
  161. package/esm/typings/src/utils/sets/difference.d.ts +3 -0
  162. package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
  163. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
  164. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
  165. package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
  166. package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
  167. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  168. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
  169. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
  170. package/package.json +4 -3
  171. package/umd/index.umd.js +259 -31
  172. package/umd/index.umd.js.map +1 -1
  173. package/umd/typings/promptbook-collection/index.d.ts +200 -30
  174. package/umd/typings/src/_packages/core.index.d.ts +7 -2
  175. package/umd/typings/src/_packages/execute-javascript.index.d.ts +1 -1
  176. package/umd/typings/src/_packages/node.index.d.ts +2 -1
  177. package/umd/typings/src/_packages/types.index.d.ts +12 -8
  178. package/umd/typings/src/_packages/utils.index.d.ts +11 -8
  179. package/umd/typings/src/cli/cli-commands/hello.d.ts +3 -0
  180. package/umd/typings/src/cli/cli-commands/make.d.ts +3 -0
  181. package/umd/typings/src/cli/cli-commands/prettify.d.ts +3 -0
  182. package/umd/typings/src/cli/promptbookCli.d.ts +1 -0
  183. package/umd/typings/src/collection/PipelineCollection.d.ts +1 -1
  184. package/umd/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
  185. package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
  186. package/umd/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
  187. package/umd/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
  188. package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
  189. package/umd/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
  190. package/umd/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
  191. package/umd/typings/src/commands/_common/types/CommandParser.d.ts +42 -14
  192. package/umd/typings/src/config.d.ts +46 -1
  193. package/umd/typings/src/config.test.d.ts +4 -0
  194. package/umd/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
  195. package/umd/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
  196. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +6 -3
  197. package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
  198. package/{esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts โ†’ umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts} +2 -2
  199. package/umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.test.d.ts +1 -0
  200. package/umd/typings/src/conversion/utils/renameParameter.d.ts +3 -3
  201. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +14 -0
  202. package/umd/typings/src/conversion/utils/stringifyPipelineJson.test.d.ts +1 -0
  203. package/umd/typings/src/conversion/validation/_importPipeline.d.ts +12 -3
  204. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +10 -1
  205. package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
  206. package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
  207. package/umd/typings/src/errors/VersionMismatchError.d.ts +8 -0
  208. package/umd/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
  209. package/umd/typings/src/execution/LlmExecutionTools.d.ts +10 -8
  210. package/umd/typings/src/execution/PipelineExecutor.d.ts +48 -26
  211. package/umd/typings/src/execution/PromptResult.d.ts +39 -54
  212. package/umd/typings/src/execution/PromptResultUsage.d.ts +29 -0
  213. package/umd/typings/src/execution/ScriptExecutionTools.d.ts +5 -4
  214. package/umd/typings/src/execution/UncertainNumber.d.ts +18 -0
  215. package/umd/typings/src/execution/UserInterfaceTools.d.ts +5 -5
  216. package/umd/typings/src/execution/createPipelineExecutor.d.ts +30 -3
  217. package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
  218. package/umd/typings/src/execution/utils/addUsage.d.ts +58 -2
  219. package/umd/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
  220. package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  221. package/umd/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
  222. package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
  223. package/umd/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  224. package/umd/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
  225. package/umd/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
  226. package/umd/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
  227. package/umd/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
  228. package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
  229. package/umd/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
  230. package/umd/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
  231. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
  232. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -0
  233. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -23
  234. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  235. package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +8 -14
  236. package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +30 -0
  237. package/umd/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
  238. package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +11 -0
  239. package/umd/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
  240. package/umd/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  241. package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +16 -0
  242. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
  243. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
  244. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
  245. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
  246. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  247. package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +3 -3
  248. package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  249. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
  250. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
  251. package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  252. package/umd/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
  253. package/umd/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
  254. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
  255. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
  256. package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
  257. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
  258. package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
  259. package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  260. package/umd/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  261. package/umd/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
  262. package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  263. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +10 -8
  264. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
  265. package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
  266. package/umd/typings/src/personas/preparePersona.d.ts +15 -0
  267. package/umd/typings/src/personas/preparePersona.test.d.ts +1 -0
  268. package/umd/typings/src/prepare/PrepareOptions.d.ts +22 -0
  269. package/umd/typings/src/prepare/isPipelinePrepared.d.ts +14 -0
  270. package/umd/typings/src/prepare/isPipelinePrepared.test.d.ts +1 -0
  271. package/umd/typings/src/prepare/preparePipeline.d.ts +17 -0
  272. package/umd/typings/src/prepare/prepareTemplates.d.ts +31 -0
  273. package/umd/typings/src/prepare/unpreparePipeline.d.ts +11 -0
  274. package/umd/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
  275. package/umd/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  276. package/umd/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
  277. package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
  278. package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  279. package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
  280. package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
  281. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  282. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  283. package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
  284. package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
  285. package/umd/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
  286. package/umd/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
  287. package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
  288. package/umd/typings/src/types/ModelRequirements.d.ts +71 -11
  289. package/umd/typings/src/types/ModelVariant.d.ts +14 -0
  290. package/umd/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
  291. package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +70 -0
  292. package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +27 -0
  293. package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +10 -1
  294. package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +41 -0
  295. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +31 -5
  296. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +22 -0
  297. package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +8 -2
  298. package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
  299. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +23 -4
  300. package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +12 -2
  301. package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +7 -2
  302. package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -2
  303. package/umd/typings/src/types/PipelineString.d.ts +1 -1
  304. package/umd/typings/src/types/Prompt.d.ts +54 -10
  305. package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
  306. package/umd/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
  307. package/umd/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  308. package/umd/typings/src/types/typeAliases.d.ts +114 -15
  309. package/umd/typings/src/utils/FromtoItems.d.ts +3 -3
  310. package/umd/typings/src/utils/currentDate.d.ts +7 -0
  311. package/umd/typings/src/utils/deepClone.d.ts +9 -0
  312. package/umd/typings/src/utils/deepFreeze.d.ts +22 -0
  313. package/umd/typings/src/utils/emojis.d.ts +2 -2
  314. package/umd/typings/src/utils/{extractParameters.d.ts โ†’ extractParameterNames.d.ts} +2 -2
  315. package/umd/typings/src/utils/extractParameterNames.test.d.ts +1 -0
  316. package/umd/typings/src/utils/formatNumber.d.ts +1 -1
  317. package/umd/typings/src/utils/isRunningInWhatever.d.ts +3 -0
  318. package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
  319. package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
  320. package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  321. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  322. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
  323. package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  324. package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
  325. package/umd/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
  326. package/umd/typings/src/utils/organization/TODO_USE.d.ts +12 -0
  327. package/umd/typings/src/utils/organization/TODO_any.d.ts +6 -0
  328. package/umd/typings/src/utils/organization/TODO_object.d.ts +6 -0
  329. package/umd/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
  330. package/umd/typings/src/utils/organization/___.d.ts +6 -0
  331. package/{esm/typings/src/utils โ†’ umd/typings/src/utils/organization}/just.d.ts +5 -1
  332. package/umd/typings/src/utils/organization/keepUnused.d.ts +16 -0
  333. package/umd/typings/src/utils/organization/really_any.d.ts +6 -0
  334. package/umd/typings/src/utils/organization/really_unknown.d.ts +6 -0
  335. package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
  336. package/umd/typings/src/{execution/utils โ†’ utils}/replaceParameters.d.ts +2 -4
  337. package/umd/typings/src/utils/replaceParameters.test.d.ts +1 -0
  338. package/umd/typings/src/utils/sets/difference.d.ts +3 -0
  339. package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
  340. package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
  341. package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
  342. package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
  343. package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
  344. package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  345. package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
  346. package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
  347. package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  348. package/esm/typings/src/personas/personaToModelRequirements.d.ts +0 -6
  349. package/esm/typings/src/types/Parameters.d.ts +0 -14
  350. package/esm/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
  351. package/esm/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
  352. package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  353. package/umd/typings/src/personas/personaToModelRequirements.d.ts +0 -6
  354. package/umd/typings/src/types/Parameters.d.ts +0 -14
  355. package/umd/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
  356. package/umd/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
  357. /package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts โ†’ extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
  358. /package/esm/typings/src/{execution/addPromptResultUsage.test.d.ts โ†’ conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
  359. /package/esm/typings/src/{execution/utils/replaceParameters.test.d.ts โ†’ knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts} +0 -0
  360. /package/esm/typings/src/{utils/extractParameters.test.d.ts โ†’ personas/preparePersona.test.d.ts} +0 -0
  361. /package/esm/typings/src/{utils/postprocessing โ†’ postprocessing/utils}/extractBlock.d.ts +0 -0
  362. /package/{umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.test.d.ts โ†’ esm/typings/src/prepare/isPipelinePrepared.test.d.ts} +0 -0
  363. /package/{umd/typings/src/execution/addPromptResultUsage.test.d.ts โ†’ esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts} +0 -0
  364. /package/{umd/typings/src/execution/utils/replaceParameters.test.d.ts โ†’ esm/typings/src/utils/extractParameterNames.test.d.ts} +0 -0
  365. /package/{umd/typings/src/utils/extractParameters.test.d.ts โ†’ esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts} +0 -0
  366. /package/umd/typings/src/{utils/postprocessing โ†’ postprocessing/utils}/extractBlock.d.ts +0 -0
package/README.md CHANGED
@@ -39,13 +39,13 @@ npm i @promptbook/azure-openai
39
39
  import { createPipelineExecutor, assertsExecutionSuccessful } from '@promptbook/core';
40
40
  import { createCollectionFromDirectory } from '@promptbook/node';
41
41
  import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
42
- import { OpenAiExecutionTools } from '@promptbook/openai';
42
+ import { AzureOpenAiExecutionTools } from '@promptbook/azure-openai';
43
43
 
44
44
  // โ–ถ Create whole pipeline collection
45
45
  const collection = await createCollectionFromDirectory('./promptbook-collection');
46
46
 
47
47
  // โ–ถ Get single Pipeline
48
- const pipeline = await library.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
48
+ const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
49
49
 
50
50
  // โ–ถ Prepare tools
51
51
  const tools = {
@@ -83,13 +83,15 @@ You can use multiple LLM providers in one Promptbook execution. The best model w
83
83
  import { createPipelineExecutor, assertsExecutionSuccessful } from '@promptbook/core';
84
84
  import { createCollectionFromDirectory } from '@promptbook/node';
85
85
  import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
86
+ import { AzureOpenAiExecutionTools } from '@promptbook/azure-openai';
86
87
  import { OpenAiExecutionTools } from '@promptbook/openai';
88
+ import { AnthropicClaudeExecutionTools } from '@promptbook/anthropic-claude';
87
89
 
88
90
  // โ–ถ Create whole pipeline collection
89
91
  const collection = await createCollectionFromDirectory('./promptbook-collection');
90
92
 
91
93
  // โ–ถ Get single Pipeline
92
- const pipeline = await library.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
94
+ const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
93
95
 
94
96
  // โ–ถ Prepare multiple tools
95
97
  const tools = {
@@ -188,7 +190,7 @@ File `write-website-content.ptbk.md`:
188
190
  > - PROMPTBOOK VERSION 0.0.1
189
191
  > - INPUTโ€ฏโ€ฏPARAM `{rawTitle}` Automatically suggested a site name or empty text
190
192
  > - INPUTโ€ฏโ€ฏPARAM `{rawAssigment}` Automatically generated site entry from image recognition
191
- > - OUTPUTโ€ฏPARAM `{content}` Web content
193
+ > - OUTPUTโ€ฏPARAM `{websiteContent}` Web content
192
194
  > - OUTPUTโ€ฏPARAM `{keywords}` Keywords
193
195
  >
194
196
  > ## ๐Ÿ‘ค Specifying the assigment
@@ -347,7 +349,7 @@ File `write-website-content.ptbk.md`:
347
349
  > {contentBody}
348
350
  > ```
349
351
  >
350
- > `-> {content}`
352
+ > `-> {websiteContent}`
351
353
 
352
354
 
353
355
 
@@ -387,7 +389,7 @@ flowchart LR
387
389
  templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
388
390
  templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
389
391
 
390
- templateCombineTheContent--"{content}"-->output
392
+ templateCombineTheContent--"{websiteContent}"-->output
391
393
  output((Output)):::output
392
394
 
393
395
  classDef input color: grey;
package/esm/index.es.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { OpenAIClient, AzureKeyCredential } from '@azure/openai';
2
2
  import colors from 'colors';
3
+ import { spaceTrim } from 'spacetrim';
3
4
 
4
5
  /*! *****************************************************************************
5
6
  Copyright (c) Microsoft Corporation.
@@ -81,6 +82,18 @@ function __generator(thisArg, body) {
81
82
  }
82
83
  }
83
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
+
84
97
  function __read(o, n) {
85
98
  var m = typeof Symbol === "function" && o[Symbol.iterator];
86
99
  if (!m) return o;
@@ -96,6 +109,16 @@ function __read(o, n) {
96
109
  finally { if (e) throw e.error; }
97
110
  }
98
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));
99
122
  }
100
123
 
101
124
  /**
@@ -468,10 +491,186 @@ function getCurrentIsoDate() {
468
491
  return new Date().toISOString();
469
492
  }
470
493
 
494
+ /**
495
+ * @@@
496
+ *
497
+ * @returns The same object as the input, but deeply frozen
498
+ *
499
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
500
+ */
501
+ function deepFreeze(objectValue) {
502
+ var e_1, _a;
503
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
504
+ try {
505
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
506
+ var propertyName = propertyNames_1_1.value;
507
+ var value = objectValue[propertyName];
508
+ if (value && typeof value === 'object') {
509
+ deepFreeze(value);
510
+ }
511
+ }
512
+ }
513
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
514
+ finally {
515
+ try {
516
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
517
+ }
518
+ finally { if (e_1) throw e_1.error; }
519
+ }
520
+ return Object.freeze(objectValue);
521
+ }
522
+ /**
523
+ * TODO: [๐Ÿ”ผ] Export from `@promptbook/utils`
524
+ * TODO: [๐Ÿง ] Is there a way how to meaningfully test this utility
525
+ */
526
+
527
+ /**
528
+ * The maximum number of iterations for a loops
529
+ */
530
+ var LOOP_LIMIT = 1000;
531
+ /**
532
+ * Nonce which is used for replacing things in strings
533
+ */
534
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
535
+ /**
536
+ * The names of the parameters that are reserved for special purposes
537
+ */
538
+ deepFreeze([
539
+ 'content',
540
+ 'context',
541
+ 'knowledge',
542
+ 'samples',
543
+ 'modelName',
544
+ 'currentDate',
545
+ // <- TODO: Add more like 'date', 'modelName',...
546
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
547
+ ]);
548
+ /**
549
+ * @@@
550
+ */
551
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
552
+ /**
553
+ * @@@
554
+ */
555
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
556
+ /*
557
+ TODO: !!! Just testing false-negative detection of [๐ŸŸก][๐ŸŸข][๐Ÿ”ต][โšช] leak
558
+ */
559
+ // [๐ŸŸก][๐ŸŸข][๐Ÿ”ต][โšช]
560
+ /**
561
+ * TODO: [๐Ÿ”ผ] Export all to core
562
+ */
563
+
564
+ /**
565
+ * This error type indicates that some limit was reached
566
+ */
567
+ var LimitReachedError = /** @class */ (function (_super) {
568
+ __extends(LimitReachedError, _super);
569
+ function LimitReachedError(message) {
570
+ var _this = _super.call(this, message) || this;
571
+ _this.name = 'LimitReachedError';
572
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
573
+ return _this;
574
+ }
575
+ return LimitReachedError;
576
+ }(Error));
577
+
578
+ /**
579
+ * This error type indicates that the error should not happen and its last check before crashing with some other error
580
+ */
581
+ var UnexpectedError = /** @class */ (function (_super) {
582
+ __extends(UnexpectedError, _super);
583
+ function UnexpectedError(message) {
584
+ var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
585
+ _this.name = 'UnexpectedError';
586
+ Object.setPrototypeOf(_this, UnexpectedError.prototype);
587
+ return _this;
588
+ }
589
+ return UnexpectedError;
590
+ }(Error));
591
+
592
+ /**
593
+ * Replaces parameters in template with values from parameters object
594
+ *
595
+ * @param template the template with parameters in {curly} braces
596
+ * @param parameters the object with parameters
597
+ * @returns the template with replaced parameters
598
+ * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
599
+ */
600
+ function replaceParameters(template, parameters) {
601
+ var e_1, _a;
602
+ try {
603
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
604
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
605
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
606
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
607
+ }
608
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
609
+ // TODO: [๐Ÿต]
610
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
611
+ }
612
+ }
613
+ }
614
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
615
+ finally {
616
+ try {
617
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
618
+ }
619
+ finally { if (e_1) throw e_1.error; }
620
+ }
621
+ var replacedTemplate = template;
622
+ var match;
623
+ var loopLimit = LOOP_LIMIT;
624
+ var _loop_1 = function () {
625
+ if (loopLimit-- < 0) {
626
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
627
+ }
628
+ var precol = match.groups.precol;
629
+ var parameterName = match.groups.parameterName;
630
+ if (parameterName === '') {
631
+ return "continue";
632
+ }
633
+ if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
634
+ throw new PipelineExecutionError('Parameter is already opened or not closed');
635
+ }
636
+ if (parameters[parameterName] === undefined) {
637
+ throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
638
+ }
639
+ var parameterValue = parameters[parameterName];
640
+ if (parameterValue === undefined) {
641
+ throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
642
+ }
643
+ parameterValue = parameterValue.toString();
644
+ if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
645
+ parameterValue = parameterValue
646
+ .split('\n')
647
+ .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
648
+ .join('\n');
649
+ }
650
+ replacedTemplate =
651
+ replacedTemplate.substring(0, match.index + precol.length) +
652
+ parameterValue +
653
+ replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
654
+ };
655
+ while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
656
+ .exec(replacedTemplate))) {
657
+ _loop_1();
658
+ }
659
+ // [๐Ÿ’ซ] Check if there are parameters that are not closed properly
660
+ if (/{\w+$/.test(replacedTemplate)) {
661
+ throw new PipelineExecutionError('Parameter is not closed');
662
+ }
663
+ // [๐Ÿ’ซ] Check if there are parameters that are not opened properly
664
+ if (/^\w+}/.test(replacedTemplate)) {
665
+ throw new PipelineExecutionError('Parameter is not opened');
666
+ }
667
+ return replacedTemplate;
668
+ }
669
+
471
670
  /**
472
671
  * Function computeUsage will create price per one token based on the string value found on openai page
473
672
  *
474
- * @private within the package, used only as internal helper for `OPENAI_MODELS`
673
+ * @private within the repository, used only as internal helper for `OPENAI_MODELS`
475
674
  */
476
675
  function computeUsage(value) {
477
676
  var _a = __read(value.split(' / '), 2), price = _a[0], tokens = _a[1];
@@ -825,6 +1024,7 @@ var OPENAI_MODELS = [
825
1024
  * @see /other/playground/playground.ts
826
1025
  * TODO: [๐Ÿ“] Make better
827
1026
  * TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
1027
+ * TODO: [๐Ÿšธ] Not all models are compatible with JSON mode, add this information here and use it
828
1028
  */
829
1029
 
830
1030
  /**
@@ -860,41 +1060,54 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
860
1060
  AzureOpenAiExecutionTools.prototype.callChatModel = function (prompt) {
861
1061
  var _a, _b;
862
1062
  return __awaiter(this, void 0, void 0, function () {
863
- var content, modelRequirements, modelName, modelSettings, messages, start, complete, rawResponse, resultContent, usage, error_1;
864
- return __generator(this, function (_c) {
865
- switch (_c.label) {
1063
+ var content, parameters, modelRequirements, modelName, modelSettings, rawPromptContent, messages, start, complete, rawRequest, rawResponse, resultContent, usage, error_1;
1064
+ var _c;
1065
+ return __generator(this, function (_d) {
1066
+ switch (_d.label) {
866
1067
  case 0:
867
1068
  if (this.options.isVerbose) {
868
1069
  console.info('๐Ÿ’ฌ OpenAI callChatModel call');
869
1070
  }
870
- content = prompt.content, modelRequirements = prompt.modelRequirements;
1071
+ content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
871
1072
  // TODO: [โ˜‚] Use here more modelRequirements
872
1073
  if (modelRequirements.modelVariant !== 'CHAT') {
873
1074
  throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
874
1075
  }
875
- _c.label = 1;
1076
+ _d.label = 1;
876
1077
  case 1:
877
- _c.trys.push([1, 3, , 4]);
1078
+ _d.trys.push([1, 3, , 4]);
878
1079
  modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
879
1080
  modelSettings = {
880
1081
  maxTokens: modelRequirements.maxTokens,
881
- // <- TODO: Make some global max cap for maxTokens
1082
+ // <- TODO: [๐ŸŒพ] Make some global max cap for maxTokens
1083
+ temperature: modelRequirements.temperature,
882
1084
  user: this.options.user,
1085
+ // <- TODO: [๐Ÿˆ] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
1086
+ // <- Note: [๐Ÿง†]
883
1087
  };
884
- messages = [
1088
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
1089
+ messages = __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
1090
+ ? []
1091
+ : [
1092
+ {
1093
+ role: 'system',
1094
+ content: modelRequirements.systemMessage,
1095
+ },
1096
+ ])), false), [
885
1097
  {
886
1098
  role: 'user',
887
- content: content,
1099
+ content: rawPromptContent,
888
1100
  },
889
- ];
1101
+ ], false);
890
1102
  start = getCurrentIsoDate();
891
1103
  complete = void 0;
892
1104
  if (this.options.isVerbose) {
893
1105
  console.info(colors.bgWhite('messages'), JSON.stringify(messages, null, 4));
894
1106
  }
895
- return [4 /*yield*/, this.client.getChatCompletions(modelName, messages, modelSettings)];
1107
+ rawRequest = [modelName, messages, modelSettings];
1108
+ return [4 /*yield*/, (_c = this.client).getChatCompletions.apply(_c, __spreadArray([], __read(rawRequest), false))];
896
1109
  case 2:
897
- rawResponse = _c.sent();
1110
+ rawResponse = _d.sent();
898
1111
  if (this.options.isVerbose) {
899
1112
  console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
900
1113
  }
@@ -924,11 +1137,13 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
924
1137
  complete: complete,
925
1138
  },
926
1139
  usage: usage,
1140
+ rawPromptContent: rawPromptContent,
1141
+ rawRequest: rawRequest,
927
1142
  rawResponse: rawResponse,
928
- // <- [๐Ÿคนโ€โ™‚๏ธ]
1143
+ // <- [๐Ÿ—ฏ]
929
1144
  }];
930
1145
  case 3:
931
- error_1 = _c.sent();
1146
+ error_1 = _d.sent();
932
1147
  throw this.transformAzureError(error_1);
933
1148
  case 4: return [2 /*return*/];
934
1149
  }
@@ -941,35 +1156,46 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
941
1156
  AzureOpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
942
1157
  var _a, _b;
943
1158
  return __awaiter(this, void 0, void 0, function () {
944
- var content, modelRequirements, modelName, modelSettings, start, complete, rawResponse, resultContent, usage, error_2;
945
- return __generator(this, function (_c) {
946
- switch (_c.label) {
1159
+ var content, parameters, modelRequirements, modelName, modelSettings, start, complete, rawPromptContent, rawRequest, rawResponse, resultContent, usage, error_2;
1160
+ var _c;
1161
+ return __generator(this, function (_d) {
1162
+ switch (_d.label) {
947
1163
  case 0:
948
1164
  if (this.options.isVerbose) {
949
1165
  console.info('๐Ÿ–‹ OpenAI callCompletionModel call');
950
1166
  }
951
- content = prompt.content, modelRequirements = prompt.modelRequirements;
1167
+ content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
952
1168
  // TODO: [โ˜‚] Use here more modelRequirements
953
1169
  if (modelRequirements.modelVariant !== 'COMPLETION') {
954
1170
  throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
955
1171
  }
956
- _c.label = 1;
1172
+ _d.label = 1;
957
1173
  case 1:
958
- _c.trys.push([1, 3, , 4]);
1174
+ _d.trys.push([1, 3, , 4]);
959
1175
  modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
960
1176
  modelSettings = {
961
1177
  maxTokens: modelRequirements.maxTokens || 2000,
962
- // <- TODO: Make some global max cap for maxTokens
1178
+ // <- TODO: [๐ŸŒพ] Make some global max cap for maxTokens
1179
+ temperature: modelRequirements.temperature,
963
1180
  user: this.options.user,
1181
+ // <- TODO: [๐Ÿˆ] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
1182
+ // <- Note: [๐Ÿง†]
964
1183
  };
965
1184
  start = getCurrentIsoDate();
966
1185
  complete = void 0;
967
1186
  if (this.options.isVerbose) {
968
1187
  console.info(colors.bgWhite('content'), JSON.stringify(content, null, 4));
1188
+ console.info(colors.bgWhite('parameters'), JSON.stringify(parameters, null, 4));
969
1189
  }
970
- return [4 /*yield*/, this.client.getCompletions(modelName, [content], modelSettings)];
1190
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
1191
+ rawRequest = [
1192
+ modelName,
1193
+ [rawPromptContent],
1194
+ modelSettings,
1195
+ ];
1196
+ return [4 /*yield*/, (_c = this.client).getCompletions.apply(_c, __spreadArray([], __read(rawRequest), false))];
971
1197
  case 2:
972
- rawResponse = _c.sent();
1198
+ rawResponse = _d.sent();
973
1199
  if (this.options.isVerbose) {
974
1200
  console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
975
1201
  }
@@ -996,11 +1222,13 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
996
1222
  complete: complete,
997
1223
  },
998
1224
  usage: usage,
1225
+ rawPromptContent: rawPromptContent,
1226
+ rawRequest: rawRequest,
999
1227
  rawResponse: rawResponse,
1000
- // <- [๐Ÿคนโ€โ™‚๏ธ]
1228
+ // <- [๐Ÿ—ฏ]
1001
1229
  }];
1002
1230
  case 3:
1003
- error_2 = _c.sent();
1231
+ error_2 = _d.sent();
1004
1232
  throw this.transformAzureError(error_2);
1005
1233
  case 4: return [2 /*return*/];
1006
1234
  }
@@ -1042,12 +1270,13 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1042
1270
  /**
1043
1271
  * TODO: Maybe Create some common util for callChatModel and callCompletionModel
1044
1272
  * TODO: Maybe make custom AzureOpenaiError
1273
+ * TODO: [๐Ÿง ][๐Ÿˆ] Maybe use `isDeterministic` from options
1045
1274
  */
1046
1275
 
1047
1276
  /**
1048
1277
  * The version of the Promptbook library
1049
1278
  */
1050
- var PROMPTBOOK_VERSION = '0.61.0-8';
1279
+ var PROMPTBOOK_VERSION = '0.61.0-30';
1051
1280
  // TODO: !!!! List here all the versions and annotate + put into script
1052
1281
 
1053
1282
  export { AzureOpenAiExecutionTools, PROMPTBOOK_VERSION };