@promptbook/wizard 0.104.0-13 → 0.104.0-15

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
@@ -36,7 +36,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
36
36
  * @generated
37
37
  * @see https://github.com/webgptorg/promptbook
38
38
  */
39
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-13';
39
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-15';
40
40
  /**
41
41
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
42
42
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3265,8 +3265,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
3265
3265
  */
3266
3266
  function removeDiacritics(input) {
3267
3267
  /*eslint no-control-regex: "off"*/
3268
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
3269
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
3268
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
3269
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
3270
3270
  });
3271
3271
  }
3272
3272
  /**
@@ -9324,7 +9324,7 @@ async function forEachAsync(array, options, callbackfunction) {
9324
9324
  tasks.push(task);
9325
9325
  runningTasks.push(task);
9326
9326
  /* not await */ Promise.resolve(task).then(() => {
9327
- runningTasks = runningTasks.filter((t) => t !== task);
9327
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
9328
9328
  });
9329
9329
  if (maxParallelCount < runningTasks.length) {
9330
9330
  await Promise.race(runningTasks);
@@ -9381,10 +9381,14 @@ function addUsage(...usageItems) {
9381
9381
  }
9382
9382
 
9383
9383
  /**
9384
- * Intercepts LLM tools and counts total usage of the tools
9384
+ * Intercepts LLM tools and counts total usage of the tools.
9385
9385
  *
9386
- * @param llmTools LLM tools to be intercepted with usage counting
9387
- * @returns LLM tools with same functionality with added total cost counting
9386
+ * This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
9387
+ * usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
9388
+ * in real-time through an observable.
9389
+ *
9390
+ * @param llmTools - The LLM tools to be intercepted and tracked
9391
+ * @returns An augmented version of the tools that includes usage tracking capabilities
9388
9392
  * @public exported from `@promptbook/core`
9389
9393
  */
9390
9394
  function countUsage(llmTools) {
@@ -9649,17 +9653,21 @@ class MultipleLlmExecutionTools {
9649
9653
  */
9650
9654
 
9651
9655
  /**
9652
- * Joins multiple LLM Execution Tools into one
9656
+ * Joins multiple LLM Execution Tools into one.
9653
9657
  *
9654
- * @returns {LlmExecutionTools} Single wrapper for multiple LlmExecutionTools
9658
+ * This function takes a list of `LlmExecutionTools` and returns a single unified
9659
+ * `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
9655
9660
  *
9656
- * 0) If there is no LlmExecutionTools, it warns and returns valid but empty LlmExecutionTools
9657
- * 1) If there is only one LlmExecutionTools, it returns it wrapped in a proxy object
9658
- * 2) If there are multiple LlmExecutionTools, first will be used first, second will be used if the first hasn`t defined model variant or fails, etc.
9659
- * 3) When all LlmExecutionTools fail, it throws an error with a list of all errors merged into one
9661
+ * 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
9662
+ * If the first provider doesn't support the requested model or fails, it tries the next one.
9663
+ * 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
9664
+ * 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
9660
9665
  *
9666
+ * @param title - A descriptive title for this collection of joined tools
9667
+ * @param llmExecutionTools - An array of execution tools to be joined
9668
+ * @returns A single unified execution tool wrapper
9661
9669
  *
9662
- * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
9670
+ * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
9663
9671
  *
9664
9672
  * @public exported from `@promptbook/core`
9665
9673
  */
@@ -11762,7 +11770,7 @@ async function getKnowledgeForTask(options) {
11762
11770
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
11763
11771
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
11764
11772
  const { index } = knowledgePiece;
11765
- const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowledgeIndex.modelName);
11773
+ const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
11766
11774
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
11767
11775
  if (knowledgePieceIndex === undefined) {
11768
11776
  return {
@@ -12210,7 +12218,7 @@ async function executePipeline(options) {
12210
12218
  resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
12211
12219
  })
12212
12220
  .then(() => {
12213
- resolving = resolving.filter((w) => w !== work);
12221
+ resolving = resolving.filter((workItem) => workItem !== work);
12214
12222
  });
12215
12223
  // <- Note: Errors are catched here [3]
12216
12224
  // TODO: BUT if in multiple tasks are errors, only the first one is catched so maybe we should catch errors here and save them to errors array here
@@ -12376,7 +12384,7 @@ function createPipelineExecutor(options) {
12376
12384
  // Calculate and update tldr based on pipeline progress
12377
12385
  const cv = newOngoingResult;
12378
12386
  // Calculate progress based on parameters resolved vs total parameters
12379
- const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
12387
+ const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
12380
12388
  let resolvedParameters = 0;
12381
12389
  let currentTaskTitle = '';
12382
12390
  // Get the resolved parameters from output parameters
@@ -13723,8 +13731,8 @@ const _FormattedBookInMarkdownTranspilerRegistration = $bookTranspilersRegister.
13723
13731
  */
13724
13732
  function createCommitmentRegex(commitment, aliases = [], requiresContent = true) {
13725
13733
  const allCommitments = [commitment, ...aliases];
13726
- const patterns = allCommitments.map((c) => {
13727
- const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13734
+ const patterns = allCommitments.map((commitment) => {
13735
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13728
13736
  return escapedCommitment.split(/\s+/).join('\\s+');
13729
13737
  });
13730
13738
  const keywordPattern = patterns.join('|');
@@ -13746,8 +13754,8 @@ function createCommitmentRegex(commitment, aliases = [], requiresContent = true)
13746
13754
  */
13747
13755
  function createCommitmentTypeRegex(commitment, aliases = []) {
13748
13756
  const allCommitments = [commitment, ...aliases];
13749
- const patterns = allCommitments.map((c) => {
13750
- const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13757
+ const patterns = allCommitments.map((commitment) => {
13758
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13751
13759
  return escapedCommitment.split(/\s+/).join('\\s+');
13752
13760
  });
13753
13761
  const keywordPattern = patterns.join('|');
@@ -17409,8 +17417,8 @@ function parseParameters(text) {
17409
17417
  return match;
17410
17418
  });
17411
17419
  // Remove duplicates based on name (keep the first occurrence)
17412
- const uniqueParameters = parameters.filter((param, index, array) => {
17413
- return array.findIndex((p) => p.name === param.name) === index;
17420
+ const uniqueParameters = parameters.filter((parameter, index, array) => {
17421
+ return array.findIndex((parameterItem) => parameterItem.name === parameter.name) === index;
17414
17422
  });
17415
17423
  return uniqueParameters;
17416
17424
  }
@@ -17457,7 +17465,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
17457
17465
  commitment.type === 'DISCARD' ||
17458
17466
  commitment.type === 'REMOVE') {
17459
17467
  const targets = parseParameters(commitment.content)
17460
- .map((p) => p.name.trim().toLowerCase())
17468
+ .map((parameter) => parameter.name.trim().toLowerCase())
17461
17469
  .filter(Boolean);
17462
17470
  if (targets.length === 0) {
17463
17471
  // Ignore DELETE with no targets; also don't pass the DELETE further
@@ -17466,8 +17474,8 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
17466
17474
  // Drop prior kept commitments that contain any of the targeted tags
17467
17475
  for (let i = filteredCommitments.length - 1; i >= 0; i--) {
17468
17476
  const prev = filteredCommitments[i];
17469
- const prevParams = parseParameters(prev.content).map((p) => p.name.trim().toLowerCase());
17470
- const hasIntersection = prevParams.some((n) => targets.includes(n));
17477
+ const prevParams = parseParameters(prev.content).map((parameter) => parameter.name.trim().toLowerCase());
17478
+ const hasIntersection = prevParams.some((parameterName) => targets.includes(parameterName));
17471
17479
  if (hasIntersection) {
17472
17480
  filteredCommitments.splice(i, 1);
17473
17481
  }