@promptbook/legacy-documents 0.75.0-0 β†’ 0.75.0-1

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
@@ -23,7 +23,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
23
23
  *
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  */
@@ -462,6 +462,7 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
462
462
  // Note: In normal situations, we check the pipeline logic:
463
463
  true);
464
464
  /**
465
+ * TODO: Extract `constants.ts` from `config.ts`
465
466
  * TODO: [🧠][πŸ§œβ€β™‚οΈ] Maybe join remoteUrl and path into single value
466
467
  */
467
468
 
@@ -1704,18 +1705,18 @@ function validatePipelineCore(pipeline) {
1704
1705
  }
1705
1706
  var _loop_1 = function (parameter) {
1706
1707
  if (parameter.isInput && parameter.isOutput) {
1707
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
1708
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n\n Parameter `{".concat(parameter.name, "}` can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
1708
1709
  }
1709
1710
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
1710
1711
  if (!parameter.isInput &&
1711
1712
  !parameter.isOutput &&
1712
1713
  !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
1713
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
1714
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
1714
1715
  }
1715
1716
  // Note: Testing that parameter is either input or result of some template
1716
1717
  if (!parameter.isInput &&
1717
1718
  !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
1718
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of {").concat(parameter.name, "}\n 2) Add template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
1719
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add template that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1719
1720
  }
1720
1721
  };
1721
1722
  try {
@@ -1743,7 +1744,7 @@ function validatePipelineCore(pipeline) {
1743
1744
  var _loop_2 = function (template) {
1744
1745
  var e_4, _h, e_5, _j;
1745
1746
  if (definedParameters.has(template.resultingParameterName)) {
1746
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1747
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1747
1748
  }
1748
1749
  if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1749
1750
  throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -1756,7 +1757,7 @@ function validatePipelineCore(pipeline) {
1756
1757
  }
1757
1758
  var _loop_4 = function (joker) {
1758
1759
  if (!template.dependentParameterNames.includes(joker)) {
1759
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1760
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1760
1761
  }
1761
1762
  };
1762
1763
  try {
@@ -1851,14 +1852,24 @@ function validatePipelineCore(pipeline) {
1851
1852
  if (currentlyResovedTemplates.length === 0) {
1852
1853
  throw new PipelineLogicError(
1853
1854
  // TODO: [🐎] DRY
1854
- spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates
1855
+ spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates
1855
1856
  .map(function (_a) {
1856
1857
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
1857
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
1858
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1858
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
1859
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
1859
1860
  .join(' and '));
1860
1861
  })
1861
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n\n "); }));
1862
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
1863
+ .filter(function (name) {
1864
+ return !RESERVED_PARAMETER_NAMES.includes(name);
1865
+ })
1866
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1867
+ .join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
1868
+ .filter(function (name) {
1869
+ return RESERVED_PARAMETER_NAMES.includes(name);
1870
+ })
1871
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1872
+ .join('\n')), "\n\n\n "); }));
1862
1873
  }
1863
1874
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1864
1875
  var resultingParameterName = _a.resultingParameterName;
@@ -1869,6 +1880,7 @@ function validatePipelineCore(pipeline) {
1869
1880
  while (unresovedTemplates.length > 0) {
1870
1881
  _loop_3();
1871
1882
  }
1883
+ // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
1872
1884
  }
1873
1885
  /**
1874
1886
  * TODO: !! [πŸ§žβ€β™€οΈ] Do not allow joker + foreach
@@ -2806,8 +2818,8 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
2806
2818
  else if (errors.length > 1) {
2807
2819
  throw new PipelineExecutionError(
2808
2820
  // TODO: Tell which execution tools failed like
2809
- // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
2810
- // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
2821
+ // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2822
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2811
2823
  // 3) ...
2812
2824
  spaceTrim$1(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
2813
2825
  .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
@@ -4403,11 +4415,11 @@ function replaceParameters(template, parameters) {
4403
4415
  for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
4404
4416
  var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
4405
4417
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
4406
- throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
4418
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
4407
4419
  }
4408
4420
  else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
4409
4421
  // TODO: [🍡]
4410
- throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
4422
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
4411
4423
  }
4412
4424
  }
4413
4425
  }
@@ -4434,11 +4446,11 @@ function replaceParameters(template, parameters) {
4434
4446
  throw new PipelineExecutionError('Parameter is already opened or not closed');
4435
4447
  }
4436
4448
  if (parameters[parameterName] === undefined) {
4437
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
4449
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4438
4450
  }
4439
4451
  var parameterValue = parameters[parameterName];
4440
4452
  if (parameterValue === undefined) {
4441
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
4453
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4442
4454
  }
4443
4455
  parameterValue = parameterValue.toString();
4444
4456
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
@@ -4494,6 +4506,9 @@ var CHARACTERS_PER_STANDARD_LINE = 63;
4494
4506
  * @public exported from `@promptbook/utils`
4495
4507
  */
4496
4508
  var LINES_PER_STANDARD_PAGE = 44;
4509
+ /**
4510
+ * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
4511
+ */
4497
4512
 
4498
4513
  /**
4499
4514
  * Counts number of lines in the text
@@ -5225,7 +5240,7 @@ function executeTemplate(options) {
5225
5240
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
5226
5241
  // Houston, we have a problem
5227
5242
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
5228
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
5243
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
5229
5244
  }
5230
5245
  };
5231
5246
  try {
@@ -5304,7 +5319,7 @@ function filterJustOutputParameters(options) {
5304
5319
  var _loop_1 = function (parameter) {
5305
5320
  if (parametersToPass[parameter.name] === undefined) {
5306
5321
  // [4]
5307
- $warnings.push(new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
5322
+ $warnings.push(new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
5308
5323
  return "continue";
5309
5324
  }
5310
5325
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -5391,7 +5406,7 @@ function executePipeline(options) {
5391
5406
  case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
5392
5407
  isSuccessful: false,
5393
5408
  errors: __spreadArray([
5394
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
5409
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5395
5410
  ], __read(errors), false).map(serializeError),
5396
5411
  warnings: [],
5397
5412
  executionReport: executionReport,
@@ -5439,7 +5454,7 @@ function executePipeline(options) {
5439
5454
  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 "); }), {
5440
5455
  isSuccessful: false,
5441
5456
  errors: __spreadArray([
5442
- 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 "); }))
5457
+ 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 "); }))
5443
5458
  ], __read(errors), false).map(serializeError),
5444
5459
  warnings: warnings.map(serializeError),
5445
5460
  executionReport: executionReport,
@@ -5513,14 +5528,24 @@ function executePipeline(options) {
5513
5528
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
5514
5529
  throw new UnexpectedError(
5515
5530
  // TODO: [🐎] DRY
5516
- 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
5531
+ 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
5517
5532
  .map(function (_a) {
5518
5533
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
5519
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
5520
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
5534
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
5535
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
5521
5536
  .join(' and '));
5522
5537
  })
5523
- .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 "); }));
5538
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
5539
+ .filter(function (name) {
5540
+ return !RESERVED_PARAMETER_NAMES.includes(name);
5541
+ })
5542
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5543
+ .join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
5544
+ .filter(function (name) {
5545
+ return RESERVED_PARAMETER_NAMES.includes(name);
5546
+ })
5547
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5548
+ .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
5524
5549
  case 1:
5525
5550
  if (!!currentTemplate) return [3 /*break*/, 3];
5526
5551
  /* [πŸ€Ήβ€β™‚οΈ] */ return [4 /*yield*/, Promise.race(resolving_1)];