@promptbook/cli 0.67.8 → 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.
@@ -42,6 +42,12 @@ export declare const CONNECTION_TIMEOUT_MS: number;
42
42
  * @private within the repository - too low-level in comparison with other `MAX_...`
43
43
  */
44
44
  export declare const CONNECTION_RETRIES_LIMIT = 5;
45
+ /**
46
+ * Short time interval to prevent race conditions in milliseconds
47
+ *
48
+ * @private within the repository - too low-level in comparison with other `MAX_...`
49
+ */
50
+ export declare const IMMEDIATE_TIME = 10;
45
51
  /**
46
52
  * The maximum number of (LLM) tasks running in parallel
47
53
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.67.8",
3
+ "version": "0.67.9",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
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.67.7';
42
+ var PROMPTBOOK_VERSION = '0.67.8';
43
43
  // TODO: !!!! List here all the versions and annotate + put into script
44
44
 
45
45
  /*! *****************************************************************************
@@ -438,6 +438,12 @@
438
438
  * @private within the repository - too low-level in comparison with other `MAX_...`
439
439
  */
440
440
  var CONNECTION_RETRIES_LIMIT = 5;
441
+ /**
442
+ * Short time interval to prevent race conditions in milliseconds
443
+ *
444
+ * @private within the repository - too low-level in comparison with other `MAX_...`
445
+ */
446
+ var IMMEDIATE_TIME = 10;
441
447
  /**
442
448
  * The maximum number of (LLM) tasks running in parallel
443
449
  *
@@ -1053,7 +1059,7 @@
1053
1059
  });
1054
1060
  }
1055
1061
 
1056
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.7",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.7",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.7",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.7",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"}];
1062
+ 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"}];
1057
1063
 
1058
1064
  /**
1059
1065
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -3230,7 +3236,7 @@
3230
3236
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
3231
3237
  title = currentTemplate.title;
3232
3238
  priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
3233
- if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3239
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3234
3240
  progress_1 = {
3235
3241
  name: name,
3236
3242
  title: title,
@@ -3633,7 +3639,7 @@
3633
3639
  if (resultString === null) {
3634
3640
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3635
3641
  }
3636
- if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3642
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3637
3643
  progress_2 = {
3638
3644
  name: name,
3639
3645
  title: title,
@@ -3691,7 +3697,7 @@
3691
3697
  }
3692
3698
  return outputParameters;
3693
3699
  }
3694
- var errors, warnings, executionReport, isReturned, _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;
3700
+ 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;
3695
3701
  var e_1, _e, e_2, _f;
3696
3702
  return __generator(this, function (_g) {
3697
3703
  switch (_g.label) {
@@ -3717,79 +3723,122 @@
3717
3723
  promptExecutions: [],
3718
3724
  };
3719
3725
  isReturned = false;
3726
+ _g.label = 3;
3727
+ case 3:
3728
+ _g.trys.push([3, 9, 10, 11]);
3729
+ _a = __values(preparedPipeline.parameters.filter(function (_a) {
3730
+ var isInput = _a.isInput;
3731
+ return isInput;
3732
+ })), _b = _a.next();
3733
+ _g.label = 4;
3734
+ case 4:
3735
+ if (!!_b.done) return [3 /*break*/, 8];
3736
+ parameter = _b.value;
3737
+ if (!(inputParameters[parameter.name] === undefined)) return [3 /*break*/, 7];
3738
+ isReturned = true;
3739
+ if (!(onProgress !== undefined)) return [3 /*break*/, 6];
3740
+ // Note: Wait a short time to prevent race conditions
3741
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3742
+ case 5:
3743
+ // Note: Wait a short time to prevent race conditions
3744
+ _g.sent();
3745
+ _g.label = 6;
3746
+ case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3747
+ isSuccessful: false,
3748
+ errors: __spreadArray([
3749
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3750
+ ], __read(errors), false).map(serializeError),
3751
+ warnings: [],
3752
+ executionReport: executionReport,
3753
+ outputParameters: {},
3754
+ usage: ZERO_USAGE,
3755
+ preparedPipeline: preparedPipeline,
3756
+ })];
3757
+ case 7:
3758
+ _b = _a.next();
3759
+ return [3 /*break*/, 4];
3760
+ case 8: return [3 /*break*/, 11];
3761
+ case 9:
3762
+ e_1_1 = _g.sent();
3763
+ e_1 = { error: e_1_1 };
3764
+ return [3 /*break*/, 11];
3765
+ case 10:
3720
3766
  try {
3721
- // Note: Check that all input input parameters are defined
3722
- for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
3723
- var isInput = _a.isInput;
3724
- return isInput;
3725
- })), _b = _a.next(); !_b.done; _b = _a.next()) {
3726
- parameter = _b.value;
3727
- if (inputParameters[parameter.name] === undefined) {
3728
- isReturned = true;
3729
- return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3730
- isSuccessful: false,
3731
- errors: __spreadArray([
3732
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3733
- ], __read(errors), false).map(serializeError),
3734
- warnings: [],
3735
- executionReport: executionReport,
3736
- outputParameters: {},
3737
- usage: ZERO_USAGE,
3738
- preparedPipeline: preparedPipeline,
3739
- })];
3740
- }
3741
- }
3742
- }
3743
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3744
- finally {
3745
- try {
3746
- if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3747
- }
3748
- finally { if (e_1) throw e_1.error; }
3767
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3749
3768
  }
3769
+ finally { if (e_1) throw e_1.error; }
3770
+ return [7 /*endfinally*/];
3771
+ case 11:
3750
3772
  _loop_1 = function (parameterName) {
3751
- var parameter = preparedPipeline.parameters.find(function (_a) {
3752
- var name = _a.name;
3753
- return name === parameterName;
3773
+ var parameter;
3774
+ return __generator(this, function (_h) {
3775
+ switch (_h.label) {
3776
+ case 0:
3777
+ parameter = preparedPipeline.parameters.find(function (_a) {
3778
+ var name = _a.name;
3779
+ return name === parameterName;
3780
+ });
3781
+ if (!(parameter === undefined)) return [3 /*break*/, 1];
3782
+ 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 "); })));
3783
+ return [3 /*break*/, 4];
3784
+ case 1:
3785
+ if (!(parameter.isInput === false)) return [3 /*break*/, 4];
3786
+ isReturned = true;
3787
+ if (!(onProgress !== undefined)) return [3 /*break*/, 3];
3788
+ // Note: Wait a short time to prevent race conditions
3789
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3790
+ case 2:
3791
+ // Note: Wait a short time to prevent race conditions
3792
+ _h.sent();
3793
+ _h.label = 3;
3794
+ 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 "); }), {
3795
+ isSuccessful: false,
3796
+ errors: __spreadArray([
3797
+ 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 "); }))
3798
+ ], __read(errors), false).map(serializeError),
3799
+ warnings: warnings.map(serializeError),
3800
+ executionReport: executionReport,
3801
+ outputParameters: {},
3802
+ usage: ZERO_USAGE,
3803
+ preparedPipeline: preparedPipeline,
3804
+ }) }];
3805
+ case 4: return [2 /*return*/];
3806
+ }
3754
3807
  });
3755
- if (parameter === undefined) {
3756
- 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 "); })));
3757
- }
3758
- else if (parameter.isInput === false) {
3759
- isReturned = true;
3760
- return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3761
- isSuccessful: false,
3762
- errors: __spreadArray([
3763
- 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 "); }))
3764
- ], __read(errors), false).map(serializeError),
3765
- warnings: warnings.map(serializeError),
3766
- executionReport: executionReport,
3767
- outputParameters: {},
3768
- usage: ZERO_USAGE,
3769
- preparedPipeline: preparedPipeline,
3770
- }) };
3771
- }
3772
3808
  };
3809
+ _g.label = 12;
3810
+ case 12:
3811
+ _g.trys.push([12, 17, 18, 19]);
3812
+ _c = __values(Object.keys(inputParameters)), _d = _c.next();
3813
+ _g.label = 13;
3814
+ case 13:
3815
+ if (!!_d.done) return [3 /*break*/, 16];
3816
+ parameterName = _d.value;
3817
+ return [5 /*yield**/, _loop_1(parameterName)];
3818
+ case 14:
3819
+ state_1 = _g.sent();
3820
+ if (typeof state_1 === "object")
3821
+ return [2 /*return*/, state_1.value];
3822
+ _g.label = 15;
3823
+ case 15:
3824
+ _d = _c.next();
3825
+ return [3 /*break*/, 13];
3826
+ case 16: return [3 /*break*/, 19];
3827
+ case 17:
3828
+ e_2_1 = _g.sent();
3829
+ e_2 = { error: e_2_1 };
3830
+ return [3 /*break*/, 19];
3831
+ case 18:
3773
3832
  try {
3774
- // Note: Check that no extra input parameters are passed
3775
- for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
3776
- parameterName = _d.value;
3777
- state_1 = _loop_1(parameterName);
3778
- if (typeof state_1 === "object")
3779
- return [2 /*return*/, state_1.value];
3780
- }
3781
- }
3782
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3783
- finally {
3784
- try {
3785
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3786
- }
3787
- finally { if (e_2) throw e_2.error; }
3833
+ if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3788
3834
  }
3835
+ finally { if (e_2) throw e_2.error; }
3836
+ return [7 /*endfinally*/];
3837
+ case 19:
3789
3838
  parametersToPass = inputParameters;
3790
- _g.label = 3;
3791
- case 3:
3792
- _g.trys.push([3, 8, , 9]);
3839
+ _g.label = 20;
3840
+ case 20:
3841
+ _g.trys.push([20, 25, , 28]);
3793
3842
  resovedParameterNames_1 = preparedPipeline.parameters
3794
3843
  .filter(function (_a) {
3795
3844
  var isInput = _a.isInput;
@@ -3804,8 +3853,8 @@
3804
3853
  loopLimit = LOOP_LIMIT;
3805
3854
  _loop_2 = function () {
3806
3855
  var currentTemplate, work_1;
3807
- return __generator(this, function (_h) {
3808
- switch (_h.label) {
3856
+ return __generator(this, function (_j) {
3857
+ switch (_j.label) {
3809
3858
  case 0:
3810
3859
  if (loopLimit-- < 0) {
3811
3860
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
@@ -3831,7 +3880,7 @@
3831
3880
  if (!!currentTemplate) return [3 /*break*/, 3];
3832
3881
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
3833
3882
  case 2:
3834
- /* [5] */ _h.sent();
3883
+ /* [5] */ _j.sent();
3835
3884
  return [3 /*break*/, 4];
3836
3885
  case 3:
3837
3886
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
@@ -3843,23 +3892,23 @@
3843
3892
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
3844
3893
  });
3845
3894
  resolving_1.push(work_1);
3846
- _h.label = 4;
3895
+ _j.label = 4;
3847
3896
  case 4: return [2 /*return*/];
3848
3897
  }
3849
3898
  });
3850
3899
  };
3851
- _g.label = 4;
3852
- case 4:
3853
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 6];
3900
+ _g.label = 21;
3901
+ case 21:
3902
+ if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
3854
3903
  return [5 /*yield**/, _loop_2()];
3855
- case 5:
3904
+ case 22:
3856
3905
  _g.sent();
3857
- return [3 /*break*/, 4];
3858
- case 6: return [4 /*yield*/, Promise.all(resolving_1)];
3859
- case 7:
3906
+ return [3 /*break*/, 21];
3907
+ case 23: return [4 /*yield*/, Promise.all(resolving_1)];
3908
+ case 24:
3860
3909
  _g.sent();
3861
- return [3 /*break*/, 9];
3862
- case 8:
3910
+ return [3 /*break*/, 28];
3911
+ case 25:
3863
3912
  error_1 = _g.sent();
3864
3913
  if (!(error_1 instanceof Error)) {
3865
3914
  throw error_1;
@@ -3870,31 +3919,45 @@
3870
3919
  })), false));
3871
3920
  outputParameters_1 = filterJustOutputParameters();
3872
3921
  isReturned = true;
3873
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
3874
- isSuccessful: false,
3875
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
3876
- warnings: warnings.map(serializeError),
3877
- usage: usage_1,
3878
- executionReport: executionReport,
3879
- outputParameters: outputParameters_1,
3880
- preparedPipeline: preparedPipeline,
3881
- })];
3882
- case 9:
3922
+ if (!(onProgress !== undefined)) return [3 /*break*/, 27];
3923
+ // Note: Wait a short time to prevent race conditions
3924
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3925
+ case 26:
3926
+ // Note: Wait a short time to prevent race conditions
3927
+ _g.sent();
3928
+ _g.label = 27;
3929
+ case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
3930
+ isSuccessful: false,
3931
+ errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
3932
+ warnings: warnings.map(serializeError),
3933
+ usage: usage_1,
3934
+ executionReport: executionReport,
3935
+ outputParameters: outputParameters_1,
3936
+ preparedPipeline: preparedPipeline,
3937
+ })];
3938
+ case 28:
3883
3939
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
3884
3940
  var result = _a.result;
3885
3941
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
3886
3942
  })), false));
3887
3943
  outputParameters = filterJustOutputParameters();
3888
3944
  isReturned = true;
3889
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
3890
- isSuccessful: true,
3891
- errors: errors.map(serializeError),
3892
- warnings: warnings.map(serializeError),
3893
- usage: usage,
3894
- executionReport: executionReport,
3895
- outputParameters: outputParameters,
3896
- preparedPipeline: preparedPipeline,
3897
- })];
3945
+ if (!(onProgress !== undefined)) return [3 /*break*/, 30];
3946
+ // Note: Wait a short time to prevent race conditions
3947
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3948
+ case 29:
3949
+ // Note: Wait a short time to prevent race conditions
3950
+ _g.sent();
3951
+ _g.label = 30;
3952
+ case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
3953
+ isSuccessful: true,
3954
+ errors: errors.map(serializeError),
3955
+ warnings: warnings.map(serializeError),
3956
+ usage: usage,
3957
+ executionReport: executionReport,
3958
+ outputParameters: outputParameters,
3959
+ preparedPipeline: preparedPipeline,
3960
+ })];
3898
3961
  }
3899
3962
  });
3900
3963
  }); };