@promptbook/markdown-utils 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 +49 -24
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +8 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/config.d.ts +1 -0
- package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +6 -1
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
- package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +6 -1
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +4 -0
- package/esm/typings/src/formfactors/index.d.ts +26 -1
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +2 -2
- package/esm/typings/src/pipeline/pipeline-interface/constants.d.ts +9 -0
- package/esm/typings/src/utils/expectation-counters/{config.d.ts β constants.d.ts} +3 -0
- package/package.json +1 -1
- package/umd/index.umd.js +49 -24
- package/umd/index.umd.js.map +1 -1
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.
|
|
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
|
*/
|
|
@@ -910,6 +910,7 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
|
910
910
|
// Note: In normal situations, we check the pipeline logic:
|
|
911
911
|
true);
|
|
912
912
|
/**
|
|
913
|
+
* TODO: Extract `constants.ts` from `config.ts`
|
|
913
914
|
* TODO: [π§ ][π§ββοΈ] Maybe join remoteUrl and path into single value
|
|
914
915
|
*/
|
|
915
916
|
|
|
@@ -1152,18 +1153,18 @@ function validatePipelineCore(pipeline) {
|
|
|
1152
1153
|
}
|
|
1153
1154
|
var _loop_1 = function (parameter) {
|
|
1154
1155
|
if (parameter.isInput && parameter.isOutput) {
|
|
1155
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1156
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n Parameter `{".concat(parameter.name, "}` can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1156
1157
|
}
|
|
1157
1158
|
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
1158
1159
|
if (!parameter.isInput &&
|
|
1159
1160
|
!parameter.isOutput &&
|
|
1160
1161
|
!pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
|
|
1161
|
-
throw new PipelineLogicError(spaceTrim$1(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 "); }));
|
|
1162
|
+
throw new PipelineLogicError(spaceTrim$1(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 "); }));
|
|
1162
1163
|
}
|
|
1163
1164
|
// Note: Testing that parameter is either input or result of some template
|
|
1164
1165
|
if (!parameter.isInput &&
|
|
1165
1166
|
!pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
|
|
1166
|
-
throw new PipelineLogicError(spaceTrim$1(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, "}
|
|
1167
|
+
throw new PipelineLogicError(spaceTrim$1(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 "); }));
|
|
1167
1168
|
}
|
|
1168
1169
|
};
|
|
1169
1170
|
try {
|
|
@@ -1191,7 +1192,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1191
1192
|
var _loop_2 = function (template) {
|
|
1192
1193
|
var e_4, _h, e_5, _j;
|
|
1193
1194
|
if (definedParameters.has(template.resultingParameterName)) {
|
|
1194
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1195
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1195
1196
|
}
|
|
1196
1197
|
if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
|
|
1197
1198
|
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
@@ -1204,7 +1205,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1204
1205
|
}
|
|
1205
1206
|
var _loop_4 = function (joker) {
|
|
1206
1207
|
if (!template.dependentParameterNames.includes(joker)) {
|
|
1207
|
-
throw new PipelineLogicError(spaceTrim$1(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 "); }));
|
|
1208
|
+
throw new PipelineLogicError(spaceTrim$1(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 "); }));
|
|
1208
1209
|
}
|
|
1209
1210
|
};
|
|
1210
1211
|
try {
|
|
@@ -1299,14 +1300,24 @@ function validatePipelineCore(pipeline) {
|
|
|
1299
1300
|
if (currentlyResovedTemplates.length === 0) {
|
|
1300
1301
|
throw new PipelineLogicError(
|
|
1301
1302
|
// TODO: [π] DRY
|
|
1302
|
-
spaceTrim$1(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
|
|
1303
|
+
spaceTrim$1(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
|
|
1303
1304
|
.map(function (_a) {
|
|
1304
1305
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1305
|
-
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
1306
|
-
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
1306
|
+
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
1307
|
+
.map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
|
|
1307
1308
|
.join(' and '));
|
|
1308
1309
|
})
|
|
1309
|
-
.join('\n')), "\n\n Resolved
|
|
1310
|
+
.join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
|
|
1311
|
+
.filter(function (name) {
|
|
1312
|
+
return !RESERVED_PARAMETER_NAMES.includes(name);
|
|
1313
|
+
})
|
|
1314
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1315
|
+
.join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
|
|
1316
|
+
.filter(function (name) {
|
|
1317
|
+
return RESERVED_PARAMETER_NAMES.includes(name);
|
|
1318
|
+
})
|
|
1319
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1320
|
+
.join('\n')), "\n\n\n "); }));
|
|
1310
1321
|
}
|
|
1311
1322
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
|
|
1312
1323
|
var resultingParameterName = _a.resultingParameterName;
|
|
@@ -1317,6 +1328,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1317
1328
|
while (unresovedTemplates.length > 0) {
|
|
1318
1329
|
_loop_3();
|
|
1319
1330
|
}
|
|
1331
|
+
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
1320
1332
|
}
|
|
1321
1333
|
/**
|
|
1322
1334
|
* TODO: !! [π§ββοΈ] Do not allow joker + foreach
|
|
@@ -2672,8 +2684,8 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
2672
2684
|
else if (errors.length > 1) {
|
|
2673
2685
|
throw new PipelineExecutionError(
|
|
2674
2686
|
// TODO: Tell which execution tools failed like
|
|
2675
|
-
// 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2676
|
-
// 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2687
|
+
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
2688
|
+
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
2677
2689
|
// 3) ...
|
|
2678
2690
|
spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
2679
2691
|
.map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
|
|
@@ -4194,11 +4206,11 @@ function replaceParameters(template, parameters) {
|
|
|
4194
4206
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
4195
4207
|
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
4196
4208
|
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
4197
|
-
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
4209
|
+
throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
|
|
4198
4210
|
}
|
|
4199
4211
|
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
4200
4212
|
// TODO: [π΅]
|
|
4201
|
-
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
4213
|
+
throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
|
|
4202
4214
|
}
|
|
4203
4215
|
}
|
|
4204
4216
|
}
|
|
@@ -4225,11 +4237,11 @@ function replaceParameters(template, parameters) {
|
|
|
4225
4237
|
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
4226
4238
|
}
|
|
4227
4239
|
if (parameters[parameterName] === undefined) {
|
|
4228
|
-
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
4240
|
+
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4229
4241
|
}
|
|
4230
4242
|
var parameterValue = parameters[parameterName];
|
|
4231
4243
|
if (parameterValue === undefined) {
|
|
4232
|
-
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
4244
|
+
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4233
4245
|
}
|
|
4234
4246
|
parameterValue = parameterValue.toString();
|
|
4235
4247
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
@@ -4285,6 +4297,9 @@ var CHARACTERS_PER_STANDARD_LINE = 63;
|
|
|
4285
4297
|
* @public exported from `@promptbook/utils`
|
|
4286
4298
|
*/
|
|
4287
4299
|
var LINES_PER_STANDARD_PAGE = 44;
|
|
4300
|
+
/**
|
|
4301
|
+
* TODO: [π§ ] Should be this `constants.ts` or `config.ts`?
|
|
4302
|
+
*/
|
|
4288
4303
|
|
|
4289
4304
|
/**
|
|
4290
4305
|
* Counts number of lines in the text
|
|
@@ -5016,7 +5031,7 @@ function executeTemplate(options) {
|
|
|
5016
5031
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
5017
5032
|
// Houston, we have a problem
|
|
5018
5033
|
// Note: Checking part is also done in `validatePipeline`, but itβs good to doublecheck
|
|
5019
|
-
throw new UnexpectedError(spaceTrim$1(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 "); }));
|
|
5034
|
+
throw new UnexpectedError(spaceTrim$1(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 "); }));
|
|
5020
5035
|
}
|
|
5021
5036
|
};
|
|
5022
5037
|
try {
|
|
@@ -5095,7 +5110,7 @@ function filterJustOutputParameters(options) {
|
|
|
5095
5110
|
var _loop_1 = function (parameter) {
|
|
5096
5111
|
if (parametersToPass[parameter.name] === undefined) {
|
|
5097
5112
|
// [4]
|
|
5098
|
-
$warnings.push(new PipelineExecutionError(spaceTrim$1(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 "); })));
|
|
5113
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$1(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 "); })));
|
|
5099
5114
|
return "continue";
|
|
5100
5115
|
}
|
|
5101
5116
|
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
@@ -5182,7 +5197,7 @@ function executePipeline(options) {
|
|
|
5182
5197
|
case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
5183
5198
|
isSuccessful: false,
|
|
5184
5199
|
errors: __spreadArray([
|
|
5185
|
-
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
|
|
5200
|
+
new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
|
|
5186
5201
|
], __read(errors), false).map(serializeError),
|
|
5187
5202
|
warnings: [],
|
|
5188
5203
|
executionReport: executionReport,
|
|
@@ -5230,7 +5245,7 @@ function executePipeline(options) {
|
|
|
5230
5245
|
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 "); }), {
|
|
5231
5246
|
isSuccessful: false,
|
|
5232
5247
|
errors: __spreadArray([
|
|
5233
|
-
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 "); }))
|
|
5248
|
+
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 "); }))
|
|
5234
5249
|
], __read(errors), false).map(serializeError),
|
|
5235
5250
|
warnings: warnings.map(serializeError),
|
|
5236
5251
|
executionReport: executionReport,
|
|
@@ -5304,14 +5319,24 @@ function executePipeline(options) {
|
|
|
5304
5319
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
5305
5320
|
throw new UnexpectedError(
|
|
5306
5321
|
// TODO: [π] DRY
|
|
5307
|
-
spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve
|
|
5322
|
+
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
|
|
5308
5323
|
.map(function (_a) {
|
|
5309
5324
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
5310
|
-
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
5311
|
-
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
5325
|
+
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
5326
|
+
.map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
|
|
5312
5327
|
.join(' and '));
|
|
5313
5328
|
})
|
|
5314
|
-
.join('\n')), "\n\n Resolved
|
|
5329
|
+
.join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
|
|
5330
|
+
.filter(function (name) {
|
|
5331
|
+
return !RESERVED_PARAMETER_NAMES.includes(name);
|
|
5332
|
+
})
|
|
5333
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
5334
|
+
.join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
|
|
5335
|
+
.filter(function (name) {
|
|
5336
|
+
return RESERVED_PARAMETER_NAMES.includes(name);
|
|
5337
|
+
})
|
|
5338
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
5339
|
+
.join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
|
|
5315
5340
|
case 1:
|
|
5316
5341
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
5317
5342
|
/* [π€ΉββοΈ] */ return [4 /*yield*/, Promise.race(resolving_1)];
|