@promptbook/node 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
@@ -15,7 +15,7 @@ import * as dotenv from 'dotenv';
15
15
  /**
16
16
  * The version of the Promptbook library
17
17
  */
18
- var PROMPTBOOK_VERSION = '0.69.0-18';
18
+ var PROMPTBOOK_VERSION = '0.69.0-19';
19
19
  // TODO:[main] !!!! List here all the versions and annotate + put into script
20
20
 
21
21
  /*! *****************************************************************************
@@ -3381,16 +3381,16 @@ function executeAttempts(options) {
3381
3381
  case 0:
3382
3382
  isJokerAttempt = attempt < 0;
3383
3383
  jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
3384
- // TODO: [๐Ÿง ] !!!!!! JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
3384
+ // TODO: [๐Ÿง ][๐Ÿญ] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
3385
3385
  if (isJokerAttempt && !jokerParameterName) {
3386
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
3386
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
3387
3387
  }
3388
3388
  $ongoingTemplateResult.$result = null;
3389
3389
  $ongoingTemplateResult.$resultString = null;
3390
3390
  $ongoingTemplateResult.$expectError = null;
3391
3391
  if (isJokerAttempt) {
3392
3392
  if (parameters[jokerParameterName] === undefined) {
3393
- throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
3393
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
3394
3394
  // <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
3395
3395
  }
3396
3396
  else {
@@ -3456,14 +3456,14 @@ function executeAttempts(options) {
3456
3456
  $ongoingTemplateResult.$completionResult.content;
3457
3457
  return [3 /*break*/, 10];
3458
3458
  case 8: throw new PipelineExecutionError(spaceTrim(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 "); }));
3459
- case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3459
+ case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3460
3460
  case 10: return [3 /*break*/, 25];
3461
3461
  case 11:
3462
3462
  if (arrayableToArray(tools.script).length === 0) {
3463
- throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3463
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3464
3464
  }
3465
3465
  if (!template.contentLanguage) {
3466
- throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3466
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3467
3467
  }
3468
3468
  _t.label = 12;
3469
3469
  case 12:
@@ -3517,13 +3517,13 @@ function executeAttempts(options) {
3517
3517
  throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
3518
3518
  }
3519
3519
  else {
3520
- throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
3520
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTemplateResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTemplateResult.$scriptPipelineExecutionErrors
3521
3521
  .map(function (error) { return '- ' + error.message; })
3522
- .join('\n\n')), "\n "); }));
3522
+ .join('\n\n')), "\n "); }));
3523
3523
  }
3524
3524
  case 22:
3525
3525
  if (tools.userInterface === undefined) {
3526
- throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3526
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3527
3527
  }
3528
3528
  // TODO: [๐ŸŒน] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3529
3529
  _j = $ongoingTemplateResult;
@@ -3539,7 +3539,7 @@ function executeAttempts(options) {
3539
3539
  // TODO: [๐ŸŒน] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3540
3540
  _j.$resultString = _t.sent();
3541
3541
  return [3 /*break*/, 25];
3542
- case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3542
+ case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3543
3543
  case 25:
3544
3544
  if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3545
3545
  _t.label = 26;
@@ -3630,13 +3630,13 @@ function executeAttempts(options) {
3630
3630
  }
3631
3631
  catch (error) {
3632
3632
  keepUnused(error);
3633
- throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
3634
- /*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
3633
+ throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
3634
+ /*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
3635
3635
  }
3636
3636
  }
3637
3637
  }
3638
3638
  else {
3639
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3639
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(template.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3640
3640
  }
3641
3641
  }
3642
3642
  // TODO: [๐Ÿ’] Unite object for expecting amount and format
@@ -3672,18 +3672,18 @@ function executeAttempts(options) {
3672
3672
  if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
3673
3673
  throw new PipelineExecutionError(spaceTrim(function (block) {
3674
3674
  var _a, _b, _c;
3675
- 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) || '')
3675
+ 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) || '')
3676
3676
  .split('\n')
3677
3677
  .map(function (line) { return "> ".concat(line); })
3678
- .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) || '')
3678
+ .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) || '')
3679
3679
  .split('\n')
3680
3680
  .map(function (line) { return "> ".concat(line); })
3681
- .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
3681
+ .join('\n')), "\n\n Last result:\n ").concat(block($ongoingTemplateResult.$resultString === null
3682
3682
  ? 'null'
3683
3683
  : $ongoingTemplateResult.$resultString
3684
3684
  .split('\n')
3685
3685
  .map(function (line) { return "> ".concat(line); })
3686
- .join('\n')), "\n ---\n ");
3686
+ .join('\n')), "\n ---\n ");
3687
3687
  }));
3688
3688
  }
3689
3689
  return [2 /*return*/];
@@ -3706,7 +3706,7 @@ function executeAttempts(options) {
3706
3706
  return [3 /*break*/, 1];
3707
3707
  case 4:
3708
3708
  if ($ongoingTemplateResult.$resultString === null) {
3709
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3709
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3710
3710
  }
3711
3711
  return [2 /*return*/, $ongoingTemplateResult.$resultString];
3712
3712
  }
@@ -4170,7 +4170,7 @@ function executePipeline(options) {
4170
4170
  return name === parameterName;
4171
4171
  });
4172
4172
  if (!(parameter === undefined)) return [3 /*break*/, 1];
4173
- warnings.push(new PipelineExecutionError(spaceTrim(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
4173
+ warnings.push(new PipelineExecutionError(spaceTrim(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
4174
4174
  return [3 /*break*/, 4];
4175
4175
  case 1:
4176
4176
  if (!(parameter.isInput === false)) return [3 /*break*/, 4];
@@ -4182,10 +4182,10 @@ function executePipeline(options) {
4182
4182
  // Note: Wait a short time to prevent race conditions
4183
4183
  _h.sent();
4184
4184
  _h.label = 3;
4185
- case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
4185
+ case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
4186
4186
  isSuccessful: false,
4187
4187
  errors: __spreadArray([
4188
- new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4188
+ new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
4189
4189
  ], __read(errors), false).map(serializeError),
4190
4190
  warnings: warnings.map(serializeError),
4191
4191
  executionReport: executionReport,
@@ -4249,7 +4249,7 @@ function executePipeline(options) {
4249
4249
  case 0:
4250
4250
  if (loopLimit-- < 0) {
4251
4251
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
4252
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
4252
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
4253
4253
  }
4254
4254
  currentTemplate = unresovedTemplates_1.find(function (template) {
4255
4255
  return template.dependentParameterNames.every(function (name) {
@@ -4259,14 +4259,14 @@ function executePipeline(options) {
4259
4259
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
4260
4260
  throw new UnexpectedError(
4261
4261
  // TODO: [๐ŸŽ] DRY
4262
- spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates_1
4262
+ spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates_1
4263
4263
  .map(function (_a) {
4264
4264
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
4265
4265
  return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
4266
4266
  .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
4267
4267
  .join(' and '));
4268
4268
  })
4269
- .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 "); }));
4269
+ .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 "); }));
4270
4270
  case 1:
4271
4271
  if (!!currentTemplate) return [3 /*break*/, 3];
4272
4272
  /* [๐Ÿคนโ€โ™‚๏ธ] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -4283,10 +4283,10 @@ function executePipeline(options) {
4283
4283
  llmTools: llmTools,
4284
4284
  onProgress: function (progress) {
4285
4285
  if (isReturned) {
4286
- throw new UnexpectedError(spaceTrim(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)
4286
+ throw new UnexpectedError(spaceTrim(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)
4287
4287
  .split('\n')
4288
4288
  .map(function (line) { return "> ".concat(line); })
4289
- .join('\n')), "\n "); }));
4289
+ .join('\n')), "\n "); }));
4290
4290
  }
4291
4291
  if (onProgress) {
4292
4292
  onProgress(progress);