@promptbook/markdown-utils 0.98.0-2 โ†’ 0.98.0-4

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
@@ -25,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-2';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-4';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -304,7 +304,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
304
304
  *
305
305
  * @public exported from `@promptbook/core`
306
306
  */
307
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
307
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
308
308
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
309
309
  // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
310
310
  /**
@@ -4809,6 +4809,7 @@ async function executeAttempts(options) {
4809
4809
  $resultString: null,
4810
4810
  $expectError: null,
4811
4811
  $scriptPipelineExecutionErrors: [],
4812
+ $failedResults: [], // Track all failed attempts
4812
4813
  };
4813
4814
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
4814
4815
  const _llms = arrayableToArray(tools.llm);
@@ -5054,6 +5055,14 @@ async function executeAttempts(options) {
5054
5055
  throw error;
5055
5056
  }
5056
5057
  $ongoingTaskResult.$expectError = error;
5058
+ // Store each failed attempt
5059
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
5060
+ $ongoingTaskResult.$failedResults = [];
5061
+ }
5062
+ $ongoingTaskResult.$failedResults.push({
5063
+ result: $ongoingTaskResult.$resultString,
5064
+ error: error,
5065
+ });
5057
5066
  }
5058
5067
  finally {
5059
5068
  if (!isJokerAttempt &&
@@ -5076,34 +5085,46 @@ async function executeAttempts(options) {
5076
5085
  }
5077
5086
  }
5078
5087
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
5088
+ // Store the current failure before throwing
5089
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
5090
+ $ongoingTaskResult.$failedResults.push({
5091
+ result: $ongoingTaskResult.$resultString,
5092
+ error: $ongoingTaskResult.$expectError,
5093
+ });
5094
+ // Create a summary of all failures
5095
+ const failuresSummary = $ongoingTaskResult.$failedResults
5096
+ .map((failure, index) => spaceTrim$1((block) => {
5097
+ var _a, _b;
5098
+ return `
5099
+ Attempt ${index + 1}:
5100
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
5101
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
5102
+
5103
+ Result:
5104
+ ${block(failure.result === null
5105
+ ? 'null'
5106
+ : spaceTrim$1(failure.result)
5107
+ .split('\n')
5108
+ .map((line) => `> ${line}`)
5109
+ .join('\n'))}
5110
+ `;
5111
+ }))
5112
+ .join('\n\n---\n\n');
5079
5113
  throw new PipelineExecutionError(spaceTrim$1((block) => {
5080
- var _a, _b, _c;
5114
+ var _a;
5081
5115
  return `
5082
5116
  LLM execution failed ${maxExecutionAttempts}x
5083
5117
 
5084
5118
  ${block(pipelineIdentification)}
5085
5119
 
5086
- ---
5087
5120
  The Prompt:
5088
5121
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
5089
5122
  .split('\n')
5090
5123
  .map((line) => `> ${line}`)
5091
5124
  .join('\n'))}
5092
5125
 
5093
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
5094
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
5095
- .split('\n')
5096
- .map((line) => `> ${line}`)
5097
- .join('\n'))}
5098
-
5099
- Last result:
5100
- ${block($ongoingTaskResult.$resultString === null
5101
- ? 'null'
5102
- : spaceTrim$1($ongoingTaskResult.$resultString)
5103
- .split('\n')
5104
- .map((line) => `> ${line}`)
5105
- .join('\n'))}
5106
- ---
5126
+ All Failed Attempts:
5127
+ ${block(failuresSummary)}
5107
5128
  `;
5108
5129
  }));
5109
5130
  }