@promptbook/remote-server 0.89.0-1 → 0.89.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 (24) hide show
  1. package/esm/index.es.js +109 -79
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +4 -0
  4. package/esm/typings/src/_packages/types.index.d.ts +6 -4
  5. package/esm/typings/src/cli/cli-commands/login.d.ts +15 -0
  6. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  7. package/esm/typings/src/execution/PromptResult.d.ts +2 -2
  8. package/esm/typings/src/execution/{PromptResultUsage.d.ts → Usage.d.ts} +5 -5
  9. package/esm/typings/src/execution/utils/addUsage.d.ts +2 -2
  10. package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +3 -3
  11. package/esm/typings/src/execution/utils/usage-constants.d.ts +77 -60
  12. package/esm/typings/src/execution/utils/usageToHuman.d.ts +5 -5
  13. package/esm/typings/src/execution/utils/usageToWorktime.d.ts +5 -5
  14. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +3 -3
  15. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -2
  16. package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +2 -2
  17. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +0 -9
  18. package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.d.ts +2 -2
  19. package/esm/typings/src/pipeline/PipelineJson/PreparationJson.d.ts +2 -2
  20. package/esm/typings/src/playground/BrjappConnector.d.ts +3 -0
  21. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  22. package/package.json +2 -2
  23. package/umd/index.umd.js +109 -79
  24. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -28,7 +28,7 @@
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-1';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-2';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -691,6 +691,7 @@
691
691
  }
692
692
  else {
693
693
  console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
694
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
694
695
  resolve('Command exceeded time limit');
695
696
  }
696
697
  });
@@ -716,6 +717,7 @@
716
717
  output.push(stderr.toString());
717
718
  if (isVerbose && stderr.toString().trim()) {
718
719
  console.warn(stderr.toString());
720
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
719
721
  }
720
722
  });
721
723
  const finishWithCode = (code) => {
@@ -727,6 +729,7 @@
727
729
  else {
728
730
  if (isVerbose) {
729
731
  console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
732
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
730
733
  }
731
734
  resolve(spaceTrim.spaceTrim(output.join('\n')));
732
735
  }
@@ -748,6 +751,7 @@
748
751
  else {
749
752
  if (isVerbose) {
750
753
  console.warn(error);
754
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
751
755
  }
752
756
  resolve(spaceTrim.spaceTrim(output.join('\n')));
753
757
  }
@@ -1816,6 +1820,7 @@
1816
1820
  const { isSuccessful, errors, warnings } = executionResult;
1817
1821
  for (const warning of warnings) {
1818
1822
  console.warn(warning.message);
1823
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1819
1824
  }
1820
1825
  if (isSuccessful === true) {
1821
1826
  return;
@@ -2417,30 +2422,42 @@
2417
2422
  await Promise.all(tasks);
2418
2423
  }
2419
2424
 
2425
+ /**
2426
+ * Represents the uncertain value
2427
+ *
2428
+ * @public exported from `@promptbook/core`
2429
+ */
2430
+ const ZERO_VALUE = $deepFreeze({ value: 0 });
2431
+ /**
2432
+ * Represents the uncertain value
2433
+ *
2434
+ * @public exported from `@promptbook/core`
2435
+ */
2436
+ const UNCERTAIN_ZERO_VALUE = $deepFreeze({ value: 0, isUncertain: true });
2420
2437
  /**
2421
2438
  * Represents the usage with no resources consumed
2422
2439
  *
2423
2440
  * @public exported from `@promptbook/core`
2424
2441
  */
2425
2442
  const ZERO_USAGE = $deepFreeze({
2426
- price: { value: 0 },
2443
+ price: ZERO_VALUE,
2427
2444
  input: {
2428
- tokensCount: { value: 0 },
2429
- charactersCount: { value: 0 },
2430
- wordsCount: { value: 0 },
2431
- sentencesCount: { value: 0 },
2432
- linesCount: { value: 0 },
2433
- paragraphsCount: { value: 0 },
2434
- pagesCount: { value: 0 },
2445
+ tokensCount: ZERO_VALUE,
2446
+ charactersCount: ZERO_VALUE,
2447
+ wordsCount: ZERO_VALUE,
2448
+ sentencesCount: ZERO_VALUE,
2449
+ linesCount: ZERO_VALUE,
2450
+ paragraphsCount: ZERO_VALUE,
2451
+ pagesCount: ZERO_VALUE,
2435
2452
  },
2436
2453
  output: {
2437
- tokensCount: { value: 0 },
2438
- charactersCount: { value: 0 },
2439
- wordsCount: { value: 0 },
2440
- sentencesCount: { value: 0 },
2441
- linesCount: { value: 0 },
2442
- paragraphsCount: { value: 0 },
2443
- pagesCount: { value: 0 },
2454
+ tokensCount: ZERO_VALUE,
2455
+ charactersCount: ZERO_VALUE,
2456
+ wordsCount: ZERO_VALUE,
2457
+ sentencesCount: ZERO_VALUE,
2458
+ linesCount: ZERO_VALUE,
2459
+ paragraphsCount: ZERO_VALUE,
2460
+ pagesCount: ZERO_VALUE,
2444
2461
  },
2445
2462
  });
2446
2463
  /**
@@ -2449,24 +2466,24 @@
2449
2466
  * @public exported from `@promptbook/core`
2450
2467
  */
2451
2468
  $deepFreeze({
2452
- price: { value: 0, isUncertain: true },
2469
+ price: UNCERTAIN_ZERO_VALUE,
2453
2470
  input: {
2454
- tokensCount: { value: 0, isUncertain: true },
2455
- charactersCount: { value: 0, isUncertain: true },
2456
- wordsCount: { value: 0, isUncertain: true },
2457
- sentencesCount: { value: 0, isUncertain: true },
2458
- linesCount: { value: 0, isUncertain: true },
2459
- paragraphsCount: { value: 0, isUncertain: true },
2460
- pagesCount: { value: 0, isUncertain: true },
2471
+ tokensCount: UNCERTAIN_ZERO_VALUE,
2472
+ charactersCount: UNCERTAIN_ZERO_VALUE,
2473
+ wordsCount: UNCERTAIN_ZERO_VALUE,
2474
+ sentencesCount: UNCERTAIN_ZERO_VALUE,
2475
+ linesCount: UNCERTAIN_ZERO_VALUE,
2476
+ paragraphsCount: UNCERTAIN_ZERO_VALUE,
2477
+ pagesCount: UNCERTAIN_ZERO_VALUE,
2461
2478
  },
2462
2479
  output: {
2463
- tokensCount: { value: 0, isUncertain: true },
2464
- charactersCount: { value: 0, isUncertain: true },
2465
- wordsCount: { value: 0, isUncertain: true },
2466
- sentencesCount: { value: 0, isUncertain: true },
2467
- linesCount: { value: 0, isUncertain: true },
2468
- paragraphsCount: { value: 0, isUncertain: true },
2469
- pagesCount: { value: 0, isUncertain: true },
2480
+ tokensCount: UNCERTAIN_ZERO_VALUE,
2481
+ charactersCount: UNCERTAIN_ZERO_VALUE,
2482
+ wordsCount: UNCERTAIN_ZERO_VALUE,
2483
+ sentencesCount: UNCERTAIN_ZERO_VALUE,
2484
+ linesCount: UNCERTAIN_ZERO_VALUE,
2485
+ paragraphsCount: UNCERTAIN_ZERO_VALUE,
2486
+ pagesCount: UNCERTAIN_ZERO_VALUE,
2470
2487
  },
2471
2488
  });
2472
2489
  /**
@@ -2754,6 +2771,7 @@
2754
2771
  `);
2755
2772
  // TODO: [🟥] Detect browser / node and make it colorfull
2756
2773
  console.warn(warningMessage);
2774
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
2757
2775
  /*
2758
2776
  return {
2759
2777
  async listModels() {
@@ -3697,63 +3715,73 @@
3697
3715
  const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT, rootDirname, isVerbose = DEFAULT_IS_VERBOSE } = options;
3698
3716
  const knowledgePreparedUnflatten = new Array(knowledgeSources.length);
3699
3717
  await forEachAsync(knowledgeSources, { maxParallelCount }, async (knowledgeSource, index) => {
3700
- let partialPieces = null;
3701
- const sourceHandler = await makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname, isVerbose });
3702
- const scrapers = arrayableToArray(tools.scrapers);
3703
- for (const scraper of scrapers) {
3704
- if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
3705
- // <- TODO: [🦔] Implement mime-type wildcards
3706
- ) {
3707
- continue;
3708
- }
3709
- const partialPiecesUnchecked = await scraper.scrape(sourceHandler);
3710
- if (partialPiecesUnchecked !== null) {
3711
- partialPieces = [...partialPiecesUnchecked];
3712
- // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
3713
- break;
3714
- }
3715
- console.warn(spaceTrim__default["default"]((block) => `
3716
- Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
3718
+ try {
3719
+ let partialPieces = null;
3720
+ const sourceHandler = await makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname, isVerbose });
3721
+ const scrapers = arrayableToArray(tools.scrapers);
3722
+ for (const scraper of scrapers) {
3723
+ if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
3724
+ // <- TODO: [🦔] Implement mime-type wildcards
3725
+ ) {
3726
+ continue;
3727
+ }
3728
+ const partialPiecesUnchecked = await scraper.scrape(sourceHandler);
3729
+ if (partialPiecesUnchecked !== null) {
3730
+ partialPieces = [...partialPiecesUnchecked];
3731
+ // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
3732
+ break;
3733
+ }
3734
+ console.warn(spaceTrim__default["default"]((block) => `
3735
+ Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
3717
3736
 
3718
- The source:
3719
- ${block(knowledgeSource.knowledgeSourceContent
3720
- .split('\n')
3721
- .map((line) => `> ${line}`)
3722
- .join('\n'))}
3737
+ The source:
3738
+ ${block(knowledgeSource.knowledgeSourceContent
3739
+ .split('\n')
3740
+ .map((line) => `> ${line}`)
3741
+ .join('\n'))}
3723
3742
 
3724
- ${block($registeredScrapersMessage(scrapers))}
3743
+ ${block($registeredScrapersMessage(scrapers))}
3725
3744
 
3726
3745
 
3727
- `));
3728
- }
3729
- if (partialPieces === null) {
3730
- throw new KnowledgeScrapeError(spaceTrim__default["default"]((block) => `
3731
- Cannot scrape knowledge
3746
+ `));
3747
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
3748
+ }
3749
+ if (partialPieces === null) {
3750
+ throw new KnowledgeScrapeError(spaceTrim__default["default"]((block) => `
3751
+ Cannot scrape knowledge
3732
3752
 
3733
- The source:
3734
- > ${block(knowledgeSource.knowledgeSourceContent
3735
- .split('\n')
3736
- .map((line) => `> ${line}`)
3737
- .join('\n'))}
3753
+ The source:
3754
+ > ${block(knowledgeSource.knowledgeSourceContent
3755
+ .split('\n')
3756
+ .map((line) => `> ${line}`)
3757
+ .join('\n'))}
3738
3758
 
3739
- No scraper found for the mime type "${sourceHandler.mimeType}"
3759
+ No scraper found for the mime type "${sourceHandler.mimeType}"
3740
3760
 
3741
- ${block($registeredScrapersMessage(scrapers))}
3761
+ ${block($registeredScrapersMessage(scrapers))}
3742
3762
 
3743
3763
 
3744
- `));
3764
+ `));
3765
+ }
3766
+ const pieces = partialPieces.map((partialPiece) => ({
3767
+ ...partialPiece,
3768
+ sources: [
3769
+ {
3770
+ name: knowledgeSource.name,
3771
+ // line, column <- TODO: [☀]
3772
+ // <- TODO: [❎]
3773
+ },
3774
+ ],
3775
+ }));
3776
+ knowledgePreparedUnflatten[index] = pieces;
3777
+ }
3778
+ catch (error) {
3779
+ if (!(error instanceof Error)) {
3780
+ throw error;
3781
+ }
3782
+ console.warn(error);
3783
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
3745
3784
  }
3746
- const pieces = partialPieces.map((partialPiece) => ({
3747
- ...partialPiece,
3748
- sources: [
3749
- {
3750
- name: knowledgeSource.name,
3751
- // line, column <- TODO: [☀]
3752
- // <- TODO: [❎]
3753
- },
3754
- ],
3755
- }));
3756
- knowledgePreparedUnflatten[index] = pieces;
3757
3785
  });
3758
3786
  const knowledgePrepared = knowledgePreparedUnflatten.flat();
3759
3787
  return knowledgePrepared;
@@ -4171,7 +4199,7 @@
4171
4199
  if (parameterNames.has(subparameterName)) {
4172
4200
  parameterNames.delete(subparameterName);
4173
4201
  parameterNames.add(foreach.parameterName);
4174
- // <- TODO: [🚎] Warn/logic error when `subparameterName` not used
4202
+ // <- TODO: [🏮] Warn/logic error when `subparameterName` not used
4175
4203
  }
4176
4204
  }
4177
4205
  }
@@ -5784,6 +5812,7 @@
5784
5812
 
5785
5813
  @see more at https://ptbk.io/prepare-pipeline
5786
5814
  `));
5815
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
5787
5816
  }
5788
5817
  let runCount = 0;
5789
5818
  const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
@@ -6809,6 +6838,7 @@
6809
6838
  https://github.com/webgptorg/promptbook
6810
6839
  `));
6811
6840
  });
6841
+ // TODO: !!!!!! Add login route
6812
6842
  app.get(`${rootPath}/books`, async (request, response) => {
6813
6843
  if (collection === null) {
6814
6844
  response.status(500).send('No collection available');