@promptbook/pdf 0.73.0 → 0.74.0-2

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 +130 -3
  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 +13 -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/umd/index.umd.js CHANGED
@@ -12,10 +12,20 @@
12
12
 
13
13
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
14
14
  /**
15
- * The version of the Promptbook library
15
+ * The version of the Book language
16
+ *
17
+ * @see https://github.com/webgptorg/book
18
+ */
19
+ var BOOK_LANGUAGE_VERSION = '1.0.0';
20
+ /**
21
+ * The version of the Promptbook engine
22
+ *
23
+ * @see https://github.com/webgptorg/promptbook
24
+ */
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-1';
26
+ /**
27
+ * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
16
28
  */
17
- var PROMPTBOOK_VERSION = '0.72.0';
18
- // TODO: [main] !!!! List here all the versions and annotate + put into script
19
29
 
20
30
  /*! *****************************************************************************
21
31
  Copyright (c) Microsoft Corporation.
@@ -163,10 +173,6 @@
163
173
  * @private within the repository
164
174
  */
165
175
  function TODO_USE() {
166
- var value = [];
167
- for (var _i = 0; _i < arguments.length; _i++) {
168
- value[_i] = arguments[_i];
169
- }
170
176
  }
171
177
 
172
178
  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"}];
@@ -794,7 +800,7 @@
794
800
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
795
801
  return false;
796
802
  }
797
- // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
803
+ // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
798
804
  return true;
799
805
  }
800
806
 
@@ -2085,6 +2091,188 @@
2085
2091
  },
2086
2092
  });
2087
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
+
2088
2276
  /**
2089
2277
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
2090
2278
  *
@@ -2377,188 +2565,6 @@
2377
2565
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2378
2566
  */
2379
2567
 
2380
- /**
2381
- * @@@
2382
- *
2383
- * @public exported from `@promptbook/utils`
2384
- */
2385
- function deepClone(objectValue) {
2386
- return JSON.parse(JSON.stringify(objectValue));
2387
- /*
2388
- TODO: [🧠] Is there a better implementation?
2389
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
2390
- > for (const propertyName of propertyNames) {
2391
- > const value = (objectValue as really_any)[propertyName];
2392
- > if (value && typeof value === 'object') {
2393
- > deepClone(value);
2394
- > }
2395
- > }
2396
- > return Object.assign({}, objectValue);
2397
- */
2398
- }
2399
- /**
2400
- * TODO: [🧠] Is there a way how to meaningfully test this utility
2401
- */
2402
-
2403
- /**
2404
- * Function `addUsage` will add multiple usages into one
2405
- *
2406
- * Note: If you provide 0 values, it returns ZERO_USAGE
2407
- *
2408
- * @public exported from `@promptbook/core`
2409
- */
2410
- function addUsage() {
2411
- var usageItems = [];
2412
- for (var _i = 0; _i < arguments.length; _i++) {
2413
- usageItems[_i] = arguments[_i];
2414
- }
2415
- return usageItems.reduce(function (acc, item) {
2416
- var e_1, _a, e_2, _b;
2417
- var _c;
2418
- acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
2419
- try {
2420
- for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
2421
- var key = _e.value;
2422
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2423
- //@ts-ignore
2424
- if (item.input[key]) {
2425
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2426
- //@ts-ignore
2427
- acc.input[key].value += item.input[key].value || 0;
2428
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2429
- //@ts-ignore
2430
- if (item.input[key].isUncertain) {
2431
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2432
- //@ts-ignore
2433
- acc.input[key].isUncertain = true;
2434
- }
2435
- }
2436
- }
2437
- }
2438
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2439
- finally {
2440
- try {
2441
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2442
- }
2443
- finally { if (e_1) throw e_1.error; }
2444
- }
2445
- try {
2446
- for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
2447
- var key = _g.value;
2448
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2449
- //@ts-ignore
2450
- if (item.output[key]) {
2451
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2452
- //@ts-ignore
2453
- acc.output[key].value += item.output[key].value || 0;
2454
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2455
- //@ts-ignore
2456
- if (item.output[key].isUncertain) {
2457
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2458
- //@ts-ignore
2459
- acc.output[key].isUncertain = true;
2460
- }
2461
- }
2462
- }
2463
- }
2464
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2465
- finally {
2466
- try {
2467
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2468
- }
2469
- finally { if (e_2) throw e_2.error; }
2470
- }
2471
- return acc;
2472
- }, deepClone(ZERO_USAGE));
2473
- }
2474
-
2475
- /**
2476
- * Intercepts LLM tools and counts total usage of the tools
2477
- *
2478
- * @param llmTools LLM tools to be intercepted with usage counting
2479
- * @returns LLM tools with same functionality with added total cost counting
2480
- * @public exported from `@promptbook/core`
2481
- */
2482
- function countTotalUsage(llmTools) {
2483
- var _this = this;
2484
- var totalUsage = ZERO_USAGE;
2485
- var proxyTools = {
2486
- get title() {
2487
- // TODO: [🧠] Maybe put here some suffix
2488
- return llmTools.title;
2489
- },
2490
- get description() {
2491
- // TODO: [🧠] Maybe put here some suffix
2492
- return llmTools.description;
2493
- },
2494
- checkConfiguration: function () {
2495
- return __awaiter(this, void 0, void 0, function () {
2496
- return __generator(this, function (_a) {
2497
- return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
2498
- });
2499
- });
2500
- },
2501
- listModels: function () {
2502
- return /* not await */ llmTools.listModels();
2503
- },
2504
- getTotalUsage: function () {
2505
- // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2506
- return totalUsage;
2507
- },
2508
- };
2509
- if (llmTools.callChatModel !== undefined) {
2510
- proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2511
- var promptResult;
2512
- return __generator(this, function (_a) {
2513
- switch (_a.label) {
2514
- case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
2515
- case 1:
2516
- promptResult = _a.sent();
2517
- totalUsage = addUsage(totalUsage, promptResult.usage);
2518
- return [2 /*return*/, promptResult];
2519
- }
2520
- });
2521
- }); };
2522
- }
2523
- if (llmTools.callCompletionModel !== undefined) {
2524
- proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2525
- var promptResult;
2526
- return __generator(this, function (_a) {
2527
- switch (_a.label) {
2528
- case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
2529
- case 1:
2530
- promptResult = _a.sent();
2531
- totalUsage = addUsage(totalUsage, promptResult.usage);
2532
- return [2 /*return*/, promptResult];
2533
- }
2534
- });
2535
- }); };
2536
- }
2537
- if (llmTools.callEmbeddingModel !== undefined) {
2538
- proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2539
- var promptResult;
2540
- return __generator(this, function (_a) {
2541
- switch (_a.label) {
2542
- case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
2543
- case 1:
2544
- promptResult = _a.sent();
2545
- totalUsage = addUsage(totalUsage, promptResult.usage);
2546
- return [2 /*return*/, promptResult];
2547
- }
2548
- });
2549
- }); };
2550
- }
2551
- // <- Note: [🤖]
2552
- return proxyTools;
2553
- }
2554
- /**
2555
- * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
2556
- * TODO: [🧠] Is there some meaningfull way how to test this util
2557
- * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
2558
- * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
2559
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2560
- */
2561
-
2562
2568
  /**
2563
2569
  * Takes an item or an array of items and returns an array of items
2564
2570
  *
@@ -3010,16 +3016,13 @@
3010
3016
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3011
3017
  var _a;
3012
3018
  return __awaiter(this, void 0, void 0, function () {
3013
- var sourceContent, name, _b, _c, rootDirname, _d,
3014
- // <- TODO: process.cwd() if running in Node.js
3015
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3019
+ var sourceContent, name, _b, _c, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3016
3020
  return __generator(this, function (_e) {
3017
3021
  switch (_e.label) {
3018
3022
  case 0:
3019
3023
  sourceContent = knowledgeSource.sourceContent;
3020
3024
  name = knowledgeSource.name;
3021
- _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
3022
- TODO_USE(isVerbose);
3025
+ _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _b.isVerbose;
3023
3026
  if (!name) {
3024
3027
  name = sourceContentToName(sourceContent);
3025
3028
  }
@@ -3299,15 +3302,13 @@
3299
3302
  */
3300
3303
  function prepareTemplates(pipeline, tools, options) {
3301
3304
  return __awaiter(this, void 0, void 0, function () {
3302
- var _a, maxParallelCount, templates, parameters, knowledgePiecesCount, templatesPrepared;
3305
+ var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
3303
3306
  var _this = this;
3304
3307
  return __generator(this, function (_b) {
3305
3308
  switch (_b.label) {
3306
3309
  case 0:
3307
3310
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
3308
- templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3309
- // TODO: [main] !! Apply examples to each template (if missing and is for the template defined)
3310
- TODO_USE(parameters);
3311
+ templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3311
3312
  templatesPrepared = new Array(templates.length);
3312
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 () {
3313
3314
  var dependentParameterNames, preparedContent, preparedTemplate;
@@ -3377,7 +3378,7 @@
3377
3378
  currentPreparation = {
3378
3379
  id: 1,
3379
3380
  // TODO: [🍥]> date: $currentDate(),
3380
- promptbookVersion: PROMPTBOOK_VERSION,
3381
+ promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
3381
3382
  usage: ZERO_USAGE,
3382
3383
  };
3383
3384
  preparations = [
@@ -3701,22 +3702,12 @@
3701
3702
  formatName: 'CSV',
3702
3703
  aliases: ['SPREADSHEET', 'TABLE'],
3703
3704
  isValid: function (value, settings, schema) {
3704
- // TODO: Implement CSV validation
3705
- TODO_USE(value /* <- TODO: Use value here */);
3706
- TODO_USE(settings /* <- TODO: Use settings here */);
3707
- TODO_USE(schema /* <- TODO: Use schema here */);
3708
3705
  return true;
3709
3706
  },
3710
3707
  canBeValid: function (partialValue, settings, schema) {
3711
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
3712
- TODO_USE(settings /* <- TODO: Use settings here */);
3713
- TODO_USE(schema /* <- TODO: Use schema here */);
3714
3708
  return true;
3715
3709
  },
3716
3710
  heal: function (value, settings, schema) {
3717
- TODO_USE(value /* <- TODO: Use partialValue here */);
3718
- TODO_USE(settings /* <- TODO: Use settings here */);
3719
- TODO_USE(schema /* <- TODO: Use schema here */);
3720
3711
  throw new Error('Not implemented');
3721
3712
  },
3722
3713
  subvalueDefinitions: [
@@ -3835,20 +3826,12 @@
3835
3826
  formatName: 'JSON',
3836
3827
  mimeType: 'application/json',
3837
3828
  isValid: function (value, settings, schema) {
3838
- TODO_USE(schema /* <- TODO: Use schema here */);
3839
- TODO_USE(settings /* <- TODO: Use settings here */);
3840
3829
  return isValidJsonString(value);
3841
3830
  },
3842
3831
  canBeValid: function (partialValue, settings, schema) {
3843
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
3844
- TODO_USE(settings /* <- TODO: Use settings here */);
3845
- TODO_USE(schema /* <- TODO: Use schema here */);
3846
3832
  return true;
3847
3833
  },
3848
3834
  heal: function (value, settings, schema) {
3849
- TODO_USE(value /* <- TODO: Use partialValue here */);
3850
- TODO_USE(settings /* <- TODO: Use settings here */);
3851
- TODO_USE(schema /* <- TODO: Use schema here */);
3852
3835
  throw new Error('Not implemented');
3853
3836
  },
3854
3837
  subvalueDefinitions: [],
@@ -3930,21 +3913,12 @@
3930
3913
  formatName: 'XML',
3931
3914
  mimeType: 'application/xml',
3932
3915
  isValid: function (value, settings, schema) {
3933
- TODO_USE(value /* <- TODO: Use value here */);
3934
- TODO_USE(settings /* <- TODO: Use settings here */);
3935
- TODO_USE(schema /* <- TODO: Use schema here */);
3936
3916
  return true;
3937
3917
  },
3938
3918
  canBeValid: function (partialValue, settings, schema) {
3939
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
3940
- TODO_USE(settings /* <- TODO: Use settings here */);
3941
- TODO_USE(schema /* <- TODO: Use schema here */);
3942
3919
  return true;
3943
3920
  },
3944
3921
  heal: function (value, settings, schema) {
3945
- TODO_USE(value /* <- TODO: Use partialValue here */);
3946
- TODO_USE(settings /* <- TODO: Use settings here */);
3947
- TODO_USE(schema /* <- TODO: Use schema here */);
3948
3922
  throw new Error('Not implemented');
3949
3923
  },
3950
3924
  subvalueDefinitions: [],
@@ -4158,27 +4132,6 @@
4158
4132
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
4159
4133
  */
4160
4134
 
4161
- /**
4162
- * Just says that the variable is not used but should be kept
4163
- * No side effects.
4164
- *
4165
- * Note: It can be usefull for:
4166
- *
4167
- * 1) Suppressing eager optimization of unused imports
4168
- * 2) Suppressing eslint errors of unused variables in the tests
4169
- * 3) Keeping the type of the variable for type testing
4170
- *
4171
- * @param value any values
4172
- * @returns void
4173
- * @private within the repository
4174
- */
4175
- function keepUnused() {
4176
- var valuesToKeep = [];
4177
- for (var _i = 0; _i < arguments.length; _i++) {
4178
- valuesToKeep[_i] = arguments[_i];
4179
- }
4180
- }
4181
-
4182
4135
  /**
4183
4136
  * Replaces parameters in template with values from parameters object
4184
4137
  *
@@ -4672,7 +4625,6 @@
4672
4625
  $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
4673
4626
  }
4674
4627
  catch (error) {
4675
- keepUnused(error);
4676
4628
  throw new ExpectError(spaceTrim.spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
4677
4629
  /*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
4678
4630
  }
@@ -4850,7 +4802,6 @@
4850
4802
  function getContextForTemplate(template) {
4851
4803
  return __awaiter(this, void 0, void 0, function () {
4852
4804
  return __generator(this, function (_a) {
4853
- TODO_USE(template);
4854
4805
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
4855
4806
  });
4856
4807
  });
@@ -4863,11 +4814,9 @@
4863
4814
  */
4864
4815
  function getKnowledgeForTemplate(options) {
4865
4816
  return __awaiter(this, void 0, void 0, function () {
4866
- var preparedPipeline, template;
4817
+ var preparedPipeline;
4867
4818
  return __generator(this, function (_a) {
4868
- preparedPipeline = options.preparedPipeline, template = options.template;
4869
- // TODO: [♨] Implement Better - use real index and keyword search from `template` and {examples}
4870
- TODO_USE(template);
4819
+ preparedPipeline = options.preparedPipeline, options.template;
4871
4820
  return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4872
4821
  var content = _a.content;
4873
4822
  return "- ".concat(content);
@@ -4884,8 +4833,6 @@
4884
4833
  function getExamplesForTemplate(template) {
4885
4834
  return __awaiter(this, void 0, void 0, function () {
4886
4835
  return __generator(this, function (_a) {
4887
- // TODO: [♨] Implement Better - use real index and keyword search
4888
- TODO_USE(template);
4889
4836
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4890
4837
  });
4891
4838
  });
@@ -4904,13 +4851,13 @@
4904
4851
  switch (_b.label) {
4905
4852
  case 0:
4906
4853
  preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
4907
- return [4 /*yield*/, getContextForTemplate(template)];
4854
+ return [4 /*yield*/, getContextForTemplate()];
4908
4855
  case 1:
4909
4856
  context = _b.sent();
4910
4857
  return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
4911
4858
  case 2:
4912
4859
  knowledge = _b.sent();
4913
- return [4 /*yield*/, getExamplesForTemplate(template)];
4860
+ return [4 /*yield*/, getExamplesForTemplate()];
4914
4861
  case 3:
4915
4862
  examples = _b.sent();
4916
4863
  currentDate = new Date().toISOString();
@@ -5145,7 +5092,7 @@
5145
5092
  executionReport = {
5146
5093
  pipelineUrl: preparedPipeline.pipelineUrl,
5147
5094
  title: preparedPipeline.title,
5148
- promptbookUsedVersion: PROMPTBOOK_VERSION,
5095
+ promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
5149
5096
  promptbookRequestedVersion: preparedPipeline.promptbookVersion,
5150
5097
  description: preparedPipeline.description,
5151
5098
  promptExecutions: [],
@@ -5525,13 +5472,13 @@
5525
5472
  */
5526
5473
  MarkdownScraper.prototype.scrape = function (source) {
5527
5474
  return __awaiter(this, void 0, void 0, function () {
5528
- var _a, _b, maxParallelCount, _c, isVerbose, llm, _llms, llmTools, collection, prepareKnowledgeFromMarkdownExecutor, _d, prepareTitleExecutor, _e, prepareKeywordsExecutor, _f, knowledgeContent, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
5475
+ var _a, _c, isVerbose, llm, _llms, llmTools, collection, prepareKnowledgeFromMarkdownExecutor, _d, prepareTitleExecutor, _e, prepareKeywordsExecutor, _f, knowledgeContent, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
5529
5476
  var _g, _h, _j;
5530
5477
  var _this = this;
5531
5478
  return __generator(this, function (_k) {
5532
5479
  switch (_k.label) {
5533
5480
  case 0:
5534
- _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;
5481
+ _a = this.options, _a.maxParallelCount, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
5535
5482
  llm = this.tools.llm;
5536
5483
  if (llm === undefined) {
5537
5484
  throw new MissingToolsError('LLM tools are required for scraping external files');
@@ -5539,7 +5486,6 @@
5539
5486
  }
5540
5487
  _llms = arrayableToArray(llm);
5541
5488
  llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(_llms), false));
5542
- TODO_USE(maxParallelCount); // <- [🪂]
5543
5489
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
5544
5490
  _d = createPipelineExecutor;
5545
5491
  _g = {};
@@ -5722,7 +5668,6 @@
5722
5668
  PdfScraper.prototype.$convert = function (source) {
5723
5669
  return __awaiter(this, void 0, void 0, function () {
5724
5670
  return __generator(this, function (_a) {
5725
- TODO_USE(source);
5726
5671
  TODO_USE(this.options);
5727
5672
  throw new NotYetImplementedError('PDF conversion not yet implemented');
5728
5673
  });
@@ -5734,7 +5679,6 @@
5734
5679
  PdfScraper.prototype.scrape = function (source) {
5735
5680
  return __awaiter(this, void 0, void 0, function () {
5736
5681
  return __generator(this, function (_a) {
5737
- TODO_USE(source);
5738
5682
  TODO_USE(this.options);
5739
5683
  /*
5740
5684
  const {
@@ -5780,7 +5724,8 @@
5780
5724
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
5781
5725
  */
5782
5726
 
5783
- exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
5727
+ exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
5728
+ exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
5784
5729
  exports.PdfScraper = PdfScraper;
5785
5730
  exports._PdfScraperRegistration = _PdfScraperRegistration;
5786
5731
  exports.createPdfScraper = createPdfScraper;