@promptbook/remote-server 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
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-2';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-4';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -173,7 +173,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
173
173
  *
174
174
  * @public exported from `@promptbook/core`
175
175
  */
176
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
176
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
177
177
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
178
178
  // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
179
179
  /**
@@ -5180,6 +5180,7 @@ async function executeAttempts(options) {
5180
5180
  $resultString: null,
5181
5181
  $expectError: null,
5182
5182
  $scriptPipelineExecutionErrors: [],
5183
+ $failedResults: [], // Track all failed attempts
5183
5184
  };
5184
5185
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
5185
5186
  const _llms = arrayableToArray(tools.llm);
@@ -5425,6 +5426,14 @@ async function executeAttempts(options) {
5425
5426
  throw error;
5426
5427
  }
5427
5428
  $ongoingTaskResult.$expectError = error;
5429
+ // Store each failed attempt
5430
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
5431
+ $ongoingTaskResult.$failedResults = [];
5432
+ }
5433
+ $ongoingTaskResult.$failedResults.push({
5434
+ result: $ongoingTaskResult.$resultString,
5435
+ error: error,
5436
+ });
5428
5437
  }
5429
5438
  finally {
5430
5439
  if (!isJokerAttempt &&
@@ -5447,34 +5456,46 @@ async function executeAttempts(options) {
5447
5456
  }
5448
5457
  }
5449
5458
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
5459
+ // Store the current failure before throwing
5460
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
5461
+ $ongoingTaskResult.$failedResults.push({
5462
+ result: $ongoingTaskResult.$resultString,
5463
+ error: $ongoingTaskResult.$expectError,
5464
+ });
5465
+ // Create a summary of all failures
5466
+ const failuresSummary = $ongoingTaskResult.$failedResults
5467
+ .map((failure, index) => spaceTrim$1((block) => {
5468
+ var _a, _b;
5469
+ return `
5470
+ Attempt ${index + 1}:
5471
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
5472
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
5473
+
5474
+ Result:
5475
+ ${block(failure.result === null
5476
+ ? 'null'
5477
+ : spaceTrim$1(failure.result)
5478
+ .split('\n')
5479
+ .map((line) => `> ${line}`)
5480
+ .join('\n'))}
5481
+ `;
5482
+ }))
5483
+ .join('\n\n---\n\n');
5450
5484
  throw new PipelineExecutionError(spaceTrim$1((block) => {
5451
- var _a, _b, _c;
5485
+ var _a;
5452
5486
  return `
5453
5487
  LLM execution failed ${maxExecutionAttempts}x
5454
5488
 
5455
5489
  ${block(pipelineIdentification)}
5456
5490
 
5457
- ---
5458
5491
  The Prompt:
5459
5492
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
5460
5493
  .split('\n')
5461
5494
  .map((line) => `> ${line}`)
5462
5495
  .join('\n'))}
5463
5496
 
5464
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
5465
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
5466
- .split('\n')
5467
- .map((line) => `> ${line}`)
5468
- .join('\n'))}
5469
-
5470
- Last result:
5471
- ${block($ongoingTaskResult.$resultString === null
5472
- ? 'null'
5473
- : spaceTrim$1($ongoingTaskResult.$resultString)
5474
- .split('\n')
5475
- .map((line) => `> ${line}`)
5476
- .join('\n'))}
5477
- ---
5497
+ All Failed Attempts:
5498
+ ${block(failuresSummary)}
5478
5499
  `;
5479
5500
  }));
5480
5501
  }