@promptbook/pdf 0.74.0-0 → 0.74.0-3

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 (35) hide show
  1. package/README.md +84 -16
  2. package/esm/index.es.js +209 -265
  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 +2 -2
  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 +4 -1
  26. package/esm/typings/src/commands/{PROMPTBOOK_VERSION/PromptbookVersionCommand.d.ts → BOOK_VERSION/BookVersionCommand.d.ts} +4 -4
  27. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +9 -0
  28. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
  29. package/esm/typings/src/commands/index.d.ts +1 -1
  30. package/esm/typings/src/version.d.ts +13 -2
  31. package/package.json +2 -2
  32. package/umd/index.umd.js +210 -265
  33. package/umd/index.umd.js.map +1 -1
  34. package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +0 -9
  35. /package/esm/typings/src/commands/{PROMPTBOOK_VERSION/promptbookVersionCommand.test.d.ts → BOOK_VERSION/bookVersionCommand.test.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-2';
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,10 +171,6 @@ 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
176
  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"}];
@@ -792,7 +798,7 @@ function isValidPromptbookVersion(version) {
792
798
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
793
799
  return false;
794
800
  }
795
- // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
801
+ // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
796
802
  return true;
797
803
  }
798
804
 
@@ -2083,6 +2089,188 @@ $deepFreeze({
2083
2089
  },
2084
2090
  });
2085
2091
 
2092
+ /**
2093
+ * @@@
2094
+ *
2095
+ * @public exported from `@promptbook/utils`
2096
+ */
2097
+ function deepClone(objectValue) {
2098
+ return JSON.parse(JSON.stringify(objectValue));
2099
+ /*
2100
+ TODO: [🧠] Is there a better implementation?
2101
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
2102
+ > for (const propertyName of propertyNames) {
2103
+ > const value = (objectValue as really_any)[propertyName];
2104
+ > if (value && typeof value === 'object') {
2105
+ > deepClone(value);
2106
+ > }
2107
+ > }
2108
+ > return Object.assign({}, objectValue);
2109
+ */
2110
+ }
2111
+ /**
2112
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
2113
+ */
2114
+
2115
+ /**
2116
+ * Function `addUsage` will add multiple usages into one
2117
+ *
2118
+ * Note: If you provide 0 values, it returns ZERO_USAGE
2119
+ *
2120
+ * @public exported from `@promptbook/core`
2121
+ */
2122
+ function addUsage() {
2123
+ var usageItems = [];
2124
+ for (var _i = 0; _i < arguments.length; _i++) {
2125
+ usageItems[_i] = arguments[_i];
2126
+ }
2127
+ return usageItems.reduce(function (acc, item) {
2128
+ var e_1, _a, e_2, _b;
2129
+ var _c;
2130
+ acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
2131
+ try {
2132
+ for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
2133
+ var key = _e.value;
2134
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2135
+ //@ts-ignore
2136
+ if (item.input[key]) {
2137
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2138
+ //@ts-ignore
2139
+ acc.input[key].value += item.input[key].value || 0;
2140
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2141
+ //@ts-ignore
2142
+ if (item.input[key].isUncertain) {
2143
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2144
+ //@ts-ignore
2145
+ acc.input[key].isUncertain = true;
2146
+ }
2147
+ }
2148
+ }
2149
+ }
2150
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2151
+ finally {
2152
+ try {
2153
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2154
+ }
2155
+ finally { if (e_1) throw e_1.error; }
2156
+ }
2157
+ try {
2158
+ for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
2159
+ var key = _g.value;
2160
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2161
+ //@ts-ignore
2162
+ if (item.output[key]) {
2163
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2164
+ //@ts-ignore
2165
+ acc.output[key].value += item.output[key].value || 0;
2166
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2167
+ //@ts-ignore
2168
+ if (item.output[key].isUncertain) {
2169
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2170
+ //@ts-ignore
2171
+ acc.output[key].isUncertain = true;
2172
+ }
2173
+ }
2174
+ }
2175
+ }
2176
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2177
+ finally {
2178
+ try {
2179
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2180
+ }
2181
+ finally { if (e_2) throw e_2.error; }
2182
+ }
2183
+ return acc;
2184
+ }, deepClone(ZERO_USAGE));
2185
+ }
2186
+
2187
+ /**
2188
+ * Intercepts LLM tools and counts total usage of the tools
2189
+ *
2190
+ * @param llmTools LLM tools to be intercepted with usage counting
2191
+ * @returns LLM tools with same functionality with added total cost counting
2192
+ * @public exported from `@promptbook/core`
2193
+ */
2194
+ function countTotalUsage(llmTools) {
2195
+ var _this = this;
2196
+ var totalUsage = ZERO_USAGE;
2197
+ var proxyTools = {
2198
+ get title() {
2199
+ // TODO: [🧠] Maybe put here some suffix
2200
+ return llmTools.title;
2201
+ },
2202
+ get description() {
2203
+ // TODO: [🧠] Maybe put here some suffix
2204
+ return llmTools.description;
2205
+ },
2206
+ checkConfiguration: function () {
2207
+ return __awaiter(this, void 0, void 0, function () {
2208
+ return __generator(this, function (_a) {
2209
+ return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
2210
+ });
2211
+ });
2212
+ },
2213
+ listModels: function () {
2214
+ return /* not await */ llmTools.listModels();
2215
+ },
2216
+ getTotalUsage: function () {
2217
+ // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2218
+ return totalUsage;
2219
+ },
2220
+ };
2221
+ if (llmTools.callChatModel !== undefined) {
2222
+ proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2223
+ var promptResult;
2224
+ return __generator(this, function (_a) {
2225
+ switch (_a.label) {
2226
+ case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
2227
+ case 1:
2228
+ promptResult = _a.sent();
2229
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2230
+ return [2 /*return*/, promptResult];
2231
+ }
2232
+ });
2233
+ }); };
2234
+ }
2235
+ if (llmTools.callCompletionModel !== undefined) {
2236
+ proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2237
+ var promptResult;
2238
+ return __generator(this, function (_a) {
2239
+ switch (_a.label) {
2240
+ case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
2241
+ case 1:
2242
+ promptResult = _a.sent();
2243
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2244
+ return [2 /*return*/, promptResult];
2245
+ }
2246
+ });
2247
+ }); };
2248
+ }
2249
+ if (llmTools.callEmbeddingModel !== undefined) {
2250
+ proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2251
+ var promptResult;
2252
+ return __generator(this, function (_a) {
2253
+ switch (_a.label) {
2254
+ case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
2255
+ case 1:
2256
+ promptResult = _a.sent();
2257
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2258
+ return [2 /*return*/, promptResult];
2259
+ }
2260
+ });
2261
+ }); };
2262
+ }
2263
+ // <- Note: [🤖]
2264
+ return proxyTools;
2265
+ }
2266
+ /**
2267
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
2268
+ * TODO: [🧠] Is there some meaningfull way how to test this util
2269
+ * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
2270
+ * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
2271
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2272
+ */
2273
+
2086
2274
  /**
2087
2275
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
2088
2276
  *
@@ -2375,188 +2563,6 @@ function joinLlmExecutionTools() {
2375
2563
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2376
2564
  */
2377
2565
 
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
2566
  /**
2561
2567
  * Takes an item or an array of items and returns an array of items
2562
2568
  *
@@ -3008,16 +3014,13 @@ function isFileExisting(filename, fs) {
3008
3014
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3009
3015
  var _a;
3010
3016
  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;
3017
+ var sourceContent, name, _b, _c, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3014
3018
  return __generator(this, function (_e) {
3015
3019
  switch (_e.label) {
3016
3020
  case 0:
3017
3021
  sourceContent = knowledgeSource.sourceContent;
3018
3022
  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);
3023
+ _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _b.isVerbose;
3021
3024
  if (!name) {
3022
3025
  name = sourceContentToName(sourceContent);
3023
3026
  }
@@ -3297,15 +3300,13 @@ function clonePipeline(pipeline) {
3297
3300
  */
3298
3301
  function prepareTemplates(pipeline, tools, options) {
3299
3302
  return __awaiter(this, void 0, void 0, function () {
3300
- var _a, maxParallelCount, templates, parameters, knowledgePiecesCount, templatesPrepared;
3303
+ var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
3301
3304
  var _this = this;
3302
3305
  return __generator(this, function (_b) {
3303
3306
  switch (_b.label) {
3304
3307
  case 0:
3305
3308
  _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);
3309
+ templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3309
3310
  templatesPrepared = new Array(templates.length);
3310
3311
  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
3312
  var dependentParameterNames, preparedContent, preparedTemplate;
@@ -3375,7 +3376,7 @@ function preparePipeline(pipeline, tools, options) {
3375
3376
  currentPreparation = {
3376
3377
  id: 1,
3377
3378
  // TODO: [🍥]> date: $currentDate(),
3378
- promptbookVersion: PROMPTBOOK_VERSION,
3379
+ promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
3379
3380
  usage: ZERO_USAGE,
3380
3381
  };
3381
3382
  preparations = [
@@ -3699,22 +3700,12 @@ var CsvFormatDefinition = {
3699
3700
  formatName: 'CSV',
3700
3701
  aliases: ['SPREADSHEET', 'TABLE'],
3701
3702
  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
3703
  return true;
3707
3704
  },
3708
3705
  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
3706
  return true;
3713
3707
  },
3714
3708
  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
3709
  throw new Error('Not implemented');
3719
3710
  },
3720
3711
  subvalueDefinitions: [
@@ -3833,20 +3824,12 @@ var JsonFormatDefinition = {
3833
3824
  formatName: 'JSON',
3834
3825
  mimeType: 'application/json',
3835
3826
  isValid: function (value, settings, schema) {
3836
- TODO_USE(schema /* <- TODO: Use schema here */);
3837
- TODO_USE(settings /* <- TODO: Use settings here */);
3838
3827
  return isValidJsonString(value);
3839
3828
  },
3840
3829
  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
3830
  return true;
3845
3831
  },
3846
3832
  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
3833
  throw new Error('Not implemented');
3851
3834
  },
3852
3835
  subvalueDefinitions: [],
@@ -3928,21 +3911,12 @@ var XmlFormatDefinition = {
3928
3911
  formatName: 'XML',
3929
3912
  mimeType: 'application/xml',
3930
3913
  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
3914
  return true;
3935
3915
  },
3936
3916
  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
3917
  return true;
3941
3918
  },
3942
3919
  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
3920
  throw new Error('Not implemented');
3947
3921
  },
3948
3922
  subvalueDefinitions: [],
@@ -4156,27 +4130,6 @@ function extractJsonBlock(markdown) {
4156
4130
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
4157
4131
  */
4158
4132
 
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
4133
  /**
4181
4134
  * Replaces parameters in template with values from parameters object
4182
4135
  *
@@ -4670,7 +4623,6 @@ function executeAttempts(options) {
4670
4623
  $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
4671
4624
  }
4672
4625
  catch (error) {
4673
- keepUnused(error);
4674
4626
  throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
4675
4627
  /*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
4676
4628
  }
@@ -4848,7 +4800,6 @@ function executeFormatSubvalues(options) {
4848
4800
  function getContextForTemplate(template) {
4849
4801
  return __awaiter(this, void 0, void 0, function () {
4850
4802
  return __generator(this, function (_a) {
4851
- TODO_USE(template);
4852
4803
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
4853
4804
  });
4854
4805
  });
@@ -4861,11 +4812,9 @@ function getContextForTemplate(template) {
4861
4812
  */
4862
4813
  function getKnowledgeForTemplate(options) {
4863
4814
  return __awaiter(this, void 0, void 0, function () {
4864
- var preparedPipeline, template;
4815
+ var preparedPipeline;
4865
4816
  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);
4817
+ preparedPipeline = options.preparedPipeline, options.template;
4869
4818
  return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4870
4819
  var content = _a.content;
4871
4820
  return "- ".concat(content);
@@ -4882,8 +4831,6 @@ function getKnowledgeForTemplate(options) {
4882
4831
  function getExamplesForTemplate(template) {
4883
4832
  return __awaiter(this, void 0, void 0, function () {
4884
4833
  return __generator(this, function (_a) {
4885
- // TODO: [♨] Implement Better - use real index and keyword search
4886
- TODO_USE(template);
4887
4834
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4888
4835
  });
4889
4836
  });
@@ -4902,13 +4849,13 @@ function getReservedParametersForTemplate(options) {
4902
4849
  switch (_b.label) {
4903
4850
  case 0:
4904
4851
  preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
4905
- return [4 /*yield*/, getContextForTemplate(template)];
4852
+ return [4 /*yield*/, getContextForTemplate()];
4906
4853
  case 1:
4907
4854
  context = _b.sent();
4908
4855
  return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
4909
4856
  case 2:
4910
4857
  knowledge = _b.sent();
4911
- return [4 /*yield*/, getExamplesForTemplate(template)];
4858
+ return [4 /*yield*/, getExamplesForTemplate()];
4912
4859
  case 3:
4913
4860
  examples = _b.sent();
4914
4861
  currentDate = new Date().toISOString();
@@ -5143,7 +5090,7 @@ function executePipeline(options) {
5143
5090
  executionReport = {
5144
5091
  pipelineUrl: preparedPipeline.pipelineUrl,
5145
5092
  title: preparedPipeline.title,
5146
- promptbookUsedVersion: PROMPTBOOK_VERSION,
5093
+ promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
5147
5094
  promptbookRequestedVersion: preparedPipeline.promptbookVersion,
5148
5095
  description: preparedPipeline.description,
5149
5096
  promptExecutions: [],
@@ -5523,13 +5470,13 @@ var MarkdownScraper = /** @class */ (function () {
5523
5470
  */
5524
5471
  MarkdownScraper.prototype.scrape = function (source) {
5525
5472
  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;
5473
+ var _a, _c, isVerbose, llm, _llms, llmTools, collection, prepareKnowledgeFromMarkdownExecutor, _d, prepareTitleExecutor, _e, prepareKeywordsExecutor, _f, knowledgeContent, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
5527
5474
  var _g, _h, _j;
5528
5475
  var _this = this;
5529
5476
  return __generator(this, function (_k) {
5530
5477
  switch (_k.label) {
5531
5478
  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;
5479
+ _a = this.options, _a.maxParallelCount, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
5533
5480
  llm = this.tools.llm;
5534
5481
  if (llm === undefined) {
5535
5482
  throw new MissingToolsError('LLM tools are required for scraping external files');
@@ -5537,7 +5484,6 @@ var MarkdownScraper = /** @class */ (function () {
5537
5484
  }
5538
5485
  _llms = arrayableToArray(llm);
5539
5486
  llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(_llms), false));
5540
- TODO_USE(maxParallelCount); // <- [🪂]
5541
5487
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
5542
5488
  _d = createPipelineExecutor;
5543
5489
  _g = {};
@@ -5720,7 +5666,6 @@ var PdfScraper = /** @class */ (function () {
5720
5666
  PdfScraper.prototype.$convert = function (source) {
5721
5667
  return __awaiter(this, void 0, void 0, function () {
5722
5668
  return __generator(this, function (_a) {
5723
- TODO_USE(source);
5724
5669
  TODO_USE(this.options);
5725
5670
  throw new NotYetImplementedError('PDF conversion not yet implemented');
5726
5671
  });
@@ -5732,7 +5677,6 @@ var PdfScraper = /** @class */ (function () {
5732
5677
  PdfScraper.prototype.scrape = function (source) {
5733
5678
  return __awaiter(this, void 0, void 0, function () {
5734
5679
  return __generator(this, function (_a) {
5735
- TODO_USE(source);
5736
5680
  TODO_USE(this.options);
5737
5681
  /*
5738
5682
  const {
@@ -5778,5 +5722,5 @@ var _PdfScraperRegistration = $scrapersRegister.register(createPdfScraper);
5778
5722
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
5779
5723
  */
5780
5724
 
5781
- export { PROMPTBOOK_VERSION, PdfScraper, _PdfScraperRegistration, createPdfScraper };
5725
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, PdfScraper, _PdfScraperRegistration, createPdfScraper };
5782
5726
  //# sourceMappingURL=index.es.js.map