@promptbook/cli 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
@@ -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-2';
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
  }
@@ -18044,6 +18065,38 @@ const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register(
18044
18065
  */
18045
18066
  },
18046
18067
  });
18068
+ /**
18069
+ * Registration of the OpenAI Compatible metadata
18070
+ *
18071
+ * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be instantiated directly.
18072
+ * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
18073
+ *
18074
+ * @public exported from `@promptbook/core`
18075
+ * @public exported from `@promptbook/wizard`
18076
+ * @public exported from `@promptbook/cli`
18077
+ */
18078
+ const _OpenAiCompatibleMetadataRegistration = $llmToolsMetadataRegister.register({
18079
+ title: 'Open AI Compatible',
18080
+ packageName: '@promptbook/openai',
18081
+ className: 'OpenAiCompatibleExecutionTools',
18082
+ envVariables: ['OPENAI_API_KEY'],
18083
+ trustLevel: 'CLOSED',
18084
+ order: MODEL_ORDERS.TOP_TIER,
18085
+ getBoilerplateConfiguration() {
18086
+ return {
18087
+ title: 'Open AI Compatible',
18088
+ packageName: '@promptbook/openai',
18089
+ className: 'OpenAiCompatibleExecutionTools',
18090
+ options: {
18091
+ apiKey: 'sk-',
18092
+ maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
18093
+ },
18094
+ };
18095
+ },
18096
+ createConfigurationFromEnv(env) {
18097
+ return null;
18098
+ },
18099
+ });
18047
18100
  /**
18048
18101
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
18049
18102
  */
@@ -18296,6 +18349,27 @@ const createOpenAiAssistantExecutionTools = Object.assign((options) => {
18296
18349
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
18297
18350
  */
18298
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
+
18299
18373
  /**
18300
18374
  * Execution Tools for calling OpenAI API
18301
18375
  *
@@ -18317,6 +18391,7 @@ const createOpenAiExecutionTools = Object.assign((options) => {
18317
18391
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
18318
18392
  */
18319
18393
 
18394
+ // Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be instantiated directly
18320
18395
  /**
18321
18396
  * Registration of LLM provider
18322
18397
  *
@@ -18337,6 +18412,20 @@ const _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTool
18337
18412
  * @public exported from `@promptbook/cli`
18338
18413
  */
18339
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);
18425
+ /**
18426
+ * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
18427
+ * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
18428
+ */
18340
18429
  /**
18341
18430
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
18342
18431
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -19574,5 +19663,5 @@ const _WebsiteScraperRegistration = $scrapersRegister.register(createWebsiteScra
19574
19663
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
19575
19664
  */
19576
19665
 
19577
- 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, _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 };
19578
19667
  //# sourceMappingURL=index.es.js.map