@promptbook/pdf 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
@@ -20,7 +20,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  *
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
23
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  */
@@ -724,6 +724,7 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
724
724
  // Note: In normal situations, we check the pipeline logic:
725
725
  true);
726
726
  /**
727
+ * TODO: Extract `constants.ts` from `config.ts`
727
728
  * TODO: [🧠][πŸ§œβ€β™‚οΈ] Maybe join remoteUrl and path into single value
728
729
  */
729
730
 
@@ -985,18 +986,18 @@ function validatePipelineCore(pipeline) {
985
986
  }
986
987
  var _loop_1 = function (parameter) {
987
988
  if (parameter.isInput && parameter.isOutput) {
988
- 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 "); }));
989
+ 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 "); }));
989
990
  }
990
991
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
991
992
  if (!parameter.isInput &&
992
993
  !parameter.isOutput &&
993
994
  !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
994
- 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 "); }));
995
+ 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 "); }));
995
996
  }
996
997
  // Note: Testing that parameter is either input or result of some template
997
998
  if (!parameter.isInput &&
998
999
  !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
999
- 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 "); }));
1000
+ 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 "); }));
1000
1001
  }
1001
1002
  };
1002
1003
  try {
@@ -1024,7 +1025,7 @@ function validatePipelineCore(pipeline) {
1024
1025
  var _loop_2 = function (template) {
1025
1026
  var e_4, _h, e_5, _j;
1026
1027
  if (definedParameters.has(template.resultingParameterName)) {
1027
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1028
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1028
1029
  }
1029
1030
  if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1030
1031
  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 "); }));
@@ -1037,7 +1038,7 @@ function validatePipelineCore(pipeline) {
1037
1038
  }
1038
1039
  var _loop_4 = function (joker) {
1039
1040
  if (!template.dependentParameterNames.includes(joker)) {
1040
- 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 "); }));
1041
+ 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 "); }));
1041
1042
  }
1042
1043
  };
1043
1044
  try {
@@ -1132,14 +1133,24 @@ function validatePipelineCore(pipeline) {
1132
1133
  if (currentlyResovedTemplates.length === 0) {
1133
1134
  throw new PipelineLogicError(
1134
1135
  // TODO: [🐎] DRY
1135
- 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
1136
+ 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
1136
1137
  .map(function (_a) {
1137
1138
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
1138
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
1139
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1139
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
1140
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
1140
1141
  .join(' and '));
1141
1142
  })
1142
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n\n "); }));
1143
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
1144
+ .filter(function (name) {
1145
+ return !RESERVED_PARAMETER_NAMES.includes(name);
1146
+ })
1147
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1148
+ .join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
1149
+ .filter(function (name) {
1150
+ return RESERVED_PARAMETER_NAMES.includes(name);
1151
+ })
1152
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1153
+ .join('\n')), "\n\n\n "); }));
1143
1154
  }
1144
1155
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1145
1156
  var resultingParameterName = _a.resultingParameterName;
@@ -1150,6 +1161,7 @@ function validatePipelineCore(pipeline) {
1150
1161
  while (unresovedTemplates.length > 0) {
1151
1162
  _loop_3();
1152
1163
  }
1164
+ // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
1153
1165
  }
1154
1166
  /**
1155
1167
  * TODO: !! [πŸ§žβ€β™€οΈ] Do not allow joker + foreach
@@ -2489,8 +2501,8 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
2489
2501
  else if (errors.length > 1) {
2490
2502
  throw new PipelineExecutionError(
2491
2503
  // TODO: Tell which execution tools failed like
2492
- // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
2493
- // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
2504
+ // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2505
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2494
2506
  // 3) ...
2495
2507
  spaceTrim$1(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
2496
2508
  .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
@@ -4148,11 +4160,11 @@ function replaceParameters(template, parameters) {
4148
4160
  for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
4149
4161
  var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
4150
4162
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
4151
- throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
4163
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
4152
4164
  }
4153
4165
  else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
4154
4166
  // TODO: [🍡]
4155
- throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
4167
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
4156
4168
  }
4157
4169
  }
4158
4170
  }
@@ -4179,11 +4191,11 @@ function replaceParameters(template, parameters) {
4179
4191
  throw new PipelineExecutionError('Parameter is already opened or not closed');
4180
4192
  }
4181
4193
  if (parameters[parameterName] === undefined) {
4182
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
4194
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4183
4195
  }
4184
4196
  var parameterValue = parameters[parameterName];
4185
4197
  if (parameterValue === undefined) {
4186
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
4198
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4187
4199
  }
4188
4200
  parameterValue = parameterValue.toString();
4189
4201
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
@@ -4239,6 +4251,9 @@ var CHARACTERS_PER_STANDARD_LINE = 63;
4239
4251
  * @public exported from `@promptbook/utils`
4240
4252
  */
4241
4253
  var LINES_PER_STANDARD_PAGE = 44;
4254
+ /**
4255
+ * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
4256
+ */
4242
4257
 
4243
4258
  /**
4244
4259
  * Counts number of lines in the text
@@ -4970,7 +4985,7 @@ function executeTemplate(options) {
4970
4985
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4971
4986
  // Houston, we have a problem
4972
4987
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
4973
- 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 "); }));
4988
+ 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 "); }));
4974
4989
  }
4975
4990
  };
4976
4991
  try {
@@ -5049,7 +5064,7 @@ function filterJustOutputParameters(options) {
5049
5064
  var _loop_1 = function (parameter) {
5050
5065
  if (parametersToPass[parameter.name] === undefined) {
5051
5066
  // [4]
5052
- $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 "); })));
5067
+ $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 "); })));
5053
5068
  return "continue";
5054
5069
  }
5055
5070
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -5136,7 +5151,7 @@ function executePipeline(options) {
5136
5151
  case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
5137
5152
  isSuccessful: false,
5138
5153
  errors: __spreadArray([
5139
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
5154
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5140
5155
  ], __read(errors), false).map(serializeError),
5141
5156
  warnings: [],
5142
5157
  executionReport: executionReport,
@@ -5184,7 +5199,7 @@ function executePipeline(options) {
5184
5199
  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 "); }), {
5185
5200
  isSuccessful: false,
5186
5201
  errors: __spreadArray([
5187
- 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 "); }))
5202
+ 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 "); }))
5188
5203
  ], __read(errors), false).map(serializeError),
5189
5204
  warnings: warnings.map(serializeError),
5190
5205
  executionReport: executionReport,
@@ -5258,14 +5273,24 @@ function executePipeline(options) {
5258
5273
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
5259
5274
  throw new UnexpectedError(
5260
5275
  // TODO: [🐎] DRY
5261
- 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
5276
+ 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
5262
5277
  .map(function (_a) {
5263
5278
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
5264
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
5265
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
5279
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
5280
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
5266
5281
  .join(' and '));
5267
5282
  })
5268
- .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 "); }));
5283
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
5284
+ .filter(function (name) {
5285
+ return !RESERVED_PARAMETER_NAMES.includes(name);
5286
+ })
5287
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5288
+ .join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
5289
+ .filter(function (name) {
5290
+ return RESERVED_PARAMETER_NAMES.includes(name);
5291
+ })
5292
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5293
+ .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
5269
5294
  case 1:
5270
5295
  if (!!currentTemplate) return [3 /*break*/, 3];
5271
5296
  /* [πŸ€Ήβ€β™‚οΈ] */ return [4 /*yield*/, Promise.race(resolving_1)];