@promptbook/types 0.61.0-10 → 0.61.0-11

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 (123) hide show
  1. package/esm/index.es.js +1 -1
  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/commands/_common/types/CommandParser.d.ts +3 -0
  8. package/esm/typings/src/config.d.ts +4 -0
  9. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
  10. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -0
  11. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
  12. package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
  13. package/{umd/typings/src/errors/VersionMismatch.d.ts → esm/typings/src/errors/VersionMismatchError.d.ts} +1 -1
  14. package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
  15. package/esm/typings/src/execution/PipelineExecutor.d.ts +4 -3
  16. package/esm/typings/src/execution/PromptResult.d.ts +12 -0
  17. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +4 -2
  18. package/esm/typings/src/execution/createPipelineExecutor.d.ts +2 -0
  19. package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
  20. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  21. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  22. package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  23. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  24. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  25. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
  26. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  27. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  28. package/esm/typings/src/llm-providers/utils/cache/CacheItem.d.ts +29 -0
  29. package/esm/typings/src/llm-providers/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  30. package/esm/typings/src/llm-providers/utils/cache/cacheLlmTools.d.ts +17 -0
  31. package/esm/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
  32. package/esm/typings/src/llm-providers/utils/count-total-cost/countTotalCost.d.ts +14 -0
  33. package/esm/typings/src/llm-providers/utils/createLlmToolsFromEnv.d.ts +21 -0
  34. package/esm/typings/src/personas/preparePersona.d.ts +0 -3
  35. package/esm/typings/src/prepare/preparePipeline.d.ts +2 -1
  36. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
  37. package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  38. package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +28 -0
  39. package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +10 -0
  40. package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  41. package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  42. package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +8 -0
  43. package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +8 -0
  44. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +31 -0
  45. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +23 -0
  46. package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
  47. package/esm/typings/src/types/ModelRequirements.d.ts +21 -1
  48. package/esm/typings/src/types/Parameters.d.ts +0 -1
  49. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +0 -1
  50. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -5
  51. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +1 -0
  52. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
  53. package/esm/typings/src/types/Prompt.d.ts +5 -2
  54. package/esm/typings/src/types/typeAliases.d.ts +35 -1
  55. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  56. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +7 -0
  57. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  58. package/esm/typings/src/utils/organization/notUsing.d.ts +11 -0
  59. package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
  60. package/package.json +2 -2
  61. package/umd/index.umd.js +1 -1
  62. package/umd/index.umd.js.map +1 -1
  63. package/umd/typings/promptbook-collection/index.d.ts +83 -2
  64. package/umd/typings/src/_packages/core.index.d.ts +2 -2
  65. package/umd/typings/src/_packages/types.index.d.ts +2 -2
  66. package/umd/typings/src/_packages/utils.index.d.ts +3 -1
  67. package/umd/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
  68. package/umd/typings/src/config.d.ts +4 -0
  69. package/umd/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
  70. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -0
  71. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
  72. package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
  73. package/{esm/typings/src/errors/VersionMismatch.d.ts → umd/typings/src/errors/VersionMismatchError.d.ts} +1 -1
  74. package/umd/typings/src/execution/LlmExecutionTools.d.ts +3 -1
  75. package/umd/typings/src/execution/PipelineExecutor.d.ts +4 -3
  76. package/umd/typings/src/execution/PromptResult.d.ts +12 -0
  77. package/umd/typings/src/execution/ScriptExecutionTools.d.ts +4 -2
  78. package/umd/typings/src/execution/createPipelineExecutor.d.ts +2 -0
  79. package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
  80. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
  81. package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
  82. package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
  83. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  84. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  85. package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
  86. package/umd/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
  87. package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
  88. package/umd/typings/src/llm-providers/utils/cache/CacheItem.d.ts +29 -0
  89. package/umd/typings/src/llm-providers/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
  90. package/umd/typings/src/llm-providers/utils/cache/cacheLlmTools.d.ts +17 -0
  91. package/umd/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
  92. package/umd/typings/src/llm-providers/utils/count-total-cost/countTotalCost.d.ts +14 -0
  93. package/umd/typings/src/llm-providers/utils/createLlmToolsFromEnv.d.ts +21 -0
  94. package/umd/typings/src/personas/preparePersona.d.ts +0 -3
  95. package/umd/typings/src/prepare/preparePipeline.d.ts +2 -1
  96. package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
  97. package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  98. package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +28 -0
  99. package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +10 -0
  100. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
  101. package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  102. package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +8 -0
  103. package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +8 -0
  104. package/umd/typings/src/storage/memory/MemoryStorage.d.ts +31 -0
  105. package/umd/typings/src/storage/utils/PrefixStorage.d.ts +23 -0
  106. package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
  107. package/umd/typings/src/types/ModelRequirements.d.ts +21 -1
  108. package/umd/typings/src/types/Parameters.d.ts +0 -1
  109. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +0 -1
  110. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -5
  111. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +1 -0
  112. package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
  113. package/umd/typings/src/types/Prompt.d.ts +5 -2
  114. package/umd/typings/src/types/typeAliases.d.ts +35 -1
  115. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  116. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +7 -0
  117. package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  118. package/umd/typings/src/utils/organization/notUsing.d.ts +11 -0
  119. package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
  120. package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  121. package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +0 -7
  122. package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
  123. package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +0 -7
package/esm/index.es.js CHANGED
@@ -10,7 +10,7 @@ var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPH
10
10
  /**
11
11
  * The version of the Promptbook library
12
12
  */
13
- var PROMPTBOOK_VERSION = '0.61.0-9';
13
+ var PROMPTBOOK_VERSION = '0.61.0-10';
14
14
  // TODO: !!!! List here all the versions and annotate + put into script
15
15
 
16
16
  export { EXPECTATION_UNITS, PROMPTBOOK_VERSION };
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../../../../src/types/PipelineJson/Expectations.ts","../../../../src/version.ts"],"sourcesContent":[null,null],"names":[],"mappings":"AAeA;;;;IAIa,iBAAiB,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAW;AAc/G;;;;AC/BA;;;IAGa,kBAAkB,GAA8B,WAAW;AAGxE;;;;"}
1
+ {"version":3,"file":"index.es.js","sources":["../../../../src/types/PipelineJson/Expectations.ts","../../../../src/version.ts"],"sourcesContent":[null,null],"names":[],"mappings":"AAeA;;;;IAIa,iBAAiB,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAW;AAc/G;;;;AC/BA;;;IAGa,kBAAkB,GAA8B,YAAY;AAGzE;;;;"}
@@ -26,7 +26,6 @@ declare const _default: ({
26
26
  personas: never[];
27
27
  preparations: {
28
28
  id: number;
29
- date: string;
30
29
  promptbookVersion: string;
31
30
  modelUsage: {
32
31
  price: {
@@ -115,7 +114,89 @@ declare const _default: ({
115
114
  personas: never[];
116
115
  preparations: {
117
116
  id: number;
118
- date: string;
117
+ promptbookVersion: string;
118
+ modelUsage: {
119
+ price: {
120
+ value: number;
121
+ };
122
+ input: {
123
+ tokensCount: {
124
+ value: number;
125
+ };
126
+ charactersCount: {
127
+ value: number;
128
+ };
129
+ wordsCount: {
130
+ value: number;
131
+ };
132
+ sentencesCount: {
133
+ value: number;
134
+ };
135
+ linesCount: {
136
+ value: number;
137
+ };
138
+ paragraphsCount: {
139
+ value: number;
140
+ };
141
+ pagesCount: {
142
+ value: number;
143
+ };
144
+ };
145
+ output: {
146
+ tokensCount: {
147
+ value: number;
148
+ };
149
+ charactersCount: {
150
+ value: number;
151
+ };
152
+ wordsCount: {
153
+ value: number;
154
+ };
155
+ sentencesCount: {
156
+ value: number;
157
+ };
158
+ linesCount: {
159
+ value: number;
160
+ };
161
+ paragraphsCount: {
162
+ value: number;
163
+ };
164
+ pagesCount: {
165
+ value: number;
166
+ };
167
+ };
168
+ };
169
+ }[];
170
+ sourceFile: string;
171
+ } | {
172
+ title: string;
173
+ pipelineUrl: string;
174
+ promptbookVersion: string;
175
+ parameters: {
176
+ name: string;
177
+ description: string;
178
+ isInput: boolean;
179
+ isOutput: boolean;
180
+ }[];
181
+ promptTemplates: {
182
+ name: string;
183
+ title: string;
184
+ dependentParameterNames: string[];
185
+ blockType: string;
186
+ expectFormat: string;
187
+ personaName: null;
188
+ modelRequirements: {
189
+ modelVariant: string;
190
+ modelName: string;
191
+ };
192
+ content: string;
193
+ resultingParameterName: string;
194
+ }[];
195
+ knowledgeSources: never[];
196
+ knowledgePieces: never[];
197
+ personas: never[];
198
+ preparations: {
199
+ id: number;
119
200
  promptbookVersion: string;
120
201
  modelUsage: {
121
202
  price: {
@@ -17,7 +17,7 @@ import { PipelineExecutionError } from '../errors/PipelineExecutionError';
17
17
  import { PipelineLogicError } from '../errors/PipelineLogicError';
18
18
  import { ReferenceError } from '../errors/ReferenceError';
19
19
  import { UnexpectedError } from '../errors/UnexpectedError';
20
- import { VersionMismatch } from '../errors/VersionMismatch';
20
+ import { VersionMismatchError } from '../errors/VersionMismatchError';
21
21
  import { ExpectError } from '../errors/_ExpectError';
22
22
  import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
23
23
  import { createPipelineExecutor } from '../execution/createPipelineExecutor';
@@ -45,4 +45,4 @@ export { pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, v
45
45
  export { preparePipeline, unpreparePipeline };
46
46
  export { createPipelineExecutor, joinLlmExecutionTools };
47
47
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
48
- export { CollectionError, ExpectError, NotFoundError, ParsingError, PipelineExecutionError, PipelineLogicError, ReferenceError, UnexpectedError, VersionMismatch, };
48
+ export { CollectionError, ExpectError, NotFoundError, ParsingError, PipelineExecutionError, PipelineLogicError, ReferenceError, UnexpectedError, VersionMismatchError, };
@@ -29,12 +29,12 @@ import type { ScriptLanguage } from '../types/ScriptLanguage';
29
29
  import type { TaskProgress } from '../types/TaskProgress';
30
30
  import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
31
31
  import type { string_char_emoji } from '../types/typeAliasEmoji';
32
- import type { client_id, string_char, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_script, string_semantic_version, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid } from '../types/typeAliases';
32
+ import type { client_id, number_model_temperature, number_seed, string_char, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_script, string_semantic_version, string_sha256, string_system_message, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid } from '../types/typeAliases';
33
33
  import type { FromtoItems } from '../utils/FromtoItems';
34
34
  import { PROMPTBOOK_VERSION, string_promptbook_version } from '../version';
35
35
  export { PROMPTBOOK_VERSION };
36
36
  export { EXPECTATION_UNITS };
37
- export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineJson, PipelineString, PreparationJson, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_version, string_script, string_semantic_version, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid, };
37
+ export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineJson, PipelineString, PreparationJson, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_version, string_script, string_semantic_version, string_sha256, string_system_message, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid, };
38
38
  /**
39
39
  * TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
40
40
  */
@@ -7,6 +7,7 @@ import { titleToName } from '../conversion/utils/titleToName';
7
7
  import { forEachAsync } from '../execution/utils/forEachAsync';
8
8
  import { replaceParameters } from '../execution/utils/replaceParameters';
9
9
  import { isValidJsonString } from '../formats/json/utils/isValidJsonString';
10
+ import { $currentDate } from '../utils/currentDate';
10
11
  import { countCharacters } from '../utils/expectation-counters/countCharacters';
11
12
  import { countLines } from '../utils/expectation-counters/countLines';
12
13
  import { countPages } from '../utils/expectation-counters/countPages';
@@ -34,6 +35,7 @@ import { removeDiacritics } from '../utils/normalization/removeDiacritics';
34
35
  import { searchKeywords } from '../utils/normalization/searchKeywords';
35
36
  import { parseNumber } from '../utils/parseNumber';
36
37
  import { extractBlock } from '../utils/postprocessing/extractBlock';
38
+ import { $randomSeed } from '../utils/random/randomSeed';
37
39
  import { removeEmojis } from '../utils/removeEmojis';
38
40
  import { removeQuotes } from '../utils/removeQuotes';
39
41
  import { difference } from '../utils/sets/difference';
@@ -53,7 +55,7 @@ import { isValidUrl } from '../utils/validators/url/isValidUrl';
53
55
  import { isValidUuid } from '../utils/validators/uuid/isValidUuid';
54
56
  import { PROMPTBOOK_VERSION } from '../version';
55
57
  export { forEachAsync, PROMPTBOOK_VERSION };
56
- export { extractBlock, // <- [🌻] + maybe export through `@promptbook/markdown-utils`
58
+ export { $currentDate, $randomSeed, extractBlock, // <- [🌻] + maybe export through `@promptbook/markdown-utils`
57
59
  extractParameters, extractVariables, isHostnameOnPrivateNetwork, isUrlOnPrivateNetwork, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, parseNumber, // <- [🌻]
58
60
  removeEmojis, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
59
61
  export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
@@ -1,3 +1,5 @@
1
+ import type { WritableDeep } from 'type-fest';
2
+ import type { PipelineJson } from '../../../types/PipelineJson/PipelineJson';
1
3
  import type { string_markdown_text } from '../../../types/typeAliases';
2
4
  import type { string_name } from '../../../types/typeAliases';
3
5
  import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
@@ -16,6 +18,7 @@ export type CommandParser<TCommand extends {
16
18
  * @throws {ParsingError} if the parsing fails
17
19
  */
18
20
  parse(input: CommandParserInput): TCommand;
21
+ applyToPipelineJson?(pipelineJson: WritableDeep<PipelineJson>, personaCommand: TCommand): void;
19
22
  };
20
23
  export type CommandParserInput = {
21
24
  readonly usagePlace: CommandUsagePlace;
@@ -10,6 +10,10 @@ export declare const CHARACTER_LOOP_LIMIT = 100000;
10
10
  * The maximum number of (LLM) tasks running in parallel
11
11
  */
12
12
  export declare const MAX_PARALLEL_COUNT = 5;
13
+ /**
14
+ * The maximum length of the (generated) filename
15
+ */
16
+ export declare const MAX_FILENAME_LENGTH = 30;
13
17
  /**
14
18
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
15
19
  */
@@ -31,4 +31,5 @@ export type PipelineStringToJsonOptions = {
31
31
  export declare function pipelineStringToJson(pipelineString: PipelineString, options?: PipelineStringToJsonOptions): Promise<PipelineJson>;
32
32
  /**
33
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
34
35
  */
@@ -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
  */
@@ -25,3 +25,7 @@ export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
25
25
  * > * - ...
26
26
  * > ex port function validatePipeline(promptbook: unknown): asserts promptbook is PipelineJson {
27
27
  */
28
+ /**
29
+ * TODO: [🧠] !!!!! Validate new things
30
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
31
+ */
@@ -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
+ }
@@ -2,7 +2,7 @@ import type { string_semantic_version } from '../types/typeAliases';
2
2
  /**
3
3
  * This error type indicates that the version of the pipeline is not matching the expected version
4
4
  */
5
- export declare class VersionMismatch extends Error {
5
+ export declare class VersionMismatchError extends Error {
6
6
  readonly name = "UnexpectedError";
7
7
  constructor(message: string, expectedVersion: string_semantic_version);
8
8
  }
@@ -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,7 +1,8 @@
1
1
  import type { Promisable } from 'type-fest';
2
2
  import type { TaskProgress } from '../types/TaskProgress';
3
3
  import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
4
- import type { string_name } from '../types/typeAliases';
4
+ import type { string_parameter_name } from '../types/typeAliases';
5
+ import type { string_parameter_value } from '../types/typeAliases';
5
6
  import type { PromptResultUsage } from './PromptResult';
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)_.
@@ -12,7 +13,7 @@ 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: Record<string_parameter_name, string_parameter_value>, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
16
17
  /**
17
18
  * Whether the execution was successful, details are aviable in `executionReport`
18
19
  */
@@ -34,7 +35,7 @@ export type PipelineExecutor = {
34
35
  *
35
36
  * Note: If the execution was not successful, there are only some of the result parameters
36
37
  */
37
- readonly outputParameters: Record<string_name, string>;
38
+ readonly outputParameters: Record<string_parameter_name, string_parameter_value>;
38
39
  }>;
39
40
  };
40
41
  /**
@@ -15,15 +15,21 @@ export type PromptResult = PromptCompletionResult | PromptChatResult | PromptEmb
15
15
  /**
16
16
  * Prompt completion result
17
17
  * It contains only the following text NOT the whole completion
18
+ *
19
+ * Note: This is fully serializable as JSON
18
20
  */
19
21
  export type PromptCompletionResult = PromptCommonResult;
20
22
  /**
21
23
  * Prompt chat result
24
+ *
25
+ * Note: This is fully serializable as JSON
22
26
  */
23
27
  export type PromptChatResult = PromptCommonResult & {};
24
28
  /**
25
29
  * Prompt embedding result
26
30
  * It contains only the following text NOT the whole completion
31
+ *
32
+ * Note: This is fully serializable as JSON
27
33
  */
28
34
  export type PromptEmbeddingResult = Omit<PromptCommonResult, 'content'> & {
29
35
  /**
@@ -31,6 +37,11 @@ export type PromptEmbeddingResult = Omit<PromptCommonResult, 'content'> & {
31
37
  */
32
38
  content: EmbeddingVector;
33
39
  };
40
+ /**
41
+ * Common properties for all prompt results
42
+ *
43
+ * Note: This is fully serializable as JSON
44
+ */
34
45
  export type PromptCommonResult = {
35
46
  /**
36
47
  * Exact text response from the model
@@ -111,4 +122,5 @@ export type UncertainNumber = {
111
122
  * TODO: [🧠] Maybe type raw properly - not onject but OpenAI.result.whatever
112
123
  * TODO: [🧠] Maybe remove redundant raw.choices.text
113
124
  * TODO: Log raw even if prompt failed - log the raw error
125
+ * TODO: [🏳] Add `PromptTranslationResult`
114
126
  */
@@ -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
  */
@@ -0,0 +1,10 @@
1
+ import type { LlmExecutionTools } from '../../../../execution/LlmExecutionTools';
2
+ /**
3
+ * Returns LLM tools for testing purposes
4
+ *
5
+ * @private within the package - JUST FOR TESTS, SCRIPTS AND PLAYGROUND
6
+ */
7
+ export declare function getLlmToolsForTestingAndScriptsAndPlayground(): LlmExecutionTools;
8
+ /**
9
+ * Note: [⚪]
10
+ */
@@ -1 +1,4 @@
1
1
  export {};
2
+ /**
3
+ * TODO: [📓] Maybe test all file in samples (not just 10-simple.md)
4
+ */
@@ -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
+ */
@@ -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
+ */
@@ -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: !!! Use here `seed`
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: !!! Use here `seed`
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
  */
@@ -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
+ */
@@ -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,17 @@
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 this util
12
+ * TODO: !!!!! Use this for tests in promptbook project itself
13
+ * TODO: !!!! write discussion about this and storages
14
+ * write how to combine multiple interceptors
15
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
16
+ * TODO: [🧠] Is there some meaningfull way how to test this util
17
+ */
@@ -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 this utils
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
+ */
@@ -0,0 +1,21 @@
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 this util
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
+ */
@@ -8,6 +8,3 @@ import type { string_persona_description } from '../types/typeAliases';
8
8
  * @private within the package
9
9
  */
10
10
  export declare function preparePersona(personaDescription: string_persona_description, options: PrepareOptions): Promise<PersonaPreparedJson['modelRequirements']>;
11
- /**
12
- * TODO: [🪂] Do it in parallel
13
- */
@@ -11,5 +11,6 @@ export declare function preparePipeline(pipeline: PipelineJson, options: Prepare
11
11
  * TODO: Write tests for `preparePipeline`
12
12
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
13
13
  * 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`
14
+ * TODO: !!!!! Use here countTotalUsage
15
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
15
16
  */
@@ -0,0 +1,24 @@
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: [🧠][🛫] Constrain `TItem` to JSON-serializable objects only
24
+ */
@@ -0,0 +1,5 @@
1
+ export {};
2
+ /**
3
+ * TODO: !!!!! Check that this files is not exported into build
4
+ * TODO: Is this a good pattern to do type testing?
5
+ */
@@ -0,0 +1,28 @@
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: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
28
+ */