@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
package/esm/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ import OpenAI from 'openai';
|
|
|
21
21
|
/**
|
|
22
22
|
* The version of the Promptbook library
|
|
23
23
|
*/
|
|
24
|
-
var PROMPTBOOK_VERSION = '0.69.0-
|
|
24
|
+
var PROMPTBOOK_VERSION = '0.69.0-19';
|
|
25
25
|
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
26
26
|
|
|
27
27
|
/*! *****************************************************************************
|
|
@@ -3531,16 +3531,16 @@ function executeAttempts(options) {
|
|
|
3531
3531
|
case 0:
|
|
3532
3532
|
isJokerAttempt = attempt < 0;
|
|
3533
3533
|
jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
|
|
3534
|
-
// TODO: [๐ง ]
|
|
3534
|
+
// TODO: [๐ง ][๐ญ] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
3535
3535
|
if (isJokerAttempt && !jokerParameterName) {
|
|
3536
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n
|
|
3536
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3537
3537
|
}
|
|
3538
3538
|
$ongoingTemplateResult.$result = null;
|
|
3539
3539
|
$ongoingTemplateResult.$resultString = null;
|
|
3540
3540
|
$ongoingTemplateResult.$expectError = null;
|
|
3541
3541
|
if (isJokerAttempt) {
|
|
3542
3542
|
if (parameters[jokerParameterName] === undefined) {
|
|
3543
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
3543
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3544
3544
|
// <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
|
|
3545
3545
|
}
|
|
3546
3546
|
else {
|
|
@@ -3606,14 +3606,14 @@ function executeAttempts(options) {
|
|
|
3606
3606
|
$ongoingTemplateResult.$completionResult.content;
|
|
3607
3607
|
return [3 /*break*/, 10];
|
|
3608
3608
|
case 8: throw new PipelineExecutionError(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 "); }));
|
|
3609
|
-
case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
3609
|
+
case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
3610
3610
|
case 10: return [3 /*break*/, 25];
|
|
3611
3611
|
case 11:
|
|
3612
3612
|
if (arrayableToArray(tools.script).length === 0) {
|
|
3613
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
3613
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3614
3614
|
}
|
|
3615
3615
|
if (!template.contentLanguage) {
|
|
3616
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
3616
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3617
3617
|
}
|
|
3618
3618
|
_t.label = 12;
|
|
3619
3619
|
case 12:
|
|
@@ -3667,13 +3667,13 @@ function executeAttempts(options) {
|
|
|
3667
3667
|
throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
|
|
3668
3668
|
}
|
|
3669
3669
|
else {
|
|
3670
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
3670
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
|
|
3671
3671
|
.map(function (error) { return '- ' + error.message; })
|
|
3672
|
-
.join('\n\n')), "\n
|
|
3672
|
+
.join('\n\n')), "\n "); }));
|
|
3673
3673
|
}
|
|
3674
3674
|
case 22:
|
|
3675
3675
|
if (tools.userInterface === undefined) {
|
|
3676
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
3676
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3677
3677
|
}
|
|
3678
3678
|
// TODO: [๐น] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
|
|
3679
3679
|
_j = $ongoingTemplateResult;
|
|
@@ -3689,7 +3689,7 @@ function executeAttempts(options) {
|
|
|
3689
3689
|
// TODO: [๐น] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
|
|
3690
3690
|
_j.$resultString = _t.sent();
|
|
3691
3691
|
return [3 /*break*/, 25];
|
|
3692
|
-
case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
3692
|
+
case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3693
3693
|
case 25:
|
|
3694
3694
|
if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
|
|
3695
3695
|
_t.label = 26;
|
|
@@ -3780,13 +3780,13 @@ function executeAttempts(options) {
|
|
|
3780
3780
|
}
|
|
3781
3781
|
catch (error) {
|
|
3782
3782
|
keepUnused(error);
|
|
3783
|
-
throw new ExpectError(spaceTrim(function (block) { return "\n
|
|
3784
|
-
/*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n
|
|
3783
|
+
throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
|
|
3784
|
+
/*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
|
|
3785
3785
|
}
|
|
3786
3786
|
}
|
|
3787
3787
|
}
|
|
3788
3788
|
else {
|
|
3789
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n
|
|
3789
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3790
3790
|
}
|
|
3791
3791
|
}
|
|
3792
3792
|
// TODO: [๐] Unite object for expecting amount and format
|
|
@@ -3822,18 +3822,18 @@ function executeAttempts(options) {
|
|
|
3822
3822
|
if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
3823
3823
|
throw new PipelineExecutionError(spaceTrim(function (block) {
|
|
3824
3824
|
var _a, _b, _c;
|
|
3825
|
-
return "\n
|
|
3825
|
+
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) || '')
|
|
3826
3826
|
.split('\n')
|
|
3827
3827
|
.map(function (line) { return "> ".concat(line); })
|
|
3828
|
-
.join('\n')), "\n\n
|
|
3828
|
+
.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) || '')
|
|
3829
3829
|
.split('\n')
|
|
3830
3830
|
.map(function (line) { return "> ".concat(line); })
|
|
3831
|
-
.join('\n')), "\n\n
|
|
3831
|
+
.join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
|
|
3832
3832
|
? 'null'
|
|
3833
3833
|
: $ongoingTemplateResult.$resultString
|
|
3834
3834
|
.split('\n')
|
|
3835
3835
|
.map(function (line) { return "> ".concat(line); })
|
|
3836
|
-
.join('\n')), "\n
|
|
3836
|
+
.join('\n')), "\n ---\n ");
|
|
3837
3837
|
}));
|
|
3838
3838
|
}
|
|
3839
3839
|
return [2 /*return*/];
|
|
@@ -3856,7 +3856,7 @@ function executeAttempts(options) {
|
|
|
3856
3856
|
return [3 /*break*/, 1];
|
|
3857
3857
|
case 4:
|
|
3858
3858
|
if ($ongoingTemplateResult.$resultString === null) {
|
|
3859
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n
|
|
3859
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3860
3860
|
}
|
|
3861
3861
|
return [2 /*return*/, $ongoingTemplateResult.$resultString];
|
|
3862
3862
|
}
|
|
@@ -4320,7 +4320,7 @@ function executePipeline(options) {
|
|
|
4320
4320
|
return name === parameterName;
|
|
4321
4321
|
});
|
|
4322
4322
|
if (!(parameter === undefined)) return [3 /*break*/, 1];
|
|
4323
|
-
warnings.push(new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
4323
|
+
warnings.push(new PipelineExecutionError(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 "); })));
|
|
4324
4324
|
return [3 /*break*/, 4];
|
|
4325
4325
|
case 1:
|
|
4326
4326
|
if (!(parameter.isInput === false)) return [3 /*break*/, 4];
|
|
@@ -4332,10 +4332,10 @@ function executePipeline(options) {
|
|
|
4332
4332
|
// Note: Wait a short time to prevent race conditions
|
|
4333
4333
|
_h.sent();
|
|
4334
4334
|
_h.label = 3;
|
|
4335
|
-
case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n
|
|
4335
|
+
case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
4336
4336
|
isSuccessful: false,
|
|
4337
4337
|
errors: __spreadArray([
|
|
4338
|
-
new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
4338
|
+
new PipelineExecutionError(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 "); }))
|
|
4339
4339
|
], __read(errors), false).map(serializeError),
|
|
4340
4340
|
warnings: warnings.map(serializeError),
|
|
4341
4341
|
executionReport: executionReport,
|
|
@@ -4399,7 +4399,7 @@ function executePipeline(options) {
|
|
|
4399
4399
|
case 0:
|
|
4400
4400
|
if (loopLimit-- < 0) {
|
|
4401
4401
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
4402
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n
|
|
4402
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4403
4403
|
}
|
|
4404
4404
|
currentTemplate = unresovedTemplates_1.find(function (template) {
|
|
4405
4405
|
return template.dependentParameterNames.every(function (name) {
|
|
@@ -4409,14 +4409,14 @@ function executePipeline(options) {
|
|
|
4409
4409
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
4410
4410
|
throw new UnexpectedError(
|
|
4411
4411
|
// TODO: [๐] DRY
|
|
4412
|
-
spaceTrim(function (block) { return "\n
|
|
4412
|
+
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
|
|
4413
4413
|
.map(function (_a) {
|
|
4414
4414
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
4415
4415
|
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
4416
4416
|
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
4417
4417
|
.join(' and '));
|
|
4418
4418
|
})
|
|
4419
|
-
.join('\n')), "\n\n
|
|
4419
|
+
.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 "); }));
|
|
4420
4420
|
case 1:
|
|
4421
4421
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
4422
4422
|
/* [๐คนโโ๏ธ] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -4433,10 +4433,10 @@ function executePipeline(options) {
|
|
|
4433
4433
|
llmTools: llmTools,
|
|
4434
4434
|
onProgress: function (progress) {
|
|
4435
4435
|
if (isReturned) {
|
|
4436
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n
|
|
4436
|
+
throw new UnexpectedError(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)
|
|
4437
4437
|
.split('\n')
|
|
4438
4438
|
.map(function (line) { return "> ".concat(line); })
|
|
4439
|
-
.join('\n')), "\n
|
|
4439
|
+
.join('\n')), "\n "); }));
|
|
4440
4440
|
}
|
|
4441
4441
|
if (onProgress) {
|
|
4442
4442
|
onProgress(progress);
|