@promptbook/openai 0.61.0-10 → 0.61.0-12

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 (207) hide show
  1. package/esm/index.es.js +9 -2
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/promptbook-collection/index.d.ts +83 -2
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -2
  5. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/utils.index.d.ts +3 -1
  7. package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -0
  8. package/esm/typings/src/cli/cli-commands/make.d.ts +3 -0
  9. package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -0
  10. package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
  11. package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
  12. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
  13. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -0
  14. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
  15. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -1
  16. package/esm/typings/src/config.d.ts +4 -0
  17. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
  18. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
  19. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -0
  20. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +6 -0
  21. package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
  22. package/{umd/typings/src/errors/VersionMismatch.d.ts → esm/typings/src/errors/VersionMismatchError.d.ts} +1 -1
  23. package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
  24. package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
  25. package/esm/typings/src/execution/PipelineExecutor.d.ts +4 -3
  26. package/esm/typings/src/execution/PromptResult.d.ts +12 -0
  27. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +4 -2
  28. package/esm/typings/src/execution/createPipelineExecutor.d.ts +2 -0
  29. package/esm/typings/src/formats/csv/ListFormatDefinition.d.ts +1 -0
  30. package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +1 -0
  31. package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +1 -0
  32. package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
  33. package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
  34. package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +1 -1
  35. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -0
  36. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  37. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -0
  38. package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +22 -0
  39. package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
  40. package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
  41. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
  42. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  43. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +16 -0
  44. package/esm/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
  45. package/esm/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
  46. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -0
  47. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  48. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  49. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -0
  50. package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  51. package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
  52. package/esm/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
  53. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  54. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  55. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
  56. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -0
  57. package/esm/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  58. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  59. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  60. package/esm/typings/src/personas/preparePersona.d.ts +4 -2
  61. package/esm/typings/src/prepare/preparePipeline.d.ts +3 -1
  62. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -0
  63. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
  64. package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  65. package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
  66. package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
  67. package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  68. package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  69. package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
  70. package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
  71. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
  72. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
  73. package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
  74. package/esm/typings/src/types/ModelRequirements.d.ts +21 -1
  75. package/esm/typings/src/types/Parameters.d.ts +0 -1
  76. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -2
  77. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -5
  78. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +1 -0
  79. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
  80. package/esm/typings/src/types/PipelineString.d.ts +1 -1
  81. package/esm/typings/src/types/Prompt.d.ts +5 -2
  82. package/esm/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  83. package/esm/typings/src/types/typeAliases.d.ts +35 -1
  84. package/esm/typings/src/utils/emojis.d.ts +2 -2
  85. package/esm/typings/src/utils/formatNumber.d.ts +1 -1
  86. package/esm/typings/src/utils/isRunningInWhatever.d.ts +3 -0
  87. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -1
  88. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  89. package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  90. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  91. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +7 -0
  92. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  93. package/esm/typings/src/utils/organization/TODO.d.ts +2 -0
  94. package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -0
  95. package/esm/typings/src/utils/organization/___.d.ts +2 -0
  96. package/esm/typings/src/utils/organization/just.d.ts +1 -0
  97. package/esm/typings/src/utils/organization/keepImported.d.ts +12 -0
  98. package/esm/typings/src/utils/organization/notUsing.d.ts +12 -0
  99. package/esm/typings/src/utils/organization/really_any.d.ts +2 -0
  100. package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
  101. package/esm/typings/src/version.d.ts +3 -0
  102. package/package.json +2 -2
  103. package/umd/index.umd.js +9 -2
  104. package/umd/index.umd.js.map +1 -1
  105. package/umd/typings/promptbook-collection/index.d.ts +83 -2
  106. package/umd/typings/src/_packages/core.index.d.ts +2 -2
  107. package/umd/typings/src/_packages/types.index.d.ts +2 -2
  108. package/umd/typings/src/_packages/utils.index.d.ts +3 -1
  109. package/umd/typings/src/cli/cli-commands/hello.d.ts +3 -0
  110. package/umd/typings/src/cli/cli-commands/make.d.ts +3 -0
  111. package/umd/typings/src/cli/cli-commands/prettify.d.ts +3 -0
  112. package/umd/typings/src/cli/promptbookCli.d.ts +1 -0
  113. package/umd/typings/src/collection/PipelineCollection.d.ts +1 -1
  114. package/umd/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
  115. package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -0
  116. package/umd/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
  117. package/umd/typings/src/commands/_common/types/CommandParser.d.ts +4 -1
  118. package/umd/typings/src/config.d.ts +4 -0
  119. package/umd/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
  120. package/umd/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
  121. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -0
  122. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +6 -0
  123. package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
  124. package/{esm/typings/src/errors/VersionMismatch.d.ts → umd/typings/src/errors/VersionMismatchError.d.ts} +1 -1
  125. package/umd/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
  126. package/umd/typings/src/execution/LlmExecutionTools.d.ts +3 -1
  127. package/umd/typings/src/execution/PipelineExecutor.d.ts +4 -3
  128. package/umd/typings/src/execution/PromptResult.d.ts +12 -0
  129. package/umd/typings/src/execution/ScriptExecutionTools.d.ts +4 -2
  130. package/umd/typings/src/execution/createPipelineExecutor.d.ts +2 -0
  131. package/umd/typings/src/formats/csv/ListFormatDefinition.d.ts +1 -0
  132. package/umd/typings/src/formats/json/JsonFormatDefinition.d.ts +1 -0
  133. package/umd/typings/src/formats/list/ListFormatDefinition.d.ts +1 -0
  134. package/umd/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
  135. package/umd/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
  136. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +1 -1
  137. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -0
  138. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  139. package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -0
  140. package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +22 -0
  141. package/umd/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
  142. package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
  143. package/umd/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
  144. package/umd/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  145. package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +16 -0
  146. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
  147. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
  148. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -0
  149. package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  150. package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  151. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -0
  152. package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  153. package/umd/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
  154. package/umd/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
  155. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  156. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  157. package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
  158. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -0
  159. package/umd/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  160. package/umd/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  161. package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  162. package/umd/typings/src/personas/preparePersona.d.ts +4 -2
  163. package/umd/typings/src/prepare/preparePipeline.d.ts +3 -1
  164. package/umd/typings/src/prepare/unpreparePipeline.d.ts +1 -0
  165. package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
  166. package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  167. package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
  168. package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
  169. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  170. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  171. package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
  172. package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
  173. package/umd/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
  174. package/umd/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
  175. package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
  176. package/umd/typings/src/types/ModelRequirements.d.ts +21 -1
  177. package/umd/typings/src/types/Parameters.d.ts +0 -1
  178. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -2
  179. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -5
  180. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +1 -0
  181. package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
  182. package/umd/typings/src/types/PipelineString.d.ts +1 -1
  183. package/umd/typings/src/types/Prompt.d.ts +5 -2
  184. package/umd/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  185. package/umd/typings/src/types/typeAliases.d.ts +35 -1
  186. package/umd/typings/src/utils/emojis.d.ts +2 -2
  187. package/umd/typings/src/utils/formatNumber.d.ts +1 -1
  188. package/umd/typings/src/utils/isRunningInWhatever.d.ts +3 -0
  189. package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -1
  190. package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  191. package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  192. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  193. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +7 -0
  194. package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  195. package/umd/typings/src/utils/organization/TODO.d.ts +2 -0
  196. package/umd/typings/src/utils/organization/TODO_USE.d.ts +1 -0
  197. package/umd/typings/src/utils/organization/___.d.ts +2 -0
  198. package/umd/typings/src/utils/organization/just.d.ts +1 -0
  199. package/umd/typings/src/utils/organization/keepImported.d.ts +12 -0
  200. package/umd/typings/src/utils/organization/notUsing.d.ts +12 -0
  201. package/umd/typings/src/utils/organization/really_any.d.ts +2 -0
  202. package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
  203. package/umd/typings/src/version.d.ts +3 -0
  204. package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  205. package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +0 -7
  206. package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  207. package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +0 -7
@@ -1,5 +1,6 @@
1
1
  import type { ScriptLanguage } from '../types/ScriptLanguage';
2
- import type { string_name } from '../types/typeAliases';
2
+ import type { string_parameter_name } from '../types/typeAliases';
3
+ import type { string_parameter_value } from '../types/typeAliases';
3
4
  import type { string_script } from '../types/typeAliases';
4
5
  /**
5
6
  * Represents all the tools needed to EXECUTE SCRIPTs
@@ -22,7 +23,7 @@ export type ScriptExecutionToolsExecuteOptions = {
22
23
  * Theese parameters are passed to the script as variables
23
24
  * For example: { "name": "John" } => const name = "John";
24
25
  */
25
- readonly parameters: Record<string_name, string>;
26
+ readonly parameters: Record<string_parameter_name, string_parameter_value>;
26
27
  /**
27
28
  * The content of the script to execute
28
29
  * - It can be a single statement
@@ -35,4 +36,5 @@ export type ScriptExecutionToolsExecuteOptions = {
35
36
  };
36
37
  /**
37
38
  * TODO: [🧠][💙] Distinct between options passed into ExecutionTools and to ExecutionTools.execute
39
+ * TODO: [🧠][🪐] Should be common things like types, utils in folder containing A,B,C,.. or else outside this listing folder?
38
40
  */
@@ -36,8 +36,10 @@ export declare function createPipelineExecutor(options: CreatePipelineExecutorOp
36
36
  export {};
37
37
  /**
38
38
  * TODO: [🪂] Pass maxParallelCount here
39
+ * TODO: [♈] Probbably move expectations from templates to parameters
39
40
  * TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
40
41
  * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
41
42
  * Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
42
43
  * TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
44
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
43
45
  */
@@ -8,4 +8,5 @@ export declare const CsvFormatDefinition: FormatDefinition<string, string, objec
8
8
  * TODO: [🍓] In `CsvFormatDefinition` implement partial `canBeValid`
9
9
  * TODO: [🍓] In `CsvFormatDefinition` implement `heal
10
10
  * TODO: [🍓] In `CsvFormatDefinition` implement `extractValues`
11
+ * TODO: [🏢] Allow to expect something inside CSV objects and other formats
11
12
  */
@@ -12,4 +12,5 @@ export declare const JsonFormatDefinition: FormatDefinition<string, string, obje
12
12
  * TODO: [🍓] In `JsonFormatDefinition` implement partial `canBeValid`
13
13
  * TODO: [🍓] In `JsonFormatDefinition` implement `heal
14
14
  * TODO: [🍓] In `JsonFormatDefinition` implement `extractValues`
15
+ * TODO: [🏢] Allow to expect something inside JSON objects and other formats
15
16
  */
@@ -10,4 +10,5 @@ export declare const ListFormatDefinition: FormatDefinition<string, string, obje
10
10
  * TODO: [🍓] In `ListFormatDefinition` implement partial `canBeValid`
11
11
  * TODO: [🍓] In `ListFormatDefinition` implement `heal
12
12
  * TODO: [🍓] In `ListFormatDefinition` implement `extractValues`
13
+ * TODO: [🏢] Allow to expect something inside each item of list and other formats
13
14
  */
@@ -12,4 +12,5 @@ export declare const XmlFormatDefinition: FormatDefinition<string, string, objec
12
12
  * TODO: [🍓] In `XmlFormatDefinition` implement partial `canBeValid`
13
13
  * TODO: [🍓] In `XmlFormatDefinition` implement `heal
14
14
  * TODO: [🍓] In `XmlFormatDefinition` implement `extractValues`
15
+ * TODO: [🏢] Allow to expect something inside XML and other formats
15
16
  */
@@ -15,3 +15,6 @@ export declare class SimplePromptInterfaceTools implements UserInterfaceTools {
15
15
  */
16
16
  promptDialog(options: UserInterfaceToolsPromptDialogOptions): Promise<string>;
17
17
  }
18
+ /**
19
+ * Note: [🔵] This code should never be published outside of `@promptbook/browser`
20
+ */
@@ -5,10 +5,10 @@ import type { KnowledgeSourceJson } from '../../../types/PipelineJson/KnowledgeS
5
5
  * Prepares the knowle
6
6
  *
7
7
  * @see https://github.com/webgptorg/promptbook/discussions/41
8
- * @private within the package
9
8
  */
10
9
  export declare function prepareKnowledgePieces(knowledgeSources: Array<KnowledgeSourceJson>, options: PrepareOptions): Promise<Array<Omit<KnowledgePiecePreparedJson, 'preparationIds'>>>;
11
10
  /**
11
+ * TODO: [🔼] !!! Export via `@promptbook/core`
12
12
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
13
13
  * Put `knowledgePieces` into `PrepareKnowledgeOptions`
14
14
  * TODO: [🪂] More than max things can run in parallel by acident [1,[2a,2b,_],[3a,3b,_]]
@@ -6,6 +6,7 @@ import type { string_markdown } from '../../../types/typeAliases';
6
6
  */
7
7
  export declare function prepareKnowledgeFromMarkdown(content: string_markdown, options: PrepareOptions): Promise<Array<Omit<KnowledgePiecePreparedJson, 'sources' | 'preparationIds'>>>;
8
8
  /**
9
+ * TODO: [🔼] !!! Export via `@promptbook/markdown`
9
10
  * TODO: [🪂] Do it in parallel 11:11
10
11
  * Note: No need to aggregate usage here, it is done by intercepting the llmTools
11
12
  */
@@ -1 +1,4 @@
1
1
  export {};
2
+ /**
3
+ * TODO: [📓] Maybe test all file in samples (not just 10-simple.md)
4
+ */
@@ -6,6 +6,7 @@ import type { string_base64 } from '../../../types/typeAliases';
6
6
  */
7
7
  export declare function prepareKnowledgeFromPdf(content: string_base64, options: PrepareOptions): Promise<Array<Omit<KnowledgePiecePreparedJson, 'sources' | 'preparationIds'>>>;
8
8
  /**
9
+ * TODO: [🔼] !!! Export via `@promptbook/pdf`
9
10
  * TODO: [🧺] In future, content can be alse File or Blob BUT for now for wider compatibility its only base64
10
11
  * @see https://stackoverflow.com/questions/14653349/node-js-cant-create-blobs
11
12
  * TODO: [🪂] Do it in parallel
@@ -0,0 +1,22 @@
1
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ /**
3
+ * @@@
4
+ *
5
+ * Note: This function is not cached, every call creates new instance of LlmExecutionTools
6
+ *
7
+ * It looks for environment variables:
8
+ * - `process.env.OPENAI_API_KEY`
9
+ * - `process.env.ANTHROPIC_CLAUDE_API_KEY`
10
+ *
11
+ * @returns @@@
12
+ */
13
+ export declare function createLlmToolsFromEnv(): LlmExecutionTools;
14
+ /**
15
+ * TODO: [🔼] !!! Export via `@promptbook/node`
16
+ * TODO: @@@ write discussion about this - wizzard
17
+ * TODO: Add Azure
18
+ * TODO: [🧠] Which name is better `createLlmToolsFromEnv` or `createLlmToolsFromEnvironment`?
19
+ * TODO: [🧠] Is there some meaningfull way how to test this util
20
+ * TODO: [🧠] Maybe pass env as argument
21
+ * Note: [🟢] This code should never be published outside of `@promptbook/node`
22
+ */
@@ -0,0 +1,10 @@
1
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ /**
3
+ * Returns LLM tools for CLI
4
+ *
5
+ * @private within the repository - for CLI utils
6
+ */
7
+ export declare function getLlmToolsForCli(): LlmExecutionTools;
8
+ /**
9
+ * Note: [🟡] This code should never be published outside of `@promptbook/cli`
10
+ */
@@ -0,0 +1,10 @@
1
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ /**
3
+ * Returns LLM tools for testing purposes
4
+ *
5
+ * @private within the repository - JUST FOR TESTS, SCRIPTS AND PLAYGROUND
6
+ */
7
+ export declare function getLlmToolsForTestingAndScriptsAndPlayground(): LlmExecutionTools;
8
+ /**
9
+ * Note: [⚪] This should never be in any released package
10
+ */
@@ -0,0 +1,29 @@
1
+ import type { PromptResult } from '../../../../execution/PromptResult';
2
+ import type { Prompt } from '../../../../types/Prompt';
3
+ import type { string_date_iso8601 } from '../../../../types/typeAliases';
4
+ import type { string_promptbook_version } from '../../../../version';
5
+ /**
6
+ * @@@
7
+ */
8
+ export type CacheItem = {
9
+ /**
10
+ * @@@
11
+ */
12
+ date: string_date_iso8601;
13
+ /**
14
+ * @@@
15
+ */
16
+ promptbookVersion: string_promptbook_version;
17
+ /**
18
+ * @@@
19
+ */
20
+ prompt: Prompt;
21
+ /**
22
+ * @@@
23
+ */
24
+ promptResult: PromptResult;
25
+ };
26
+ /**
27
+ * TODO: [🧠] Should be this exported alongsite `cacheLlmTools` through `@promptbook/utils` OR through `@promptbook/types`
28
+ * TODO: [🛫] `prompt` is NOT fully serializable as JSON, it contains functions which are not serializable, fix it
29
+ */
@@ -0,0 +1,10 @@
1
+ import type { PromptbookStorage } from '../../../../storage/_common/PromptbookStorage';
2
+ import type { CacheItem } from './CacheItem';
3
+ export type CacheLlmToolsOptions = {
4
+ /**
5
+ * Total cost of the execution
6
+ *
7
+ * @default MemoryStorage
8
+ */
9
+ storage: PromptbookStorage<CacheItem>;
10
+ };
@@ -0,0 +1,16 @@
1
+ import type { LlmExecutionTools } from '../../../../execution/LlmExecutionTools';
2
+ import type { CacheLlmToolsOptions } from './CacheLlmToolsOptions';
3
+ /**
4
+ * Intercepts LLM tools and counts total usage of the tools
5
+ *
6
+ * @param llmTools LLM tools to be intercepted with usage counting
7
+ * @returns LLM tools with same functionality with added total cost counting
8
+ */
9
+ export declare function cacheLlmTools(llmTools: LlmExecutionTools, options?: Partial<CacheLlmToolsOptions>): LlmExecutionTools;
10
+ /**
11
+ * TODO: [🔼] !!! Export via `@promptbook/core`
12
+ * TODO: @@@ write discussion about this and storages
13
+ * write how to combine multiple interceptors
14
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
15
+ * TODO: [🧠] Is there some meaningfull way how to test this util
16
+ */
@@ -0,0 +1,11 @@
1
+ import type { LlmExecutionTools } from '../../../../execution/LlmExecutionTools';
2
+ import type { PromptResultUsage } from '../../../../execution/PromptResult';
3
+ /**
4
+ * LLM tools with option to get total cost of the execution
5
+ */
6
+ export type LlmExecutionToolsWithTotalCost = LlmExecutionTools & {
7
+ /**
8
+ * Total cost of the execution
9
+ */
10
+ totalUsage: PromptResultUsage;
11
+ };
@@ -0,0 +1,14 @@
1
+ import type { LlmExecutionTools } from '../../../../execution/LlmExecutionTools';
2
+ import type { LlmExecutionToolsWithTotalCost } from './LlmExecutionToolsWithTotalCost';
3
+ /**
4
+ * Intercepts LLM tools and counts total usage of the tools
5
+ *
6
+ * @param llmTools LLM tools to be intercepted with usage counting
7
+ * @returns LLM tools with same functionality with added total cost counting
8
+ */
9
+ export declare function countTotalUsage(llmTools: LlmExecutionTools): LlmExecutionToolsWithTotalCost;
10
+ /**
11
+ * TODO: [🔼] !!! Export via `@promptbookcore/`
12
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
13
+ * TODO: [🧠] Is there some meaningfull way how to test this util
14
+ */
@@ -45,4 +45,5 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
45
45
  * TODO: [🧠] Maybe handle errors via transformAnthropicError (like transformAzureError)
46
46
  * TODO: Maybe Create some common util for callChatModel and callCompletionModel
47
47
  * TODO: Maybe make custom OpenaiError
48
+ * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
48
49
  */
@@ -15,7 +15,7 @@ export declare const ANTHROPIC_CLAUDE_MODELS: Array<AvailableModel & {
15
15
  }>;
16
16
  /**
17
17
  * Note: [🤖] Add models of new variant
18
- * TODO: !!!! Add embedding models OR Anthropic has only chat+completion models?
18
+ * TODO: [🧠] !!! Add embedding models OR Anthropic has only chat+completion models?
19
19
  * TODO: [🧠] Some mechanism to propagate unsureness
20
20
  * TODO: [🧠][👮‍♀️] Put here more info like description, isVision, trainingDateCutoff, languages, strengths ( Top-level performance, intelligence, fluency, and understanding), contextWindow,...
21
21
  * TODO: [🕚] Make this list dynamic - dynamically can be listed modelNames but not modelVariant, legacy status, context length and pricing
@@ -1,2 +1,5 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
+ /**
4
+ * TODO: !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
5
+ */
@@ -44,4 +44,5 @@ export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
44
44
  /**
45
45
  * TODO: Maybe Create some common util for callChatModel and callCompletionModel
46
46
  * TODO: Maybe make custom AzureOpenaiError
47
+ * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
47
48
  */
@@ -1,2 +1,5 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
+ /**
4
+ * TODO: Test here that `systemMessage`, `temperature` and `seed` are working correctly
5
+ */
@@ -10,3 +10,6 @@ export declare class LangtailExecutionTools extends OpenAiExecutionTools impleme
10
10
  get title(): string_title & string_markdown_text;
11
11
  get description(): string_markdown;
12
12
  }
13
+ /**
14
+ * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
15
+ */
@@ -7,5 +7,5 @@ import type { OpenAiExecutionToolsOptions } from '../openai/OpenAiExecutionTools
7
7
  */
8
8
  export type LangtailExecutionToolsOptions = OpenAiExecutionToolsOptions;
9
9
  /**
10
- * TODO: !!! Use or remove
10
+ * TODO: !! Use or remove
11
11
  */
@@ -29,6 +29,6 @@ export declare class MockedEchoLlmExecutionTools implements LlmExecutionTools {
29
29
  listModels(): Array<AvailableModel>;
30
30
  }
31
31
  /**
32
- * TODO: [🕵️‍♀️] Maybe just remove
32
+ * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
33
33
  * TODO: Allow in spaceTrim: nesting with > ${block(prompt.request)}, same as replace params
34
34
  */
@@ -34,5 +34,5 @@ export declare class MockedFackedLlmExecutionTools implements LlmExecutionTools
34
34
  listModels(): Array<AvailableModel>;
35
35
  }
36
36
  /**
37
- * TODO: [🕵️‍♀️] Maybe just remove
37
+ * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
38
38
  */
@@ -41,10 +41,12 @@ export declare class MultipleLlmExecutionTools implements LlmExecutionTools {
41
41
  private callModelCommon;
42
42
  /**
43
43
  * List all available models that can be used
44
- * This liost is a combination of all available models from all execution tools
44
+ * This lists is a combination of all available models from all execution tools
45
45
  */
46
46
  listModels(): Promise<Array<AvailableModel>>;
47
47
  }
48
48
  /**
49
49
  * TODO: [🧠][🎛] Aggregating multiple models - have result not only from one first aviable model BUT all of them
50
+ * TODO: [🏖] If no llmTools have for example not defined `callCompletionModel` this will still return object with defined `callCompletionModel` which just throws `PipelineExecutionError`, make it undefined instead
51
+ * Look how `countTotalUsage` (and `cacheLlmTools`) implements it
50
52
  */
@@ -62,4 +62,5 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
62
62
  * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
63
63
  * TODO: Maybe Create some common util for callChatModel and callCompletionModel
64
64
  * TODO: Maybe make custom OpenaiError
65
+ * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
65
66
  */
@@ -4,13 +4,13 @@
4
4
  * @see https://openai.com/api/pricing/
5
5
  * @see https://docs.anthropic.com/en/docs/models-overview
6
6
  *
7
- * @private within the package, used only as internal helper for `OPENAI_MODELS` and `computeUsage`
7
+ * @private within the repository, used only as internal helper for `OPENAI_MODELS` and `computeUsage`
8
8
  */
9
9
  type string_model_price = `$${number}.${number} / ${number}M tokens`;
10
10
  /**
11
11
  * Function computeUsage will create price per one token based on the string value found on openai page
12
12
  *
13
- * @private within the package, used only as internal helper for `OPENAI_MODELS`
13
+ * @private within the repository, used only as internal helper for `OPENAI_MODELS`
14
14
  */
15
15
  export declare function computeUsage(value: string_model_price): number;
16
16
  export {};
@@ -24,4 +24,5 @@ export declare const OPENAI_MODELS: Array<AvailableModel & {
24
24
  * @see /other/playground/playground.ts
25
25
  * TODO: [🍓] Make better
26
26
  * TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
27
+ * TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
27
28
  */
@@ -1,2 +1,5 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
+ /**
4
+ * TODO: !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
5
+ */
@@ -5,9 +5,11 @@ import type { string_persona_description } from '../types/typeAliases';
5
5
  * Prepares the persona for the pipeline
6
6
  *
7
7
  * @see https://github.com/webgptorg/promptbook/discussions/22
8
- * @private within the package
9
8
  */
10
9
  export declare function preparePersona(personaDescription: string_persona_description, options: PrepareOptions): Promise<PersonaPreparedJson['modelRequirements']>;
11
10
  /**
12
- * TODO: [🪂] Do it in parallel
11
+ * TODO: [🔼] !!! Export via `@promptbook/core`
12
+ * TODO: [🏢] !! Check validity of `modelName` in pipeline
13
+ * TODO: [🏢] !! Check validity of `systemMessage` in pipeline
14
+ * TODO: [🏢] !! Check validity of `temperature` in pipeline
13
15
  */
@@ -8,8 +8,10 @@ import type { PrepareOptions } from './PrepareOptions';
8
8
  */
9
9
  export declare function preparePipeline(pipeline: PipelineJson, options: PrepareOptions): Promise<PipelineJson>;
10
10
  /**
11
+ * TODO: [🔼] !!! Export via `@promptbook/core`
11
12
  * TODO: Write tests for `preparePipeline`
12
13
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
13
14
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
14
- * TODO: [💸] Make utilities `interceptLlmTools` and `costLlmTools` to compute cost and DO put this counting logic in `prepareKnowledge` or `preparePersona`
15
+ * TODO: [🎐] !!!! Use here countTotalUsage
16
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
15
17
  */
@@ -4,5 +4,6 @@ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
4
4
  */
5
5
  export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
6
6
  /**
7
+ * TODO: [🔼] !!! Export via `@promptbook/core`
7
8
  * TODO: Write tests for `preparePipeline`
8
9
  */
@@ -0,0 +1,25 @@
1
+ import { Promisable } from 'type-fest';
2
+ /**
3
+ * Storage of objects with asynchronous API
4
+ *
5
+ * Note: Naming `PromptbookStorage` not `Storage` to avoid name collision with global `Storage` interface.
6
+ * Note: This is simmilar to Web Storage API interface but everything is asynchronous and can store JSON objects.
7
+ */
8
+ export type PromptbookStorage<TItem> = {
9
+ /**
10
+ * Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object
11
+ */
12
+ getItem(key: string): Promisable<TItem | null>;
13
+ /**
14
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously
15
+ */
16
+ setItem(key: string, value: TItem): Promisable<void>;
17
+ /**
18
+ * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists
19
+ */
20
+ removeItem(key: string): Promisable<void>;
21
+ };
22
+ /**
23
+ * TODO: [🔼] !!! Export via `@promptbook/types`
24
+ * TODO: [🧠][🛫] Constrain `TItem` to JSON-serializable objects only
25
+ */
@@ -0,0 +1,5 @@
1
+ export {};
2
+ /**
3
+ * Note: [⚪] This should never be in any released package
4
+ * TODO: Is this a good pattern to do type testing?
5
+ */
@@ -0,0 +1,30 @@
1
+ import type { PromptbookStorage } from '../_common/PromptbookStorage';
2
+ import type { FilesStorageOptions } from './FilesStorageOptions';
3
+ /**
4
+ * @@@
5
+ */
6
+ export declare class FilesStorage<TItem> implements PromptbookStorage<TItem> {
7
+ private readonly options;
8
+ constructor(options: FilesStorageOptions);
9
+ /**
10
+ * @@@
11
+ */
12
+ private getFilenameForKey;
13
+ /**
14
+ * @@@ Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
15
+ */
16
+ getItem(key: string): Promise<TItem | null>;
17
+ /**
18
+ * @@@ Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
19
+ */
20
+ setItem(key: string, value: TItem): Promise<void>;
21
+ /**
22
+ * @@@ Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
23
+ */
24
+ removeItem(key: string): Promise<void>;
25
+ }
26
+ /**
27
+ * TODO: [🔼] !!! Export via `@promptbook/node`
28
+ * TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
29
+ * Note: [🟢] This code should never be published outside of `@promptbook/node`
30
+ */
@@ -0,0 +1,13 @@
1
+ import type { string_folder_path } from '../../types/typeAliases';
2
+ /**
3
+ * @@@
4
+ */
5
+ export type FilesStorageOptions = {
6
+ /**
7
+ * @@@
8
+ */
9
+ cacheFolderPath: string_folder_path;
10
+ };
11
+ /**
12
+ * TODO: [🔼] !!! Export via `@promptbook/types`
13
+ */
@@ -0,0 +1,7 @@
1
+ import type { string_name } from '../../../types/typeAliases';
2
+ /**
3
+ * @@@
4
+ *
5
+ * @private for `FilesStorage`
6
+ */
7
+ export declare function nameToSubfolderPath(name: string_name): Array<string>;
@@ -0,0 +1,9 @@
1
+ import type { PromptbookStorage } from '../_common/PromptbookStorage';
2
+ /**
3
+ * Gets wrapper around `localStorage` object which can be used as `PromptbookStorage`
4
+ */
5
+ export declare function getLocalStorage<TItem>(): PromptbookStorage<TItem>;
6
+ /**
7
+ * TODO: [🔼] !!! Export via `@promptbook/browser`
8
+ * Note: [🔵] This code should never be published outside of `@promptbook/browser`
9
+ */
@@ -0,0 +1,9 @@
1
+ import type { PromptbookStorage } from '../_common/PromptbookStorage';
2
+ /**
3
+ * Gets wrapper around `sessionStorage` object which can be used as `PromptbookStorage`
4
+ */
5
+ export declare function getSessionStorage<TItem>(): PromptbookStorage<TItem>;
6
+ /**
7
+ * TODO: [🔼] !!! Export via `@promptbook/browser`
8
+ * Note: [🔵] This code should never be published outside of `@promptbook/browser`
9
+ */
@@ -0,0 +1,34 @@
1
+ import type { PromptbookStorage } from '../_common/PromptbookStorage';
2
+ /**
3
+ * Stores
4
+ */
5
+ export declare class MemoryStorage<TItem> implements PromptbookStorage<TItem> {
6
+ private storage;
7
+ /**
8
+ * Returns the number of key/value pairs currently present in the list associated with the object.
9
+ */
10
+ get length(): number;
11
+ /**
12
+ * Empties the list associated with the object of all key/value pairs, if there are any.
13
+ */
14
+ clear(): void;
15
+ /**
16
+ * Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
17
+ */
18
+ getItem(key: string): TItem | null;
19
+ /**
20
+ * Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
21
+ */
22
+ key(index: number): string | null;
23
+ /**
24
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
25
+ */
26
+ setItem(key: string, value: TItem): void;
27
+ /**
28
+ * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
29
+ */
30
+ removeItem(key: string): void;
31
+ }
32
+ /**
33
+ * TODO: [🔼] !!! Export via `@promptbook/core`
34
+ */
@@ -0,0 +1,26 @@
1
+ import { Promisable } from 'type-fest';
2
+ import type { PromptbookStorage } from '../_common/PromptbookStorage';
3
+ /**
4
+ * This class behaves like LocalStorage but separates keys by prefix
5
+ */
6
+ export declare class PrefixStorage<TItem> implements PromptbookStorage<TItem> {
7
+ private baseStorage;
8
+ private keyPrefix;
9
+ private separator;
10
+ constructor(baseStorage: PromptbookStorage<TItem>, keyPrefix: string, separator?: string);
11
+ /**
12
+ * Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
13
+ */
14
+ getItem(key: string): Promisable<TItem | null>;
15
+ /**
16
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
17
+ */
18
+ setItem(key: string, value: TItem): Promisable<void>;
19
+ /**
20
+ * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
21
+ */
22
+ removeItem(key: string): void;
23
+ }
24
+ /**
25
+ * TODO: [🔼] !!! Export via `@promptbook/core`
26
+ */
@@ -0,0 +1,11 @@
1
+ import type { PromptbookStorage } from '../_common/PromptbookStorage';
2
+ /**
3
+ * @@@
4
+ *
5
+ * @private for `getLocalStorage` and `getSessionStorage`
6
+ */
7
+ export declare function makePromptbookStorageFromWebStorage<TValue>(webStorage: Storage): PromptbookStorage<TValue>;
8
+ /**
9
+ * TODO: [🧠] Should this be named `makePromptbookStorageFromWebStorage` vs `createPromptbookStorageFromWebStorage`
10
+ * TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
11
+ */