@promptbook/cli 0.67.7 → 0.67.9
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 +206 -121
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/commands/EXPECT/ExpectAmountCommand.d.ts +3 -0
- package/esm/typings/src/config.d.ts +6 -0
- package/package.json +1 -1
- package/umd/index.umd.js +206 -121
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -20,7 +20,7 @@ import OpenAI from 'openai';
|
|
|
20
20
|
/**
|
|
21
21
|
* The version of the Promptbook library
|
|
22
22
|
*/
|
|
23
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
23
|
+
var PROMPTBOOK_VERSION = '0.67.8';
|
|
24
24
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
25
25
|
|
|
26
26
|
/*! *****************************************************************************
|
|
@@ -419,6 +419,12 @@ var CONNECTION_TIMEOUT_MS = 7 * 1000;
|
|
|
419
419
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
420
420
|
*/
|
|
421
421
|
var CONNECTION_RETRIES_LIMIT = 5;
|
|
422
|
+
/**
|
|
423
|
+
* Short time interval to prevent race conditions in milliseconds
|
|
424
|
+
*
|
|
425
|
+
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
426
|
+
*/
|
|
427
|
+
var IMMEDIATE_TIME = 10;
|
|
422
428
|
/**
|
|
423
429
|
* The maximum number of (LLM) tasks running in parallel
|
|
424
430
|
*
|
|
@@ -1034,7 +1040,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1034
1040
|
});
|
|
1035
1041
|
}
|
|
1036
1042
|
|
|
1037
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
1043
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.8",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.67.8",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.67.8",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.67.8",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1038
1044
|
|
|
1039
1045
|
/**
|
|
1040
1046
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -3203,7 +3209,7 @@ function createPipelineExecutor(options) {
|
|
|
3203
3209
|
}
|
|
3204
3210
|
function executeSingleTemplate(currentTemplate) {
|
|
3205
3211
|
return __awaiter(this, void 0, void 0, function () {
|
|
3206
|
-
var name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2;
|
|
3212
|
+
var name, title, priority, progress_1, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2, progress_2;
|
|
3207
3213
|
var e_4, _f, _g;
|
|
3208
3214
|
return __generator(this, function (_h) {
|
|
3209
3215
|
switch (_h.label) {
|
|
@@ -3211,17 +3217,24 @@ function createPipelineExecutor(options) {
|
|
|
3211
3217
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
3212
3218
|
title = currentTemplate.title;
|
|
3213
3219
|
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
3214
|
-
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3220
|
+
if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
3221
|
+
progress_1 = {
|
|
3222
|
+
name: name,
|
|
3223
|
+
title: title,
|
|
3224
|
+
isStarted: false,
|
|
3225
|
+
isDone: false,
|
|
3226
|
+
blockType: currentTemplate.blockType,
|
|
3227
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3228
|
+
parameterValue: null,
|
|
3229
|
+
// <- [3]
|
|
3230
|
+
};
|
|
3231
|
+
if (isReturned) {
|
|
3232
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4F\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_1, null, 4)
|
|
3233
|
+
.split('\n')
|
|
3234
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3235
|
+
.join('\n')), "\n "); }));
|
|
3236
|
+
}
|
|
3237
|
+
return [4 /*yield*/, onProgress(progress_1)];
|
|
3225
3238
|
case 1:
|
|
3226
3239
|
_h.sent();
|
|
3227
3240
|
_h.label = 2;
|
|
@@ -3607,18 +3620,28 @@ function createPipelineExecutor(options) {
|
|
|
3607
3620
|
if (resultString === null) {
|
|
3608
3621
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3609
3622
|
}
|
|
3610
|
-
if (onProgress /* <- [3] */)
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3623
|
+
if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
|
|
3624
|
+
progress_2 = {
|
|
3625
|
+
name: name,
|
|
3626
|
+
title: title,
|
|
3627
|
+
isStarted: true,
|
|
3628
|
+
isDone: true,
|
|
3629
|
+
blockType: currentTemplate.blockType,
|
|
3630
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3631
|
+
parameterValue: resultString,
|
|
3632
|
+
// <- [3]
|
|
3633
|
+
};
|
|
3634
|
+
if (isReturned) {
|
|
3635
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4E\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_2, null, 4)
|
|
3636
|
+
.split('\n')
|
|
3637
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3638
|
+
.join('\n')), "\n\n "); }));
|
|
3621
3639
|
}
|
|
3640
|
+
return [4 /*yield*/, onProgress(progress_2)];
|
|
3641
|
+
case 8:
|
|
3642
|
+
_h.sent();
|
|
3643
|
+
_h.label = 9;
|
|
3644
|
+
case 9:
|
|
3622
3645
|
parametersToPass = Object.freeze(__assign(__assign({}, parametersToPass), (_g = {}, _g[currentTemplate.resultingParameterName] = resultString /* <- Note: Not need to detect parameter collision here because pipeline checks logic consistency during construction */, _g)));
|
|
3623
3646
|
return [2 /*return*/];
|
|
3624
3647
|
}
|
|
@@ -3655,7 +3678,7 @@ function createPipelineExecutor(options) {
|
|
|
3655
3678
|
}
|
|
3656
3679
|
return outputParameters;
|
|
3657
3680
|
}
|
|
3658
|
-
var errors, warnings, executionReport, _a, _b, parameter, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
3681
|
+
var errors, warnings, executionReport, isReturned, _a, _b, parameter, e_1_1, _loop_1, _c, _d, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
3659
3682
|
var e_1, _e, e_2, _f;
|
|
3660
3683
|
return __generator(this, function (_g) {
|
|
3661
3684
|
switch (_g.label) {
|
|
@@ -3680,77 +3703,123 @@ function createPipelineExecutor(options) {
|
|
|
3680
3703
|
description: preparedPipeline.description,
|
|
3681
3704
|
promptExecutions: [],
|
|
3682
3705
|
};
|
|
3706
|
+
isReturned = false;
|
|
3707
|
+
_g.label = 3;
|
|
3708
|
+
case 3:
|
|
3709
|
+
_g.trys.push([3, 9, 10, 11]);
|
|
3710
|
+
_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
3711
|
+
var isInput = _a.isInput;
|
|
3712
|
+
return isInput;
|
|
3713
|
+
})), _b = _a.next();
|
|
3714
|
+
_g.label = 4;
|
|
3715
|
+
case 4:
|
|
3716
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
3717
|
+
parameter = _b.value;
|
|
3718
|
+
if (!(inputParameters[parameter.name] === undefined)) return [3 /*break*/, 7];
|
|
3719
|
+
isReturned = true;
|
|
3720
|
+
if (!(onProgress !== undefined)) return [3 /*break*/, 6];
|
|
3721
|
+
// Note: Wait a short time to prevent race conditions
|
|
3722
|
+
return [4 /*yield*/, forTime(IMMEDIATE_TIME)];
|
|
3723
|
+
case 5:
|
|
3724
|
+
// Note: Wait a short time to prevent race conditions
|
|
3725
|
+
_g.sent();
|
|
3726
|
+
_g.label = 6;
|
|
3727
|
+
case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
3728
|
+
isSuccessful: false,
|
|
3729
|
+
errors: __spreadArray([
|
|
3730
|
+
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
|
|
3731
|
+
], __read(errors), false).map(serializeError),
|
|
3732
|
+
warnings: [],
|
|
3733
|
+
executionReport: executionReport,
|
|
3734
|
+
outputParameters: {},
|
|
3735
|
+
usage: ZERO_USAGE,
|
|
3736
|
+
preparedPipeline: preparedPipeline,
|
|
3737
|
+
})];
|
|
3738
|
+
case 7:
|
|
3739
|
+
_b = _a.next();
|
|
3740
|
+
return [3 /*break*/, 4];
|
|
3741
|
+
case 8: return [3 /*break*/, 11];
|
|
3742
|
+
case 9:
|
|
3743
|
+
e_1_1 = _g.sent();
|
|
3744
|
+
e_1 = { error: e_1_1 };
|
|
3745
|
+
return [3 /*break*/, 11];
|
|
3746
|
+
case 10:
|
|
3683
3747
|
try {
|
|
3684
|
-
|
|
3685
|
-
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
3686
|
-
var isInput = _a.isInput;
|
|
3687
|
-
return isInput;
|
|
3688
|
-
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
3689
|
-
parameter = _b.value;
|
|
3690
|
-
if (inputParameters[parameter.name] === undefined) {
|
|
3691
|
-
return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
3692
|
-
isSuccessful: false,
|
|
3693
|
-
errors: __spreadArray([
|
|
3694
|
-
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
|
|
3695
|
-
], __read(errors), false).map(serializeError),
|
|
3696
|
-
warnings: [],
|
|
3697
|
-
executionReport: executionReport,
|
|
3698
|
-
outputParameters: {},
|
|
3699
|
-
usage: ZERO_USAGE,
|
|
3700
|
-
preparedPipeline: preparedPipeline,
|
|
3701
|
-
})];
|
|
3702
|
-
}
|
|
3703
|
-
}
|
|
3704
|
-
}
|
|
3705
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3706
|
-
finally {
|
|
3707
|
-
try {
|
|
3708
|
-
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
3709
|
-
}
|
|
3710
|
-
finally { if (e_1) throw e_1.error; }
|
|
3748
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
3711
3749
|
}
|
|
3750
|
+
finally { if (e_1) throw e_1.error; }
|
|
3751
|
+
return [7 /*endfinally*/];
|
|
3752
|
+
case 11:
|
|
3712
3753
|
_loop_1 = function (parameterName) {
|
|
3713
|
-
var parameter
|
|
3714
|
-
|
|
3715
|
-
|
|
3754
|
+
var parameter;
|
|
3755
|
+
return __generator(this, function (_h) {
|
|
3756
|
+
switch (_h.label) {
|
|
3757
|
+
case 0:
|
|
3758
|
+
parameter = preparedPipeline.parameters.find(function (_a) {
|
|
3759
|
+
var name = _a.name;
|
|
3760
|
+
return name === parameterName;
|
|
3761
|
+
});
|
|
3762
|
+
if (!(parameter === undefined)) return [3 /*break*/, 1];
|
|
3763
|
+
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 "); })));
|
|
3764
|
+
return [3 /*break*/, 4];
|
|
3765
|
+
case 1:
|
|
3766
|
+
if (!(parameter.isInput === false)) return [3 /*break*/, 4];
|
|
3767
|
+
isReturned = true;
|
|
3768
|
+
if (!(onProgress !== undefined)) return [3 /*break*/, 3];
|
|
3769
|
+
// Note: Wait a short time to prevent race conditions
|
|
3770
|
+
return [4 /*yield*/, forTime(IMMEDIATE_TIME)];
|
|
3771
|
+
case 2:
|
|
3772
|
+
// Note: Wait a short time to prevent race conditions
|
|
3773
|
+
_h.sent();
|
|
3774
|
+
_h.label = 3;
|
|
3775
|
+
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 "); }), {
|
|
3776
|
+
isSuccessful: false,
|
|
3777
|
+
errors: __spreadArray([
|
|
3778
|
+
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 "); }))
|
|
3779
|
+
], __read(errors), false).map(serializeError),
|
|
3780
|
+
warnings: warnings.map(serializeError),
|
|
3781
|
+
executionReport: executionReport,
|
|
3782
|
+
outputParameters: {},
|
|
3783
|
+
usage: ZERO_USAGE,
|
|
3784
|
+
preparedPipeline: preparedPipeline,
|
|
3785
|
+
}) }];
|
|
3786
|
+
case 4: return [2 /*return*/];
|
|
3787
|
+
}
|
|
3716
3788
|
});
|
|
3717
|
-
if (parameter === undefined) {
|
|
3718
|
-
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 "); })));
|
|
3719
|
-
}
|
|
3720
|
-
else if (parameter.isInput === false) {
|
|
3721
|
-
return { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
3722
|
-
isSuccessful: false,
|
|
3723
|
-
errors: __spreadArray([
|
|
3724
|
-
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 "); }))
|
|
3725
|
-
], __read(errors), false).map(serializeError),
|
|
3726
|
-
warnings: warnings.map(serializeError),
|
|
3727
|
-
executionReport: executionReport,
|
|
3728
|
-
outputParameters: {},
|
|
3729
|
-
usage: ZERO_USAGE,
|
|
3730
|
-
preparedPipeline: preparedPipeline,
|
|
3731
|
-
}) };
|
|
3732
|
-
}
|
|
3733
3789
|
};
|
|
3790
|
+
_g.label = 12;
|
|
3791
|
+
case 12:
|
|
3792
|
+
_g.trys.push([12, 17, 18, 19]);
|
|
3793
|
+
_c = __values(Object.keys(inputParameters)), _d = _c.next();
|
|
3794
|
+
_g.label = 13;
|
|
3795
|
+
case 13:
|
|
3796
|
+
if (!!_d.done) return [3 /*break*/, 16];
|
|
3797
|
+
parameterName = _d.value;
|
|
3798
|
+
return [5 /*yield**/, _loop_1(parameterName)];
|
|
3799
|
+
case 14:
|
|
3800
|
+
state_1 = _g.sent();
|
|
3801
|
+
if (typeof state_1 === "object")
|
|
3802
|
+
return [2 /*return*/, state_1.value];
|
|
3803
|
+
_g.label = 15;
|
|
3804
|
+
case 15:
|
|
3805
|
+
_d = _c.next();
|
|
3806
|
+
return [3 /*break*/, 13];
|
|
3807
|
+
case 16: return [3 /*break*/, 19];
|
|
3808
|
+
case 17:
|
|
3809
|
+
e_2_1 = _g.sent();
|
|
3810
|
+
e_2 = { error: e_2_1 };
|
|
3811
|
+
return [3 /*break*/, 19];
|
|
3812
|
+
case 18:
|
|
3734
3813
|
try {
|
|
3735
|
-
|
|
3736
|
-
for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3737
|
-
parameterName = _d.value;
|
|
3738
|
-
state_1 = _loop_1(parameterName);
|
|
3739
|
-
if (typeof state_1 === "object")
|
|
3740
|
-
return [2 /*return*/, state_1.value];
|
|
3741
|
-
}
|
|
3742
|
-
}
|
|
3743
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3744
|
-
finally {
|
|
3745
|
-
try {
|
|
3746
|
-
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
3747
|
-
}
|
|
3748
|
-
finally { if (e_2) throw e_2.error; }
|
|
3814
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
3749
3815
|
}
|
|
3816
|
+
finally { if (e_2) throw e_2.error; }
|
|
3817
|
+
return [7 /*endfinally*/];
|
|
3818
|
+
case 19:
|
|
3750
3819
|
parametersToPass = inputParameters;
|
|
3751
|
-
_g.label =
|
|
3752
|
-
case
|
|
3753
|
-
_g.trys.push([
|
|
3820
|
+
_g.label = 20;
|
|
3821
|
+
case 20:
|
|
3822
|
+
_g.trys.push([20, 25, , 28]);
|
|
3754
3823
|
resovedParameterNames_1 = preparedPipeline.parameters
|
|
3755
3824
|
.filter(function (_a) {
|
|
3756
3825
|
var isInput = _a.isInput;
|
|
@@ -3765,8 +3834,8 @@ function createPipelineExecutor(options) {
|
|
|
3765
3834
|
loopLimit = LOOP_LIMIT;
|
|
3766
3835
|
_loop_2 = function () {
|
|
3767
3836
|
var currentTemplate, work_1;
|
|
3768
|
-
return __generator(this, function (
|
|
3769
|
-
switch (
|
|
3837
|
+
return __generator(this, function (_j) {
|
|
3838
|
+
switch (_j.label) {
|
|
3770
3839
|
case 0:
|
|
3771
3840
|
if (loopLimit-- < 0) {
|
|
3772
3841
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
@@ -3792,7 +3861,7 @@ function createPipelineExecutor(options) {
|
|
|
3792
3861
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
3793
3862
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
3794
3863
|
case 2:
|
|
3795
|
-
/* [5] */
|
|
3864
|
+
/* [5] */ _j.sent();
|
|
3796
3865
|
return [3 /*break*/, 4];
|
|
3797
3866
|
case 3:
|
|
3798
3867
|
unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
|
|
@@ -3804,23 +3873,23 @@ function createPipelineExecutor(options) {
|
|
|
3804
3873
|
resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
|
|
3805
3874
|
});
|
|
3806
3875
|
resolving_1.push(work_1);
|
|
3807
|
-
|
|
3876
|
+
_j.label = 4;
|
|
3808
3877
|
case 4: return [2 /*return*/];
|
|
3809
3878
|
}
|
|
3810
3879
|
});
|
|
3811
3880
|
};
|
|
3812
|
-
_g.label =
|
|
3813
|
-
case
|
|
3814
|
-
if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/,
|
|
3881
|
+
_g.label = 21;
|
|
3882
|
+
case 21:
|
|
3883
|
+
if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
|
|
3815
3884
|
return [5 /*yield**/, _loop_2()];
|
|
3816
|
-
case
|
|
3885
|
+
case 22:
|
|
3817
3886
|
_g.sent();
|
|
3818
|
-
return [3 /*break*/,
|
|
3819
|
-
case
|
|
3820
|
-
case
|
|
3887
|
+
return [3 /*break*/, 21];
|
|
3888
|
+
case 23: return [4 /*yield*/, Promise.all(resolving_1)];
|
|
3889
|
+
case 24:
|
|
3821
3890
|
_g.sent();
|
|
3822
|
-
return [3 /*break*/,
|
|
3823
|
-
case
|
|
3891
|
+
return [3 /*break*/, 28];
|
|
3892
|
+
case 25:
|
|
3824
3893
|
error_1 = _g.sent();
|
|
3825
3894
|
if (!(error_1 instanceof Error)) {
|
|
3826
3895
|
throw error_1;
|
|
@@ -3830,30 +3899,46 @@ function createPipelineExecutor(options) {
|
|
|
3830
3899
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3831
3900
|
})), false));
|
|
3832
3901
|
outputParameters_1 = filterJustOutputParameters();
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3902
|
+
isReturned = true;
|
|
3903
|
+
if (!(onProgress !== undefined)) return [3 /*break*/, 27];
|
|
3904
|
+
// Note: Wait a short time to prevent race conditions
|
|
3905
|
+
return [4 /*yield*/, forTime(IMMEDIATE_TIME)];
|
|
3906
|
+
case 26:
|
|
3907
|
+
// Note: Wait a short time to prevent race conditions
|
|
3908
|
+
_g.sent();
|
|
3909
|
+
_g.label = 27;
|
|
3910
|
+
case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
|
|
3911
|
+
isSuccessful: false,
|
|
3912
|
+
errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
|
|
3913
|
+
warnings: warnings.map(serializeError),
|
|
3914
|
+
usage: usage_1,
|
|
3915
|
+
executionReport: executionReport,
|
|
3916
|
+
outputParameters: outputParameters_1,
|
|
3917
|
+
preparedPipeline: preparedPipeline,
|
|
3918
|
+
})];
|
|
3919
|
+
case 28:
|
|
3843
3920
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
3844
3921
|
var result = _a.result;
|
|
3845
3922
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3846
3923
|
})), false));
|
|
3847
3924
|
outputParameters = filterJustOutputParameters();
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3925
|
+
isReturned = true;
|
|
3926
|
+
if (!(onProgress !== undefined)) return [3 /*break*/, 30];
|
|
3927
|
+
// Note: Wait a short time to prevent race conditions
|
|
3928
|
+
return [4 /*yield*/, forTime(IMMEDIATE_TIME)];
|
|
3929
|
+
case 29:
|
|
3930
|
+
// Note: Wait a short time to prevent race conditions
|
|
3931
|
+
_g.sent();
|
|
3932
|
+
_g.label = 30;
|
|
3933
|
+
case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
|
|
3934
|
+
isSuccessful: true,
|
|
3935
|
+
errors: errors.map(serializeError),
|
|
3936
|
+
warnings: warnings.map(serializeError),
|
|
3937
|
+
usage: usage,
|
|
3938
|
+
executionReport: executionReport,
|
|
3939
|
+
outputParameters: outputParameters,
|
|
3940
|
+
preparedPipeline: preparedPipeline,
|
|
3941
|
+
})];
|
|
3857
3942
|
}
|
|
3858
3943
|
});
|
|
3859
3944
|
}); };
|