@promptbook/website-crawler 0.92.0-31 β†’ 0.92.0-33

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-31';
32
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-33';
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
  }
@@ -2959,23 +2971,17 @@ class MultipleLlmExecutionTools {
2959
2971
  * Check the configuration of all execution tools
2960
2972
  */
2961
2973
  async checkConfiguration() {
2962
- // TODO: Maybe do it in parallel
2963
- for (const llmExecutionTools of this.llmExecutionTools) {
2964
- await llmExecutionTools.checkConfiguration();
2965
- }
2974
+ // Note: Run checks in parallel
2975
+ await Promise.all(this.llmExecutionTools.map((tools) => tools.checkConfiguration()));
2966
2976
  }
2967
2977
  /**
2968
2978
  * List all available models that can be used
2969
2979
  * This lists is a combination of all available models from all execution tools
2970
2980
  */
2971
2981
  async listModels() {
2972
- const availableModels = [];
2973
- for (const llmExecutionTools of this.llmExecutionTools) {
2974
- // TODO: [πŸͺ‚] Obtain models in parallel
2975
- const models = await llmExecutionTools.listModels();
2976
- availableModels.push(...models);
2977
- }
2978
- return availableModels;
2982
+ // Obtain all models in parallel and flatten
2983
+ const modelArrays = await Promise.all(this.llmExecutionTools.map((tools) => tools.listModels()));
2984
+ return modelArrays.flat();
2979
2985
  }
2980
2986
  /**
2981
2987
  * Calls the best available chat model
@@ -5371,7 +5377,7 @@ async function getKnowledgeForTask(options) {
5371
5377
  });
5372
5378
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5373
5379
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5374
- console.log('!!! Embedding', {
5380
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5375
5381
  task,
5376
5382
  taskEmbeddingPrompt,
5377
5383
  taskEmbeddingResult,
@@ -5407,6 +5413,7 @@ async function getKnowledgeForTask(options) {
5407
5413
  */
5408
5414
  async function getReservedParametersForTask(options) {
5409
5415
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5416
+ console.log('!!! getReservedParametersForTask', options);
5410
5417
  const context = await getContextForTask(); // <- [🏍]
5411
5418
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5412
5419
  const examples = await getExamplesForTask();
@@ -5443,6 +5450,7 @@ async function getReservedParametersForTask(options) {
5443
5450
  */
5444
5451
  async function executeTask(options) {
5445
5452
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5453
+ console.log('!!! executeTask', options);
5446
5454
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5447
5455
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5448
5456
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5466,14 +5474,15 @@ async function executeTask(options) {
5466
5474
 
5467
5475
  `));
5468
5476
  }
5477
+ const reservedParameters = await getReservedParametersForTask({
5478
+ tools,
5479
+ preparedPipeline,
5480
+ task: currentTask,
5481
+ pipelineIdentification,
5482
+ parameters: parametersToPass,
5483
+ });
5469
5484
  const definedParameters = Object.freeze({
5470
- ...(await getReservedParametersForTask({
5471
- tools,
5472
- preparedPipeline,
5473
- task: currentTask,
5474
- pipelineIdentification,
5475
- parameters: parametersToPass,
5476
- })),
5485
+ ...reservedParameters,
5477
5486
  ...parametersToPass,
5478
5487
  });
5479
5488
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -5920,6 +5929,7 @@ function createPipelineExecutor(options) {
5920
5929
  };
5921
5930
  const pipelineExecutor = (inputParameters) => createTask({
5922
5931
  taskType: 'EXECUTION',
5932
+ title: pipeline.title,
5923
5933
  taskProcessCallback(updateOngoingResult) {
5924
5934
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
5925
5935
  updateOngoingResult(newOngoingResult);