@promptbook/wizard 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
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-3';
41
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-4';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -232,7 +232,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
232
232
  *
233
233
  * @public exported from `@promptbook/core`
234
234
  */
235
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
235
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
236
236
  // <- TODO: [๐Ÿ]
237
237
  /**
238
238
  * Where to store your books
@@ -5371,6 +5371,27 @@ const createOpenAiAssistantExecutionTools = Object.assign((options) => {
5371
5371
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
5372
5372
  */
5373
5373
 
5374
+ /**
5375
+ * Execution Tools for calling OpenAI compatible API
5376
+ *
5377
+ * Note: This can be used for any OpenAI compatible APIs
5378
+ *
5379
+ * @public exported from `@promptbook/openai`
5380
+ */
5381
+ const createOpenAiCompatibleExecutionTools = Object.assign((options) => {
5382
+ if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
5383
+ options = { ...options, dangerouslyAllowBrowser: true };
5384
+ }
5385
+ return new OpenAiExecutionTools(options);
5386
+ }, {
5387
+ packageName: '@promptbook/openai',
5388
+ className: 'OpenAiCompatibleExecutionTools',
5389
+ });
5390
+ /**
5391
+ * TODO: [๐Ÿฆบ] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
5392
+ * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
5393
+ */
5394
+
5374
5395
  /**
5375
5396
  * Execution Tools for calling OpenAI API
5376
5397
  *
@@ -5413,6 +5434,16 @@ const _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTool
5413
5434
  * @public exported from `@promptbook/cli`
5414
5435
  */
5415
5436
  const _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);
5437
+ /**
5438
+ * Registration of the OpenAI Compatible provider
5439
+ *
5440
+ * Note: [๐Ÿ] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
5441
+ *
5442
+ * @public exported from `@promptbook/openai`
5443
+ * @public exported from `@promptbook/wizard`
5444
+ * @public exported from `@promptbook/cli`
5445
+ */
5446
+ const _OpenAiCompatibleRegistration = $llmToolsRegister.register(createOpenAiCompatibleExecutionTools);
5416
5447
  /**
5417
5448
  * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
5418
5449
  * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
@@ -8677,6 +8708,7 @@ async function executeAttempts(options) {
8677
8708
  $resultString: null,
8678
8709
  $expectError: null,
8679
8710
  $scriptPipelineExecutionErrors: [],
8711
+ $failedResults: [], // Track all failed attempts
8680
8712
  };
8681
8713
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
8682
8714
  const _llms = arrayableToArray(tools.llm);
@@ -8922,6 +8954,14 @@ async function executeAttempts(options) {
8922
8954
  throw error;
8923
8955
  }
8924
8956
  $ongoingTaskResult.$expectError = error;
8957
+ // Store each failed attempt
8958
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
8959
+ $ongoingTaskResult.$failedResults = [];
8960
+ }
8961
+ $ongoingTaskResult.$failedResults.push({
8962
+ result: $ongoingTaskResult.$resultString,
8963
+ error: error,
8964
+ });
8925
8965
  }
8926
8966
  finally {
8927
8967
  if (!isJokerAttempt &&
@@ -8944,34 +8984,46 @@ async function executeAttempts(options) {
8944
8984
  }
8945
8985
  }
8946
8986
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
8987
+ // Store the current failure before throwing
8988
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
8989
+ $ongoingTaskResult.$failedResults.push({
8990
+ result: $ongoingTaskResult.$resultString,
8991
+ error: $ongoingTaskResult.$expectError,
8992
+ });
8993
+ // Create a summary of all failures
8994
+ const failuresSummary = $ongoingTaskResult.$failedResults
8995
+ .map((failure, index) => spaceTrim$1((block) => {
8996
+ var _a, _b;
8997
+ return `
8998
+ Attempt ${index + 1}:
8999
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
9000
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
9001
+
9002
+ Result:
9003
+ ${block(failure.result === null
9004
+ ? 'null'
9005
+ : spaceTrim$1(failure.result)
9006
+ .split('\n')
9007
+ .map((line) => `> ${line}`)
9008
+ .join('\n'))}
9009
+ `;
9010
+ }))
9011
+ .join('\n\n---\n\n');
8947
9012
  throw new PipelineExecutionError(spaceTrim$1((block) => {
8948
- var _a, _b, _c;
9013
+ var _a;
8949
9014
  return `
8950
9015
  LLM execution failed ${maxExecutionAttempts}x
8951
9016
 
8952
9017
  ${block(pipelineIdentification)}
8953
9018
 
8954
- ---
8955
9019
  The Prompt:
8956
9020
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
8957
9021
  .split('\n')
8958
9022
  .map((line) => `> ${line}`)
8959
9023
  .join('\n'))}
8960
9024
 
8961
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
8962
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
8963
- .split('\n')
8964
- .map((line) => `> ${line}`)
8965
- .join('\n'))}
8966
-
8967
- Last result:
8968
- ${block($ongoingTaskResult.$resultString === null
8969
- ? 'null'
8970
- : spaceTrim$1($ongoingTaskResult.$resultString)
8971
- .split('\n')
8972
- .map((line) => `> ${line}`)
8973
- .join('\n'))}
8974
- ---
9025
+ All Failed Attempts:
9026
+ ${block(failuresSummary)}
8975
9027
  `;
8976
9028
  }));
8977
9029
  }
@@ -16700,5 +16752,5 @@ const wizard = new Wizard();
16700
16752
  * Note: [๐ŸŸข] Code in this file should never be never released in packages that could be imported into browser environment
16701
16753
  */
16702
16754
 
16703
- export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _BoilerplateScraperMetadataRegistration, _BoilerplateScraperRegistration, _DeepseekMetadataRegistration, _DeepseekRegistration, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _MarkitdownScraperMetadataRegistration, _MarkitdownScraperRegistration, _OllamaMetadataRegistration, _OllamaRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration, wizard };
16755
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _BoilerplateScraperMetadataRegistration, _BoilerplateScraperRegistration, _DeepseekMetadataRegistration, _DeepseekRegistration, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _MarkitdownScraperMetadataRegistration, _MarkitdownScraperRegistration, _OllamaMetadataRegistration, _OllamaRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiCompatibleRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration, wizard };
16704
16756
  //# sourceMappingURL=index.es.js.map