@promptbook/core 0.98.0-3 โ†’ 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
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-3';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-4';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -354,7 +354,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
354
354
  *
355
355
  * @public exported from `@promptbook/core`
356
356
  */
357
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
357
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
358
358
  /**
359
359
  * The maximum depth to which knowledge sources will be scraped when building a knowledge base.
360
360
  * This prevents infinite recursion and limits resource usage.
@@ -4056,6 +4056,7 @@ async function executeAttempts(options) {
4056
4056
  $resultString: null,
4057
4057
  $expectError: null,
4058
4058
  $scriptPipelineExecutionErrors: [],
4059
+ $failedResults: [], // Track all failed attempts
4059
4060
  };
4060
4061
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
4061
4062
  const _llms = arrayableToArray(tools.llm);
@@ -4301,6 +4302,14 @@ async function executeAttempts(options) {
4301
4302
  throw error;
4302
4303
  }
4303
4304
  $ongoingTaskResult.$expectError = error;
4305
+ // Store each failed attempt
4306
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
4307
+ $ongoingTaskResult.$failedResults = [];
4308
+ }
4309
+ $ongoingTaskResult.$failedResults.push({
4310
+ result: $ongoingTaskResult.$resultString,
4311
+ error: error,
4312
+ });
4304
4313
  }
4305
4314
  finally {
4306
4315
  if (!isJokerAttempt &&
@@ -4323,34 +4332,46 @@ async function executeAttempts(options) {
4323
4332
  }
4324
4333
  }
4325
4334
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
4335
+ // Store the current failure before throwing
4336
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
4337
+ $ongoingTaskResult.$failedResults.push({
4338
+ result: $ongoingTaskResult.$resultString,
4339
+ error: $ongoingTaskResult.$expectError,
4340
+ });
4341
+ // Create a summary of all failures
4342
+ const failuresSummary = $ongoingTaskResult.$failedResults
4343
+ .map((failure, index) => spaceTrim$1((block) => {
4344
+ var _a, _b;
4345
+ return `
4346
+ Attempt ${index + 1}:
4347
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
4348
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
4349
+
4350
+ Result:
4351
+ ${block(failure.result === null
4352
+ ? 'null'
4353
+ : spaceTrim$1(failure.result)
4354
+ .split('\n')
4355
+ .map((line) => `> ${line}`)
4356
+ .join('\n'))}
4357
+ `;
4358
+ }))
4359
+ .join('\n\n---\n\n');
4326
4360
  throw new PipelineExecutionError(spaceTrim$1((block) => {
4327
- var _a, _b, _c;
4361
+ var _a;
4328
4362
  return `
4329
4363
  LLM execution failed ${maxExecutionAttempts}x
4330
4364
 
4331
4365
  ${block(pipelineIdentification)}
4332
4366
 
4333
- ---
4334
4367
  The Prompt:
4335
4368
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
4336
4369
  .split('\n')
4337
4370
  .map((line) => `> ${line}`)
4338
4371
  .join('\n'))}
4339
4372
 
4340
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
4341
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
4342
- .split('\n')
4343
- .map((line) => `> ${line}`)
4344
- .join('\n'))}
4345
-
4346
- Last result:
4347
- ${block($ongoingTaskResult.$resultString === null
4348
- ? 'null'
4349
- : spaceTrim$1($ongoingTaskResult.$resultString)
4350
- .split('\n')
4351
- .map((line) => `> ${line}`)
4352
- .join('\n'))}
4353
- ---
4373
+ All Failed Attempts:
4374
+ ${block(failuresSummary)}
4354
4375
  `;
4355
4376
  }));
4356
4377
  }