@promptbook/node 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 +39 -18
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/openai.index.d.ts +6 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +7 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +3 -3
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +3 -5
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +17 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +11 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +14 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +39 -18
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
30
30
|
* @generated
|
|
31
31
|
* @see https://github.com/webgptorg/promptbook
|
|
32
32
|
*/
|
|
33
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.98.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.98.0-4';
|
|
34
34
|
/**
|
|
35
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
36
36
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -174,7 +174,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐คนโโ๏ธ]
|
|
|
174
174
|
*
|
|
175
175
|
* @public exported from `@promptbook/core`
|
|
176
176
|
*/
|
|
177
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
177
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐คนโโ๏ธ]
|
|
178
178
|
// <- TODO: [๐] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
179
179
|
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
180
180
|
/**
|
|
@@ -3752,6 +3752,7 @@ async function executeAttempts(options) {
|
|
|
3752
3752
|
$resultString: null,
|
|
3753
3753
|
$expectError: null,
|
|
3754
3754
|
$scriptPipelineExecutionErrors: [],
|
|
3755
|
+
$failedResults: [], // Track all failed attempts
|
|
3755
3756
|
};
|
|
3756
3757
|
// TODO: [๐] Make arrayable LLMs -> single LLM DRY
|
|
3757
3758
|
const _llms = arrayableToArray(tools.llm);
|
|
@@ -3997,6 +3998,14 @@ async function executeAttempts(options) {
|
|
|
3997
3998
|
throw error;
|
|
3998
3999
|
}
|
|
3999
4000
|
$ongoingTaskResult.$expectError = error;
|
|
4001
|
+
// Store each failed attempt
|
|
4002
|
+
if (!Array.isArray($ongoingTaskResult.$failedResults)) {
|
|
4003
|
+
$ongoingTaskResult.$failedResults = [];
|
|
4004
|
+
}
|
|
4005
|
+
$ongoingTaskResult.$failedResults.push({
|
|
4006
|
+
result: $ongoingTaskResult.$resultString,
|
|
4007
|
+
error: error,
|
|
4008
|
+
});
|
|
4000
4009
|
}
|
|
4001
4010
|
finally {
|
|
4002
4011
|
if (!isJokerAttempt &&
|
|
@@ -4019,34 +4028,46 @@ async function executeAttempts(options) {
|
|
|
4019
4028
|
}
|
|
4020
4029
|
}
|
|
4021
4030
|
if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
4031
|
+
// Store the current failure before throwing
|
|
4032
|
+
$ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
|
|
4033
|
+
$ongoingTaskResult.$failedResults.push({
|
|
4034
|
+
result: $ongoingTaskResult.$resultString,
|
|
4035
|
+
error: $ongoingTaskResult.$expectError,
|
|
4036
|
+
});
|
|
4037
|
+
// Create a summary of all failures
|
|
4038
|
+
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
4039
|
+
.map((failure, index) => spaceTrim$1((block) => {
|
|
4040
|
+
var _a, _b;
|
|
4041
|
+
return `
|
|
4042
|
+
Attempt ${index + 1}:
|
|
4043
|
+
Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
|
|
4044
|
+
${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
|
|
4045
|
+
|
|
4046
|
+
Result:
|
|
4047
|
+
${block(failure.result === null
|
|
4048
|
+
? 'null'
|
|
4049
|
+
: spaceTrim$1(failure.result)
|
|
4050
|
+
.split('\n')
|
|
4051
|
+
.map((line) => `> ${line}`)
|
|
4052
|
+
.join('\n'))}
|
|
4053
|
+
`;
|
|
4054
|
+
}))
|
|
4055
|
+
.join('\n\n---\n\n');
|
|
4022
4056
|
throw new PipelineExecutionError(spaceTrim$1((block) => {
|
|
4023
|
-
var _a
|
|
4057
|
+
var _a;
|
|
4024
4058
|
return `
|
|
4025
4059
|
LLM execution failed ${maxExecutionAttempts}x
|
|
4026
4060
|
|
|
4027
4061
|
${block(pipelineIdentification)}
|
|
4028
4062
|
|
|
4029
|
-
---
|
|
4030
4063
|
The Prompt:
|
|
4031
4064
|
${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
|
|
4032
4065
|
.split('\n')
|
|
4033
4066
|
.map((line) => `> ${line}`)
|
|
4034
4067
|
.join('\n'))}
|
|
4035
4068
|
|
|
4036
|
-
|
|
4037
|
-
${block(
|
|
4038
|
-
.split('\n')
|
|
4039
|
-
.map((line) => `> ${line}`)
|
|
4040
|
-
.join('\n'))}
|
|
4041
|
-
|
|
4042
|
-
Last result:
|
|
4043
|
-
${block($ongoingTaskResult.$resultString === null
|
|
4044
|
-
? 'null'
|
|
4045
|
-
: spaceTrim$1($ongoingTaskResult.$resultString)
|
|
4046
|
-
.split('\n')
|
|
4047
|
-
.map((line) => `> ${line}`)
|
|
4048
|
-
.join('\n'))}
|
|
4049
|
-
---
|
|
4069
|
+
All Failed Attempts:
|
|
4070
|
+
${block(failuresSummary)}
|
|
4050
4071
|
`;
|
|
4051
4072
|
}));
|
|
4052
4073
|
}
|