@promptbook/pdf 0.98.0-3 โ†’ 0.98.0-5

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.98.0-3';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-5';
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
@@ -175,7 +175,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
175
175
  *
176
176
  * @public exported from `@promptbook/core`
177
177
  */
178
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
178
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
179
179
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
180
180
  // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
181
181
  /**
@@ -4838,6 +4838,7 @@ async function executeAttempts(options) {
4838
4838
  $resultString: null,
4839
4839
  $expectError: null,
4840
4840
  $scriptPipelineExecutionErrors: [],
4841
+ $failedResults: [], // Track all failed attempts
4841
4842
  };
4842
4843
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
4843
4844
  const _llms = arrayableToArray(tools.llm);
@@ -5083,6 +5084,14 @@ async function executeAttempts(options) {
5083
5084
  throw error;
5084
5085
  }
5085
5086
  $ongoingTaskResult.$expectError = error;
5087
+ // Store each failed attempt
5088
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
5089
+ $ongoingTaskResult.$failedResults = [];
5090
+ }
5091
+ $ongoingTaskResult.$failedResults.push({
5092
+ result: $ongoingTaskResult.$resultString,
5093
+ error: error,
5094
+ });
5086
5095
  }
5087
5096
  finally {
5088
5097
  if (!isJokerAttempt &&
@@ -5105,34 +5114,46 @@ async function executeAttempts(options) {
5105
5114
  }
5106
5115
  }
5107
5116
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
5117
+ // Store the current failure before throwing
5118
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
5119
+ $ongoingTaskResult.$failedResults.push({
5120
+ result: $ongoingTaskResult.$resultString,
5121
+ error: $ongoingTaskResult.$expectError,
5122
+ });
5123
+ // Create a summary of all failures
5124
+ const failuresSummary = $ongoingTaskResult.$failedResults
5125
+ .map((failure, index) => spaceTrim$1((block) => {
5126
+ var _a, _b;
5127
+ return `
5128
+ Attempt ${index + 1}:
5129
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
5130
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
5131
+
5132
+ Result:
5133
+ ${block(failure.result === null
5134
+ ? 'null'
5135
+ : spaceTrim$1(failure.result)
5136
+ .split('\n')
5137
+ .map((line) => `> ${line}`)
5138
+ .join('\n'))}
5139
+ `;
5140
+ }))
5141
+ .join('\n\n---\n\n');
5108
5142
  throw new PipelineExecutionError(spaceTrim$1((block) => {
5109
- var _a, _b, _c;
5143
+ var _a;
5110
5144
  return `
5111
5145
  LLM execution failed ${maxExecutionAttempts}x
5112
5146
 
5113
5147
  ${block(pipelineIdentification)}
5114
5148
 
5115
- ---
5116
5149
  The Prompt:
5117
5150
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
5118
5151
  .split('\n')
5119
5152
  .map((line) => `> ${line}`)
5120
5153
  .join('\n'))}
5121
5154
 
5122
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
5123
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
5124
- .split('\n')
5125
- .map((line) => `> ${line}`)
5126
- .join('\n'))}
5127
-
5128
- Last result:
5129
- ${block($ongoingTaskResult.$resultString === null
5130
- ? 'null'
5131
- : spaceTrim$1($ongoingTaskResult.$resultString)
5132
- .split('\n')
5133
- .map((line) => `> ${line}`)
5134
- .join('\n'))}
5135
- ---
5155
+ All Failed Attempts:
5156
+ ${block(failuresSummary)}
5136
5157
  `;
5137
5158
  }));
5138
5159
  }