@promptbook/legacy-documents 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
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-3';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-5';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -177,7 +177,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
177
177
  *
178
178
  * @public exported from `@promptbook/core`
179
179
  */
180
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
180
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
181
181
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
182
182
  // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
183
183
  /**
@@ -4989,6 +4989,7 @@ async function executeAttempts(options) {
4989
4989
  $resultString: null,
4990
4990
  $expectError: null,
4991
4991
  $scriptPipelineExecutionErrors: [],
4992
+ $failedResults: [], // Track all failed attempts
4992
4993
  };
4993
4994
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
4994
4995
  const _llms = arrayableToArray(tools.llm);
@@ -5234,6 +5235,14 @@ async function executeAttempts(options) {
5234
5235
  throw error;
5235
5236
  }
5236
5237
  $ongoingTaskResult.$expectError = error;
5238
+ // Store each failed attempt
5239
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
5240
+ $ongoingTaskResult.$failedResults = [];
5241
+ }
5242
+ $ongoingTaskResult.$failedResults.push({
5243
+ result: $ongoingTaskResult.$resultString,
5244
+ error: error,
5245
+ });
5237
5246
  }
5238
5247
  finally {
5239
5248
  if (!isJokerAttempt &&
@@ -5256,34 +5265,46 @@ async function executeAttempts(options) {
5256
5265
  }
5257
5266
  }
5258
5267
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
5268
+ // Store the current failure before throwing
5269
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
5270
+ $ongoingTaskResult.$failedResults.push({
5271
+ result: $ongoingTaskResult.$resultString,
5272
+ error: $ongoingTaskResult.$expectError,
5273
+ });
5274
+ // Create a summary of all failures
5275
+ const failuresSummary = $ongoingTaskResult.$failedResults
5276
+ .map((failure, index) => spaceTrim((block) => {
5277
+ var _a, _b;
5278
+ return `
5279
+ Attempt ${index + 1}:
5280
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
5281
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
5282
+
5283
+ Result:
5284
+ ${block(failure.result === null
5285
+ ? 'null'
5286
+ : spaceTrim(failure.result)
5287
+ .split('\n')
5288
+ .map((line) => `> ${line}`)
5289
+ .join('\n'))}
5290
+ `;
5291
+ }))
5292
+ .join('\n\n---\n\n');
5259
5293
  throw new PipelineExecutionError(spaceTrim((block) => {
5260
- var _a, _b, _c;
5294
+ var _a;
5261
5295
  return `
5262
5296
  LLM execution failed ${maxExecutionAttempts}x
5263
5297
 
5264
5298
  ${block(pipelineIdentification)}
5265
5299
 
5266
- ---
5267
5300
  The Prompt:
5268
5301
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
5269
5302
  .split('\n')
5270
5303
  .map((line) => `> ${line}`)
5271
5304
  .join('\n'))}
5272
5305
 
5273
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
5274
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
5275
- .split('\n')
5276
- .map((line) => `> ${line}`)
5277
- .join('\n'))}
5278
-
5279
- Last result:
5280
- ${block($ongoingTaskResult.$resultString === null
5281
- ? 'null'
5282
- : spaceTrim($ongoingTaskResult.$resultString)
5283
- .split('\n')
5284
- .map((line) => `> ${line}`)
5285
- .join('\n'))}
5286
- ---
5306
+ All Failed Attempts:
5307
+ ${block(failuresSummary)}
5287
5308
  `;
5288
5309
  }));
5289
5310
  }