@promptbook/documents 0.88.0 → 0.89.0-11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +7 -1
  2. package/esm/index.es.js +164 -88
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +18 -6
  5. package/esm/typings/src/_packages/remote-client.index.d.ts +6 -8
  6. package/esm/typings/src/_packages/remote-server.index.d.ts +6 -6
  7. package/esm/typings/src/_packages/types.index.d.ts +18 -10
  8. package/esm/typings/src/cli/cli-commands/login.d.ts +15 -0
  9. package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +7 -0
  10. package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +15 -0
  11. package/esm/typings/src/config.d.ts +15 -8
  12. package/esm/typings/src/errors/0-index.d.ts +6 -0
  13. package/esm/typings/src/errors/AuthenticationError.d.ts +9 -0
  14. package/esm/typings/src/errors/PromptbookFetchError.d.ts +9 -0
  15. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  16. package/esm/typings/src/execution/PromptResult.d.ts +2 -2
  17. package/esm/typings/src/execution/{PromptResultUsage.d.ts → Usage.d.ts} +5 -5
  18. package/esm/typings/src/execution/utils/addUsage.d.ts +2 -2
  19. package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +3 -3
  20. package/esm/typings/src/execution/utils/usage-constants.d.ts +77 -60
  21. package/esm/typings/src/execution/utils/usageToHuman.d.ts +5 -5
  22. package/esm/typings/src/execution/utils/usageToWorktime.d.ts +5 -5
  23. package/esm/typings/src/llm-providers/_common/register/$provideEnvFilename.d.ts +12 -0
  24. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +2 -8
  25. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -0
  26. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +36 -1
  27. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -0
  28. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +9 -2
  29. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/{countTotalUsage.d.ts → countUsage.d.ts} +1 -1
  30. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -2
  31. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +2 -2
  33. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +0 -9
  35. package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.d.ts +2 -2
  36. package/esm/typings/src/pipeline/PipelineJson/PreparationJson.d.ts +2 -2
  37. package/esm/typings/src/playground/playground.d.ts +5 -0
  38. package/esm/typings/src/remote-server/RemoteServer.d.ts +23 -0
  39. package/esm/typings/src/remote-server/socket-types/_subtypes/{PromptbookServer_Identification.d.ts → Identification.d.ts} +5 -4
  40. package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +2 -2
  41. package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +2 -2
  42. package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +2 -2
  43. package/esm/typings/src/remote-server/startRemoteServer.d.ts +2 -2
  44. package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +4 -12
  45. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +88 -6
  46. package/esm/typings/src/scrapers/_common/utils/{scraperFetch.d.ts → promptbookFetch.d.ts} +2 -2
  47. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +37 -0
  48. package/esm/typings/src/types/typeAliases.d.ts +8 -2
  49. package/esm/typings/src/utils/organization/TODO_narrow.d.ts +6 -0
  50. package/package.json +2 -2
  51. package/umd/index.umd.js +164 -88
  52. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -26,7 +26,7 @@
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.88.0';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-11';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -160,6 +160,7 @@
160
160
  */
161
161
  const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [🤹‍♂️]
162
162
  // <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
163
+ // TODO: !!!!!! Just .promptbook dir, hardocode others
163
164
  /**
164
165
  * Where to store the temporary downloads
165
166
  *
@@ -211,7 +212,7 @@
211
212
  true);
212
213
  /**
213
214
  * Note: [💞] Ignore a discrepancy between file name and entity name
214
- * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
215
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
215
216
  */
216
217
 
217
218
  /**
@@ -430,6 +431,7 @@
430
431
  }
431
432
  else {
432
433
  console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
434
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
433
435
  resolve('Command exceeded time limit');
434
436
  }
435
437
  });
@@ -455,6 +457,7 @@
455
457
  output.push(stderr.toString());
456
458
  if (isVerbose && stderr.toString().trim()) {
457
459
  console.warn(stderr.toString());
460
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
458
461
  }
459
462
  });
460
463
  const finishWithCode = (code) => {
@@ -466,6 +469,7 @@
466
469
  else {
467
470
  if (isVerbose) {
468
471
  console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
472
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
469
473
  }
470
474
  resolve(spaceTrim.spaceTrim(output.join('\n')));
471
475
  }
@@ -487,6 +491,7 @@
487
491
  else {
488
492
  if (isVerbose) {
489
493
  console.warn(error);
494
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
490
495
  }
491
496
  resolve(spaceTrim.spaceTrim(output.join('\n')));
492
497
  }
@@ -2302,6 +2307,19 @@
2302
2307
  }
2303
2308
  }
2304
2309
 
2310
+ /**
2311
+ * AuthenticationError is thrown from login function which is dependency of remote server
2312
+ *
2313
+ * @public exported from `@promptbook/core`
2314
+ */
2315
+ class AuthenticationError extends Error {
2316
+ constructor(message) {
2317
+ super(message);
2318
+ this.name = 'AuthenticationError';
2319
+ Object.setPrototypeOf(this, AuthenticationError.prototype);
2320
+ }
2321
+ }
2322
+
2305
2323
  /**
2306
2324
  * This error indicates that the pipeline collection cannot be propperly loaded
2307
2325
  *
@@ -2367,6 +2385,19 @@
2367
2385
  }
2368
2386
  }
2369
2387
 
2388
+ /**
2389
+ * Error thrown when a fetch request fails
2390
+ *
2391
+ * @public exported from `@promptbook/core`
2392
+ */
2393
+ class PromptbookFetchError extends Error {
2394
+ constructor(message) {
2395
+ super(message);
2396
+ this.name = 'PromptbookFetchError';
2397
+ Object.setPrototypeOf(this, PromptbookFetchError.prototype);
2398
+ }
2399
+ }
2400
+
2370
2401
  /**
2371
2402
  * Index of all custom errors
2372
2403
  *
@@ -2404,6 +2435,8 @@
2404
2435
  TypeError,
2405
2436
  URIError,
2406
2437
  AggregateError,
2438
+ AuthenticationError,
2439
+ PromptbookFetchError,
2407
2440
  /*
2408
2441
  Note: Not widely supported
2409
2442
  > InternalError,
@@ -2465,6 +2498,7 @@
2465
2498
  const { isSuccessful, errors, warnings } = executionResult;
2466
2499
  for (const warning of warnings) {
2467
2500
  console.warn(warning.message);
2501
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
2468
2502
  }
2469
2503
  if (isSuccessful === true) {
2470
2504
  return;
@@ -2602,6 +2636,10 @@
2602
2636
 
2603
2637
  Cannot serialize error with name "${name}"
2604
2638
 
2639
+ Authors of Promptbook probably forgot to add this error into the list of errors:
2640
+ https://github.com/webgptorg/promptbook/blob/main/src/errors/0-index.ts
2641
+
2642
+
2605
2643
  ${block(stack || message)}
2606
2644
 
2607
2645
  `));
@@ -2643,30 +2681,42 @@
2643
2681
  await Promise.all(tasks);
2644
2682
  }
2645
2683
 
2684
+ /**
2685
+ * Represents the uncertain value
2686
+ *
2687
+ * @public exported from `@promptbook/core`
2688
+ */
2689
+ const ZERO_VALUE = $deepFreeze({ value: 0 });
2690
+ /**
2691
+ * Represents the uncertain value
2692
+ *
2693
+ * @public exported from `@promptbook/core`
2694
+ */
2695
+ const UNCERTAIN_ZERO_VALUE = $deepFreeze({ value: 0, isUncertain: true });
2646
2696
  /**
2647
2697
  * Represents the usage with no resources consumed
2648
2698
  *
2649
2699
  * @public exported from `@promptbook/core`
2650
2700
  */
2651
2701
  const ZERO_USAGE = $deepFreeze({
2652
- price: { value: 0 },
2702
+ price: ZERO_VALUE,
2653
2703
  input: {
2654
- tokensCount: { value: 0 },
2655
- charactersCount: { value: 0 },
2656
- wordsCount: { value: 0 },
2657
- sentencesCount: { value: 0 },
2658
- linesCount: { value: 0 },
2659
- paragraphsCount: { value: 0 },
2660
- pagesCount: { value: 0 },
2704
+ tokensCount: ZERO_VALUE,
2705
+ charactersCount: ZERO_VALUE,
2706
+ wordsCount: ZERO_VALUE,
2707
+ sentencesCount: ZERO_VALUE,
2708
+ linesCount: ZERO_VALUE,
2709
+ paragraphsCount: ZERO_VALUE,
2710
+ pagesCount: ZERO_VALUE,
2661
2711
  },
2662
2712
  output: {
2663
- tokensCount: { value: 0 },
2664
- charactersCount: { value: 0 },
2665
- wordsCount: { value: 0 },
2666
- sentencesCount: { value: 0 },
2667
- linesCount: { value: 0 },
2668
- paragraphsCount: { value: 0 },
2669
- pagesCount: { value: 0 },
2713
+ tokensCount: ZERO_VALUE,
2714
+ charactersCount: ZERO_VALUE,
2715
+ wordsCount: ZERO_VALUE,
2716
+ sentencesCount: ZERO_VALUE,
2717
+ linesCount: ZERO_VALUE,
2718
+ paragraphsCount: ZERO_VALUE,
2719
+ pagesCount: ZERO_VALUE,
2670
2720
  },
2671
2721
  });
2672
2722
  /**
@@ -2675,24 +2725,24 @@
2675
2725
  * @public exported from `@promptbook/core`
2676
2726
  */
2677
2727
  $deepFreeze({
2678
- price: { value: 0, isUncertain: true },
2728
+ price: UNCERTAIN_ZERO_VALUE,
2679
2729
  input: {
2680
- tokensCount: { value: 0, isUncertain: true },
2681
- charactersCount: { value: 0, isUncertain: true },
2682
- wordsCount: { value: 0, isUncertain: true },
2683
- sentencesCount: { value: 0, isUncertain: true },
2684
- linesCount: { value: 0, isUncertain: true },
2685
- paragraphsCount: { value: 0, isUncertain: true },
2686
- pagesCount: { value: 0, isUncertain: true },
2730
+ tokensCount: UNCERTAIN_ZERO_VALUE,
2731
+ charactersCount: UNCERTAIN_ZERO_VALUE,
2732
+ wordsCount: UNCERTAIN_ZERO_VALUE,
2733
+ sentencesCount: UNCERTAIN_ZERO_VALUE,
2734
+ linesCount: UNCERTAIN_ZERO_VALUE,
2735
+ paragraphsCount: UNCERTAIN_ZERO_VALUE,
2736
+ pagesCount: UNCERTAIN_ZERO_VALUE,
2687
2737
  },
2688
2738
  output: {
2689
- tokensCount: { value: 0, isUncertain: true },
2690
- charactersCount: { value: 0, isUncertain: true },
2691
- wordsCount: { value: 0, isUncertain: true },
2692
- sentencesCount: { value: 0, isUncertain: true },
2693
- linesCount: { value: 0, isUncertain: true },
2694
- paragraphsCount: { value: 0, isUncertain: true },
2695
- pagesCount: { value: 0, isUncertain: true },
2739
+ tokensCount: UNCERTAIN_ZERO_VALUE,
2740
+ charactersCount: UNCERTAIN_ZERO_VALUE,
2741
+ wordsCount: UNCERTAIN_ZERO_VALUE,
2742
+ sentencesCount: UNCERTAIN_ZERO_VALUE,
2743
+ linesCount: UNCERTAIN_ZERO_VALUE,
2744
+ paragraphsCount: UNCERTAIN_ZERO_VALUE,
2745
+ pagesCount: UNCERTAIN_ZERO_VALUE,
2696
2746
  },
2697
2747
  });
2698
2748
  /**
@@ -2753,8 +2803,9 @@
2753
2803
  * @returns LLM tools with same functionality with added total cost counting
2754
2804
  * @public exported from `@promptbook/core`
2755
2805
  */
2756
- function countTotalUsage(llmTools) {
2806
+ function countUsage(llmTools) {
2757
2807
  let totalUsage = ZERO_USAGE;
2808
+ const spending = new rxjs.Subject();
2758
2809
  const proxyTools = {
2759
2810
  get title() {
2760
2811
  // TODO: [🧠] Maybe put here some suffix
@@ -2764,12 +2815,15 @@
2764
2815
  // TODO: [🧠] Maybe put here some suffix
2765
2816
  return llmTools.description;
2766
2817
  },
2767
- async checkConfiguration() {
2818
+ checkConfiguration() {
2768
2819
  return /* not await */ llmTools.checkConfiguration();
2769
2820
  },
2770
2821
  listModels() {
2771
2822
  return /* not await */ llmTools.listModels();
2772
2823
  },
2824
+ spending() {
2825
+ return spending.asObservable();
2826
+ },
2773
2827
  getTotalUsage() {
2774
2828
  // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2775
2829
  return totalUsage;
@@ -2780,6 +2834,7 @@
2780
2834
  // console.info('[🚕] callChatModel through countTotalUsage');
2781
2835
  const promptResult = await llmTools.callChatModel(prompt);
2782
2836
  totalUsage = addUsage(totalUsage, promptResult.usage);
2837
+ spending.next(promptResult.usage);
2783
2838
  return promptResult;
2784
2839
  };
2785
2840
  }
@@ -2788,6 +2843,7 @@
2788
2843
  // console.info('[🚕] callCompletionModel through countTotalUsage');
2789
2844
  const promptResult = await llmTools.callCompletionModel(prompt);
2790
2845
  totalUsage = addUsage(totalUsage, promptResult.usage);
2846
+ spending.next(promptResult.usage);
2791
2847
  return promptResult;
2792
2848
  };
2793
2849
  }
@@ -2796,6 +2852,7 @@
2796
2852
  // console.info('[🚕] callEmbeddingModel through countTotalUsage');
2797
2853
  const promptResult = await llmTools.callEmbeddingModel(prompt);
2798
2854
  totalUsage = addUsage(totalUsage, promptResult.usage);
2855
+ spending.next(promptResult.usage);
2799
2856
  return promptResult;
2800
2857
  };
2801
2858
  }
@@ -2973,6 +3030,7 @@
2973
3030
  `);
2974
3031
  // TODO: [🟥] Detect browser / node and make it colorfull
2975
3032
  console.warn(warningMessage);
3033
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
2976
3034
  /*
2977
3035
  return {
2978
3036
  async listModels() {
@@ -3348,17 +3406,24 @@
3348
3406
  /**
3349
3407
  * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
3350
3408
  *
3351
- * @private as default `fetch` function used in Promptbook scrapers
3409
+ * @public exported from `@promptbook/core`
3352
3410
  */
3353
- const scraperFetch = async (url, init) => {
3411
+ const promptbookFetch = async (urlOrRequest, init) => {
3354
3412
  try {
3355
- return await fetch(url, init);
3413
+ return await fetch(urlOrRequest, init);
3356
3414
  }
3357
3415
  catch (error) {
3358
3416
  if (!(error instanceof Error)) {
3359
3417
  throw error;
3360
3418
  }
3361
- throw new KnowledgeScrapeError(spaceTrim__default["default"]((block) => `
3419
+ let url;
3420
+ if (typeof urlOrRequest === 'string') {
3421
+ url = urlOrRequest;
3422
+ }
3423
+ else if (urlOrRequest instanceof Request) {
3424
+ url = urlOrRequest.url;
3425
+ }
3426
+ throw new PromptbookFetchError(spaceTrim__default["default"]((block) => `
3362
3427
  Can not fetch "${url}"
3363
3428
 
3364
3429
  Fetch error:
@@ -3379,7 +3444,7 @@
3379
3444
  async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3380
3445
  // console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
3381
3446
  var _a;
3382
- const { fetch = scraperFetch } = tools;
3447
+ const { fetch = promptbookFetch } = tools;
3383
3448
  const { knowledgeSourceContent } = knowledgeSource;
3384
3449
  let { name } = knowledgeSource;
3385
3450
  const { rootDirname = null,
@@ -3520,63 +3585,73 @@
3520
3585
  const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT, rootDirname, isVerbose = DEFAULT_IS_VERBOSE } = options;
3521
3586
  const knowledgePreparedUnflatten = new Array(knowledgeSources.length);
3522
3587
  await forEachAsync(knowledgeSources, { maxParallelCount }, async (knowledgeSource, index) => {
3523
- let partialPieces = null;
3524
- const sourceHandler = await makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname, isVerbose });
3525
- const scrapers = arrayableToArray(tools.scrapers);
3526
- for (const scraper of scrapers) {
3527
- if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
3528
- // <- TODO: [🦔] Implement mime-type wildcards
3529
- ) {
3530
- continue;
3531
- }
3532
- const partialPiecesUnchecked = await scraper.scrape(sourceHandler);
3533
- if (partialPiecesUnchecked !== null) {
3534
- partialPieces = [...partialPiecesUnchecked];
3535
- // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
3536
- break;
3537
- }
3538
- console.warn(spaceTrim__default["default"]((block) => `
3539
- Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
3588
+ try {
3589
+ let partialPieces = null;
3590
+ const sourceHandler = await makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname, isVerbose });
3591
+ const scrapers = arrayableToArray(tools.scrapers);
3592
+ for (const scraper of scrapers) {
3593
+ if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
3594
+ // <- TODO: [🦔] Implement mime-type wildcards
3595
+ ) {
3596
+ continue;
3597
+ }
3598
+ const partialPiecesUnchecked = await scraper.scrape(sourceHandler);
3599
+ if (partialPiecesUnchecked !== null) {
3600
+ partialPieces = [...partialPiecesUnchecked];
3601
+ // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
3602
+ break;
3603
+ }
3604
+ console.warn(spaceTrim__default["default"]((block) => `
3605
+ Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
3540
3606
 
3541
- The source:
3542
- ${block(knowledgeSource.knowledgeSourceContent
3543
- .split('\n')
3544
- .map((line) => `> ${line}`)
3545
- .join('\n'))}
3607
+ The source:
3608
+ ${block(knowledgeSource.knowledgeSourceContent
3609
+ .split('\n')
3610
+ .map((line) => `> ${line}`)
3611
+ .join('\n'))}
3546
3612
 
3547
- ${block($registeredScrapersMessage(scrapers))}
3613
+ ${block($registeredScrapersMessage(scrapers))}
3548
3614
 
3549
3615
 
3550
- `));
3551
- }
3552
- if (partialPieces === null) {
3553
- throw new KnowledgeScrapeError(spaceTrim__default["default"]((block) => `
3554
- Cannot scrape knowledge
3616
+ `));
3617
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
3618
+ }
3619
+ if (partialPieces === null) {
3620
+ throw new KnowledgeScrapeError(spaceTrim__default["default"]((block) => `
3621
+ Cannot scrape knowledge
3555
3622
 
3556
- The source:
3557
- > ${block(knowledgeSource.knowledgeSourceContent
3558
- .split('\n')
3559
- .map((line) => `> ${line}`)
3560
- .join('\n'))}
3623
+ The source:
3624
+ > ${block(knowledgeSource.knowledgeSourceContent
3625
+ .split('\n')
3626
+ .map((line) => `> ${line}`)
3627
+ .join('\n'))}
3561
3628
 
3562
- No scraper found for the mime type "${sourceHandler.mimeType}"
3629
+ No scraper found for the mime type "${sourceHandler.mimeType}"
3563
3630
 
3564
- ${block($registeredScrapersMessage(scrapers))}
3631
+ ${block($registeredScrapersMessage(scrapers))}
3565
3632
 
3566
3633
 
3567
- `));
3634
+ `));
3635
+ }
3636
+ const pieces = partialPieces.map((partialPiece) => ({
3637
+ ...partialPiece,
3638
+ sources: [
3639
+ {
3640
+ name: knowledgeSource.name,
3641
+ // line, column <- TODO: [☀]
3642
+ // <- TODO: [❎]
3643
+ },
3644
+ ],
3645
+ }));
3646
+ knowledgePreparedUnflatten[index] = pieces;
3647
+ }
3648
+ catch (error) {
3649
+ if (!(error instanceof Error)) {
3650
+ throw error;
3651
+ }
3652
+ console.warn(error);
3653
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
3568
3654
  }
3569
- const pieces = partialPieces.map((partialPiece) => ({
3570
- ...partialPiece,
3571
- sources: [
3572
- {
3573
- name: knowledgeSource.name,
3574
- // line, column <- TODO: [☀]
3575
- // <- TODO: [❎]
3576
- },
3577
- ],
3578
- }));
3579
- knowledgePreparedUnflatten[index] = pieces;
3580
3655
  });
3581
3656
  const knowledgePrepared = knowledgePreparedUnflatten.flat();
3582
3657
  return knowledgePrepared;
@@ -3682,7 +3757,7 @@
3682
3757
  // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
3683
3758
  const _llms = arrayableToArray(tools.llm);
3684
3759
  const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
3685
- const llmToolsWithUsage = countTotalUsage(llmTools);
3760
+ const llmToolsWithUsage = countUsage(llmTools);
3686
3761
  // <- TODO: [🌯]
3687
3762
  /*
3688
3763
  TODO: [🧠][🪑][🔃] Should this be done or not
@@ -3994,7 +4069,7 @@
3994
4069
  if (parameterNames.has(subparameterName)) {
3995
4070
  parameterNames.delete(subparameterName);
3996
4071
  parameterNames.add(foreach.parameterName);
3997
- // <- TODO: [🚎] Warn/logic error when `subparameterName` not used
4072
+ // <- TODO: [🏮] Warn/logic error when `subparameterName` not used
3998
4073
  }
3999
4074
  }
4000
4075
  }
@@ -5590,6 +5665,7 @@
5590
5665
 
5591
5666
  @see more at https://ptbk.io/prepare-pipeline
5592
5667
  `));
5668
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
5593
5669
  }
5594
5670
  let runCount = 0;
5595
5671
  const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {