@promptbook/node 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.
@@ -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-3`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.98.0-3",
3
+ "version": "0.98.0-4",
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/node.index.d.ts",
76
76
  "peerDependencies": {
77
- "@promptbook/core": "0.98.0-3"
77
+ "@promptbook/core": "0.98.0-4"
78
78
  },
79
79
  "dependencies": {
80
80
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -46,7 +46,7 @@
46
46
  * @generated
47
47
  * @see https://github.com/webgptorg/promptbook
48
48
  */
49
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-3';
49
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0-4';
50
50
  /**
51
51
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
52
52
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -190,7 +190,7 @@
190
190
  *
191
191
  * @public exported from `@promptbook/core`
192
192
  */
193
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
193
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
194
194
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
195
195
  // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
196
196
  /**
@@ -3768,6 +3768,7 @@
3768
3768
  $resultString: null,
3769
3769
  $expectError: null,
3770
3770
  $scriptPipelineExecutionErrors: [],
3771
+ $failedResults: [], // Track all failed attempts
3771
3772
  };
3772
3773
  // TODO: [๐Ÿš] Make arrayable LLMs -> single LLM DRY
3773
3774
  const _llms = arrayableToArray(tools.llm);
@@ -4013,6 +4014,14 @@
4013
4014
  throw error;
4014
4015
  }
4015
4016
  $ongoingTaskResult.$expectError = error;
4017
+ // Store each failed attempt
4018
+ if (!Array.isArray($ongoingTaskResult.$failedResults)) {
4019
+ $ongoingTaskResult.$failedResults = [];
4020
+ }
4021
+ $ongoingTaskResult.$failedResults.push({
4022
+ result: $ongoingTaskResult.$resultString,
4023
+ error: error,
4024
+ });
4016
4025
  }
4017
4026
  finally {
4018
4027
  if (!isJokerAttempt &&
@@ -4035,34 +4044,46 @@
4035
4044
  }
4036
4045
  }
4037
4046
  if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
4047
+ // Store the current failure before throwing
4048
+ $ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
4049
+ $ongoingTaskResult.$failedResults.push({
4050
+ result: $ongoingTaskResult.$resultString,
4051
+ error: $ongoingTaskResult.$expectError,
4052
+ });
4053
+ // Create a summary of all failures
4054
+ const failuresSummary = $ongoingTaskResult.$failedResults
4055
+ .map((failure, index) => spaceTrim.spaceTrim((block) => {
4056
+ var _a, _b;
4057
+ return `
4058
+ Attempt ${index + 1}:
4059
+ Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
4060
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
4061
+
4062
+ Result:
4063
+ ${block(failure.result === null
4064
+ ? 'null'
4065
+ : spaceTrim.spaceTrim(failure.result)
4066
+ .split('\n')
4067
+ .map((line) => `> ${line}`)
4068
+ .join('\n'))}
4069
+ `;
4070
+ }))
4071
+ .join('\n\n---\n\n');
4038
4072
  throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
4039
- var _a, _b, _c;
4073
+ var _a;
4040
4074
  return `
4041
4075
  LLM execution failed ${maxExecutionAttempts}x
4042
4076
 
4043
4077
  ${block(pipelineIdentification)}
4044
4078
 
4045
- ---
4046
4079
  The Prompt:
4047
4080
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
4048
4081
  .split('\n')
4049
4082
  .map((line) => `> ${line}`)
4050
4083
  .join('\n'))}
4051
4084
 
4052
- Last error ${((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || ''}:
4053
- ${block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
4054
- .split('\n')
4055
- .map((line) => `> ${line}`)
4056
- .join('\n'))}
4057
-
4058
- Last result:
4059
- ${block($ongoingTaskResult.$resultString === null
4060
- ? 'null'
4061
- : spaceTrim.spaceTrim($ongoingTaskResult.$resultString)
4062
- .split('\n')
4063
- .map((line) => `> ${line}`)
4064
- .join('\n'))}
4065
- ---
4085
+ All Failed Attempts:
4086
+ ${block(failuresSummary)}
4066
4087
  `;
4067
4088
  }));
4068
4089
  }