@promptbook/pdf 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
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-31';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-33';
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
@@ -2514,6 +2514,7 @@ function assertsTaskSuccessful(executionResult) {
2514
2514
  */
2515
2515
  function createTask(options) {
2516
2516
  const { taskType, taskProcessCallback } = options;
2517
+ let { title } = options;
2517
2518
  // TODO: [πŸ™] DRY
2518
2519
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
2519
2520
  let status = 'RUNNING';
@@ -2525,6 +2526,10 @@ function createTask(options) {
2525
2526
  const partialResultSubject = new Subject();
2526
2527
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2527
2528
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
2529
+ if (newOngoingResult.title) {
2530
+ title = newOngoingResult.title;
2531
+ }
2532
+ updatedAt = new Date();
2528
2533
  Object.assign(currentValue, newOngoingResult);
2529
2534
  // <- TODO: assign deep
2530
2535
  partialResultSubject.next(newOngoingResult);
@@ -2570,17 +2575,24 @@ function createTask(options) {
2570
2575
  return {
2571
2576
  taskType,
2572
2577
  taskId,
2578
+ get promptbookVersion() {
2579
+ return PROMPTBOOK_ENGINE_VERSION;
2580
+ },
2581
+ get title() {
2582
+ return title;
2583
+ // <- Note: [1] Theese must be getters to allow changing the value in the future
2584
+ },
2573
2585
  get status() {
2574
2586
  return status;
2575
- // <- Note: [1] Theese must be getters to allow changing the value in the future
2587
+ // <- Note: [1] --||--
2576
2588
  },
2577
2589
  get createdAt() {
2578
2590
  return createdAt;
2579
- // <- Note: [1]
2591
+ // <- Note: [1] --||--
2580
2592
  },
2581
2593
  get updatedAt() {
2582
2594
  return updatedAt;
2583
- // <- Note: [1]
2595
+ // <- Note: [1] --||--
2584
2596
  },
2585
2597
  asPromise,
2586
2598
  asObservable() {
@@ -2588,15 +2600,15 @@ function createTask(options) {
2588
2600
  },
2589
2601
  get errors() {
2590
2602
  return errors;
2591
- // <- Note: [1]
2603
+ // <- Note: [1] --||--
2592
2604
  },
2593
2605
  get warnings() {
2594
2606
  return warnings;
2595
- // <- Note: [1]
2607
+ // <- Note: [1] --||--
2596
2608
  },
2597
2609
  get currentValue() {
2598
2610
  return currentValue;
2599
- // <- Note: [1]
2611
+ // <- Note: [1] --||--
2600
2612
  },
2601
2613
  };
2602
2614
  }
@@ -2843,23 +2855,17 @@ class MultipleLlmExecutionTools {
2843
2855
  * Check the configuration of all execution tools
2844
2856
  */
2845
2857
  async checkConfiguration() {
2846
- // TODO: Maybe do it in parallel
2847
- for (const llmExecutionTools of this.llmExecutionTools) {
2848
- await llmExecutionTools.checkConfiguration();
2849
- }
2858
+ // Note: Run checks in parallel
2859
+ await Promise.all(this.llmExecutionTools.map((tools) => tools.checkConfiguration()));
2850
2860
  }
2851
2861
  /**
2852
2862
  * List all available models that can be used
2853
2863
  * This lists is a combination of all available models from all execution tools
2854
2864
  */
2855
2865
  async listModels() {
2856
- const availableModels = [];
2857
- for (const llmExecutionTools of this.llmExecutionTools) {
2858
- // TODO: [πŸͺ‚] Obtain models in parallel
2859
- const models = await llmExecutionTools.listModels();
2860
- availableModels.push(...models);
2861
- }
2862
- return availableModels;
2866
+ // Obtain all models in parallel and flatten
2867
+ const modelArrays = await Promise.all(this.llmExecutionTools.map((tools) => tools.listModels()));
2868
+ return modelArrays.flat();
2863
2869
  }
2864
2870
  /**
2865
2871
  * Calls the best available chat model
@@ -5370,7 +5376,7 @@ async function getKnowledgeForTask(options) {
5370
5376
  });
5371
5377
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5372
5378
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5373
- console.log('!!! Embedding', {
5379
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5374
5380
  task,
5375
5381
  taskEmbeddingPrompt,
5376
5382
  taskEmbeddingResult,
@@ -5406,6 +5412,7 @@ async function getKnowledgeForTask(options) {
5406
5412
  */
5407
5413
  async function getReservedParametersForTask(options) {
5408
5414
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5415
+ console.log('!!! getReservedParametersForTask', options);
5409
5416
  const context = await getContextForTask(); // <- [🏍]
5410
5417
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5411
5418
  const examples = await getExamplesForTask();
@@ -5442,6 +5449,7 @@ async function getReservedParametersForTask(options) {
5442
5449
  */
5443
5450
  async function executeTask(options) {
5444
5451
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5452
+ console.log('!!! executeTask', options);
5445
5453
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5446
5454
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5447
5455
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5465,14 +5473,15 @@ async function executeTask(options) {
5465
5473
 
5466
5474
  `));
5467
5475
  }
5476
+ const reservedParameters = await getReservedParametersForTask({
5477
+ tools,
5478
+ preparedPipeline,
5479
+ task: currentTask,
5480
+ pipelineIdentification,
5481
+ parameters: parametersToPass,
5482
+ });
5468
5483
  const definedParameters = Object.freeze({
5469
- ...(await getReservedParametersForTask({
5470
- tools,
5471
- preparedPipeline,
5472
- task: currentTask,
5473
- pipelineIdentification,
5474
- parameters: parametersToPass,
5475
- })),
5484
+ ...reservedParameters,
5476
5485
  ...parametersToPass,
5477
5486
  });
5478
5487
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -5919,6 +5928,7 @@ function createPipelineExecutor(options) {
5919
5928
  };
5920
5929
  const pipelineExecutor = (inputParameters) => createTask({
5921
5930
  taskType: 'EXECUTION',
5931
+ title: pipeline.title,
5922
5932
  taskProcessCallback(updateOngoingResult) {
5923
5933
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
5924
5934
  updateOngoingResult(newOngoingResult);