@promptbook/website-crawler 0.71.0-17 → 0.72.0-10

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 (42) hide show
  1. package/esm/index.es.js +229 -202
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/cli.index.d.ts +4 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +6 -2
  5. package/esm/typings/src/_packages/openai.index.d.ts +8 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +8 -2
  7. package/esm/typings/src/dialogs/callback/CallbackInterfaceTools.d.ts +1 -1
  8. package/esm/typings/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
  9. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
  10. package/esm/typings/src/execution/utils/addUsage.d.ts +0 -56
  11. package/esm/typings/src/execution/utils/usage-constants.d.ts +127 -0
  12. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  13. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
  14. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
  15. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
  16. package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +1 -1
  17. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  18. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  19. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +37 -0
  20. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +14 -0
  21. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +11 -2
  22. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  23. package/esm/typings/src/llm-providers/openai/createOpenAiAssistantExecutionTools.d.ts +15 -0
  24. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +9 -0
  25. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +9 -0
  26. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +3 -3
  27. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +15 -6
  28. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +2 -2
  29. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +6 -12
  30. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Response.d.ts +1 -1
  31. package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +9 -14
  32. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +22 -8
  33. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  34. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
  35. package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +1 -1
  36. package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +1 -1
  37. package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +1 -1
  38. package/esm/typings/src/types/Prompt.d.ts +1 -0
  39. package/esm/typings/src/types/typeAliases.d.ts +11 -8
  40. package/package.json +2 -2
  41. package/umd/index.umd.js +229 -202
  42. package/umd/index.umd.js.map +1 -1
package/esm/index.es.js CHANGED
@@ -16,7 +16,7 @@ import { Converter } from 'showdown';
16
16
  /**
17
17
  * The version of the Promptbook library
18
18
  */
19
- var PROMPTBOOK_VERSION = '0.71.0-16';
19
+ var PROMPTBOOK_VERSION = '0.72.0-9';
20
20
  // TODO: [main] !!!! List here all the versions and annotate + put into script
21
21
 
22
22
  /*! *****************************************************************************
@@ -2239,127 +2239,6 @@ function serializeError(error) {
2239
2239
  };
2240
2240
  }
2241
2241
 
2242
- /**
2243
- * @@@
2244
- *
2245
- * @public exported from `@promptbook/utils`
2246
- */
2247
- function deepClone(objectValue) {
2248
- return JSON.parse(JSON.stringify(objectValue));
2249
- /*
2250
- TODO: [🧠] Is there a better implementation?
2251
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
2252
- > for (const propertyName of propertyNames) {
2253
- > const value = (objectValue as really_any)[propertyName];
2254
- > if (value && typeof value === 'object') {
2255
- > deepClone(value);
2256
- > }
2257
- > }
2258
- > return Object.assign({}, objectValue);
2259
- */
2260
- }
2261
- /**
2262
- * TODO: [🧠] Is there a way how to meaningfully test this utility
2263
- */
2264
-
2265
- /**
2266
- * @@@
2267
- *
2268
- * @public exported from `@promptbook/core`
2269
- */
2270
- var ZERO_USAGE = $deepFreeze({
2271
- price: { value: 0 },
2272
- input: {
2273
- tokensCount: { value: 0 },
2274
- charactersCount: { value: 0 },
2275
- wordsCount: { value: 0 },
2276
- sentencesCount: { value: 0 },
2277
- linesCount: { value: 0 },
2278
- paragraphsCount: { value: 0 },
2279
- pagesCount: { value: 0 },
2280
- },
2281
- output: {
2282
- tokensCount: { value: 0 },
2283
- charactersCount: { value: 0 },
2284
- wordsCount: { value: 0 },
2285
- sentencesCount: { value: 0 },
2286
- linesCount: { value: 0 },
2287
- paragraphsCount: { value: 0 },
2288
- pagesCount: { value: 0 },
2289
- },
2290
- });
2291
- /**
2292
- * Function `addUsage` will add multiple usages into one
2293
- *
2294
- * Note: If you provide 0 values, it returns ZERO_USAGE
2295
- *
2296
- * @public exported from `@promptbook/core`
2297
- */
2298
- function addUsage() {
2299
- var usageItems = [];
2300
- for (var _i = 0; _i < arguments.length; _i++) {
2301
- usageItems[_i] = arguments[_i];
2302
- }
2303
- return usageItems.reduce(function (acc, item) {
2304
- var e_1, _a, e_2, _b;
2305
- var _c;
2306
- acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
2307
- try {
2308
- for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
2309
- var key = _e.value;
2310
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2311
- //@ts-ignore
2312
- if (item.input[key]) {
2313
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2314
- //@ts-ignore
2315
- acc.input[key].value += item.input[key].value || 0;
2316
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2317
- //@ts-ignore
2318
- if (item.input[key].isUncertain) {
2319
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2320
- //@ts-ignore
2321
- acc.input[key].isUncertain = true;
2322
- }
2323
- }
2324
- }
2325
- }
2326
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2327
- finally {
2328
- try {
2329
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2330
- }
2331
- finally { if (e_1) throw e_1.error; }
2332
- }
2333
- try {
2334
- for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
2335
- var key = _g.value;
2336
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2337
- //@ts-ignore
2338
- if (item.output[key]) {
2339
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2340
- //@ts-ignore
2341
- acc.output[key].value += item.output[key].value || 0;
2342
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2343
- //@ts-ignore
2344
- if (item.output[key].isUncertain) {
2345
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2346
- //@ts-ignore
2347
- acc.output[key].isUncertain = true;
2348
- }
2349
- }
2350
- }
2351
- }
2352
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2353
- finally {
2354
- try {
2355
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2356
- }
2357
- finally { if (e_2) throw e_2.error; }
2358
- }
2359
- return acc;
2360
- }, deepClone(ZERO_USAGE));
2361
- }
2362
-
2363
2242
  /**
2364
2243
  * Async version of Array.forEach
2365
2244
  *
@@ -2437,91 +2316,57 @@ function forEachAsync(array, options, callbackfunction) {
2437
2316
  }
2438
2317
 
2439
2318
  /**
2440
- * Intercepts LLM tools and counts total usage of the tools
2319
+ * Represents the usage with no resources consumed
2441
2320
  *
2442
- * @param llmTools LLM tools to be intercepted with usage counting
2443
- * @returns LLM tools with same functionality with added total cost counting
2444
2321
  * @public exported from `@promptbook/core`
2445
2322
  */
2446
- function countTotalUsage(llmTools) {
2447
- var _this = this;
2448
- var totalUsage = ZERO_USAGE;
2449
- var proxyTools = {
2450
- get title() {
2451
- // TODO: [🧠] Maybe put here some suffix
2452
- return llmTools.title;
2453
- },
2454
- get description() {
2455
- // TODO: [🧠] Maybe put here some suffix
2456
- return llmTools.description;
2457
- },
2458
- checkConfiguration: function () {
2459
- return __awaiter(this, void 0, void 0, function () {
2460
- return __generator(this, function (_a) {
2461
- return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
2462
- });
2463
- });
2464
- },
2465
- listModels: function () {
2466
- return /* not await */ llmTools.listModels();
2467
- },
2468
- getTotalUsage: function () {
2469
- // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2470
- return totalUsage;
2471
- },
2472
- };
2473
- if (llmTools.callChatModel !== undefined) {
2474
- proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2475
- var promptResult;
2476
- return __generator(this, function (_a) {
2477
- switch (_a.label) {
2478
- case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
2479
- case 1:
2480
- promptResult = _a.sent();
2481
- totalUsage = addUsage(totalUsage, promptResult.usage);
2482
- return [2 /*return*/, promptResult];
2483
- }
2484
- });
2485
- }); };
2486
- }
2487
- if (llmTools.callCompletionModel !== undefined) {
2488
- proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2489
- var promptResult;
2490
- return __generator(this, function (_a) {
2491
- switch (_a.label) {
2492
- case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
2493
- case 1:
2494
- promptResult = _a.sent();
2495
- totalUsage = addUsage(totalUsage, promptResult.usage);
2496
- return [2 /*return*/, promptResult];
2497
- }
2498
- });
2499
- }); };
2500
- }
2501
- if (llmTools.callEmbeddingModel !== undefined) {
2502
- proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2503
- var promptResult;
2504
- return __generator(this, function (_a) {
2505
- switch (_a.label) {
2506
- case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
2507
- case 1:
2508
- promptResult = _a.sent();
2509
- totalUsage = addUsage(totalUsage, promptResult.usage);
2510
- return [2 /*return*/, promptResult];
2511
- }
2512
- });
2513
- }); };
2514
- }
2515
- // <- Note: [🤖]
2516
- return proxyTools;
2517
- }
2323
+ var ZERO_USAGE = $deepFreeze({
2324
+ price: { value: 0 },
2325
+ input: {
2326
+ tokensCount: { value: 0 },
2327
+ charactersCount: { value: 0 },
2328
+ wordsCount: { value: 0 },
2329
+ sentencesCount: { value: 0 },
2330
+ linesCount: { value: 0 },
2331
+ paragraphsCount: { value: 0 },
2332
+ pagesCount: { value: 0 },
2333
+ },
2334
+ output: {
2335
+ tokensCount: { value: 0 },
2336
+ charactersCount: { value: 0 },
2337
+ wordsCount: { value: 0 },
2338
+ sentencesCount: { value: 0 },
2339
+ linesCount: { value: 0 },
2340
+ paragraphsCount: { value: 0 },
2341
+ pagesCount: { value: 0 },
2342
+ },
2343
+ });
2518
2344
  /**
2519
- * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
2520
- * TODO: [🧠] Is there some meaningfull way how to test this util
2521
- * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
2522
- * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
2523
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2345
+ * Represents the usage with unknown resources consumed
2346
+ *
2347
+ * @public exported from `@promptbook/core`
2524
2348
  */
2349
+ $deepFreeze({
2350
+ price: { value: 0, isUncertain: true },
2351
+ input: {
2352
+ tokensCount: { value: 0, isUncertain: true },
2353
+ charactersCount: { value: 0, isUncertain: true },
2354
+ wordsCount: { value: 0, isUncertain: true },
2355
+ sentencesCount: { value: 0, isUncertain: true },
2356
+ linesCount: { value: 0, isUncertain: true },
2357
+ paragraphsCount: { value: 0, isUncertain: true },
2358
+ pagesCount: { value: 0, isUncertain: true },
2359
+ },
2360
+ output: {
2361
+ tokensCount: { value: 0, isUncertain: true },
2362
+ charactersCount: { value: 0, isUncertain: true },
2363
+ wordsCount: { value: 0, isUncertain: true },
2364
+ sentencesCount: { value: 0, isUncertain: true },
2365
+ linesCount: { value: 0, isUncertain: true },
2366
+ paragraphsCount: { value: 0, isUncertain: true },
2367
+ pagesCount: { value: 0, isUncertain: true },
2368
+ },
2369
+ });
2525
2370
 
2526
2371
  /**
2527
2372
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
@@ -2816,6 +2661,188 @@ function joinLlmExecutionTools() {
2816
2661
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2817
2662
  */
2818
2663
 
2664
+ /**
2665
+ * @@@
2666
+ *
2667
+ * @public exported from `@promptbook/utils`
2668
+ */
2669
+ function deepClone(objectValue) {
2670
+ return JSON.parse(JSON.stringify(objectValue));
2671
+ /*
2672
+ TODO: [🧠] Is there a better implementation?
2673
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
2674
+ > for (const propertyName of propertyNames) {
2675
+ > const value = (objectValue as really_any)[propertyName];
2676
+ > if (value && typeof value === 'object') {
2677
+ > deepClone(value);
2678
+ > }
2679
+ > }
2680
+ > return Object.assign({}, objectValue);
2681
+ */
2682
+ }
2683
+ /**
2684
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
2685
+ */
2686
+
2687
+ /**
2688
+ * Function `addUsage` will add multiple usages into one
2689
+ *
2690
+ * Note: If you provide 0 values, it returns ZERO_USAGE
2691
+ *
2692
+ * @public exported from `@promptbook/core`
2693
+ */
2694
+ function addUsage() {
2695
+ var usageItems = [];
2696
+ for (var _i = 0; _i < arguments.length; _i++) {
2697
+ usageItems[_i] = arguments[_i];
2698
+ }
2699
+ return usageItems.reduce(function (acc, item) {
2700
+ var e_1, _a, e_2, _b;
2701
+ var _c;
2702
+ acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
2703
+ try {
2704
+ for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
2705
+ var key = _e.value;
2706
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2707
+ //@ts-ignore
2708
+ if (item.input[key]) {
2709
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2710
+ //@ts-ignore
2711
+ acc.input[key].value += item.input[key].value || 0;
2712
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2713
+ //@ts-ignore
2714
+ if (item.input[key].isUncertain) {
2715
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2716
+ //@ts-ignore
2717
+ acc.input[key].isUncertain = true;
2718
+ }
2719
+ }
2720
+ }
2721
+ }
2722
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2723
+ finally {
2724
+ try {
2725
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2726
+ }
2727
+ finally { if (e_1) throw e_1.error; }
2728
+ }
2729
+ try {
2730
+ for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
2731
+ var key = _g.value;
2732
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2733
+ //@ts-ignore
2734
+ if (item.output[key]) {
2735
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2736
+ //@ts-ignore
2737
+ acc.output[key].value += item.output[key].value || 0;
2738
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2739
+ //@ts-ignore
2740
+ if (item.output[key].isUncertain) {
2741
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2742
+ //@ts-ignore
2743
+ acc.output[key].isUncertain = true;
2744
+ }
2745
+ }
2746
+ }
2747
+ }
2748
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2749
+ finally {
2750
+ try {
2751
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2752
+ }
2753
+ finally { if (e_2) throw e_2.error; }
2754
+ }
2755
+ return acc;
2756
+ }, deepClone(ZERO_USAGE));
2757
+ }
2758
+
2759
+ /**
2760
+ * Intercepts LLM tools and counts total usage of the tools
2761
+ *
2762
+ * @param llmTools LLM tools to be intercepted with usage counting
2763
+ * @returns LLM tools with same functionality with added total cost counting
2764
+ * @public exported from `@promptbook/core`
2765
+ */
2766
+ function countTotalUsage(llmTools) {
2767
+ var _this = this;
2768
+ var totalUsage = ZERO_USAGE;
2769
+ var proxyTools = {
2770
+ get title() {
2771
+ // TODO: [🧠] Maybe put here some suffix
2772
+ return llmTools.title;
2773
+ },
2774
+ get description() {
2775
+ // TODO: [🧠] Maybe put here some suffix
2776
+ return llmTools.description;
2777
+ },
2778
+ checkConfiguration: function () {
2779
+ return __awaiter(this, void 0, void 0, function () {
2780
+ return __generator(this, function (_a) {
2781
+ return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
2782
+ });
2783
+ });
2784
+ },
2785
+ listModels: function () {
2786
+ return /* not await */ llmTools.listModels();
2787
+ },
2788
+ getTotalUsage: function () {
2789
+ // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2790
+ return totalUsage;
2791
+ },
2792
+ };
2793
+ if (llmTools.callChatModel !== undefined) {
2794
+ proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2795
+ var promptResult;
2796
+ return __generator(this, function (_a) {
2797
+ switch (_a.label) {
2798
+ case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
2799
+ case 1:
2800
+ promptResult = _a.sent();
2801
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2802
+ return [2 /*return*/, promptResult];
2803
+ }
2804
+ });
2805
+ }); };
2806
+ }
2807
+ if (llmTools.callCompletionModel !== undefined) {
2808
+ proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2809
+ var promptResult;
2810
+ return __generator(this, function (_a) {
2811
+ switch (_a.label) {
2812
+ case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
2813
+ case 1:
2814
+ promptResult = _a.sent();
2815
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2816
+ return [2 /*return*/, promptResult];
2817
+ }
2818
+ });
2819
+ }); };
2820
+ }
2821
+ if (llmTools.callEmbeddingModel !== undefined) {
2822
+ proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2823
+ var promptResult;
2824
+ return __generator(this, function (_a) {
2825
+ switch (_a.label) {
2826
+ case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
2827
+ case 1:
2828
+ promptResult = _a.sent();
2829
+ totalUsage = addUsage(totalUsage, promptResult.usage);
2830
+ return [2 /*return*/, promptResult];
2831
+ }
2832
+ });
2833
+ }); };
2834
+ }
2835
+ // <- Note: [🤖]
2836
+ return proxyTools;
2837
+ }
2838
+ /**
2839
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
2840
+ * TODO: [🧠] Is there some meaningfull way how to test this util
2841
+ * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
2842
+ * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
2843
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2844
+ */
2845
+
2819
2846
  /**
2820
2847
  * Takes an item or an array of items and returns an array of items
2821
2848
  *