@promptbook/core 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.
@@ -12,3 +12,6 @@ export type ExpectAmountCommand = {
12
12
  readonly unit: ExpectationUnit;
13
13
  readonly amount: ExpectationAmount;
14
14
  };
15
+ /**
16
+ * TODO: [🍋] Allow to `EXPECT` relative amounts like `EXPECT MAX 130% {foo} Words`
17
+ */
@@ -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.7",
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.6';
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.6",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.6",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.6",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.6",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
  {
@@ -3379,7 +3385,7 @@
3379
3385
  }
3380
3386
  function executeSingleTemplate(currentTemplate) {
3381
3387
  return __awaiter(this, void 0, void 0, function () {
3382
- 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;
3388
+ 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;
3383
3389
  var e_4, _f, _g;
3384
3390
  return __generator(this, function (_h) {
3385
3391
  switch (_h.label) {
@@ -3387,17 +3393,24 @@
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] */
3391
- return [4 /*yield*/, onProgress({
3392
- name: name,
3393
- title: title,
3394
- isStarted: false,
3395
- isDone: false,
3396
- blockType: currentTemplate.blockType,
3397
- parameterName: currentTemplate.resultingParameterName,
3398
- parameterValue: null,
3399
- // <- [3]
3400
- })];
3396
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3397
+ progress_1 = {
3398
+ name: name,
3399
+ title: title,
3400
+ isStarted: false,
3401
+ isDone: false,
3402
+ blockType: currentTemplate.blockType,
3403
+ parameterName: currentTemplate.resultingParameterName,
3404
+ parameterValue: null,
3405
+ // <- [3]
3406
+ };
3407
+ if (isReturned) {
3408
+ throw new UnexpectedError(spaceTrim.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)
3409
+ .split('\n')
3410
+ .map(function (line) { return "> ".concat(line); })
3411
+ .join('\n')), "\n "); }));
3412
+ }
3413
+ return [4 /*yield*/, onProgress(progress_1)];
3401
3414
  case 1:
3402
3415
  _h.sent();
3403
3416
  _h.label = 2;
@@ -3783,18 +3796,28 @@
3783
3796
  if (resultString === null) {
3784
3797
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3785
3798
  }
3786
- if (onProgress /* <- [3] */) {
3787
- onProgress({
3788
- name: name,
3789
- title: title,
3790
- isStarted: true,
3791
- isDone: true,
3792
- blockType: currentTemplate.blockType,
3793
- parameterName: currentTemplate.resultingParameterName,
3794
- parameterValue: resultString,
3795
- // <- [3]
3796
- });
3799
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3800
+ progress_2 = {
3801
+ name: name,
3802
+ title: title,
3803
+ isStarted: true,
3804
+ isDone: true,
3805
+ blockType: currentTemplate.blockType,
3806
+ parameterName: currentTemplate.resultingParameterName,
3807
+ parameterValue: resultString,
3808
+ // <- [3]
3809
+ };
3810
+ if (isReturned) {
3811
+ throw new UnexpectedError(spaceTrim.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)
3812
+ .split('\n')
3813
+ .map(function (line) { return "> ".concat(line); })
3814
+ .join('\n')), "\n\n "); }));
3797
3815
  }
3816
+ return [4 /*yield*/, onProgress(progress_2)];
3817
+ case 8:
3818
+ _h.sent();
3819
+ _h.label = 9;
3820
+ case 9:
3798
3821
  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)));
3799
3822
  return [2 /*return*/];
3800
3823
  }
@@ -3831,7 +3854,7 @@
3831
3854
  }
3832
3855
  return outputParameters;
3833
3856
  }
3834
- 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;
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;
3835
3858
  var e_1, _e, e_2, _f;
3836
3859
  return __generator(this, function (_g) {
3837
3860
  switch (_g.label) {
@@ -3856,77 +3879,123 @@
3856
3879
  description: preparedPipeline.description,
3857
3880
  promptExecutions: [],
3858
3881
  };
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:
3859
3923
  try {
3860
- // Note: Check that all input input parameters are defined
3861
- for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
3862
- var isInput = _a.isInput;
3863
- return isInput;
3864
- })), _b = _a.next(); !_b.done; _b = _a.next()) {
3865
- parameter = _b.value;
3866
- if (inputParameters[parameter.name] === undefined) {
3867
- return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3868
- isSuccessful: false,
3869
- errors: __spreadArray([
3870
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3871
- ], __read(errors), false).map(serializeError),
3872
- warnings: [],
3873
- executionReport: executionReport,
3874
- outputParameters: {},
3875
- usage: ZERO_USAGE,
3876
- preparedPipeline: preparedPipeline,
3877
- })];
3878
- }
3879
- }
3880
- }
3881
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3882
- finally {
3883
- try {
3884
- if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3885
- }
3886
- finally { if (e_1) throw e_1.error; }
3924
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3887
3925
  }
3926
+ finally { if (e_1) throw e_1.error; }
3927
+ return [7 /*endfinally*/];
3928
+ case 11:
3888
3929
  _loop_1 = function (parameterName) {
3889
- var parameter = preparedPipeline.parameters.find(function (_a) {
3890
- var name = _a.name;
3891
- 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
+ }
3892
3964
  });
3893
- if (parameter === undefined) {
3894
- 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 "); })));
3895
- }
3896
- else if (parameter.isInput === false) {
3897
- return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3898
- isSuccessful: false,
3899
- errors: __spreadArray([
3900
- 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 "); }))
3901
- ], __read(errors), false).map(serializeError),
3902
- warnings: warnings.map(serializeError),
3903
- executionReport: executionReport,
3904
- outputParameters: {},
3905
- usage: ZERO_USAGE,
3906
- preparedPipeline: preparedPipeline,
3907
- }) };
3908
- }
3909
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:
3910
3989
  try {
3911
- // Note: Check that no extra input parameters are passed
3912
- for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
3913
- parameterName = _d.value;
3914
- state_1 = _loop_1(parameterName);
3915
- if (typeof state_1 === "object")
3916
- return [2 /*return*/, state_1.value];
3917
- }
3918
- }
3919
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3920
- finally {
3921
- try {
3922
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3923
- }
3924
- finally { if (e_2) throw e_2.error; }
3990
+ if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3925
3991
  }
3992
+ finally { if (e_2) throw e_2.error; }
3993
+ return [7 /*endfinally*/];
3994
+ case 19:
3926
3995
  parametersToPass = inputParameters;
3927
- _g.label = 3;
3928
- case 3:
3929
- _g.trys.push([3, 8, , 9]);
3996
+ _g.label = 20;
3997
+ case 20:
3998
+ _g.trys.push([20, 25, , 28]);
3930
3999
  resovedParameterNames_1 = preparedPipeline.parameters
3931
4000
  .filter(function (_a) {
3932
4001
  var isInput = _a.isInput;
@@ -3941,8 +4010,8 @@
3941
4010
  loopLimit = LOOP_LIMIT;
3942
4011
  _loop_2 = function () {
3943
4012
  var currentTemplate, work_1;
3944
- return __generator(this, function (_h) {
3945
- switch (_h.label) {
4013
+ return __generator(this, function (_j) {
4014
+ switch (_j.label) {
3946
4015
  case 0:
3947
4016
  if (loopLimit-- < 0) {
3948
4017
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
@@ -3968,7 +4037,7 @@
3968
4037
  if (!!currentTemplate) return [3 /*break*/, 3];
3969
4038
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
3970
4039
  case 2:
3971
- /* [5] */ _h.sent();
4040
+ /* [5] */ _j.sent();
3972
4041
  return [3 /*break*/, 4];
3973
4042
  case 3:
3974
4043
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
@@ -3980,23 +4049,23 @@
3980
4049
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
3981
4050
  });
3982
4051
  resolving_1.push(work_1);
3983
- _h.label = 4;
4052
+ _j.label = 4;
3984
4053
  case 4: return [2 /*return*/];
3985
4054
  }
3986
4055
  });
3987
4056
  };
3988
- _g.label = 4;
3989
- case 4:
3990
- 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];
3991
4060
  return [5 /*yield**/, _loop_2()];
3992
- case 5:
4061
+ case 22:
3993
4062
  _g.sent();
3994
- return [3 /*break*/, 4];
3995
- case 6: return [4 /*yield*/, Promise.all(resolving_1)];
3996
- case 7:
4063
+ return [3 /*break*/, 21];
4064
+ case 23: return [4 /*yield*/, Promise.all(resolving_1)];
4065
+ case 24:
3997
4066
  _g.sent();
3998
- return [3 /*break*/, 9];
3999
- case 8:
4067
+ return [3 /*break*/, 28];
4068
+ case 25:
4000
4069
  error_1 = _g.sent();
4001
4070
  if (!(error_1 instanceof Error)) {
4002
4071
  throw error_1;
@@ -4006,30 +4075,46 @@
4006
4075
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
4007
4076
  })), false));
4008
4077
  outputParameters_1 = filterJustOutputParameters();
4009
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
4010
- isSuccessful: false,
4011
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
4012
- warnings: warnings.map(serializeError),
4013
- usage: usage_1,
4014
- executionReport: executionReport,
4015
- outputParameters: outputParameters_1,
4016
- preparedPipeline: preparedPipeline,
4017
- })];
4018
- case 9:
4078
+ isReturned = true;
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:
4019
4096
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
4020
4097
  var result = _a.result;
4021
4098
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
4022
4099
  })), false));
4023
4100
  outputParameters = filterJustOutputParameters();
4024
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
4025
- isSuccessful: true,
4026
- errors: errors.map(serializeError),
4027
- warnings: warnings.map(serializeError),
4028
- usage: usage,
4029
- executionReport: executionReport,
4030
- outputParameters: outputParameters,
4031
- preparedPipeline: preparedPipeline,
4032
- })];
4101
+ isReturned = true;
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
+ })];
4033
4118
  }
4034
4119
  });
4035
4120
  }); };