@promptbook/wizard 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
@@ -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-2';
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
@@ -5087,6 +5087,38 @@ const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register(
5087
5087
  */
5088
5088
  },
5089
5089
  });
5090
+ /**
5091
+ * Registration of the OpenAI Compatible metadata
5092
+ *
5093
+ * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be instantiated directly.
5094
+ * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
5095
+ *
5096
+ * @public exported from `@promptbook/core`
5097
+ * @public exported from `@promptbook/wizard`
5098
+ * @public exported from `@promptbook/cli`
5099
+ */
5100
+ const _OpenAiCompatibleMetadataRegistration = $llmToolsMetadataRegister.register({
5101
+ title: 'Open AI Compatible',
5102
+ packageName: '@promptbook/openai',
5103
+ className: 'OpenAiCompatibleExecutionTools',
5104
+ envVariables: ['OPENAI_API_KEY'],
5105
+ trustLevel: 'CLOSED',
5106
+ order: MODEL_ORDERS.TOP_TIER,
5107
+ getBoilerplateConfiguration() {
5108
+ return {
5109
+ title: 'Open AI Compatible',
5110
+ packageName: '@promptbook/openai',
5111
+ className: 'OpenAiCompatibleExecutionTools',
5112
+ options: {
5113
+ apiKey: 'sk-',
5114
+ maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
5115
+ },
5116
+ };
5117
+ },
5118
+ createConfigurationFromEnv(env) {
5119
+ return null;
5120
+ },
5121
+ });
5090
5122
  /**
5091
5123
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
5092
5124
  */
@@ -5339,6 +5371,27 @@ const createOpenAiAssistantExecutionTools = Object.assign((options) => {
5339
5371
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
5340
5372
  */
5341
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
+
5342
5395
  /**
5343
5396
  * Execution Tools for calling OpenAI API
5344
5397
  *
@@ -5360,6 +5413,7 @@ const createOpenAiExecutionTools = Object.assign((options) => {
5360
5413
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
5361
5414
  */
5362
5415
 
5416
+ // Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be instantiated directly
5363
5417
  /**
5364
5418
  * Registration of LLM provider
5365
5419
  *
@@ -5380,6 +5434,20 @@ const _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTool
5380
5434
  * @public exported from `@promptbook/cli`
5381
5435
  */
5382
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);
5447
+ /**
5448
+ * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
5449
+ * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
5450
+ */
5383
5451
  /**
5384
5452
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
5385
5453
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -8640,6 +8708,7 @@ async function executeAttempts(options) {
8640
8708
  $resultString: null,
8641
8709
  $expectError: null,
8642
8710
  $scriptPipelineExecutionErrors: [],
8711
+ $failedResults: [], // Track all failed attempts
8643
8712
  };
8644
8713
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
8645
8714
  const _llms = arrayableToArray(tools.llm);
@@ -8885,6 +8954,14 @@ async function executeAttempts(options) {
8885
8954
  throw error;
8886
8955
  }
8887
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
+ });
8888
8965
  }
8889
8966
  finally {
8890
8967
  if (!isJokerAttempt &&
@@ -8907,34 +8984,46 @@ async function executeAttempts(options) {
8907
8984
  }
8908
8985
  }
8909
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');
8910
9012
  throw new PipelineExecutionError(spaceTrim$1((block) => {
8911
- var _a, _b, _c;
9013
+ var _a;
8912
9014
  return `
8913
9015
  LLM execution failed ${maxExecutionAttempts}x
8914
9016
 
8915
9017
  ${block(pipelineIdentification)}
8916
9018
 
8917
- ---
8918
9019
  The Prompt:
8919
9020
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
8920
9021
  .split('\n')
8921
9022
  .map((line) => `> ${line}`)
8922
9023
  .join('\n'))}
8923
9024
 
8924
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
8925
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
8926
- .split('\n')
8927
- .map((line) => `> ${line}`)
8928
- .join('\n'))}
8929
-
8930
- Last result:
8931
- ${block($ongoingTaskResult.$resultString === null
8932
- ? 'null'
8933
- : spaceTrim$1($ongoingTaskResult.$resultString)
8934
- .split('\n')
8935
- .map((line) => `> ${line}`)
8936
- .join('\n'))}
8937
- ---
9025
+ All Failed Attempts:
9026
+ ${block(failuresSummary)}
8938
9027
  `;
8939
9028
  }));
8940
9029
  }
@@ -16663,5 +16752,5 @@ const wizard = new Wizard();
16663
16752
  * Note: [๐ŸŸข] Code in this file should never be never released in packages that could be imported into browser environment
16664
16753
  */
16665
16754
 
16666
- 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, _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 };
16667
16756
  //# sourceMappingURL=index.es.js.map