@promptbook/openai 0.61.0-2 → 0.61.0-20

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 (360) hide show
  1. package/README.md +2 -2
  2. package/esm/index.es.js +181 -18
  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 +11 -7
  9. package/esm/typings/src/_packages/utils.index.d.ts +8 -6
  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 +8 -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 +38 -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 +5 -3
  28. package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
  29. package/esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.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 +13 -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 +9 -8
  40. package/esm/typings/src/execution/PromptResult.d.ts +28 -58
  41. package/esm/typings/src/execution/PromptResultUsage.d.ts +26 -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 +19 -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 +3 -2
  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 +9 -7
  92. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
  93. package/esm/typings/src/personas/preparePersona.d.ts +15 -0
  94. package/esm/typings/src/prepare/PrepareOptions.d.ts +22 -0
  95. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +10 -0
  96. package/esm/typings/src/prepare/preparePipeline.d.ts +18 -0
  97. package/esm/typings/src/prepare/unpreparePipeline.d.ts +9 -0
  98. package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
  99. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  100. package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
  101. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
  102. package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  103. package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
  104. package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
  105. package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  106. package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  107. package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
  108. package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
  109. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
  110. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
  111. package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
  112. package/esm/typings/src/types/ModelRequirements.d.ts +71 -11
  113. package/esm/typings/src/types/ModelVariant.d.ts +14 -0
  114. package/esm/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
  115. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +67 -0
  116. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +24 -0
  117. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +9 -1
  118. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +38 -0
  119. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +29 -4
  120. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +21 -0
  121. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +5 -0
  122. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
  123. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +13 -4
  124. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
  125. package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +2 -0
  126. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +2 -0
  127. package/esm/typings/src/types/PipelineString.d.ts +1 -1
  128. package/esm/typings/src/types/Prompt.d.ts +54 -10
  129. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
  130. package/esm/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
  131. package/esm/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  132. package/esm/typings/src/types/typeAliases.d.ts +114 -15
  133. package/esm/typings/src/utils/FromtoItems.d.ts +3 -3
  134. package/esm/typings/src/utils/currentDate.d.ts +7 -0
  135. package/esm/typings/src/utils/deepClone.d.ts +9 -0
  136. package/esm/typings/src/utils/deepFreeze.d.ts +22 -0
  137. package/esm/typings/src/utils/emojis.d.ts +2 -2
  138. package/esm/typings/src/utils/extractParameters.d.ts +2 -2
  139. package/esm/typings/src/utils/formatNumber.d.ts +1 -1
  140. package/esm/typings/src/utils/isRunningInWhatever.d.ts +3 -0
  141. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
  142. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
  143. package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  144. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  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/esm/typings/src/utils/{just.d.ts → 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/{umd/typings/src/execution → esm/typings/src}/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 +2 -2
  171. package/umd/index.umd.js +181 -18
  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 +11 -7
  178. package/umd/typings/src/_packages/utils.index.d.ts +8 -6
  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 +8 -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 +38 -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 +5 -3
  197. package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
  198. package/umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
  199. package/umd/typings/src/conversion/utils/renameParameter.d.ts +3 -3
  200. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +13 -0
  201. package/umd/typings/src/conversion/utils/stringifyPipelineJson.test.d.ts +1 -0
  202. package/umd/typings/src/conversion/validation/_importPipeline.d.ts +12 -3
  203. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +10 -1
  204. package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
  205. package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
  206. package/umd/typings/src/errors/VersionMismatchError.d.ts +8 -0
  207. package/umd/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
  208. package/umd/typings/src/execution/LlmExecutionTools.d.ts +10 -8
  209. package/umd/typings/src/execution/PipelineExecutor.d.ts +9 -8
  210. package/umd/typings/src/execution/PromptResult.d.ts +28 -58
  211. package/umd/typings/src/execution/PromptResultUsage.d.ts +26 -0
  212. package/umd/typings/src/execution/ScriptExecutionTools.d.ts +5 -4
  213. package/umd/typings/src/execution/UncertainNumber.d.ts +18 -0
  214. package/umd/typings/src/execution/UserInterfaceTools.d.ts +5 -5
  215. package/umd/typings/src/execution/createPipelineExecutor.d.ts +19 -3
  216. package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
  217. package/umd/typings/src/execution/utils/addUsage.d.ts +58 -2
  218. package/umd/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
  219. package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  220. package/umd/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
  221. package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
  222. package/umd/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  223. package/umd/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
  224. package/umd/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
  225. package/umd/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
  226. package/umd/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
  227. package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
  228. package/umd/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
  229. package/umd/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
  230. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
  231. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -0
  232. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -23
  233. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  234. package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +8 -14
  235. package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +30 -0
  236. package/umd/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
  237. package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +11 -0
  238. package/umd/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
  239. package/umd/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  240. package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +16 -0
  241. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
  242. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
  243. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
  244. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -2
  245. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  246. package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +3 -3
  247. package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  248. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
  249. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
  250. package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  251. package/umd/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
  252. package/umd/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
  253. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
  254. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
  255. package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
  256. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
  257. package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
  258. package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  259. package/umd/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  260. package/umd/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
  261. package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  262. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +9 -7
  263. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
  264. package/umd/typings/src/personas/preparePersona.d.ts +15 -0
  265. package/umd/typings/src/personas/preparePersona.test.d.ts +1 -0
  266. package/umd/typings/src/prepare/PrepareOptions.d.ts +22 -0
  267. package/umd/typings/src/prepare/isPipelinePrepared.d.ts +10 -0
  268. package/umd/typings/src/prepare/isPipelinePrepared.test.d.ts +1 -0
  269. package/umd/typings/src/prepare/preparePipeline.d.ts +18 -0
  270. package/umd/typings/src/prepare/unpreparePipeline.d.ts +9 -0
  271. package/umd/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
  272. package/umd/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  273. package/umd/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
  274. package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
  275. package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  276. package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
  277. package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
  278. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  279. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  280. package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
  281. package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
  282. package/umd/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
  283. package/umd/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
  284. package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
  285. package/umd/typings/src/types/ModelRequirements.d.ts +71 -11
  286. package/umd/typings/src/types/ModelVariant.d.ts +14 -0
  287. package/umd/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
  288. package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +67 -0
  289. package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +24 -0
  290. package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +9 -1
  291. package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +38 -0
  292. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +29 -4
  293. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +21 -0
  294. package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +5 -0
  295. package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
  296. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +13 -4
  297. package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
  298. package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +2 -0
  299. package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +2 -0
  300. package/umd/typings/src/types/PipelineString.d.ts +1 -1
  301. package/umd/typings/src/types/Prompt.d.ts +54 -10
  302. package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
  303. package/umd/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
  304. package/umd/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  305. package/umd/typings/src/types/typeAliases.d.ts +114 -15
  306. package/umd/typings/src/utils/FromtoItems.d.ts +3 -3
  307. package/umd/typings/src/utils/currentDate.d.ts +7 -0
  308. package/umd/typings/src/utils/deepClone.d.ts +9 -0
  309. package/umd/typings/src/utils/deepFreeze.d.ts +22 -0
  310. package/umd/typings/src/utils/emojis.d.ts +2 -2
  311. package/umd/typings/src/utils/extractParameters.d.ts +2 -2
  312. package/umd/typings/src/utils/formatNumber.d.ts +1 -1
  313. package/umd/typings/src/utils/isRunningInWhatever.d.ts +3 -0
  314. package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
  315. package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
  316. package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  317. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  318. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
  319. package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  320. package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
  321. package/umd/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
  322. package/umd/typings/src/utils/organization/TODO_USE.d.ts +12 -0
  323. package/umd/typings/src/utils/organization/TODO_any.d.ts +6 -0
  324. package/umd/typings/src/utils/organization/TODO_object.d.ts +6 -0
  325. package/umd/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
  326. package/umd/typings/src/utils/organization/___.d.ts +6 -0
  327. package/umd/typings/src/utils/{just.d.ts → organization/just.d.ts} +5 -1
  328. package/umd/typings/src/utils/organization/keepUnused.d.ts +16 -0
  329. package/umd/typings/src/utils/organization/really_any.d.ts +6 -0
  330. package/umd/typings/src/utils/organization/really_unknown.d.ts +6 -0
  331. package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
  332. package/{esm/typings/src/execution → umd/typings/src}/utils/replaceParameters.d.ts +2 -4
  333. package/umd/typings/src/utils/replaceParameters.test.d.ts +1 -0
  334. package/umd/typings/src/utils/sets/difference.d.ts +3 -0
  335. package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
  336. package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
  337. package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
  338. package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
  339. package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
  340. package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  341. package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
  342. package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
  343. package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  344. package/esm/typings/src/personas/personaToModelRequirements.d.ts +0 -6
  345. package/esm/typings/src/types/Parameters.d.ts +0 -14
  346. package/esm/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
  347. package/esm/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
  348. package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  349. package/umd/typings/src/personas/personaToModelRequirements.d.ts +0 -6
  350. package/umd/typings/src/types/Parameters.d.ts +0 -14
  351. package/umd/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
  352. package/umd/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
  353. /package/esm/typings/src/_packages/{markdown-utils.d.ts → markdown-utils.index.d.ts} +0 -0
  354. /package/esm/typings/src/{execution/addPromptResultUsage.test.d.ts → conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
  355. /package/esm/typings/src/{execution/utils/replaceParameters.test.d.ts → knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts} +0 -0
  356. /package/{umd/typings/src/execution/addPromptResultUsage.test.d.ts → esm/typings/src/personas/preparePersona.test.d.ts} +0 -0
  357. /package/esm/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
  358. /package/{umd/typings/src/execution/utils/replaceParameters.test.d.ts → esm/typings/src/prepare/isPipelinePrepared.test.d.ts} +0 -0
  359. /package/umd/typings/src/_packages/{markdown-utils.d.ts → markdown-utils.index.d.ts} +0 -0
  360. /package/umd/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
@@ -1,33 +1,61 @@
1
+ import type { WritableDeep } from 'type-fest';
2
+ import type { PromptTemplateJson } from '../../../types/PipelineJson/PromptTemplateJson';
3
+ import type { PipelineJson } from '../../../types/PipelineJson/PipelineJson';
1
4
  import type { string_markdown_text } from '../../../types/typeAliases';
2
5
  import type { string_name } from '../../../types/typeAliases';
6
+ import type { string_promptbook_documentation_url } from '../../../types/typeAliases';
3
7
  import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
4
8
  import type { CommandUsagePlace } from './CommandUsagePlaces';
5
9
  export type CommandParser<TCommand extends {
6
10
  type: string_name & string_SCREAMING_CASE;
7
11
  }> = {
8
- name: string_name & string_SCREAMING_CASE;
9
- aliasNames?: Array<string_name & string_SCREAMING_CASE>;
10
- deprecatedNames?: Array<string_name & string_SCREAMING_CASE>;
11
- usagePlaces: Array<CommandUsagePlace>;
12
- description: string_markdown_text;
13
- discussionUrl: `https://github.com/webgptorg/promptbook/discussions/${number | '@@'}`;
14
- examples: Array<string_markdown_text>;
12
+ readonly name: string_name & string_SCREAMING_CASE;
13
+ readonly aliasNames?: Array<string_name & string_SCREAMING_CASE>;
14
+ readonly deprecatedNames?: Array<string_name & string_SCREAMING_CASE>;
15
+ readonly usagePlaces: Array<CommandUsagePlace>;
16
+ readonly description: string_markdown_text;
17
+ readonly documentationUrl: string_promptbook_documentation_url;
18
+ readonly examples: Array<string_markdown_text>;
15
19
  /**
16
20
  * @throws {ParsingError} if the parsing fails
17
21
  */
18
22
  parse(input: CommandParserInput): TCommand;
23
+ /**
24
+ * @@@ Mutated by the command
25
+ */
26
+ applyToPipelineJson?(command: TCommand, subjects: ApplyToPipelineJsonSubjects): void;
19
27
  };
20
28
  export type CommandParserInput = {
21
- usagePlace: CommandUsagePlace;
22
- raw: string_markdown_text;
23
- rawArgs: string_markdown_text;
24
- normalized: string_name & string_SCREAMING_CASE;
25
- args: Array<string_name & string_SCREAMING_CASE>;
29
+ readonly usagePlace: CommandUsagePlace;
30
+ readonly raw: string_markdown_text;
31
+ readonly rawArgs: string_markdown_text;
32
+ readonly normalized: string_name & string_SCREAMING_CASE;
33
+ readonly args: Array<string_name & string_SCREAMING_CASE>;
34
+ };
35
+ /**
36
+ * @@@ Mutated by the command
37
+ */
38
+ export type ApplyToPipelineJsonSubjects = {
39
+ /**
40
+ * @@@ Mutated by the command
41
+ */
42
+ readonly pipelineJson: WritableDeep<PipelineJson>;
43
+ /**
44
+ * @@@
45
+ *
46
+ * @@@ Mutated by the command
47
+ *
48
+ * When used in
49
+ * - `PIPELINE_HEAD` it is `null`
50
+ * - `PIPELINE_TEMPLATE` it is the prompt template
51
+ */
52
+ readonly templateJson: null | Partial<WritableDeep<PromptTemplateJson>>;
26
53
  };
27
54
  /**
28
- * TODO: !!!! Annotate
55
+ * TODO: @@@ Annotate all
56
+ * TODO: [🍧][♓️] Add order here
29
57
  * TODO: [🧠] Maybe put flag if it is for whole `.ptbk.md` file of just one section
30
- * TODO: [🍧] CommandParser should have applyToPipelineJson method
58
+ * TODO: [🍧] All commands must implement `applyToPipelineJson` method
31
59
  * which will apply parsed command to the pipeline JSON
32
60
  * it will be called from `pipelineStringToJsonSync`
33
61
  * and replace hardcoded switch statement and [💐]
@@ -6,6 +6,32 @@ export declare const LOOP_LIMIT = 1000;
6
6
  * The maximum number of iterations for a loops which adds characters one by one
7
7
  */
8
8
  export declare const CHARACTER_LOOP_LIMIT = 100000;
9
+ /**
10
+ * The maximum number of (LLM) tasks running in parallel
11
+ */
12
+ export declare const MAX_PARALLEL_COUNT = 5;
13
+ /**
14
+ * The maximum number of attempts to execute LLM task before giving up
15
+ */
16
+ export declare const MAX_EXECUTION_ATTEMPTS = 3;
17
+ /**
18
+ * The maximum length of the (generated) filename
19
+ */
20
+ export declare const MAX_FILENAME_LENGTH = 30;
21
+ /**
22
+ * @@@
23
+ * TODO: [🐝] !!! Use
24
+ */
25
+ export declare const MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
26
+ /**
27
+ * @@@
28
+ * TODO: [🐝] !!! Use
29
+ */
30
+ export declare const MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
31
+ /**
32
+ * Where to store the cache of executions for promptbook CLI
33
+ */
34
+ export declare const EXECUTIONS_CACHE_DIRNAME = "/.promptbook/executions-cache";
9
35
  /**
10
36
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
11
37
  */
@@ -13,4 +39,15 @@ export declare const PIPELINE_COLLECTION_BASE_FILENAME = "index";
13
39
  /**
14
40
  * The names of the parameters that are reserved for special purposes
15
41
  */
16
- export declare const RESERVED_PARAMETER_NAMES: string[];
42
+ export declare const RESERVED_PARAMETER_NAMES: readonly ["context", "currentDate"];
43
+ /**
44
+ * @@@
45
+ */
46
+ export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
47
+ /**
48
+ * Nonce which is used for replacing things in strings
49
+ */
50
+ export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
51
+ /**
52
+ * TODO: [🔼] Export all to core
53
+ */
@@ -0,0 +1,4 @@
1
+ export {};
2
+ /**
3
+ * TODO: [🧠] Maybe more elegant how to prevent accidental costs
4
+ */
@@ -8,7 +8,7 @@ import type { PipelineString } from '../types/PipelineString';
8
8
  */
9
9
  export declare function pipelineJsonToString(pipelineJson: PipelineJson): PipelineString;
10
10
  /**
11
- * TODO: !!!!! Implement new features and commands into `promptTemplateParameterJsonToString`
11
+ * TODO: !!!! Implement new features and commands into `promptTemplateParameterJsonToString`
12
12
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
13
13
  * TODO: Escape all
14
14
  */
@@ -2,20 +2,23 @@ import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
2
2
  import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
3
3
  import type { PipelineString } from '../types/PipelineString';
4
4
  /**
5
- * Options for pipelineStringToJson
5
+ * Options for `pipelineStringToJson`
6
6
  */
7
7
  export type PipelineStringToJsonOptions = {
8
8
  /**
9
- * Tools for processing required for knowledge processing *(not for actual execution)*
9
+ * Tools for processing required for preparation of knowledge *(not for actual execution)*
10
+ *
11
+ * Note: If you provide `null`, the knowledge will not be prepared
10
12
  */
11
- llmTools?: LlmExecutionTools;
13
+ readonly llmTools: LlmExecutionTools | null;
12
14
  };
13
15
  /**
14
- * Compile promptbook from string (markdown) format to JSON format
16
+ * Compile pipeline from string (markdown) format to JSON format
15
17
  *
16
- * Note: There are two similar functions:
18
+ * Note: There are 3 similar functions:
17
19
  * - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
18
20
  * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
21
+ * - `preparePipeline` - just one step in the compilation process
19
22
  *
20
23
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
21
24
  * @param options - Options and tools for the compilation
@@ -28,4 +31,5 @@ export type PipelineStringToJsonOptions = {
28
31
  export declare function pipelineStringToJson(pipelineString: PipelineString, options?: PipelineStringToJsonOptions): Promise<PipelineJson>;
29
32
  /**
30
33
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
34
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
31
35
  */
@@ -1,14 +1,14 @@
1
1
  import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
2
2
  import type { PipelineString } from '../types/PipelineString';
3
3
  /**
4
- * Compile promptbook from string (markdown) format to JSON format synchronously
4
+ * Compile pipeline from string (markdown) format to JSON format synchronously
5
5
  *
6
- * Note: There are two similar functions:
6
+ * Note: There are 3 similar functions:
7
7
  * - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
8
8
  * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
9
+ * - `preparePipeline` - just one step in the compilation process
9
10
  *
10
11
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
11
- * @param options - Options and tools for the compilation
12
12
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
13
13
  * @throws {ParsingError} if the promptbook string is not valid
14
14
  *
@@ -22,4 +22,6 @@ export declare function pipelineStringToJsonSync(pipelineString: PipelineString)
22
22
  * TODO: Use spaceTrim more effectively
23
23
  * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
24
24
  * TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
25
+ * TODO: [♈] Probbably move expectations from templates to parameters
26
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
25
27
  */
@@ -5,9 +5,9 @@ export type PrettifyOptions = {
5
5
  /***
6
6
  * If true, adds Mermaid graph to the Promptbook string
7
7
  */
8
- isGraphAdded?: boolean;
8
+ readonly isGraphAdded?: boolean;
9
9
  /**
10
10
  * If true, the string is prettifyed as markdown
11
11
  */
12
- isPrettifyed?: boolean;
12
+ readonly isPrettifyed?: boolean;
13
13
  };
@@ -1,5 +1,5 @@
1
1
  import type { PromptTemplateJson } from '../../types/PipelineJson/PromptTemplateJson';
2
- import type { string_name } from '../../types/typeAliases';
2
+ import type { string_parameter_name } from '../../types/typeAliases';
3
3
  /**
4
4
  * Parses the prompt template and returns the set of all used parameters
5
5
  *
@@ -7,7 +7,7 @@ import type { string_name } from '../../types/typeAliases';
7
7
  * @returns the set of parameter names
8
8
  * @throws {ParsingError} if the script is invalid
9
9
  */
10
- export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'blockType' | 'content'>): Set<string_name>;
10
+ export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'blockType' | 'content' | 'jokerParameterNames'>): Set<string_parameter_name>;
11
11
  /**
12
12
  * TODO: [🔣] If script require contentLanguage
13
13
  */
@@ -5,15 +5,15 @@ type RenameParameterOptions = {
5
5
  * Pipeline to search and replace for parameters
6
6
  * This pipeline is returned as copy with replaced parameters
7
7
  */
8
- pipeline: PipelineJson;
8
+ readonly pipeline: PipelineJson;
9
9
  /**
10
10
  * Original parameter name that should be replaced
11
11
  */
12
- oldParameterName: string_name;
12
+ readonly oldParameterName: string_name;
13
13
  /**
14
14
  * New parameter name that should replace the original parameter name
15
15
  */
16
- newParameterName: string_name;
16
+ readonly newParameterName: string_name;
17
17
  };
18
18
  /**
19
19
  * Function renameParameter will find all usable parameters for given prompt template
@@ -0,0 +1,13 @@
1
+ import type { string_json } from '../../types/typeAliases';
2
+ /**
3
+ * Stringify the PipelineJson with proper formatting
4
+ *
5
+ * Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
6
+ * Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
7
+ */
8
+ export declare function stringifyPipelineJson<TType>(pipeline: TType): string_json<TType>;
9
+ /**
10
+ * TODO: !!!! Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
11
+ * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
12
+ * TODO: [🧠] Maybe more elegant solution than replacing via regex
13
+ */
@@ -1,7 +1,8 @@
1
1
  import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
2
2
  import type { PipelineString } from '../../types/PipelineString';
3
+ import type { string_json } from '../../types/typeAliases';
3
4
  /**
4
- * Import the text file
5
+ * Import the pipeline.ptbk.md or pipeline.ptbk.json file
5
6
  *
6
7
  * Note: Using here custom import to work in jest tests
7
8
  * Note: Using sync version is 💩 in the production code, but it's ok here in tests
@@ -9,5 +10,13 @@ import type { PipelineString } from '../../types/PipelineString';
9
10
  * @param path - The path to the file relative to samples/templates directory
10
11
  * @private
11
12
  */
12
- export declare function importPipeline(path: `${string}.ptbk.md`): PipelineString;
13
- export declare function importPipeline(path: `${string}.ptbk.json`): PipelineJson;
13
+ export declare function importPipelineWithoutPreparation(path: `${string}.ptbk.md`): PipelineString;
14
+ export declare function importPipelineWithoutPreparation(path: `${string}.ptbk.json`): PipelineJson;
15
+ /**
16
+ * Import the pipeline.ptbk.json file as parsed JSON
17
+ */
18
+ export declare function importPipelineJson(path: `${string}.ptbk.json`): PipelineJson;
19
+ /**
20
+ * Import the pipeline.ptbk.json file as string
21
+ */
22
+ export declare function importPipelineJsonAsString(path: `${string}.ptbk.json`): string_json<PipelineJson>;
@@ -23,5 +23,14 @@ export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
23
23
  * > * It checks:
24
24
  * > * - it has a valid structure
25
25
  * > * - ...
26
- * > ex port function validatePipeline(promptbook: unknown): asserts promptbook is PipelineJson {
26
+ * > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
27
+ */
28
+ /**
29
+ * TODO: [🧠][🐣] !!!! Validate that all samples match expectations
30
+ * TODO: [🧠][🐣] !!!! Validate that knowledge is valid (non-void)
31
+ * TODO: [🧠][🐣] !!!! Validate that persona can be used only with CHAT variant
32
+ * TODO: !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
33
+ * TODO: !!!! Validate that reserved parameter is not used as joker
34
+ * TODO: [🧠] !!! Validationg not only logic itself but imports around - files and websites and rerefenced pipelines exists
35
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
27
36
  */
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This error type indicates that you try to use a feature that is not available in the current environment
3
+ */
4
+ export declare class EnvironmentMismatchError extends Error {
5
+ readonly name = "EnvironmentMismatchError";
6
+ constructor(message: string);
7
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This error type indicates that some limit was reached
3
+ */
4
+ export declare class LimitReachedError extends Error {
5
+ readonly name = "LimitReachedError";
6
+ constructor(message: string);
7
+ }
@@ -0,0 +1,8 @@
1
+ import type { string_semantic_version } from '../types/typeAliases';
2
+ /**
3
+ * This error type indicates that the version of the pipeline is not matching the expected version
4
+ */
5
+ export declare class VersionMismatchError extends Error {
6
+ readonly name = "UnexpectedError";
7
+ constructor(message: string, expectedVersion: string_semantic_version);
8
+ }
@@ -5,5 +5,6 @@ export type CommonExecutionToolsOptions = {
5
5
  readonly isVerbose?: boolean;
6
6
  };
7
7
  /**
8
+ * TODO: [🈁] Maybe add here `isDeterministic`
8
9
  * TODO: [🧠][💙] Distinct between options passed into ExecutionTools and to ExecutionTools.execute
9
10
  */
@@ -1,13 +1,13 @@
1
1
  import type { Promisable } from 'type-fest';
2
- import type { ModelVariant } from '../types/ModelRequirements';
2
+ import type { ModelVariant } from '../types/ModelVariant';
3
3
  import type { Prompt } from '../types/Prompt';
4
4
  import type { string_markdown } from '../types/typeAliases';
5
5
  import type { string_markdown_text } from '../types/typeAliases';
6
6
  import type { string_model_name } from '../types/typeAliases';
7
7
  import type { string_title } from '../types/typeAliases';
8
- import type { PromptChatResult } from './PromptResult';
9
- import type { PromptCompletionResult } from './PromptResult';
10
- import type { PromptEmbeddingResult } from './PromptResult';
8
+ import type { ChatPromptResult } from './PromptResult';
9
+ import type { CompletionPromptResult } from './PromptResult';
10
+ import type { EmbeddingPromptResult } from './PromptResult';
11
11
  /**
12
12
  * Container for all the tools needed to execute prompts to large language models like GPT-4
13
13
  * On its interface it exposes common methods for prompt execution.
@@ -31,15 +31,15 @@ export type LlmExecutionTools = {
31
31
  /**
32
32
  * Calls a chat model
33
33
  */
34
- callChatModel?(prompt: Prompt): Promise<PromptChatResult>;
34
+ callChatModel?(prompt: Prompt): Promise<ChatPromptResult>;
35
35
  /**
36
36
  * Calls a completion model
37
37
  */
38
- callCompletionModel?(prompt: Prompt): Promise<PromptCompletionResult>;
38
+ callCompletionModel?(prompt: Prompt): Promise<CompletionPromptResult>;
39
39
  /**
40
40
  * Calls an embedding model
41
41
  */
42
- callEmbeddingModel?(prompt: Prompt): Promise<PromptEmbeddingResult>;
42
+ callEmbeddingModel?(prompt: Prompt): Promise<EmbeddingPromptResult>;
43
43
  /**
44
44
  * List all available models that can be used
45
45
  */
@@ -63,8 +63,10 @@ export type AvailableModel = {
63
63
  readonly modelVariant: ModelVariant;
64
64
  };
65
65
  /**
66
- * TODO: !!!! Translation model
66
+ * TODO: [🏳] Add `callTranslationModel`
67
+ * TODO: Maybe reorder `listModels` and put it befor `callChatModel`, `callCompletionModel`, `callEmbeddingModel`
67
68
  * TODO: [🧠] Emulation of one type of model with another one - emuate chat with completion; emulate translation with chat
68
69
  * TODO: [🍓][♐] Some heuristic to pick the best model in listed models
69
70
  * TODO: [🧠] Should or should not there be a word "GPT" in both callCompletionModel and callChatModel
71
+ * TODO: [🧠][🪐] Should be common things like types, utils in folder containing A,B,C,.. or else outside this listing folder?
70
72
  */
@@ -1,8 +1,9 @@
1
1
  import type { Promisable } from 'type-fest';
2
+ import { PipelineExecutionError } from '../errors/PipelineExecutionError';
2
3
  import type { TaskProgress } from '../types/TaskProgress';
3
4
  import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
4
- import type { string_name } from '../types/typeAliases';
5
- import type { PromptResultUsage } from './PromptResult';
5
+ import type { Parameters } from '../types/typeAliases';
6
+ import type { PromptResultUsage } from './PromptResultUsage';
6
7
  /**
7
8
  * Executor is a simple async function that takes INPUT PARAMETERs and returns result parameters _(along with all intermediate parameters and INPUT PARAMETERs = it extends input object)_.
8
9
  * Executor is made by combining execution tools and pipeline collection.
@@ -12,29 +13,29 @@ import type { PromptResultUsage } from './PromptResult';
12
13
  * @see https://github.com/webgptorg/promptbook#executor
13
14
  */
14
15
  export type PipelineExecutor = {
15
- (inputParameters: Record<string_name, string>, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
16
+ (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
16
17
  /**
17
18
  * Whether the execution was successful, details are aviable in `executionReport`
18
19
  */
19
- isSuccessful: boolean;
20
+ readonly isSuccessful: boolean;
20
21
  /**
21
22
  * Added usage of whole execution, detailed usage is aviable in `executionReport`
22
23
  */
23
- usage: PromptResultUsage;
24
+ readonly usage: PromptResultUsage;
24
25
  /**
25
26
  * Errors that occured during the execution, details are aviable in `executionReport`
26
27
  */
27
- errors: Array<Error>;
28
+ readonly errors: Array<PipelineExecutionError | Error>;
28
29
  /**
29
30
  * The report of the execution with all details
30
31
  */
31
- executionReport: ExecutionReportJson;
32
+ readonly executionReport: ExecutionReportJson;
32
33
  /**
33
34
  * Result parameters of the execution
34
35
  *
35
36
  * Note: If the execution was not successful, there are only some of the result parameters
36
37
  */
37
- outputParameters: Record<string_name, string>;
38
+ readonly outputParameters: Parameters;
38
39
  }>;
39
40
  };
40
41
  /**
@@ -1,37 +1,45 @@
1
- import type { KebabCase } from 'type-fest';
2
- import type { ExpectationUnit } from '../types/PipelineJson/Expectations';
3
- import type { number_positive } from '../types/typeAliases';
4
- import type { number_usd } from '../types/typeAliases';
5
1
  import type { string_date_iso8601 } from '../types/typeAliases';
6
2
  import type { string_model_name } from '../types/typeAliases';
3
+ import type { TODO_object } from '../utils/organization/TODO_object';
7
4
  import type { EmbeddingVector } from './EmbeddingVector';
5
+ import type { PromptResultUsage } from './PromptResultUsage';
8
6
  /**
9
7
  * Prompt result is the simplest concept of execution.
10
8
  * It is the result of executing one prompt _(NOT a template)_.
11
9
  *
12
10
  * @see https://github.com/webgptorg/promptbook#prompt-result
13
11
  */
14
- export type PromptResult = PromptCompletionResult | PromptChatResult | PromptEmbeddingResult;
12
+ export type PromptResult = CompletionPromptResult | ChatPromptResult | EmbeddingPromptResult;
15
13
  /**
16
- * Prompt completion result
17
- * It contains only the following text NOT the whole completion
14
+ * Completion prompt result
15
+ *
16
+ * Note:It contains only the newly generated text NOT the whole completion
17
+ * Note: This is fully serializable as JSON
18
18
  */
19
- export type PromptCompletionResult = PromptCommonResult;
19
+ export type CompletionPromptResult = CommonPromptResult;
20
20
  /**
21
- * Prompt chat result
21
+ *Chat prompt result
22
+ *
23
+ * Note: This is fully serializable as JSON
22
24
  */
23
- export type PromptChatResult = PromptCommonResult & {};
25
+ export type ChatPromptResult = CommonPromptResult & {};
24
26
  /**
25
- * Prompt embedding result
26
- * It contains only the following text NOT the whole completion
27
+ * Embedding prompt result
28
+ *
29
+ * Note: This is fully serializable as JSON
27
30
  */
28
- export type PromptEmbeddingResult = Omit<PromptCommonResult, 'content'> & {
31
+ export type EmbeddingPromptResult = Omit<CommonPromptResult, 'content'> & {
29
32
  /**
30
33
  * The response from the model
31
34
  */
32
35
  content: EmbeddingVector;
33
36
  };
34
- export type PromptCommonResult = {
37
+ /**
38
+ * Common properties for all prompt results
39
+ *
40
+ * Note: This is fully serializable as JSON
41
+ */
42
+ export type CommonPromptResult = {
35
43
  /**
36
44
  * Exact text response from the model
37
45
  */
@@ -47,15 +55,15 @@ export type PromptCommonResult = {
47
55
  /**
48
56
  * Start of the execution
49
57
  */
50
- start: string_date_iso8601;
58
+ readonly start: string_date_iso8601;
51
59
  /**
52
60
  * First token generated
53
61
  */
54
- firstToken?: string_date_iso8601;
62
+ readonly firstToken?: string_date_iso8601;
55
63
  /**
56
64
  * End of the execution
57
65
  */
58
- complete: string_date_iso8601;
66
+ readonly complete: string_date_iso8601;
59
67
  };
60
68
  /**
61
69
  * Usage of the prompt execution
@@ -64,51 +72,13 @@ export type PromptCommonResult = {
64
72
  /**
65
73
  * Raw response from the model
66
74
  */
67
- readonly rawResponse: object;
68
- };
69
- /**
70
- * Usage statistics for one or many prompt results
71
- */
72
- export type PromptResultUsage = {
73
- /**
74
- * Cost of the execution in USD
75
- *
76
- * Note: If the cost is unknown, the value 0 and isUncertain is true
77
- */
78
- price: UncertainNumber;
79
- /**
80
- * Number of whatever used in the input aka. `prompt_tokens`
81
- */
82
- input: PromptResultUsageCounts;
83
- /**
84
- * Number of tokens used in the output aka. `completion_tokens`
85
- */
86
- output: PromptResultUsageCounts;
87
- };
88
- /**
89
- * Record of all possible measurable units
90
- */
91
- export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>;
92
- /**
93
- * Number which can be uncertain
94
- *
95
- * Note: If the value is completelly unknown, the value 0 and isUncertain is true
96
- * Note: Not using NaN or null because it looses the value which is better to be uncertain then not to be at all
97
- */
98
- export type UncertainNumber = {
99
- /**
100
- * The numeric value
101
- */
102
- value: number_usd & (number_positive | 0);
103
- /**
104
- * Is the value uncertain
105
- */
106
- isUncertain?: true;
75
+ readonly rawResponse: TODO_object;
107
76
  };
108
77
  /**
109
78
  * TODO: [🧠] Maybe timing more accurate then seconds?
110
79
  * TODO: [🧠] Should here be link to the prompt?
111
- * TODO: [🧠] Maybe type raw properly - not onject but OpenAI.result.whatever
80
+ * TODO: [🧠] Maybe type `rawResponse` properly - not onject but OpenAI.result.whatever
112
81
  * TODO: [🧠] Maybe remove redundant raw.choices.text
113
82
  * TODO: Log raw even if prompt failed - log the raw error
83
+ * TODO: [🏳] Add `TranslationPromptResult`
114
84
  */
@@ -0,0 +1,26 @@
1
+ import type { KebabCase } from 'type-fest';
2
+ import type { ExpectationUnit } from '../types/PipelineJson/Expectations';
3
+ import type { UncertainNumber } from './UncertainNumber';
4
+ /**
5
+ * Usage statistics for one or many prompt results
6
+ */
7
+ export type PromptResultUsage = {
8
+ /**
9
+ * Cost of the execution in USD
10
+ *
11
+ * Note: If the cost is unknown, the value 0 and isUncertain is true
12
+ */
13
+ readonly price: UncertainNumber;
14
+ /**
15
+ * Number of whatever used in the input aka. `prompt_tokens`
16
+ */
17
+ readonly input: PromptResultUsageCounts;
18
+ /**
19
+ * Number of tokens used in the output aka. `completion_tokens`
20
+ */
21
+ readonly output: PromptResultUsageCounts;
22
+ };
23
+ /**
24
+ * Record of all possible measurable units
25
+ */
26
+ export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>;
@@ -1,5 +1,5 @@
1
1
  import type { ScriptLanguage } from '../types/ScriptLanguage';
2
- import type { string_name } from '../types/typeAliases';
2
+ import type { Parameters } from '../types/typeAliases';
3
3
  import type { string_script } from '../types/typeAliases';
4
4
  /**
5
5
  * Represents all the tools needed to EXECUTE SCRIPTs
@@ -16,13 +16,13 @@ export type ScriptExecutionToolsExecuteOptions = {
16
16
  /**
17
17
  * Language of the script
18
18
  */
19
- scriptLanguage: ScriptLanguage;
19
+ readonly scriptLanguage: ScriptLanguage;
20
20
  /**
21
21
  * Parameters for the script
22
22
  * Theese parameters are passed to the script as variables
23
23
  * For example: { "name": "John" } => const name = "John";
24
24
  */
25
- parameters: Record<string_name, string>;
25
+ readonly parameters: Parameters;
26
26
  /**
27
27
  * The content of the script to execute
28
28
  * - It can be a single statement
@@ -31,8 +31,9 @@ export type ScriptExecutionToolsExecuteOptions = {
31
31
  * - It can be IIFE (immediately invoked function expression)
32
32
  * - It can use the parameters as variables and functions from global scope
33
33
  */
34
- script: string_script;
34
+ readonly script: string_script;
35
35
  };
36
36
  /**
37
37
  * TODO: [🧠][💙] Distinct between options passed into ExecutionTools and to ExecutionTools.execute
38
+ * TODO: [🧠][🪐] Should be common things like types, utils in folder containing A,B,C,.. or else outside this listing folder?
38
39
  */