@promptbook/cli 0.69.0-19 โ 0.69.0-20
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 +27 -27
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +5 -6
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTemplateResult.d.ts +24 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +27 -27
- package/umd/index.umd.js.map +1 -1
|
@@ -15,7 +15,7 @@ export type PipelineExecutorResult = {
|
|
|
15
15
|
*
|
|
16
16
|
* Note: If the execution was not successful, there are only some of the result parameters
|
|
17
17
|
*/
|
|
18
|
-
readonly outputParameters: Parameters
|
|
18
|
+
readonly outputParameters: Readonly<Parameters>;
|
|
19
19
|
/**
|
|
20
20
|
* Whether the execution was successful, details are aviable in `executionReport`
|
|
21
21
|
*/
|
|
@@ -23,19 +23,19 @@ export type PipelineExecutorResult = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Added usage of whole execution, detailed usage is aviable in `executionReport`
|
|
25
25
|
*/
|
|
26
|
-
readonly usage: PromptResultUsage
|
|
26
|
+
readonly usage: ReadonlyDeep<PromptResultUsage>;
|
|
27
27
|
/**
|
|
28
28
|
* Errors that occured during the execution, details are aviable in `executionReport`
|
|
29
29
|
*/
|
|
30
|
-
readonly errors: Array<ErrorJson
|
|
30
|
+
readonly errors: ReadonlyDeep<Array<ErrorJson>>;
|
|
31
31
|
/**
|
|
32
32
|
* Warnings that occured during the execution, details are aviable in `executionReport`
|
|
33
33
|
*/
|
|
34
|
-
readonly warnings: Array<ErrorJson
|
|
34
|
+
readonly warnings: ReadonlyDeep<Array<ErrorJson>>;
|
|
35
35
|
/**
|
|
36
36
|
* The report of the execution with all details
|
|
37
37
|
*/
|
|
38
|
-
readonly executionReport: ExecutionReportJson
|
|
38
|
+
readonly executionReport: ReadonlyDeep<ExecutionReportJson>;
|
|
39
39
|
/**
|
|
40
40
|
* The prepared pipeline that was used for the execution
|
|
41
41
|
*
|
|
@@ -45,7 +45,6 @@ export type PipelineExecutorResult = {
|
|
|
45
45
|
readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
|
-
* TODO: !!!!!! Maybe add ReadonlyDeep< to all
|
|
49
48
|
* TODO: [๐ง ] Should this file be in /execution or /types folder?
|
|
50
49
|
* TODO: [๐ง ] Maybe constrain `ErrorJson` -> `ErrorJson & { name: 'PipelineExecutionError' | 'Error' }`
|
|
51
50
|
*/
|
|
@@ -10,12 +10,36 @@ import type { PromptResult } from '../PromptResult';
|
|
|
10
10
|
* @private internal utility of `createPipelineExecutor`
|
|
11
11
|
*/
|
|
12
12
|
export type $OngoingTemplateResult = {
|
|
13
|
+
/**
|
|
14
|
+
* @@@
|
|
15
|
+
*/
|
|
13
16
|
$prompt?: Prompt;
|
|
17
|
+
/**
|
|
18
|
+
* @@@
|
|
19
|
+
*/
|
|
14
20
|
$chatResult?: ChatPromptResult;
|
|
21
|
+
/**
|
|
22
|
+
* @@@
|
|
23
|
+
*/
|
|
15
24
|
$completionResult?: CompletionPromptResult;
|
|
25
|
+
/**
|
|
26
|
+
* @@@
|
|
27
|
+
*/
|
|
16
28
|
$embeddingResult?: EmbeddingPromptResult;
|
|
29
|
+
/**
|
|
30
|
+
* @@@
|
|
31
|
+
*/
|
|
17
32
|
$result: PromptResult | null;
|
|
33
|
+
/**
|
|
34
|
+
* @@@
|
|
35
|
+
*/
|
|
18
36
|
$resultString: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* @@@
|
|
39
|
+
*/
|
|
19
40
|
$expectError: ExpectError | null;
|
|
41
|
+
/**
|
|
42
|
+
* @@@
|
|
43
|
+
*/
|
|
20
44
|
$scriptPipelineExecutionErrors: Array<Error>;
|
|
21
45
|
};
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/**
|
|
40
40
|
* The version of the Promptbook library
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_VERSION = '0.69.0-
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.69.0-19';
|
|
43
43
|
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -3549,16 +3549,16 @@
|
|
|
3549
3549
|
case 0:
|
|
3550
3550
|
isJokerAttempt = attempt < 0;
|
|
3551
3551
|
jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
|
|
3552
|
-
// TODO: [๐ง ]
|
|
3552
|
+
// TODO: [๐ง ][๐ญ] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
3553
3553
|
if (isJokerAttempt && !jokerParameterName) {
|
|
3554
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3554
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3555
3555
|
}
|
|
3556
3556
|
$ongoingTemplateResult.$result = null;
|
|
3557
3557
|
$ongoingTemplateResult.$resultString = null;
|
|
3558
3558
|
$ongoingTemplateResult.$expectError = null;
|
|
3559
3559
|
if (isJokerAttempt) {
|
|
3560
3560
|
if (parameters[jokerParameterName] === undefined) {
|
|
3561
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3561
|
+
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3562
3562
|
// <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
|
|
3563
3563
|
}
|
|
3564
3564
|
else {
|
|
@@ -3624,14 +3624,14 @@
|
|
|
3624
3624
|
$ongoingTemplateResult.$completionResult.content;
|
|
3625
3625
|
return [3 /*break*/, 10];
|
|
3626
3626
|
case 8: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Embedding model can not be used in pipeline\n\n This should be catched during parsing\n\n ".concat(block(pipelineIdentification), "\n\n "); }));
|
|
3627
|
-
case 9: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3627
|
+
case 9: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
3628
3628
|
case 10: return [3 /*break*/, 25];
|
|
3629
3629
|
case 11:
|
|
3630
3630
|
if (arrayableToArray(tools.script).length === 0) {
|
|
3631
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3631
|
+
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3632
3632
|
}
|
|
3633
3633
|
if (!template.contentLanguage) {
|
|
3634
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3634
|
+
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3635
3635
|
}
|
|
3636
3636
|
_t.label = 12;
|
|
3637
3637
|
case 12:
|
|
@@ -3685,13 +3685,13 @@
|
|
|
3685
3685
|
throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
|
|
3686
3686
|
}
|
|
3687
3687
|
else {
|
|
3688
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3688
|
+
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
|
|
3689
3689
|
.map(function (error) { return '- ' + error.message; })
|
|
3690
|
-
.join('\n\n')), "\n
|
|
3690
|
+
.join('\n\n')), "\n "); }));
|
|
3691
3691
|
}
|
|
3692
3692
|
case 22:
|
|
3693
3693
|
if (tools.userInterface === undefined) {
|
|
3694
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3694
|
+
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3695
3695
|
}
|
|
3696
3696
|
// TODO: [๐น] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
|
|
3697
3697
|
_j = $ongoingTemplateResult;
|
|
@@ -3707,7 +3707,7 @@
|
|
|
3707
3707
|
// TODO: [๐น] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
|
|
3708
3708
|
_j.$resultString = _t.sent();
|
|
3709
3709
|
return [3 /*break*/, 25];
|
|
3710
|
-
case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3710
|
+
case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3711
3711
|
case 25:
|
|
3712
3712
|
if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
|
|
3713
3713
|
_t.label = 26;
|
|
@@ -3798,13 +3798,13 @@
|
|
|
3798
3798
|
}
|
|
3799
3799
|
catch (error) {
|
|
3800
3800
|
keepUnused(error);
|
|
3801
|
-
throw new ExpectError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3802
|
-
/*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n
|
|
3801
|
+
throw new ExpectError(spaceTrim.spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
|
|
3802
|
+
/*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
|
|
3803
3803
|
}
|
|
3804
3804
|
}
|
|
3805
3805
|
}
|
|
3806
3806
|
else {
|
|
3807
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3807
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3808
3808
|
}
|
|
3809
3809
|
}
|
|
3810
3810
|
// TODO: [๐] Unite object for expecting amount and format
|
|
@@ -3840,18 +3840,18 @@
|
|
|
3840
3840
|
if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
3841
3841
|
throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) {
|
|
3842
3842
|
var _a, _b, _c;
|
|
3843
|
-
return "\n
|
|
3843
|
+
return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $ongoingTemplateResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
|
|
3844
3844
|
.split('\n')
|
|
3845
3845
|
.map(function (line) { return "> ".concat(line); })
|
|
3846
|
-
.join('\n')), "\n\n
|
|
3846
|
+
.join('\n')), "\n\n Last error ").concat(((_b = $ongoingTemplateResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || '', ":\n ").concat(block((((_c = $ongoingTemplateResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
|
|
3847
3847
|
.split('\n')
|
|
3848
3848
|
.map(function (line) { return "> ".concat(line); })
|
|
3849
|
-
.join('\n')), "\n\n
|
|
3849
|
+
.join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
|
|
3850
3850
|
? 'null'
|
|
3851
3851
|
: $ongoingTemplateResult.$resultString
|
|
3852
3852
|
.split('\n')
|
|
3853
3853
|
.map(function (line) { return "> ".concat(line); })
|
|
3854
|
-
.join('\n')), "\n
|
|
3854
|
+
.join('\n')), "\n ---\n ");
|
|
3855
3855
|
}));
|
|
3856
3856
|
}
|
|
3857
3857
|
return [2 /*return*/];
|
|
@@ -3874,7 +3874,7 @@
|
|
|
3874
3874
|
return [3 /*break*/, 1];
|
|
3875
3875
|
case 4:
|
|
3876
3876
|
if ($ongoingTemplateResult.$resultString === null) {
|
|
3877
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
3877
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3878
3878
|
}
|
|
3879
3879
|
return [2 /*return*/, $ongoingTemplateResult.$resultString];
|
|
3880
3880
|
}
|
|
@@ -4338,7 +4338,7 @@
|
|
|
4338
4338
|
return name === parameterName;
|
|
4339
4339
|
});
|
|
4340
4340
|
if (!(parameter === undefined)) return [3 /*break*/, 1];
|
|
4341
|
-
warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
4341
|
+
warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
|
|
4342
4342
|
return [3 /*break*/, 4];
|
|
4343
4343
|
case 1:
|
|
4344
4344
|
if (!(parameter.isInput === false)) return [3 /*break*/, 4];
|
|
@@ -4350,10 +4350,10 @@
|
|
|
4350
4350
|
// Note: Wait a short time to prevent race conditions
|
|
4351
4351
|
_h.sent();
|
|
4352
4352
|
_h.label = 3;
|
|
4353
|
-
case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n
|
|
4353
|
+
case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
4354
4354
|
isSuccessful: false,
|
|
4355
4355
|
errors: __spreadArray([
|
|
4356
|
-
new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
4356
|
+
new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
4357
4357
|
], __read(errors), false).map(serializeError),
|
|
4358
4358
|
warnings: warnings.map(serializeError),
|
|
4359
4359
|
executionReport: executionReport,
|
|
@@ -4417,7 +4417,7 @@
|
|
|
4417
4417
|
case 0:
|
|
4418
4418
|
if (loopLimit-- < 0) {
|
|
4419
4419
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
4420
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
4420
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4421
4421
|
}
|
|
4422
4422
|
currentTemplate = unresovedTemplates_1.find(function (template) {
|
|
4423
4423
|
return template.dependentParameterNames.every(function (name) {
|
|
@@ -4427,14 +4427,14 @@
|
|
|
4427
4427
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
4428
4428
|
throw new UnexpectedError(
|
|
4429
4429
|
// TODO: [๐] DRY
|
|
4430
|
-
spaceTrim.spaceTrim(function (block) { return "\n
|
|
4430
|
+
spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates_1
|
|
4431
4431
|
.map(function (_a) {
|
|
4432
4432
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
4433
4433
|
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
4434
4434
|
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
4435
4435
|
.join(' and '));
|
|
4436
4436
|
})
|
|
4437
|
-
.join('\n')), "\n\n
|
|
4437
|
+
.join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameterNames_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
|
|
4438
4438
|
case 1:
|
|
4439
4439
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
4440
4440
|
/* [๐คนโโ๏ธ] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -4451,10 +4451,10 @@
|
|
|
4451
4451
|
llmTools: llmTools,
|
|
4452
4452
|
onProgress: function (progress) {
|
|
4453
4453
|
if (isReturned) {
|
|
4454
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n
|
|
4454
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
|
|
4455
4455
|
.split('\n')
|
|
4456
4456
|
.map(function (line) { return "> ".concat(line); })
|
|
4457
|
-
.join('\n')), "\n
|
|
4457
|
+
.join('\n')), "\n "); }));
|
|
4458
4458
|
}
|
|
4459
4459
|
if (onProgress) {
|
|
4460
4460
|
onProgress(progress);
|