@promptbook/pdf 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
@@ -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-32';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-34';
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
  }
@@ -2761,12 +2773,14 @@ function countUsage(llmTools) {
2761
2773
  const spending = new Subject();
2762
2774
  const proxyTools = {
2763
2775
  get title() {
2764
- // TODO: [🧠] Maybe put here some suffix
2765
- return llmTools.title;
2776
+ return `${llmTools.title} (+usage)`;
2777
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
2778
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
2766
2779
  },
2767
2780
  get description() {
2768
- // TODO: [🧠] Maybe put here some suffix
2769
- return llmTools.description;
2781
+ return `${llmTools.description} (+usage)`;
2782
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
2783
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
2770
2784
  },
2771
2785
  checkConfiguration() {
2772
2786
  return /* not await */ llmTools.checkConfiguration();
@@ -2837,7 +2851,14 @@ class MultipleLlmExecutionTools {
2837
2851
  return 'Multiple LLM Providers';
2838
2852
  }
2839
2853
  get description() {
2840
- return this.llmExecutionTools.map(({ title }, index) => `${index + 1}) \`${title}\``).join('\n');
2854
+ const innerModelsTitlesAndDescriptions = this.llmExecutionTools
2855
+ .map(({ title, description }, index) => `${index + 1}) \`${title}\`\n${description}`)
2856
+ .join('\n\n');
2857
+ return spaceTrim((block) => `
2858
+ Multiple LLM Providers:
2859
+
2860
+ ${block(innerModelsTitlesAndDescriptions)}
2861
+ `);
2841
2862
  }
2842
2863
  /**
2843
2864
  * Check the configuration of all execution tools
@@ -5326,6 +5347,7 @@ function knowledgePiecesToString(knowledgePieces) {
5326
5347
  */
5327
5348
  async function getKnowledgeForTask(options) {
5328
5349
  const { tools, preparedPipeline, task, parameters } = options;
5350
+ console.log('!!! getKnowledgeForTask', options);
5329
5351
  const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
5330
5352
  const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
5331
5353
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
@@ -5364,7 +5386,7 @@ async function getKnowledgeForTask(options) {
5364
5386
  });
5365
5387
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5366
5388
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5367
- console.log('!!! Embedding', {
5389
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5368
5390
  task,
5369
5391
  taskEmbeddingPrompt,
5370
5392
  taskEmbeddingResult,
@@ -5400,6 +5422,7 @@ async function getKnowledgeForTask(options) {
5400
5422
  */
5401
5423
  async function getReservedParametersForTask(options) {
5402
5424
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5425
+ console.log('!!! getReservedParametersForTask', options);
5403
5426
  const context = await getContextForTask(); // <- [🏍]
5404
5427
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5405
5428
  const examples = await getExamplesForTask();
@@ -5436,6 +5459,7 @@ async function getReservedParametersForTask(options) {
5436
5459
  */
5437
5460
  async function executeTask(options) {
5438
5461
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5462
+ console.log('!!! executeTask', options);
5439
5463
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5440
5464
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5441
5465
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5459,14 +5483,15 @@ async function executeTask(options) {
5459
5483
 
5460
5484
  `));
5461
5485
  }
5486
+ const reservedParameters = await getReservedParametersForTask({
5487
+ tools,
5488
+ preparedPipeline,
5489
+ task: currentTask,
5490
+ pipelineIdentification,
5491
+ parameters: parametersToPass,
5492
+ });
5462
5493
  const definedParameters = Object.freeze({
5463
- ...(await getReservedParametersForTask({
5464
- tools,
5465
- preparedPipeline,
5466
- task: currentTask,
5467
- pipelineIdentification,
5468
- parameters: parametersToPass,
5469
- })),
5494
+ ...reservedParameters,
5470
5495
  ...parametersToPass,
5471
5496
  });
5472
5497
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -5913,6 +5938,7 @@ function createPipelineExecutor(options) {
5913
5938
  };
5914
5939
  const pipelineExecutor = (inputParameters) => createTask({
5915
5940
  taskType: 'EXECUTION',
5941
+ title: pipeline.title,
5916
5942
  taskProcessCallback(updateOngoingResult) {
5917
5943
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
5918
5944
  updateOngoingResult(newOngoingResult);
@@ -6043,6 +6069,12 @@ class MarkdownScraper {
6043
6069
  }
6044
6070
  // ---
6045
6071
  if (!llmTools.callEmbeddingModel) {
6072
+ console.log('!!! No callEmbeddingModel function provided', {
6073
+ 'llmTools.title': llmTools.title,
6074
+ 'llmTools.description': llmTools.description,
6075
+ 'llmTools.callEmbeddingModel': llmTools.callEmbeddingModel,
6076
+ llmTools,
6077
+ });
6046
6078
  // TODO: [🟥] Detect browser / node and make it colorfull
6047
6079
  console.error('No callEmbeddingModel function provided');
6048
6080
  }