@promptbook/pdf 0.88.0 → 0.89.0-1

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/README.md CHANGED
@@ -23,6 +23,10 @@
23
23
 
24
24
 
25
25
 
26
+ <blockquote style="color: #ff8811">
27
+ <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
28
+ </blockquote>
29
+
26
30
  ## 📦 Package `@promptbook/pdf`
27
31
 
28
32
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
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.88.0';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-1';
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
@@ -2598,8 +2598,9 @@ function addUsage(...usageItems) {
2598
2598
  * @returns LLM tools with same functionality with added total cost counting
2599
2599
  * @public exported from `@promptbook/core`
2600
2600
  */
2601
- function countTotalUsage(llmTools) {
2601
+ function countUsage(llmTools) {
2602
2602
  let totalUsage = ZERO_USAGE;
2603
+ const spending = new Subject();
2603
2604
  const proxyTools = {
2604
2605
  get title() {
2605
2606
  // TODO: [🧠] Maybe put here some suffix
@@ -2609,12 +2610,15 @@ function countTotalUsage(llmTools) {
2609
2610
  // TODO: [🧠] Maybe put here some suffix
2610
2611
  return llmTools.description;
2611
2612
  },
2612
- async checkConfiguration() {
2613
+ checkConfiguration() {
2613
2614
  return /* not await */ llmTools.checkConfiguration();
2614
2615
  },
2615
2616
  listModels() {
2616
2617
  return /* not await */ llmTools.listModels();
2617
2618
  },
2619
+ spending() {
2620
+ return spending.asObservable();
2621
+ },
2618
2622
  getTotalUsage() {
2619
2623
  // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2620
2624
  return totalUsage;
@@ -2625,6 +2629,7 @@ function countTotalUsage(llmTools) {
2625
2629
  // console.info('[🚕] callChatModel through countTotalUsage');
2626
2630
  const promptResult = await llmTools.callChatModel(prompt);
2627
2631
  totalUsage = addUsage(totalUsage, promptResult.usage);
2632
+ spending.next(promptResult.usage);
2628
2633
  return promptResult;
2629
2634
  };
2630
2635
  }
@@ -2633,6 +2638,7 @@ function countTotalUsage(llmTools) {
2633
2638
  // console.info('[🚕] callCompletionModel through countTotalUsage');
2634
2639
  const promptResult = await llmTools.callCompletionModel(prompt);
2635
2640
  totalUsage = addUsage(totalUsage, promptResult.usage);
2641
+ spending.next(promptResult.usage);
2636
2642
  return promptResult;
2637
2643
  };
2638
2644
  }
@@ -2641,6 +2647,7 @@ function countTotalUsage(llmTools) {
2641
2647
  // console.info('[🚕] callEmbeddingModel through countTotalUsage');
2642
2648
  const promptResult = await llmTools.callEmbeddingModel(prompt);
2643
2649
  totalUsage = addUsage(totalUsage, promptResult.usage);
2650
+ spending.next(promptResult.usage);
2644
2651
  return promptResult;
2645
2652
  };
2646
2653
  }
@@ -3537,7 +3544,7 @@ async function preparePipeline(pipeline, tools, options) {
3537
3544
  // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
3538
3545
  const _llms = arrayableToArray(tools.llm);
3539
3546
  const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
3540
- const llmToolsWithUsage = countTotalUsage(llmTools);
3547
+ const llmToolsWithUsage = countUsage(llmTools);
3541
3548
  // <- TODO: [🌯]
3542
3549
  /*
3543
3550
  TODO: [🧠][🪑][🔃] Should this be done or not