@promptbook/website-crawler 0.92.0-32 → 0.92.0-34

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.
package/esm/index.es.js CHANGED
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
29
29
  * @generated
30
30
  * @see https://github.com/webgptorg/promptbook
31
31
  */
32
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-32';
32
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-34';
33
33
  /**
34
34
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
35
35
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2630,6 +2630,7 @@ function assertsTaskSuccessful(executionResult) {
2630
2630
  */
2631
2631
  function createTask(options) {
2632
2632
  const { taskType, taskProcessCallback } = options;
2633
+ let { title } = options;
2633
2634
  // TODO: [🐙] DRY
2634
2635
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
2635
2636
  let status = 'RUNNING';
@@ -2641,6 +2642,10 @@ function createTask(options) {
2641
2642
  const partialResultSubject = new Subject();
2642
2643
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2643
2644
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
2645
+ if (newOngoingResult.title) {
2646
+ title = newOngoingResult.title;
2647
+ }
2648
+ updatedAt = new Date();
2644
2649
  Object.assign(currentValue, newOngoingResult);
2645
2650
  // <- TODO: assign deep
2646
2651
  partialResultSubject.next(newOngoingResult);
@@ -2686,17 +2691,24 @@ function createTask(options) {
2686
2691
  return {
2687
2692
  taskType,
2688
2693
  taskId,
2694
+ get promptbookVersion() {
2695
+ return PROMPTBOOK_ENGINE_VERSION;
2696
+ },
2697
+ get title() {
2698
+ return title;
2699
+ // <- Note: [1] Theese must be getters to allow changing the value in the future
2700
+ },
2689
2701
  get status() {
2690
2702
  return status;
2691
- // <- Note: [1] Theese must be getters to allow changing the value in the future
2703
+ // <- Note: [1] --||--
2692
2704
  },
2693
2705
  get createdAt() {
2694
2706
  return createdAt;
2695
- // <- Note: [1]
2707
+ // <- Note: [1] --||--
2696
2708
  },
2697
2709
  get updatedAt() {
2698
2710
  return updatedAt;
2699
- // <- Note: [1]
2711
+ // <- Note: [1] --||--
2700
2712
  },
2701
2713
  asPromise,
2702
2714
  asObservable() {
@@ -2704,15 +2716,15 @@ function createTask(options) {
2704
2716
  },
2705
2717
  get errors() {
2706
2718
  return errors;
2707
- // <- Note: [1]
2719
+ // <- Note: [1] --||--
2708
2720
  },
2709
2721
  get warnings() {
2710
2722
  return warnings;
2711
- // <- Note: [1]
2723
+ // <- Note: [1] --||--
2712
2724
  },
2713
2725
  get currentValue() {
2714
2726
  return currentValue;
2715
- // <- Note: [1]
2727
+ // <- Note: [1] --||--
2716
2728
  },
2717
2729
  };
2718
2730
  }
@@ -2877,12 +2889,14 @@ function countUsage(llmTools) {
2877
2889
  const spending = new Subject();
2878
2890
  const proxyTools = {
2879
2891
  get title() {
2880
- // TODO: [🧠] Maybe put here some suffix
2881
- return llmTools.title;
2892
+ return `${llmTools.title} (+usage)`;
2893
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
2894
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
2882
2895
  },
2883
2896
  get description() {
2884
- // TODO: [🧠] Maybe put here some suffix
2885
- return llmTools.description;
2897
+ return `${llmTools.description} (+usage)`;
2898
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
2899
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
2886
2900
  },
2887
2901
  checkConfiguration() {
2888
2902
  return /* not await */ llmTools.checkConfiguration();
@@ -2953,7 +2967,14 @@ class MultipleLlmExecutionTools {
2953
2967
  return 'Multiple LLM Providers';
2954
2968
  }
2955
2969
  get description() {
2956
- return this.llmExecutionTools.map(({ title }, index) => `${index + 1}) \`${title}\``).join('\n');
2970
+ const innerModelsTitlesAndDescriptions = this.llmExecutionTools
2971
+ .map(({ title, description }, index) => `${index + 1}) \`${title}\`\n${description}`)
2972
+ .join('\n\n');
2973
+ return spaceTrim$1((block) => `
2974
+ Multiple LLM Providers:
2975
+
2976
+ ${block(innerModelsTitlesAndDescriptions)}
2977
+ `);
2957
2978
  }
2958
2979
  /**
2959
2980
  * Check the configuration of all execution tools
@@ -5327,6 +5348,7 @@ function knowledgePiecesToString(knowledgePieces) {
5327
5348
  */
5328
5349
  async function getKnowledgeForTask(options) {
5329
5350
  const { tools, preparedPipeline, task, parameters } = options;
5351
+ console.log('!!! getKnowledgeForTask', options);
5330
5352
  const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
5331
5353
  const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
5332
5354
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
@@ -5365,7 +5387,7 @@ async function getKnowledgeForTask(options) {
5365
5387
  });
5366
5388
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5367
5389
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5368
- console.log('!!! Embedding', {
5390
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5369
5391
  task,
5370
5392
  taskEmbeddingPrompt,
5371
5393
  taskEmbeddingResult,
@@ -5401,6 +5423,7 @@ async function getKnowledgeForTask(options) {
5401
5423
  */
5402
5424
  async function getReservedParametersForTask(options) {
5403
5425
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5426
+ console.log('!!! getReservedParametersForTask', options);
5404
5427
  const context = await getContextForTask(); // <- [🏍]
5405
5428
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5406
5429
  const examples = await getExamplesForTask();
@@ -5437,6 +5460,7 @@ async function getReservedParametersForTask(options) {
5437
5460
  */
5438
5461
  async function executeTask(options) {
5439
5462
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5463
+ console.log('!!! executeTask', options);
5440
5464
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5441
5465
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5442
5466
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5460,14 +5484,15 @@ async function executeTask(options) {
5460
5484
 
5461
5485
  `));
5462
5486
  }
5487
+ const reservedParameters = await getReservedParametersForTask({
5488
+ tools,
5489
+ preparedPipeline,
5490
+ task: currentTask,
5491
+ pipelineIdentification,
5492
+ parameters: parametersToPass,
5493
+ });
5463
5494
  const definedParameters = Object.freeze({
5464
- ...(await getReservedParametersForTask({
5465
- tools,
5466
- preparedPipeline,
5467
- task: currentTask,
5468
- pipelineIdentification,
5469
- parameters: parametersToPass,
5470
- })),
5495
+ ...reservedParameters,
5471
5496
  ...parametersToPass,
5472
5497
  });
5473
5498
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -5914,6 +5939,7 @@ function createPipelineExecutor(options) {
5914
5939
  };
5915
5940
  const pipelineExecutor = (inputParameters) => createTask({
5916
5941
  taskType: 'EXECUTION',
5942
+ title: pipeline.title,
5917
5943
  taskProcessCallback(updateOngoingResult) {
5918
5944
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
5919
5945
  updateOngoingResult(newOngoingResult);
@@ -6044,6 +6070,12 @@ class MarkdownScraper {
6044
6070
  }
6045
6071
  // ---
6046
6072
  if (!llmTools.callEmbeddingModel) {
6073
+ console.log('!!! No callEmbeddingModel function provided', {
6074
+ 'llmTools.title': llmTools.title,
6075
+ 'llmTools.description': llmTools.description,
6076
+ 'llmTools.callEmbeddingModel': llmTools.callEmbeddingModel,
6077
+ llmTools,
6078
+ });
6047
6079
  // TODO: [🟥] Detect browser / node and make it colorfull
6048
6080
  console.error('No callEmbeddingModel function provided');
6049
6081
  }