@promptbook/core 0.69.0-19 โ†’ 0.69.0-20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.es.js CHANGED
@@ -11,7 +11,7 @@ import moment from 'moment';
11
11
  /**
12
12
  * The version of the Promptbook library
13
13
  */
14
- var PROMPTBOOK_VERSION = '0.69.0-18';
14
+ var PROMPTBOOK_VERSION = '0.69.0-19';
15
15
  // TODO:[main] !!!! List here all the versions and annotate + put into script
16
16
 
17
17
  /*! *****************************************************************************
@@ -3701,16 +3701,16 @@ function executeAttempts(options) {
3701
3701
  case 0:
3702
3702
  isJokerAttempt = attempt < 0;
3703
3703
  jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
3704
- // TODO: [๐Ÿง ] !!!!!! JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
3704
+ // TODO: [๐Ÿง ][๐Ÿญ] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
3705
3705
  if (isJokerAttempt && !jokerParameterName) {
3706
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
3706
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
3707
3707
  }
3708
3708
  $ongoingTemplateResult.$result = null;
3709
3709
  $ongoingTemplateResult.$resultString = null;
3710
3710
  $ongoingTemplateResult.$expectError = null;
3711
3711
  if (isJokerAttempt) {
3712
3712
  if (parameters[jokerParameterName] === undefined) {
3713
- throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
3713
+ throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
3714
3714
  // <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
3715
3715
  }
3716
3716
  else {
@@ -3776,14 +3776,14 @@ function executeAttempts(options) {
3776
3776
  $ongoingTemplateResult.$completionResult.content;
3777
3777
  return [3 /*break*/, 10];
3778
3778
  case 8: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Embedding model can not be used in pipeline\n\n This should be catched during parsing\n\n ".concat(block(pipelineIdentification), "\n\n "); }));
3779
- case 9: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3779
+ case 9: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3780
3780
  case 10: return [3 /*break*/, 25];
3781
3781
  case 11:
3782
3782
  if (arrayableToArray(tools.script).length === 0) {
3783
- throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3783
+ throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3784
3784
  }
3785
3785
  if (!template.contentLanguage) {
3786
- throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3786
+ throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3787
3787
  }
3788
3788
  _t.label = 12;
3789
3789
  case 12:
@@ -3837,13 +3837,13 @@ function executeAttempts(options) {
3837
3837
  throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
3838
3838
  }
3839
3839
  else {
3840
- throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
3840
+ throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
3841
3841
  .map(function (error) { return '- ' + error.message; })
3842
- .join('\n\n')), "\n "); }));
3842
+ .join('\n\n')), "\n "); }));
3843
3843
  }
3844
3844
  case 22:
3845
3845
  if (tools.userInterface === undefined) {
3846
- throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3846
+ throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3847
3847
  }
3848
3848
  // TODO: [๐ŸŒน] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3849
3849
  _j = $ongoingTemplateResult;
@@ -3859,7 +3859,7 @@ function executeAttempts(options) {
3859
3859
  // TODO: [๐ŸŒน] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3860
3860
  _j.$resultString = _t.sent();
3861
3861
  return [3 /*break*/, 25];
3862
- case 24: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3862
+ case 24: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3863
3863
  case 25:
3864
3864
  if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3865
3865
  _t.label = 26;
@@ -3950,13 +3950,13 @@ function executeAttempts(options) {
3950
3950
  }
3951
3951
  catch (error) {
3952
3952
  keepUnused(error);
3953
- throw new ExpectError(spaceTrim$1(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
3954
- /*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
3953
+ throw new ExpectError(spaceTrim$1(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
3954
+ /*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
3955
3955
  }
3956
3956
  }
3957
3957
  }
3958
3958
  else {
3959
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3959
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3960
3960
  }
3961
3961
  }
3962
3962
  // TODO: [๐Ÿ’] Unite object for expecting amount and format
@@ -3992,18 +3992,18 @@ function executeAttempts(options) {
3992
3992
  if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
3993
3993
  throw new PipelineExecutionError(spaceTrim$1(function (block) {
3994
3994
  var _a, _b, _c;
3995
- return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $ongoingTemplateResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
3995
+ return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $ongoingTemplateResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
3996
3996
  .split('\n')
3997
3997
  .map(function (line) { return "> ".concat(line); })
3998
- .join('\n')), "\n\n Last error ").concat(((_b = $ongoingTemplateResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || '', ":\n ").concat(block((((_c = $ongoingTemplateResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
3998
+ .join('\n')), "\n\n Last error ").concat(((_b = $ongoingTemplateResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || '', ":\n ").concat(block((((_c = $ongoingTemplateResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
3999
3999
  .split('\n')
4000
4000
  .map(function (line) { return "> ".concat(line); })
4001
- .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
4001
+ .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
4002
4002
  ? 'null'
4003
4003
  : $ongoingTemplateResult.$resultString
4004
4004
  .split('\n')
4005
4005
  .map(function (line) { return "> ".concat(line); })
4006
- .join('\n')), "\n ---\n ");
4006
+ .join('\n')), "\n ---\n ");
4007
4007
  }));
4008
4008
  }
4009
4009
  return [2 /*return*/];
@@ -4026,7 +4026,7 @@ function executeAttempts(options) {
4026
4026
  return [3 /*break*/, 1];
4027
4027
  case 4:
4028
4028
  if ($ongoingTemplateResult.$resultString === null) {
4029
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
4029
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
4030
4030
  }
4031
4031
  return [2 /*return*/, $ongoingTemplateResult.$resultString];
4032
4032
  }
@@ -4490,7 +4490,7 @@ function executePipeline(options) {
4490
4490
  return name === parameterName;
4491
4491
  });
4492
4492
  if (!(parameter === undefined)) return [3 /*break*/, 1];
4493
- warnings.push(new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
4493
+ warnings.push(new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
4494
4494
  return [3 /*break*/, 4];
4495
4495
  case 1:
4496
4496
  if (!(parameter.isInput === false)) return [3 /*break*/, 4];
@@ -4502,10 +4502,10 @@ function executePipeline(options) {
4502
4502
  // Note: Wait a short time to prevent race conditions
4503
4503
  _h.sent();
4504
4504
  _h.label = 3;
4505
- case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim$1(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
4505
+ case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim$1(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
4506
4506
  isSuccessful: false,
4507
4507
  errors: __spreadArray([
4508
- new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4508
+ new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4509
4509
  ], __read(errors), false).map(serializeError),
4510
4510
  warnings: warnings.map(serializeError),
4511
4511
  executionReport: executionReport,
@@ -4569,7 +4569,7 @@ function executePipeline(options) {
4569
4569
  case 0:
4570
4570
  if (loopLimit-- < 0) {
4571
4571
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
4572
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
4572
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
4573
4573
  }
4574
4574
  currentTemplate = unresovedTemplates_1.find(function (template) {
4575
4575
  return template.dependentParameterNames.every(function (name) {
@@ -4579,14 +4579,14 @@ function executePipeline(options) {
4579
4579
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
4580
4580
  throw new UnexpectedError(
4581
4581
  // TODO: [๐ŸŽ] DRY
4582
- spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates_1
4582
+ spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates_1
4583
4583
  .map(function (_a) {
4584
4584
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
4585
4585
  return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
4586
4586
  .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
4587
4587
  .join(' and '));
4588
4588
  })
4589
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameterNames_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
4589
+ .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameterNames_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
4590
4590
  case 1:
4591
4591
  if (!!currentTemplate) return [3 /*break*/, 3];
4592
4592
  /* [๐Ÿคนโ€โ™‚๏ธ] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -4603,10 +4603,10 @@ function executePipeline(options) {
4603
4603
  llmTools: llmTools,
4604
4604
  onProgress: function (progress) {
4605
4605
  if (isReturned) {
4606
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
4606
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
4607
4607
  .split('\n')
4608
4608
  .map(function (line) { return "> ".concat(line); })
4609
- .join('\n')), "\n "); }));
4609
+ .join('\n')), "\n "); }));
4610
4610
  }
4611
4611
  if (onProgress) {
4612
4612
  onProgress(progress);