@promptbook/core 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/core",
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,
@@ -49,6 +49,7 @@
49
49
  "dependencies": {
50
50
  "moment": "2.30.1",
51
51
  "prettier": "2.8.1",
52
- "spacetrim": "0.11.39"
52
+ "spacetrim": "0.11.39",
53
+ "waitasecond": "1.11.83"
53
54
  }
54
55
  }
package/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('moment')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'moment'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.moment));
5
- })(this, (function (exports, spaceTrim, prettier, parserHtml, hexEncoder, sha256, moment) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('moment')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'moment'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.waitasecond, global.hexEncoder, global.sha256, global.moment));
5
+ })(this, (function (exports, spaceTrim, prettier, parserHtml, waitasecond, hexEncoder, sha256, moment) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -16,7 +16,7 @@
16
16
  /**
17
17
  * The version of the Promptbook library
18
18
  */
19
- var PROMPTBOOK_VERSION = '0.67.7';
19
+ var PROMPTBOOK_VERSION = '0.67.8';
20
20
  // TODO: !!!! List here all the versions and annotate + put into script
21
21
 
22
22
  /*! *****************************************************************************
@@ -647,6 +647,12 @@
647
647
  * @private within the repository - too low-level in comparison with other `MAX_...`
648
648
  */
649
649
  var LOOP_LIMIT = 1000;
650
+ /**
651
+ * Short time interval to prevent race conditions in milliseconds
652
+ *
653
+ * @private within the repository - too low-level in comparison with other `MAX_...`
654
+ */
655
+ var IMMEDIATE_TIME = 10;
650
656
  /**
651
657
  * The maximum number of (LLM) tasks running in parallel
652
658
  *
@@ -1786,7 +1792,7 @@
1786
1792
  });
1787
1793
  }
1788
1794
 
1789
- 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"}];
1795
+ 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"}];
1790
1796
 
1791
1797
  var defaultDiacriticsRemovalMap = [
1792
1798
  {
@@ -3387,7 +3393,7 @@
3387
3393
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
3388
3394
  title = currentTemplate.title;
3389
3395
  priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
3390
- if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3396
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3391
3397
  progress_1 = {
3392
3398
  name: name,
3393
3399
  title: title,
@@ -3790,7 +3796,7 @@
3790
3796
  if (resultString === null) {
3791
3797
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3792
3798
  }
3793
- if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3799
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3794
3800
  progress_2 = {
3795
3801
  name: name,
3796
3802
  title: title,
@@ -3848,7 +3854,7 @@
3848
3854
  }
3849
3855
  return outputParameters;
3850
3856
  }
3851
- 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;
3857
+ 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;
3852
3858
  var e_1, _e, e_2, _f;
3853
3859
  return __generator(this, function (_g) {
3854
3860
  switch (_g.label) {
@@ -3874,79 +3880,122 @@
3874
3880
  promptExecutions: [],
3875
3881
  };
3876
3882
  isReturned = false;
3883
+ _g.label = 3;
3884
+ case 3:
3885
+ _g.trys.push([3, 9, 10, 11]);
3886
+ _a = __values(preparedPipeline.parameters.filter(function (_a) {
3887
+ var isInput = _a.isInput;
3888
+ return isInput;
3889
+ })), _b = _a.next();
3890
+ _g.label = 4;
3891
+ case 4:
3892
+ if (!!_b.done) return [3 /*break*/, 8];
3893
+ parameter = _b.value;
3894
+ if (!(inputParameters[parameter.name] === undefined)) return [3 /*break*/, 7];
3895
+ isReturned = true;
3896
+ if (!(onProgress !== undefined)) return [3 /*break*/, 6];
3897
+ // Note: Wait a short time to prevent race conditions
3898
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3899
+ case 5:
3900
+ // Note: Wait a short time to prevent race conditions
3901
+ _g.sent();
3902
+ _g.label = 6;
3903
+ case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3904
+ isSuccessful: false,
3905
+ errors: __spreadArray([
3906
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3907
+ ], __read(errors), false).map(serializeError),
3908
+ warnings: [],
3909
+ executionReport: executionReport,
3910
+ outputParameters: {},
3911
+ usage: ZERO_USAGE,
3912
+ preparedPipeline: preparedPipeline,
3913
+ })];
3914
+ case 7:
3915
+ _b = _a.next();
3916
+ return [3 /*break*/, 4];
3917
+ case 8: return [3 /*break*/, 11];
3918
+ case 9:
3919
+ e_1_1 = _g.sent();
3920
+ e_1 = { error: e_1_1 };
3921
+ return [3 /*break*/, 11];
3922
+ case 10:
3877
3923
  try {
3878
- // Note: Check that all input input parameters are defined
3879
- for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
3880
- var isInput = _a.isInput;
3881
- return isInput;
3882
- })), _b = _a.next(); !_b.done; _b = _a.next()) {
3883
- parameter = _b.value;
3884
- if (inputParameters[parameter.name] === undefined) {
3885
- isReturned = true;
3886
- return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3887
- isSuccessful: false,
3888
- errors: __spreadArray([
3889
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3890
- ], __read(errors), false).map(serializeError),
3891
- warnings: [],
3892
- executionReport: executionReport,
3893
- outputParameters: {},
3894
- usage: ZERO_USAGE,
3895
- preparedPipeline: preparedPipeline,
3896
- })];
3897
- }
3898
- }
3899
- }
3900
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3901
- finally {
3902
- try {
3903
- if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3904
- }
3905
- finally { if (e_1) throw e_1.error; }
3924
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3906
3925
  }
3926
+ finally { if (e_1) throw e_1.error; }
3927
+ return [7 /*endfinally*/];
3928
+ case 11:
3907
3929
  _loop_1 = function (parameterName) {
3908
- var parameter = preparedPipeline.parameters.find(function (_a) {
3909
- var name = _a.name;
3910
- return name === parameterName;
3930
+ var parameter;
3931
+ return __generator(this, function (_h) {
3932
+ switch (_h.label) {
3933
+ case 0:
3934
+ parameter = preparedPipeline.parameters.find(function (_a) {
3935
+ var name = _a.name;
3936
+ return name === parameterName;
3937
+ });
3938
+ if (!(parameter === undefined)) return [3 /*break*/, 1];
3939
+ 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 "); })));
3940
+ return [3 /*break*/, 4];
3941
+ case 1:
3942
+ if (!(parameter.isInput === false)) return [3 /*break*/, 4];
3943
+ isReturned = true;
3944
+ if (!(onProgress !== undefined)) return [3 /*break*/, 3];
3945
+ // Note: Wait a short time to prevent race conditions
3946
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3947
+ case 2:
3948
+ // Note: Wait a short time to prevent race conditions
3949
+ _h.sent();
3950
+ _h.label = 3;
3951
+ 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 "); }), {
3952
+ isSuccessful: false,
3953
+ errors: __spreadArray([
3954
+ 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 "); }))
3955
+ ], __read(errors), false).map(serializeError),
3956
+ warnings: warnings.map(serializeError),
3957
+ executionReport: executionReport,
3958
+ outputParameters: {},
3959
+ usage: ZERO_USAGE,
3960
+ preparedPipeline: preparedPipeline,
3961
+ }) }];
3962
+ case 4: return [2 /*return*/];
3963
+ }
3911
3964
  });
3912
- if (parameter === undefined) {
3913
- 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 "); })));
3914
- }
3915
- else if (parameter.isInput === false) {
3916
- isReturned = true;
3917
- return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3918
- isSuccessful: false,
3919
- errors: __spreadArray([
3920
- 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 "); }))
3921
- ], __read(errors), false).map(serializeError),
3922
- warnings: warnings.map(serializeError),
3923
- executionReport: executionReport,
3924
- outputParameters: {},
3925
- usage: ZERO_USAGE,
3926
- preparedPipeline: preparedPipeline,
3927
- }) };
3928
- }
3929
3965
  };
3966
+ _g.label = 12;
3967
+ case 12:
3968
+ _g.trys.push([12, 17, 18, 19]);
3969
+ _c = __values(Object.keys(inputParameters)), _d = _c.next();
3970
+ _g.label = 13;
3971
+ case 13:
3972
+ if (!!_d.done) return [3 /*break*/, 16];
3973
+ parameterName = _d.value;
3974
+ return [5 /*yield**/, _loop_1(parameterName)];
3975
+ case 14:
3976
+ state_1 = _g.sent();
3977
+ if (typeof state_1 === "object")
3978
+ return [2 /*return*/, state_1.value];
3979
+ _g.label = 15;
3980
+ case 15:
3981
+ _d = _c.next();
3982
+ return [3 /*break*/, 13];
3983
+ case 16: return [3 /*break*/, 19];
3984
+ case 17:
3985
+ e_2_1 = _g.sent();
3986
+ e_2 = { error: e_2_1 };
3987
+ return [3 /*break*/, 19];
3988
+ case 18:
3930
3989
  try {
3931
- // Note: Check that no extra input parameters are passed
3932
- for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
3933
- parameterName = _d.value;
3934
- state_1 = _loop_1(parameterName);
3935
- if (typeof state_1 === "object")
3936
- return [2 /*return*/, state_1.value];
3937
- }
3938
- }
3939
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3940
- finally {
3941
- try {
3942
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3943
- }
3944
- finally { if (e_2) throw e_2.error; }
3990
+ if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3945
3991
  }
3992
+ finally { if (e_2) throw e_2.error; }
3993
+ return [7 /*endfinally*/];
3994
+ case 19:
3946
3995
  parametersToPass = inputParameters;
3947
- _g.label = 3;
3948
- case 3:
3949
- _g.trys.push([3, 8, , 9]);
3996
+ _g.label = 20;
3997
+ case 20:
3998
+ _g.trys.push([20, 25, , 28]);
3950
3999
  resovedParameterNames_1 = preparedPipeline.parameters
3951
4000
  .filter(function (_a) {
3952
4001
  var isInput = _a.isInput;
@@ -3961,8 +4010,8 @@
3961
4010
  loopLimit = LOOP_LIMIT;
3962
4011
  _loop_2 = function () {
3963
4012
  var currentTemplate, work_1;
3964
- return __generator(this, function (_h) {
3965
- switch (_h.label) {
4013
+ return __generator(this, function (_j) {
4014
+ switch (_j.label) {
3966
4015
  case 0:
3967
4016
  if (loopLimit-- < 0) {
3968
4017
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
@@ -3988,7 +4037,7 @@
3988
4037
  if (!!currentTemplate) return [3 /*break*/, 3];
3989
4038
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
3990
4039
  case 2:
3991
- /* [5] */ _h.sent();
4040
+ /* [5] */ _j.sent();
3992
4041
  return [3 /*break*/, 4];
3993
4042
  case 3:
3994
4043
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
@@ -4000,23 +4049,23 @@
4000
4049
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
4001
4050
  });
4002
4051
  resolving_1.push(work_1);
4003
- _h.label = 4;
4052
+ _j.label = 4;
4004
4053
  case 4: return [2 /*return*/];
4005
4054
  }
4006
4055
  });
4007
4056
  };
4008
- _g.label = 4;
4009
- case 4:
4010
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 6];
4057
+ _g.label = 21;
4058
+ case 21:
4059
+ if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
4011
4060
  return [5 /*yield**/, _loop_2()];
4012
- case 5:
4061
+ case 22:
4013
4062
  _g.sent();
4014
- return [3 /*break*/, 4];
4015
- case 6: return [4 /*yield*/, Promise.all(resolving_1)];
4016
- case 7:
4063
+ return [3 /*break*/, 21];
4064
+ case 23: return [4 /*yield*/, Promise.all(resolving_1)];
4065
+ case 24:
4017
4066
  _g.sent();
4018
- return [3 /*break*/, 9];
4019
- case 8:
4067
+ return [3 /*break*/, 28];
4068
+ case 25:
4020
4069
  error_1 = _g.sent();
4021
4070
  if (!(error_1 instanceof Error)) {
4022
4071
  throw error_1;
@@ -4027,31 +4076,45 @@
4027
4076
  })), false));
4028
4077
  outputParameters_1 = filterJustOutputParameters();
4029
4078
  isReturned = true;
4030
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
4031
- isSuccessful: false,
4032
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
4033
- warnings: warnings.map(serializeError),
4034
- usage: usage_1,
4035
- executionReport: executionReport,
4036
- outputParameters: outputParameters_1,
4037
- preparedPipeline: preparedPipeline,
4038
- })];
4039
- case 9:
4079
+ if (!(onProgress !== undefined)) return [3 /*break*/, 27];
4080
+ // Note: Wait a short time to prevent race conditions
4081
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
4082
+ case 26:
4083
+ // Note: Wait a short time to prevent race conditions
4084
+ _g.sent();
4085
+ _g.label = 27;
4086
+ case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
4087
+ isSuccessful: false,
4088
+ errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
4089
+ warnings: warnings.map(serializeError),
4090
+ usage: usage_1,
4091
+ executionReport: executionReport,
4092
+ outputParameters: outputParameters_1,
4093
+ preparedPipeline: preparedPipeline,
4094
+ })];
4095
+ case 28:
4040
4096
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
4041
4097
  var result = _a.result;
4042
4098
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
4043
4099
  })), false));
4044
4100
  outputParameters = filterJustOutputParameters();
4045
4101
  isReturned = true;
4046
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
4047
- isSuccessful: true,
4048
- errors: errors.map(serializeError),
4049
- warnings: warnings.map(serializeError),
4050
- usage: usage,
4051
- executionReport: executionReport,
4052
- outputParameters: outputParameters,
4053
- preparedPipeline: preparedPipeline,
4054
- })];
4102
+ if (!(onProgress !== undefined)) return [3 /*break*/, 30];
4103
+ // Note: Wait a short time to prevent race conditions
4104
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
4105
+ case 29:
4106
+ // Note: Wait a short time to prevent race conditions
4107
+ _g.sent();
4108
+ _g.label = 30;
4109
+ case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
4110
+ isSuccessful: true,
4111
+ errors: errors.map(serializeError),
4112
+ warnings: warnings.map(serializeError),
4113
+ usage: usage,
4114
+ executionReport: executionReport,
4115
+ outputParameters: outputParameters,
4116
+ preparedPipeline: preparedPipeline,
4117
+ })];
4055
4118
  }
4056
4119
  });
4057
4120
  }); };