@promptbook/pdf 0.74.0-0 → 0.74.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 (56) hide show
  1. package/README.md +135 -30
  2. package/esm/index.es.js +235 -287
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -2
  5. package/esm/typings/src/_packages/azure-openai.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/browser.index.d.ts +2 -2
  7. package/esm/typings/src/_packages/cli.index.d.ts +2 -2
  8. package/esm/typings/src/_packages/core.index.d.ts +7 -3
  9. package/esm/typings/src/_packages/documents.index.d.ts +2 -2
  10. package/esm/typings/src/_packages/execute-javascript.index.d.ts +2 -2
  11. package/esm/typings/src/_packages/fake-llm.index.d.ts +2 -2
  12. package/esm/typings/src/_packages/langtail.index.d.ts +2 -2
  13. package/esm/typings/src/_packages/legacy-documents.index.d.ts +2 -2
  14. package/esm/typings/src/_packages/markdown-utils.index.d.ts +2 -2
  15. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  16. package/esm/typings/src/_packages/openai.index.d.ts +2 -2
  17. package/esm/typings/src/_packages/pdf.index.d.ts +2 -2
  18. package/esm/typings/src/_packages/remote-client.index.d.ts +2 -2
  19. package/esm/typings/src/_packages/remote-server.index.d.ts +2 -2
  20. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  21. package/esm/typings/src/_packages/website-crawler.index.d.ts +2 -2
  22. package/esm/typings/src/cli/cli-commands/make.d.ts +0 -1
  23. package/esm/typings/src/cli/cli-commands/run.d.ts +14 -0
  24. package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
  25. package/esm/typings/src/cli/test/ptbk.d.ts +5 -2
  26. package/esm/typings/src/collection/collectionToJson.test.d.ts +1 -1
  27. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
  28. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +11 -0
  29. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +9 -0
  30. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
  31. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
  32. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
  33. package/esm/typings/src/commands/index.d.ts +1 -1
  34. package/esm/typings/src/config.d.ts +6 -0
  35. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
  36. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
  37. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
  38. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  39. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +7 -7
  40. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  41. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
  42. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  43. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
  44. package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
  45. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +6 -4
  46. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  47. package/esm/typings/src/types/Prompt.d.ts +1 -1
  48. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  49. package/esm/typings/src/version.d.ts +13 -2
  50. package/package.json +2 -2
  51. package/umd/index.umd.js +236 -287
  52. package/umd/index.umd.js.map +1 -1
  53. package/esm/typings/src/commands/PROMPTBOOK_VERSION/PromptbookVersionCommand.d.ts +0 -11
  54. package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +0 -9
  55. /package/esm/typings/src/commands/{PROMPTBOOK_VERSION/promptbookVersionCommand.test.d.ts → BOOK_VERSION/bookVersionCommand.test.d.ts} +0 -0
  56. /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -10,10 +10,20 @@ import { unparse, parse } from 'papaparse';
10
10
 
11
11
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
12
12
  /**
13
- * The version of the Promptbook library
13
+ * The version of the Book language
14
+ *
15
+ * @see https://github.com/webgptorg/book
16
+ */
17
+ var BOOK_LANGUAGE_VERSION = '1.0.0';
18
+ /**
19
+ * The version of the Promptbook engine
20
+ *
21
+ * @see https://github.com/webgptorg/promptbook
22
+ */
23
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-11';
24
+ /**
25
+ * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
14
26
  */
15
- var PROMPTBOOK_VERSION = '0.73.0';
16
- // TODO: [main] !!!! List here all the versions and annotate + put into script
17
27
 
18
28
  /*! *****************************************************************************
19
29
  Copyright (c) Microsoft Corporation.
@@ -161,13 +171,9 @@ var NotYetImplementedError = /** @class */ (function (_super) {
161
171
  * @private within the repository
162
172
  */
163
173
  function TODO_USE() {
164
- var value = [];
165
- for (var _i = 0; _i < arguments.length; _i++) {
166
- value[_i] = arguments[_i];
167
- }
168
174
  }
169
175
 
170
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
176
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.book.md"}];
171
177
 
172
178
  /**
173
179
  * Prettify the html code
@@ -215,13 +221,13 @@ function capitalize(word) {
215
221
  /**
216
222
  * Converts promptbook in JSON format to string format
217
223
  *
218
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
219
- * @returns Promptbook in string format (.ptbk.md)
224
+ * @param pipelineJson Promptbook in JSON format (.book.json)
225
+ * @returns Promptbook in string format (.book.md)
220
226
  * @public exported from `@promptbook/core`
221
227
  */
222
228
  function pipelineJsonToString(pipelineJson) {
223
229
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
224
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
230
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
225
231
  var pipelineString = "# ".concat(title);
226
232
  if (description) {
227
233
  pipelineString += '\n\n';
@@ -231,8 +237,10 @@ function pipelineJsonToString(pipelineJson) {
231
237
  if (pipelineUrl) {
232
238
  commands.push("PIPELINE URL ".concat(pipelineUrl));
233
239
  }
234
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
235
- // TODO: [main] !!! This increase size of the bundle and is probbably not necessary
240
+ if (bookVersion !== "undefined") {
241
+ commands.push("BOOK VERSION ".concat(bookVersion));
242
+ }
243
+ // TODO: [main] !!!!!! This increase size of the bundle and is probbably not necessary
236
244
  pipelineString = prettifyMarkdown(pipelineString);
237
245
  try {
238
246
  for (var _g = __values(parameters.filter(function (_a) {
@@ -412,7 +420,7 @@ function templateParameterJsonToString(templateParameterJson) {
412
420
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
413
421
  * TODO: [🏛] Maybe make some markdown builder
414
422
  * TODO: [🏛] Escape all
415
- * TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
423
+ * TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
416
424
  */
417
425
 
418
426
  /**
@@ -792,7 +800,7 @@ function isValidPromptbookVersion(version) {
792
800
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
793
801
  return false;
794
802
  }
795
- // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
803
+ // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
796
804
  return true;
797
805
  }
798
806
 
@@ -892,7 +900,7 @@ function isValidPipelineUrl(url) {
892
900
  if (!url.startsWith('https://')) {
893
901
  return false;
894
902
  }
895
- if (!url.endsWith('.ptbk.md')) {
903
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
896
904
  return false;
897
905
  }
898
906
  if (url.includes('#')) {
@@ -961,9 +969,9 @@ function validatePipelineCore(pipeline) {
961
969
  // <- Note: [🚲]
962
970
  throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
963
971
  }
964
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
972
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
965
973
  // <- Note: [🚲]
966
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
974
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
967
975
  }
968
976
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
969
977
  if (!Array.isArray(pipeline.parameters)) {
@@ -2083,6 +2091,188 @@ $deepFreeze({
2083
2091
  },
2084
2092
  });
2085
2093
 
2094
+ /**
2095
+ * @@@
2096
+ *
2097
+ * @public exported from `@promptbook/utils`
2098
+ */
2099
+ function deepClone(objectValue) {
2100
+ return JSON.parse(JSON.stringify(objectValue));
2101
+ /*
2102
+ TODO: [🧠] Is there a better implementation?
2103
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
2104
+ > for (const propertyName of propertyNames) {
2105
+ > const value = (objectValue as really_any)[propertyName];
2106
+ > if (value && typeof value === 'object') {
2107
+ > deepClone(value);
2108
+ > }
2109
+ > }
2110
+ > return Object.assign({}, objectValue);
2111
+ */
2112
+ }
2113
+ /**
2114
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
2115
+ */
2116
+
2117
+ /**
2118
+ * Function `addUsage` will add multiple usages into one
2119
+ *
2120
+ * Note: If you provide 0 values, it returns ZERO_USAGE
2121
+ *
2122
+ * @public exported from `@promptbook/core`
2123
+ */
2124
+ function addUsage() {
2125
+ var usageItems = [];
2126
+ for (var _i = 0; _i < arguments.length; _i++) {
2127
+ usageItems[_i] = arguments[_i];
2128
+ }
2129
+ return usageItems.reduce(function (acc, item) {
2130
+ var e_1, _a, e_2, _b;
2131
+ var _c;
2132
+ acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
2133
+ try {
2134
+ for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
2135
+ var key = _e.value;
2136
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2137
+ //@ts-ignore
2138
+ if (item.input[key]) {
2139
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2140
+ //@ts-ignore
2141
+ acc.input[key].value += item.input[key].value || 0;
2142
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2143
+ //@ts-ignore
2144
+ if (item.input[key].isUncertain) {
2145
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2146
+ //@ts-ignore
2147
+ acc.input[key].isUncertain = true;
2148
+ }
2149
+ }
2150
+ }
2151
+ }
2152
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2153
+ finally {
2154
+ try {
2155
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2156
+ }
2157
+ finally { if (e_1) throw e_1.error; }
2158
+ }
2159
+ try {
2160
+ for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
2161
+ var key = _g.value;
2162
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2163
+ //@ts-ignore
2164
+ if (item.output[key]) {
2165
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2166
+ //@ts-ignore
2167
+ acc.output[key].value += item.output[key].value || 0;
2168
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2169
+ //@ts-ignore
2170
+ if (item.output[key].isUncertain) {
2171
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2172
+ //@ts-ignore
2173
+ acc.output[key].isUncertain = true;
2174
+ }
2175
+ }
2176
+ }
2177
+ }
2178
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2179
+ finally {
2180
+ try {
2181
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2182
+ }
2183
+ finally { if (e_2) throw e_2.error; }
2184
+ }
2185
+ return acc;
2186
+ }, deepClone(ZERO_USAGE));
2187
+ }
2188
+
2189
+ /**
2190
+ * Intercepts LLM tools and counts total usage of the tools
2191
+ *
2192
+ * @param llmTools LLM tools to be intercepted with usage counting
2193
+ * @returns LLM tools with same functionality with added total cost counting
2194
+ * @public exported from `@promptbook/core`
2195
+ */
2196
+ function countTotalUsage(llmTools) {
2197
+ var _this = this;
2198
+ var totalUsage = ZERO_USAGE;
2199
+ var proxyTools = {
2200
+ get title() {
2201
+ // TODO: [🧠] Maybe put here some suffix
2202
+ return llmTools.title;
2203
+ },
2204
+ get description() {
2205
+ // TODO: [🧠] Maybe put here some suffix
2206
+ return llmTools.description;
2207
+ },
2208
+ checkConfiguration: function () {
2209
+ return __awaiter(this, void 0, void 0, function () {
2210
+ return __generator(this, function (_a) {
2211
+ return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
2212
+ });
2213
+ });
2214
+ },
2215
+ listModels: function () {
2216
+ return /* not await */ llmTools.listModels();
2217
+ },
2218
+ getTotalUsage: function () {
2219
+ // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2220
+ return totalUsage;
2221
+ },
2222
+ };
2223
+ if (llmTools.callChatModel !== undefined) {
2224
+ proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2225
+ var promptResult;
2226
+ return __generator(this, function (_a) {
2227
+ switch (_a.label) {
2228
+ case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
2229
+ case 1:
2230
+ promptResult = _a.sent();
2231
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2232
+ return [2 /*return*/, promptResult];
2233
+ }
2234
+ });
2235
+ }); };
2236
+ }
2237
+ if (llmTools.callCompletionModel !== undefined) {
2238
+ proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2239
+ var promptResult;
2240
+ return __generator(this, function (_a) {
2241
+ switch (_a.label) {
2242
+ case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
2243
+ case 1:
2244
+ promptResult = _a.sent();
2245
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2246
+ return [2 /*return*/, promptResult];
2247
+ }
2248
+ });
2249
+ }); };
2250
+ }
2251
+ if (llmTools.callEmbeddingModel !== undefined) {
2252
+ proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2253
+ var promptResult;
2254
+ return __generator(this, function (_a) {
2255
+ switch (_a.label) {
2256
+ case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
2257
+ case 1:
2258
+ promptResult = _a.sent();
2259
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2260
+ return [2 /*return*/, promptResult];
2261
+ }
2262
+ });
2263
+ }); };
2264
+ }
2265
+ // <- Note: [🤖]
2266
+ return proxyTools;
2267
+ }
2268
+ /**
2269
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
2270
+ * TODO: [🧠] Is there some meaningfull way how to test this util
2271
+ * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
2272
+ * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
2273
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2274
+ */
2275
+
2086
2276
  /**
2087
2277
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
2088
2278
  *
@@ -2375,188 +2565,6 @@ function joinLlmExecutionTools() {
2375
2565
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2376
2566
  */
2377
2567
 
2378
- /**
2379
- * @@@
2380
- *
2381
- * @public exported from `@promptbook/utils`
2382
- */
2383
- function deepClone(objectValue) {
2384
- return JSON.parse(JSON.stringify(objectValue));
2385
- /*
2386
- TODO: [🧠] Is there a better implementation?
2387
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
2388
- > for (const propertyName of propertyNames) {
2389
- > const value = (objectValue as really_any)[propertyName];
2390
- > if (value && typeof value === 'object') {
2391
- > deepClone(value);
2392
- > }
2393
- > }
2394
- > return Object.assign({}, objectValue);
2395
- */
2396
- }
2397
- /**
2398
- * TODO: [🧠] Is there a way how to meaningfully test this utility
2399
- */
2400
-
2401
- /**
2402
- * Function `addUsage` will add multiple usages into one
2403
- *
2404
- * Note: If you provide 0 values, it returns ZERO_USAGE
2405
- *
2406
- * @public exported from `@promptbook/core`
2407
- */
2408
- function addUsage() {
2409
- var usageItems = [];
2410
- for (var _i = 0; _i < arguments.length; _i++) {
2411
- usageItems[_i] = arguments[_i];
2412
- }
2413
- return usageItems.reduce(function (acc, item) {
2414
- var e_1, _a, e_2, _b;
2415
- var _c;
2416
- acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
2417
- try {
2418
- for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
2419
- var key = _e.value;
2420
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2421
- //@ts-ignore
2422
- if (item.input[key]) {
2423
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2424
- //@ts-ignore
2425
- acc.input[key].value += item.input[key].value || 0;
2426
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2427
- //@ts-ignore
2428
- if (item.input[key].isUncertain) {
2429
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2430
- //@ts-ignore
2431
- acc.input[key].isUncertain = true;
2432
- }
2433
- }
2434
- }
2435
- }
2436
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2437
- finally {
2438
- try {
2439
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2440
- }
2441
- finally { if (e_1) throw e_1.error; }
2442
- }
2443
- try {
2444
- for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
2445
- var key = _g.value;
2446
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2447
- //@ts-ignore
2448
- if (item.output[key]) {
2449
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2450
- //@ts-ignore
2451
- acc.output[key].value += item.output[key].value || 0;
2452
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2453
- //@ts-ignore
2454
- if (item.output[key].isUncertain) {
2455
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2456
- //@ts-ignore
2457
- acc.output[key].isUncertain = true;
2458
- }
2459
- }
2460
- }
2461
- }
2462
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2463
- finally {
2464
- try {
2465
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2466
- }
2467
- finally { if (e_2) throw e_2.error; }
2468
- }
2469
- return acc;
2470
- }, deepClone(ZERO_USAGE));
2471
- }
2472
-
2473
- /**
2474
- * Intercepts LLM tools and counts total usage of the tools
2475
- *
2476
- * @param llmTools LLM tools to be intercepted with usage counting
2477
- * @returns LLM tools with same functionality with added total cost counting
2478
- * @public exported from `@promptbook/core`
2479
- */
2480
- function countTotalUsage(llmTools) {
2481
- var _this = this;
2482
- var totalUsage = ZERO_USAGE;
2483
- var proxyTools = {
2484
- get title() {
2485
- // TODO: [🧠] Maybe put here some suffix
2486
- return llmTools.title;
2487
- },
2488
- get description() {
2489
- // TODO: [🧠] Maybe put here some suffix
2490
- return llmTools.description;
2491
- },
2492
- checkConfiguration: function () {
2493
- return __awaiter(this, void 0, void 0, function () {
2494
- return __generator(this, function (_a) {
2495
- return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
2496
- });
2497
- });
2498
- },
2499
- listModels: function () {
2500
- return /* not await */ llmTools.listModels();
2501
- },
2502
- getTotalUsage: function () {
2503
- // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2504
- return totalUsage;
2505
- },
2506
- };
2507
- if (llmTools.callChatModel !== undefined) {
2508
- proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2509
- var promptResult;
2510
- return __generator(this, function (_a) {
2511
- switch (_a.label) {
2512
- case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
2513
- case 1:
2514
- promptResult = _a.sent();
2515
- totalUsage = addUsage(totalUsage, promptResult.usage);
2516
- return [2 /*return*/, promptResult];
2517
- }
2518
- });
2519
- }); };
2520
- }
2521
- if (llmTools.callCompletionModel !== undefined) {
2522
- proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2523
- var promptResult;
2524
- return __generator(this, function (_a) {
2525
- switch (_a.label) {
2526
- case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
2527
- case 1:
2528
- promptResult = _a.sent();
2529
- totalUsage = addUsage(totalUsage, promptResult.usage);
2530
- return [2 /*return*/, promptResult];
2531
- }
2532
- });
2533
- }); };
2534
- }
2535
- if (llmTools.callEmbeddingModel !== undefined) {
2536
- proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2537
- var promptResult;
2538
- return __generator(this, function (_a) {
2539
- switch (_a.label) {
2540
- case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
2541
- case 1:
2542
- promptResult = _a.sent();
2543
- totalUsage = addUsage(totalUsage, promptResult.usage);
2544
- return [2 /*return*/, promptResult];
2545
- }
2546
- });
2547
- }); };
2548
- }
2549
- // <- Note: [🤖]
2550
- return proxyTools;
2551
- }
2552
- /**
2553
- * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
2554
- * TODO: [🧠] Is there some meaningfull way how to test this util
2555
- * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
2556
- * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
2557
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2558
- */
2559
-
2560
2568
  /**
2561
2569
  * Takes an item or an array of items and returns an array of items
2562
2570
  *
@@ -2596,7 +2604,7 @@ function preparePersona(personaDescription, tools, options) {
2596
2604
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
2597
2605
  _b = createPipelineExecutor;
2598
2606
  _c = {};
2599
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
2607
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
2600
2608
  case 1:
2601
2609
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
2602
2610
  _c.tools = tools,
@@ -3008,16 +3016,13 @@ function isFileExisting(filename, fs) {
3008
3016
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3009
3017
  var _a;
3010
3018
  return __awaiter(this, void 0, void 0, function () {
3011
- var sourceContent, name, _b, _c, rootDirname, _d,
3012
- // <- TODO: process.cwd() if running in Node.js
3013
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3019
+ var sourceContent, name, _b, _c, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3014
3020
  return __generator(this, function (_e) {
3015
3021
  switch (_e.label) {
3016
3022
  case 0:
3017
3023
  sourceContent = knowledgeSource.sourceContent;
3018
3024
  name = knowledgeSource.name;
3019
- _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
3020
- TODO_USE(isVerbose);
3025
+ _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _b.isVerbose;
3021
3026
  if (!name) {
3022
3027
  name = sourceContentToName(sourceContent);
3023
3028
  }
@@ -3271,12 +3276,12 @@ TODO: [🧊] This is how it can look in future
3271
3276
  */
3272
3277
  function clonePipeline(pipeline) {
3273
3278
  // Note: Not using spread operator (...) because @@@
3274
- var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, promptbookVersion = pipeline.promptbookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
3279
+ var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
3275
3280
  return {
3276
3281
  pipelineUrl: pipelineUrl,
3277
3282
  sourceFile: sourceFile,
3278
3283
  title: title,
3279
- promptbookVersion: promptbookVersion,
3284
+ bookVersion: bookVersion,
3280
3285
  description: description,
3281
3286
  parameters: parameters,
3282
3287
  templates: templates,
@@ -3297,15 +3302,13 @@ function clonePipeline(pipeline) {
3297
3302
  */
3298
3303
  function prepareTemplates(pipeline, tools, options) {
3299
3304
  return __awaiter(this, void 0, void 0, function () {
3300
- var _a, maxParallelCount, templates, parameters, knowledgePiecesCount, templatesPrepared;
3305
+ var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
3301
3306
  var _this = this;
3302
3307
  return __generator(this, function (_b) {
3303
3308
  switch (_b.label) {
3304
3309
  case 0:
3305
3310
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
3306
- templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3307
- // TODO: [main] !! Apply examples to each template (if missing and is for the template defined)
3308
- TODO_USE(parameters);
3311
+ templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3309
3312
  templatesPrepared = new Array(templates.length);
3310
3313
  return [4 /*yield*/, forEachAsync(templates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
3311
3314
  var dependentParameterNames, preparedContent, preparedTemplate;
@@ -3375,7 +3378,7 @@ function preparePipeline(pipeline, tools, options) {
3375
3378
  currentPreparation = {
3376
3379
  id: 1,
3377
3380
  // TODO: [🍥]> date: $currentDate(),
3378
- promptbookVersion: PROMPTBOOK_VERSION,
3381
+ promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
3379
3382
  usage: ZERO_USAGE,
3380
3383
  };
3381
3384
  preparations = [
@@ -3699,22 +3702,12 @@ var CsvFormatDefinition = {
3699
3702
  formatName: 'CSV',
3700
3703
  aliases: ['SPREADSHEET', 'TABLE'],
3701
3704
  isValid: function (value, settings, schema) {
3702
- // TODO: Implement CSV validation
3703
- TODO_USE(value /* <- TODO: Use value here */);
3704
- TODO_USE(settings /* <- TODO: Use settings here */);
3705
- TODO_USE(schema /* <- TODO: Use schema here */);
3706
3705
  return true;
3707
3706
  },
3708
3707
  canBeValid: function (partialValue, settings, schema) {
3709
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
3710
- TODO_USE(settings /* <- TODO: Use settings here */);
3711
- TODO_USE(schema /* <- TODO: Use schema here */);
3712
3708
  return true;
3713
3709
  },
3714
3710
  heal: function (value, settings, schema) {
3715
- TODO_USE(value /* <- TODO: Use partialValue here */);
3716
- TODO_USE(settings /* <- TODO: Use settings here */);
3717
- TODO_USE(schema /* <- TODO: Use schema here */);
3718
3711
  throw new Error('Not implemented');
3719
3712
  },
3720
3713
  subvalueDefinitions: [
@@ -3833,20 +3826,12 @@ var JsonFormatDefinition = {
3833
3826
  formatName: 'JSON',
3834
3827
  mimeType: 'application/json',
3835
3828
  isValid: function (value, settings, schema) {
3836
- TODO_USE(schema /* <- TODO: Use schema here */);
3837
- TODO_USE(settings /* <- TODO: Use settings here */);
3838
3829
  return isValidJsonString(value);
3839
3830
  },
3840
3831
  canBeValid: function (partialValue, settings, schema) {
3841
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
3842
- TODO_USE(settings /* <- TODO: Use settings here */);
3843
- TODO_USE(schema /* <- TODO: Use schema here */);
3844
3832
  return true;
3845
3833
  },
3846
3834
  heal: function (value, settings, schema) {
3847
- TODO_USE(value /* <- TODO: Use partialValue here */);
3848
- TODO_USE(settings /* <- TODO: Use settings here */);
3849
- TODO_USE(schema /* <- TODO: Use schema here */);
3850
3835
  throw new Error('Not implemented');
3851
3836
  },
3852
3837
  subvalueDefinitions: [],
@@ -3928,21 +3913,12 @@ var XmlFormatDefinition = {
3928
3913
  formatName: 'XML',
3929
3914
  mimeType: 'application/xml',
3930
3915
  isValid: function (value, settings, schema) {
3931
- TODO_USE(value /* <- TODO: Use value here */);
3932
- TODO_USE(settings /* <- TODO: Use settings here */);
3933
- TODO_USE(schema /* <- TODO: Use schema here */);
3934
3916
  return true;
3935
3917
  },
3936
3918
  canBeValid: function (partialValue, settings, schema) {
3937
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
3938
- TODO_USE(settings /* <- TODO: Use settings here */);
3939
- TODO_USE(schema /* <- TODO: Use schema here */);
3940
3919
  return true;
3941
3920
  },
3942
3921
  heal: function (value, settings, schema) {
3943
- TODO_USE(value /* <- TODO: Use partialValue here */);
3944
- TODO_USE(settings /* <- TODO: Use settings here */);
3945
- TODO_USE(schema /* <- TODO: Use schema here */);
3946
3922
  throw new Error('Not implemented');
3947
3923
  },
3948
3924
  subvalueDefinitions: [],
@@ -4156,27 +4132,6 @@ function extractJsonBlock(markdown) {
4156
4132
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
4157
4133
  */
4158
4134
 
4159
- /**
4160
- * Just says that the variable is not used but should be kept
4161
- * No side effects.
4162
- *
4163
- * Note: It can be usefull for:
4164
- *
4165
- * 1) Suppressing eager optimization of unused imports
4166
- * 2) Suppressing eslint errors of unused variables in the tests
4167
- * 3) Keeping the type of the variable for type testing
4168
- *
4169
- * @param value any values
4170
- * @returns void
4171
- * @private within the repository
4172
- */
4173
- function keepUnused() {
4174
- var valuesToKeep = [];
4175
- for (var _i = 0; _i < arguments.length; _i++) {
4176
- valuesToKeep[_i] = arguments[_i];
4177
- }
4178
- }
4179
-
4180
4135
  /**
4181
4136
  * Replaces parameters in template with values from parameters object
4182
4137
  *
@@ -4289,10 +4244,12 @@ function countLines(text) {
4289
4244
  * @public exported from `@promptbook/utils`
4290
4245
  */
4291
4246
  function countPages(text) {
4292
- var sentencesPerPage = 5; // Assuming each page has 5 sentences
4293
- var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
4294
- var pageCount = Math.ceil(sentences.length / sentencesPerPage);
4295
- return pageCount;
4247
+ if (text === '') {
4248
+ return 0;
4249
+ }
4250
+ var pagesByLinesCount = Math.ceil(countLines(text) / 44);
4251
+ var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
4252
+ return Math.max(pagesByLinesCount, pagesByCharactersCount);
4296
4253
  }
4297
4254
 
4298
4255
  /**
@@ -4572,7 +4529,7 @@ function executeAttempts(options) {
4572
4529
  promptTitle: template.title,
4573
4530
  promptMessage: replaceParameters(template.description || '', parameters),
4574
4531
  defaultValue: replaceParameters(preparedContent, parameters),
4575
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
4532
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4576
4533
  placeholder: undefined,
4577
4534
  priority: priority,
4578
4535
  }))];
@@ -4670,7 +4627,6 @@ function executeAttempts(options) {
4670
4627
  $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
4671
4628
  }
4672
4629
  catch (error) {
4673
- keepUnused(error);
4674
4630
  throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
4675
4631
  /*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
4676
4632
  }
@@ -4848,7 +4804,6 @@ function executeFormatSubvalues(options) {
4848
4804
  function getContextForTemplate(template) {
4849
4805
  return __awaiter(this, void 0, void 0, function () {
4850
4806
  return __generator(this, function (_a) {
4851
- TODO_USE(template);
4852
4807
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
4853
4808
  });
4854
4809
  });
@@ -4861,11 +4816,9 @@ function getContextForTemplate(template) {
4861
4816
  */
4862
4817
  function getKnowledgeForTemplate(options) {
4863
4818
  return __awaiter(this, void 0, void 0, function () {
4864
- var preparedPipeline, template;
4819
+ var preparedPipeline;
4865
4820
  return __generator(this, function (_a) {
4866
- preparedPipeline = options.preparedPipeline, template = options.template;
4867
- // TODO: [♨] Implement Better - use real index and keyword search from `template` and {examples}
4868
- TODO_USE(template);
4821
+ preparedPipeline = options.preparedPipeline, options.template;
4869
4822
  return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4870
4823
  var content = _a.content;
4871
4824
  return "- ".concat(content);
@@ -4882,8 +4835,6 @@ function getKnowledgeForTemplate(options) {
4882
4835
  function getExamplesForTemplate(template) {
4883
4836
  return __awaiter(this, void 0, void 0, function () {
4884
4837
  return __generator(this, function (_a) {
4885
- // TODO: [♨] Implement Better - use real index and keyword search
4886
- TODO_USE(template);
4887
4838
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4888
4839
  });
4889
4840
  });
@@ -4902,13 +4853,13 @@ function getReservedParametersForTemplate(options) {
4902
4853
  switch (_b.label) {
4903
4854
  case 0:
4904
4855
  preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
4905
- return [4 /*yield*/, getContextForTemplate(template)];
4856
+ return [4 /*yield*/, getContextForTemplate()];
4906
4857
  case 1:
4907
4858
  context = _b.sent();
4908
4859
  return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
4909
4860
  case 2:
4910
4861
  knowledge = _b.sent();
4911
- return [4 /*yield*/, getExamplesForTemplate(template)];
4862
+ return [4 /*yield*/, getExamplesForTemplate()];
4912
4863
  case 3:
4913
4864
  examples = _b.sent();
4914
4865
  currentDate = new Date().toISOString();
@@ -5143,8 +5094,8 @@ function executePipeline(options) {
5143
5094
  executionReport = {
5144
5095
  pipelineUrl: preparedPipeline.pipelineUrl,
5145
5096
  title: preparedPipeline.title,
5146
- promptbookUsedVersion: PROMPTBOOK_VERSION,
5147
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
5097
+ promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
5098
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
5148
5099
  description: preparedPipeline.description,
5149
5100
  promptExecutions: [],
5150
5101
  };
@@ -5523,13 +5474,13 @@ var MarkdownScraper = /** @class */ (function () {
5523
5474
  */
5524
5475
  MarkdownScraper.prototype.scrape = function (source) {
5525
5476
  return __awaiter(this, void 0, void 0, function () {
5526
- var _a, _b, maxParallelCount, _c, isVerbose, llm, _llms, llmTools, collection, prepareKnowledgeFromMarkdownExecutor, _d, prepareTitleExecutor, _e, prepareKeywordsExecutor, _f, knowledgeContent, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
5477
+ var _a, _c, isVerbose, llm, _llms, llmTools, collection, prepareKnowledgeFromMarkdownExecutor, _d, prepareTitleExecutor, _e, prepareKeywordsExecutor, _f, knowledgeContent, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
5527
5478
  var _g, _h, _j;
5528
5479
  var _this = this;
5529
5480
  return __generator(this, function (_k) {
5530
5481
  switch (_k.label) {
5531
5482
  case 0:
5532
- _a = this.options, _b = _a.maxParallelCount, maxParallelCount = _b === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
5483
+ _a = this.options, _a.maxParallelCount, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
5533
5484
  llm = this.tools.llm;
5534
5485
  if (llm === undefined) {
5535
5486
  throw new MissingToolsError('LLM tools are required for scraping external files');
@@ -5537,11 +5488,10 @@ var MarkdownScraper = /** @class */ (function () {
5537
5488
  }
5538
5489
  _llms = arrayableToArray(llm);
5539
5490
  llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(_llms), false));
5540
- TODO_USE(maxParallelCount); // <- [🪂]
5541
5491
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
5542
5492
  _d = createPipelineExecutor;
5543
5493
  _g = {};
5544
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
5494
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
5545
5495
  case 1:
5546
5496
  prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
5547
5497
  _g.tools = {
@@ -5550,7 +5500,7 @@ var MarkdownScraper = /** @class */ (function () {
5550
5500
  _g)]);
5551
5501
  _e = createPipelineExecutor;
5552
5502
  _h = {};
5553
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md')];
5503
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
5554
5504
  case 2:
5555
5505
  prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
5556
5506
  _h.tools = {
@@ -5559,7 +5509,7 @@ var MarkdownScraper = /** @class */ (function () {
5559
5509
  _h)]);
5560
5510
  _f = createPipelineExecutor;
5561
5511
  _j = {};
5562
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md')];
5512
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
5563
5513
  case 3:
5564
5514
  prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
5565
5515
  _j.tools = {
@@ -5720,7 +5670,6 @@ var PdfScraper = /** @class */ (function () {
5720
5670
  PdfScraper.prototype.$convert = function (source) {
5721
5671
  return __awaiter(this, void 0, void 0, function () {
5722
5672
  return __generator(this, function (_a) {
5723
- TODO_USE(source);
5724
5673
  TODO_USE(this.options);
5725
5674
  throw new NotYetImplementedError('PDF conversion not yet implemented');
5726
5675
  });
@@ -5732,7 +5681,6 @@ var PdfScraper = /** @class */ (function () {
5732
5681
  PdfScraper.prototype.scrape = function (source) {
5733
5682
  return __awaiter(this, void 0, void 0, function () {
5734
5683
  return __generator(this, function (_a) {
5735
- TODO_USE(source);
5736
5684
  TODO_USE(this.options);
5737
5685
  /*
5738
5686
  const {
@@ -5778,5 +5726,5 @@ var _PdfScraperRegistration = $scrapersRegister.register(createPdfScraper);
5778
5726
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
5779
5727
  */
5780
5728
 
5781
- export { PROMPTBOOK_VERSION, PdfScraper, _PdfScraperRegistration, createPdfScraper };
5729
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, PdfScraper, _PdfScraperRegistration, createPdfScraper };
5782
5730
  //# sourceMappingURL=index.es.js.map