@promptbook/wizard 0.98.0-3 โ†’ 0.98.0-5

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.
@@ -15,6 +15,7 @@ import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/re
15
15
  import { _OpenAiCompatibleMetadataRegistration } from '../llm-providers/openai/register-configuration';
16
16
  import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
17
17
  import { _OpenAiAssistantRegistration } from '../llm-providers/openai/register-constructor';
18
+ import { _OpenAiCompatibleRegistration } from '../llm-providers/openai/register-constructor';
18
19
  import { _BoilerplateScraperRegistration } from '../scrapers/_boilerplate/register-constructor';
19
20
  import { _BoilerplateScraperMetadataRegistration } from '../scrapers/_boilerplate/register-metadata';
20
21
  import { _LegacyDocumentScraperRegistration } from '../scrapers/document-legacy/register-constructor';
@@ -46,6 +47,7 @@ export { _OpenAiAssistantMetadataRegistration };
46
47
  export { _OpenAiCompatibleMetadataRegistration };
47
48
  export { _OpenAiRegistration };
48
49
  export { _OpenAiAssistantRegistration };
50
+ export { _OpenAiCompatibleRegistration };
49
51
  export { _BoilerplateScraperRegistration };
50
52
  export { _BoilerplateScraperMetadataRegistration };
51
53
  export { _LegacyDocumentScraperRegistration };
@@ -11,6 +11,7 @@ import { OpenAiExecutionTools } from '../llm-providers/openai/OpenAiExecutionToo
11
11
  import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions';
12
12
  import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
13
13
  import { _OpenAiAssistantRegistration } from '../llm-providers/openai/register-constructor';
14
+ import { _OpenAiCompatibleRegistration } from '../llm-providers/openai/register-constructor';
14
15
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
15
16
  export { createOpenAiAssistantExecutionTools };
16
17
  export { createOpenAiCompatibleExecutionTools };
@@ -24,3 +25,4 @@ export { OpenAiExecutionTools };
24
25
  export type { OpenAiExecutionToolsOptions };
25
26
  export { _OpenAiRegistration };
26
27
  export { _OpenAiAssistantRegistration };
28
+ export { _OpenAiCompatibleRegistration };
@@ -14,6 +14,7 @@ import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/re
14
14
  import { _OpenAiCompatibleMetadataRegistration } from '../llm-providers/openai/register-configuration';
15
15
  import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
16
16
  import { _OpenAiAssistantRegistration } from '../llm-providers/openai/register-constructor';
17
+ import { _OpenAiCompatibleRegistration } from '../llm-providers/openai/register-constructor';
17
18
  import { _BoilerplateScraperRegistration } from '../scrapers/_boilerplate/register-constructor';
18
19
  import { _BoilerplateScraperMetadataRegistration } from '../scrapers/_boilerplate/register-metadata';
19
20
  import { _LegacyDocumentScraperRegistration } from '../scrapers/document-legacy/register-constructor';
@@ -45,6 +46,7 @@ export { _OpenAiAssistantMetadataRegistration };
45
46
  export { _OpenAiCompatibleMetadataRegistration };
46
47
  export { _OpenAiRegistration };
47
48
  export { _OpenAiAssistantRegistration };
49
+ export { _OpenAiCompatibleRegistration };
48
50
  export { _BoilerplateScraperRegistration };
49
51
  export { _BoilerplateScraperMetadataRegistration };
50
52
  export { _LegacyDocumentScraperRegistration };
@@ -176,7 +176,7 @@ export declare const DEFAULT_MAX_PARALLEL_COUNT = 5;
176
176
  *
177
177
  * @public exported from `@promptbook/core`
178
178
  */
179
- export declare const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10;
179
+ export declare const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3;
180
180
  /**
181
181
  * The maximum depth to which knowledge sources will be scraped when building a knowledge base.
182
182
  * This prevents infinite recursion and limits resource usage.
@@ -45,4 +45,11 @@ export type $OngoingTaskResult = {
45
45
  * List of errors encountered during script postprocessing or execution.
46
46
  */
47
47
  $scriptPipelineExecutionErrors: Array<Error>;
48
+ /**
49
+ * Array of all failed attempts, storing both the result string and the error for each failure
50
+ */
51
+ $failedResults: Array<{
52
+ result: string | null;
53
+ error: ExpectError;
54
+ }>;
48
55
  };
@@ -19,6 +19,16 @@ export declare const _OpenAiRegistration: Registration;
19
19
  * @public exported from `@promptbook/cli`
20
20
  */
21
21
  export declare const _OpenAiAssistantRegistration: Registration;
22
+ /**
23
+ * Registration of the OpenAI Compatible provider
24
+ *
25
+ * Note: [๐Ÿ] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
26
+ *
27
+ * @public exported from `@promptbook/openai`
28
+ * @public exported from `@promptbook/wizard`
29
+ * @public exported from `@promptbook/cli`
30
+ */
31
+ export declare const _OpenAiCompatibleRegistration: Registration;
22
32
  /**
23
33
  * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
24
34
  * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.98.0-2`).
18
+ * It follows semantic versioning (e.g., `0.98.0-4`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/wizard",
3
- "version": "0.98.0-3",
3
+ "version": "0.98.0-5",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -74,7 +74,7 @@
74
74
  "module": "./esm/index.es.js",
75
75
  "typings": "./esm/typings/src/_packages/wizard.index.d.ts",
76
76
  "peerDependencies": {
77
- "@promptbook/core": "0.98.0-3"
77
+ "@promptbook/core": "0.98.0-5"
78
78
  },
79
79
  "dependencies": {
80
80
  "@ai-sdk/deepseek": "0.1.6",
package/umd/index.umd.js CHANGED
@@ -49,7 +49,7 @@
49
49
  * @generated
50
50
  * @see https://github.com/webgptorg/promptbook
51
51
  */
52
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-3';
52
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-5';
53
53
  /**
54
54
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
55
55
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -243,7 +243,7 @@
243
243
  *
244
244
  * @public exported from `@promptbook/core`
245
245
  */
246
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
246
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
247
247
  // <- TODO: [๐Ÿ]
248
248
  /**
249
249
  * Where to store your books
@@ -5382,6 +5382,27 @@
5382
5382
  * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
5383
5383
  */
5384
5384
 
5385
+ /**
5386
+ * Execution Tools for calling OpenAI compatible API
5387
+ *
5388
+ * Note: This can be used for any OpenAI compatible APIs
5389
+ *
5390
+ * @public exported from `@promptbook/openai`
5391
+ */
5392
+ const createOpenAiCompatibleExecutionTools = Object.assign((options) => {
5393
+ if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
5394
+ options = { ...options, dangerouslyAllowBrowser: true };
5395
+ }
5396
+ return new OpenAiExecutionTools(options);
5397
+ }, {
5398
+ packageName: '@promptbook/openai',
5399
+ className: 'OpenAiCompatibleExecutionTools',
5400
+ });
5401
+ /**
5402
+ * TODO: [๐Ÿฆบ] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
5403
+ * TODO: [๐ŸŽถ] Naming "constructor" vs "creator" vs "factory"
5404
+ */
5405
+
5385
5406
  /**
5386
5407
  * Execution Tools for calling OpenAI API
5387
5408
  *
@@ -5424,6 +5445,16 @@
5424
5445
  * @public exported from `@promptbook/cli`
5425
5446
  */
5426
5447
  const _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);
5448
+ /**
5449
+ * Registration of the OpenAI Compatible provider
5450
+ *
5451
+ * Note: [๐Ÿ] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
5452
+ *
5453
+ * @public exported from `@promptbook/openai`
5454
+ * @public exported from `@promptbook/wizard`
5455
+ * @public exported from `@promptbook/cli`
5456
+ */
5457
+ const _OpenAiCompatibleRegistration = $llmToolsRegister.register(createOpenAiCompatibleExecutionTools);
5427
5458
  /**
5428
5459
  * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
5429
5460
  * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
@@ -8688,6 +8719,7 @@
8688
8719
  $resultString: null,
8689
8720
  $expectError: null,
8690
8721
  $scriptPipelineExecutionErrors: [],
8722
+ $failedResults: [], // Track all failed attempts
8691
8723
  };
8692
8724
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
8693
8725
  const _llms = arrayableToArray(tools.llm);
@@ -8933,6 +8965,14 @@
8933
8965
  throw error;
8934
8966
  }
8935
8967
  $ongoingTaskResult.$expectError = error;
8968
+ // Store each failed attempt
8969
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
8970
+ $ongoingTaskResult.$failedResults = [];
8971
+ }
8972
+ $ongoingTaskResult.$failedResults.push({
8973
+ result: $ongoingTaskResult.$resultString,
8974
+ error: error,
8975
+ });
8936
8976
  }
8937
8977
  finally {
8938
8978
  if (!isJokerAttempt &&
@@ -8955,34 +8995,46 @@
8955
8995
  }
8956
8996
  }
8957
8997
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
8998
+ // Store the current failure before throwing
8999
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
9000
+ $ongoingTaskResult.$failedResults.push({
9001
+ result: $ongoingTaskResult.$resultString,
9002
+ error: $ongoingTaskResult.$expectError,
9003
+ });
9004
+ // Create a summary of all failures
9005
+ const failuresSummary = $ongoingTaskResult.$failedResults
9006
+ .map((failure, index) => spaceTrim.spaceTrim((block) => {
9007
+ var _a, _b;
9008
+ return `
9009
+ Attempt ${index + 1}:
9010
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
9011
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
9012
+
9013
+ Result:
9014
+ ${block(failure.result === null
9015
+ ? 'null'
9016
+ : spaceTrim.spaceTrim(failure.result)
9017
+ .split('\n')
9018
+ .map((line) => `> ${line}`)
9019
+ .join('\n'))}
9020
+ `;
9021
+ }))
9022
+ .join('\n\n---\n\n');
8958
9023
  throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
8959
- var _a, _b, _c;
9024
+ var _a;
8960
9025
  return `
8961
9026
  LLM execution failed ${maxExecutionAttempts}x
8962
9027
 
8963
9028
  ${block(pipelineIdentification)}
8964
9029
 
8965
- ---
8966
9030
  The Prompt:
8967
9031
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
8968
9032
  .split('\n')
8969
9033
  .map((line) => `> ${line}`)
8970
9034
  .join('\n'))}
8971
9035
 
8972
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
8973
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
8974
- .split('\n')
8975
- .map((line) => `> ${line}`)
8976
- .join('\n'))}
8977
-
8978
- Last result:
8979
- ${block($ongoingTaskResult.$resultString === null
8980
- ? 'null'
8981
- : spaceTrim.spaceTrim($ongoingTaskResult.$resultString)
8982
- .split('\n')
8983
- .map((line) => `> ${line}`)
8984
- .join('\n'))}
8985
- ---
9036
+ All Failed Attempts:
9037
+ ${block(failuresSummary)}
8986
9038
  `;
8987
9039
  }));
8988
9040
  }
@@ -16736,6 +16788,7 @@
16736
16788
  exports._OpenAiAssistantMetadataRegistration = _OpenAiAssistantMetadataRegistration;
16737
16789
  exports._OpenAiAssistantRegistration = _OpenAiAssistantRegistration;
16738
16790
  exports._OpenAiCompatibleMetadataRegistration = _OpenAiCompatibleMetadataRegistration;
16791
+ exports._OpenAiCompatibleRegistration = _OpenAiCompatibleRegistration;
16739
16792
  exports._OpenAiMetadataRegistration = _OpenAiMetadataRegistration;
16740
16793
  exports._OpenAiRegistration = _OpenAiRegistration;
16741
16794
  exports._PdfScraperMetadataRegistration = _PdfScraperMetadataRegistration;