@promptbook/cli 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
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-3';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-4';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -261,7 +261,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
261
261
  *
262
262
  * @public exported from `@promptbook/core`
263
263
  */
264
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
264
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
265
265
  // <- TODO: [๐Ÿ]
266
266
  /**
267
267
  * Where to store your books
@@ -6284,6 +6284,7 @@ async function executeAttempts(options) {
6284
6284
  $resultString: null,
6285
6285
  $expectError: null,
6286
6286
  $scriptPipelineExecutionErrors: [],
6287
+ $failedResults: [], // Track all failed attempts
6287
6288
  };
6288
6289
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
6289
6290
  const _llms = arrayableToArray(tools.llm);
@@ -6529,6 +6530,14 @@ async function executeAttempts(options) {
6529
6530
  throw error;
6530
6531
  }
6531
6532
  $ongoingTaskResult.$expectError = error;
6533
+ // Store each failed attempt
6534
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
6535
+ $ongoingTaskResult.$failedResults = [];
6536
+ }
6537
+ $ongoingTaskResult.$failedResults.push({
6538
+ result: $ongoingTaskResult.$resultString,
6539
+ error: error,
6540
+ });
6532
6541
  }
6533
6542
  finally {
6534
6543
  if (!isJokerAttempt &&
@@ -6551,34 +6560,46 @@ async function executeAttempts(options) {
6551
6560
  }
6552
6561
  }
6553
6562
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
6563
+ // Store the current failure before throwing
6564
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
6565
+ $ongoingTaskResult.$failedResults.push({
6566
+ result: $ongoingTaskResult.$resultString,
6567
+ error: $ongoingTaskResult.$expectError,
6568
+ });
6569
+ // Create a summary of all failures
6570
+ const failuresSummary = $ongoingTaskResult.$failedResults
6571
+ .map((failure, index) => spaceTrim$1((block) => {
6572
+ var _a, _b;
6573
+ return `
6574
+ Attempt ${index + 1}:
6575
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
6576
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
6577
+
6578
+ Result:
6579
+ ${block(failure.result === null
6580
+ ? 'null'
6581
+ : spaceTrim$1(failure.result)
6582
+ .split('\n')
6583
+ .map((line) => `> ${line}`)
6584
+ .join('\n'))}
6585
+ `;
6586
+ }))
6587
+ .join('\n\n---\n\n');
6554
6588
  throw new PipelineExecutionError(spaceTrim$1((block) => {
6555
- var _a, _b, _c;
6589
+ var _a;
6556
6590
  return `
6557
6591
  LLM execution failed ${maxExecutionAttempts}x
6558
6592
 
6559
6593
  ${block(pipelineIdentification)}
6560
6594
 
6561
- ---
6562
6595
  The Prompt:
6563
6596
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
6564
6597
  .split('\n')
6565
6598
  .map((line) => `> ${line}`)
6566
6599
  .join('\n'))}
6567
6600
 
6568
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
6569
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
6570
- .split('\n')
6571
- .map((line) => `> ${line}`)
6572
- .join('\n'))}
6573
-
6574
- Last result:
6575
- ${block($ongoingTaskResult.$resultString === null
6576
- ? 'null'
6577
- : spaceTrim$1($ongoingTaskResult.$resultString)
6578
- .split('\n')
6579
- .map((line) => `> ${line}`)
6580
- .join('\n'))}
6581
- ---
6601
+ All Failed Attempts:
6602
+ ${block(failuresSummary)}
6582
6603
  `;
6583
6604
  }));
6584
6605
  }
@@ -18328,6 +18349,27 @@ const createOpenAiAssistantExecutionTools = Object.assign((options) => {
18328
18349
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
18329
18350
  */
18330
18351
 
18352
+ /**
18353
+ * Execution Tools for calling OpenAI compatible API
18354
+ *
18355
+ * Note: This can be used for any OpenAI compatible APIs
18356
+ *
18357
+ * @public exported from `@promptbook/openai`
18358
+ */
18359
+ const createOpenAiCompatibleExecutionTools = Object.assign((options) => {
18360
+ if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
18361
+ options = { ...options, dangerouslyAllowBrowser: true };
18362
+ }
18363
+ return new OpenAiExecutionTools(options);
18364
+ }, {
18365
+ packageName: '@promptbook/openai',
18366
+ className: 'OpenAiCompatibleExecutionTools',
18367
+ });
18368
+ /**
18369
+ * TODO: [๐Ÿฆบ] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
18370
+ * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
18371
+ */
18372
+
18331
18373
  /**
18332
18374
  * Execution Tools for calling OpenAI API
18333
18375
  *
@@ -18370,6 +18412,16 @@ const _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTool
18370
18412
  * @public exported from `@promptbook/cli`
18371
18413
  */
18372
18414
  const _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);
18415
+ /**
18416
+ * Registration of the OpenAI Compatible provider
18417
+ *
18418
+ * Note: [๐Ÿ] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
18419
+ *
18420
+ * @public exported from `@promptbook/openai`
18421
+ * @public exported from `@promptbook/wizard`
18422
+ * @public exported from `@promptbook/cli`
18423
+ */
18424
+ const _OpenAiCompatibleRegistration = $llmToolsRegister.register(createOpenAiCompatibleExecutionTools);
18373
18425
  /**
18374
18426
  * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
18375
18427
  * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
@@ -19611,5 +19663,5 @@ const _WebsiteScraperRegistration = $scrapersRegister.register(createWebsiteScra
19611
19663
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
19612
19664
  */
19613
19665
 
19614
- export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _BoilerplateScraperMetadataRegistration, _BoilerplateScraperRegistration, _CLI, _DeepseekMetadataRegistration, _DeepseekRegistration, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _MarkitdownScraperMetadataRegistration, _MarkitdownScraperRegistration, _OllamaMetadataRegistration, _OllamaRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration };
19666
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _BoilerplateScraperMetadataRegistration, _BoilerplateScraperRegistration, _CLI, _DeepseekMetadataRegistration, _DeepseekRegistration, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _MarkitdownScraperMetadataRegistration, _MarkitdownScraperRegistration, _OllamaMetadataRegistration, _OllamaRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiCompatibleRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration };
19615
19667
  //# sourceMappingURL=index.es.js.map