@promptbook/node 0.77.1 → 0.78.2
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 +377 -334
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +10 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -8
- package/esm/typings/src/commands/_common/types/CommandType.d.ts +17 -0
- package/esm/typings/src/config.d.ts +14 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +1 -1
- package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/removePipelineCommand.d.ts +22 -0
- package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts} +3 -3
- package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +6 -0
- package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
- package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +238 -195
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/conversion/utils/{extractVariables.test.d.ts → extractVariablesFromScript.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{renameParameter.test.d.ts → removePipelineCommand.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{titleToName.test.d.ts → renamePipelineParameter.test.d.ts} +0 -0
- /package/esm/typings/src/{conversion/utils → utils/normalization}/titleToName.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
2
|
import { stat, access, constants, readFile, writeFile, readdir, mkdir, unlink } from 'fs/promises';
|
|
3
3
|
import { join, basename, dirname } from 'path';
|
|
4
|
-
import spaceTrim
|
|
4
|
+
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
5
5
|
import { format } from 'prettier';
|
|
6
6
|
import parserHtml from 'prettier/parser-html';
|
|
7
7
|
import { forTime } from 'waitasecond';
|
|
@@ -26,7 +26,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
*
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
29
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.78.1';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -172,198 +172,25 @@ function just(value) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
178
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
175
|
+
* Name for the Promptbook
|
|
179
176
|
*
|
|
180
|
-
*
|
|
181
|
-
* @public exported from `@promptbook/utils`
|
|
182
|
-
*/
|
|
183
|
-
function $deepFreeze(objectValue) {
|
|
184
|
-
var e_1, _a;
|
|
185
|
-
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
186
|
-
try {
|
|
187
|
-
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
188
|
-
var propertyName = propertyNames_1_1.value;
|
|
189
|
-
var value = objectValue[propertyName];
|
|
190
|
-
if (value && typeof value === 'object') {
|
|
191
|
-
$deepFreeze(value);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
196
|
-
finally {
|
|
197
|
-
try {
|
|
198
|
-
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
199
|
-
}
|
|
200
|
-
finally { if (e_1) throw e_1.error; }
|
|
201
|
-
}
|
|
202
|
-
return Object.freeze(objectValue);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
177
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
210
178
|
*
|
|
211
179
|
* @public exported from `@promptbook/core`
|
|
212
180
|
*/
|
|
213
|
-
var
|
|
214
|
-
__extends(UnexpectedError, _super);
|
|
215
|
-
function UnexpectedError(message) {
|
|
216
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
217
|
-
_this.name = 'UnexpectedError';
|
|
218
|
-
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
219
|
-
return _this;
|
|
220
|
-
}
|
|
221
|
-
return UnexpectedError;
|
|
222
|
-
}(Error));
|
|
223
|
-
|
|
181
|
+
var NAME = "Promptbook";
|
|
224
182
|
/**
|
|
225
|
-
*
|
|
226
|
-
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
183
|
+
* Email of the responsible person
|
|
227
184
|
*
|
|
228
|
-
*
|
|
229
|
-
* - `undefined` is not serializable
|
|
230
|
-
* - `NaN` is not serializable
|
|
231
|
-
* - Objects and arrays are serializable if all their properties are serializable
|
|
232
|
-
* - Functions are not serializable
|
|
233
|
-
* - Circular references are not serializable
|
|
234
|
-
* - `Date` objects are not serializable
|
|
235
|
-
* - `Map` and `Set` objects are not serializable
|
|
236
|
-
* - `RegExp` objects are not serializable
|
|
237
|
-
* - `Error` objects are not serializable
|
|
238
|
-
* - `Symbol` objects are not serializable
|
|
239
|
-
* - And much more...
|
|
240
|
-
*
|
|
241
|
-
* @throws UnexpectedError if the value is not serializable as JSON
|
|
242
|
-
* @public exported from `@promptbook/utils`
|
|
243
|
-
*/
|
|
244
|
-
function checkSerializableAsJson(name, value) {
|
|
245
|
-
var e_1, _a;
|
|
246
|
-
if (value === undefined) {
|
|
247
|
-
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
248
|
-
}
|
|
249
|
-
else if (value === null) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
else if (typeof value === 'boolean') {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
else if (typeof value === 'number' && !isNaN(value)) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
else if (typeof value === 'string') {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
else if (typeof value === 'symbol') {
|
|
262
|
-
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
263
|
-
}
|
|
264
|
-
else if (typeof value === 'function') {
|
|
265
|
-
throw new UnexpectedError("".concat(name, " is function"));
|
|
266
|
-
}
|
|
267
|
-
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
268
|
-
for (var i = 0; i < value.length; i++) {
|
|
269
|
-
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
else if (typeof value === 'object') {
|
|
273
|
-
if (value instanceof Date) {
|
|
274
|
-
throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
275
|
-
}
|
|
276
|
-
else if (value instanceof Map) {
|
|
277
|
-
throw new UnexpectedError("".concat(name, " is Map"));
|
|
278
|
-
}
|
|
279
|
-
else if (value instanceof Set) {
|
|
280
|
-
throw new UnexpectedError("".concat(name, " is Set"));
|
|
281
|
-
}
|
|
282
|
-
else if (value instanceof RegExp) {
|
|
283
|
-
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
284
|
-
}
|
|
285
|
-
else if (value instanceof Error) {
|
|
286
|
-
throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
try {
|
|
290
|
-
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
291
|
-
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
292
|
-
if (subValue === undefined) {
|
|
293
|
-
// Note: undefined in object is serializable - it is just omited
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
300
|
-
finally {
|
|
301
|
-
try {
|
|
302
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
303
|
-
}
|
|
304
|
-
finally { if (e_1) throw e_1.error; }
|
|
305
|
-
}
|
|
306
|
-
try {
|
|
307
|
-
JSON.stringify(value); // <- TODO: [0]
|
|
308
|
-
}
|
|
309
|
-
catch (error) {
|
|
310
|
-
if (!(error instanceof Error)) {
|
|
311
|
-
throw error;
|
|
312
|
-
}
|
|
313
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
314
|
-
}
|
|
315
|
-
/*
|
|
316
|
-
TODO: [0] Is there some more elegant way to check circular references?
|
|
317
|
-
const seen = new Set();
|
|
318
|
-
const stack = [{ value }];
|
|
319
|
-
while (stack.length > 0) {
|
|
320
|
-
const { value } = stack.pop()!;
|
|
321
|
-
if (typeof value === 'object' && value !== null) {
|
|
322
|
-
if (seen.has(value)) {
|
|
323
|
-
throw new UnexpectedError(`${name} has circular reference`);
|
|
324
|
-
}
|
|
325
|
-
seen.add(value);
|
|
326
|
-
if (Array.isArray(value)) {
|
|
327
|
-
stack.push(...value.map((value) => ({ value })));
|
|
328
|
-
} else {
|
|
329
|
-
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
*/
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
343
|
-
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
344
|
-
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
185
|
+
* @public exported from `@promptbook/core`
|
|
345
186
|
*/
|
|
346
|
-
|
|
187
|
+
var ADMIN_EMAIL = 'me@pavolhejny.com';
|
|
347
188
|
/**
|
|
348
|
-
*
|
|
349
|
-
* @@@
|
|
350
|
-
*
|
|
351
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
189
|
+
* Name of the responsible person for the Promptbook on GitHub
|
|
352
190
|
*
|
|
353
|
-
* @
|
|
354
|
-
* @param objectValue - Object to be deeply frozen
|
|
355
|
-
* @returns The same object as the input, but deeply frozen
|
|
356
|
-
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
357
|
-
*/
|
|
358
|
-
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
359
|
-
checkSerializableAsJson(name, objectValue);
|
|
360
|
-
return $deepFreeze(objectValue);
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
364
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
191
|
+
* @public exported from `@promptbook/core`
|
|
365
192
|
*/
|
|
366
|
-
|
|
193
|
+
var ADMIN_GITHUB_NAME = 'hejny';
|
|
367
194
|
/**
|
|
368
195
|
* When the title is not provided, the default title is used
|
|
369
196
|
*
|
|
@@ -433,7 +260,8 @@ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
|
433
260
|
*
|
|
434
261
|
* @public exported from `@promptbook/core`
|
|
435
262
|
*/
|
|
436
|
-
var RESERVED_PARAMETER_NAMES =
|
|
263
|
+
var RESERVED_PARAMETER_NAMES =
|
|
264
|
+
/* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
|
|
437
265
|
'content',
|
|
438
266
|
'context',
|
|
439
267
|
'knowledge',
|
|
@@ -443,7 +271,7 @@ var RESERVED_PARAMETER_NAMES = $asDeeplyFrozenSerializableJson('RESERVED_PARAMET
|
|
|
443
271
|
// <- TODO: list here all command names
|
|
444
272
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
445
273
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
446
|
-
]
|
|
274
|
+
];
|
|
447
275
|
/**
|
|
448
276
|
* @@@
|
|
449
277
|
*
|
|
@@ -707,7 +535,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
707
535
|
pipelineString += '\n\n';
|
|
708
536
|
pipelineString += '```' + contentLanguage;
|
|
709
537
|
pipelineString += '\n';
|
|
710
|
-
pipelineString += spaceTrim
|
|
538
|
+
pipelineString += spaceTrim(content);
|
|
711
539
|
// <- TODO: [main] !!! Escape
|
|
712
540
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
713
541
|
pipelineString += '\n';
|
|
@@ -752,7 +580,7 @@ function taskParameterJsonToString(taskParameterJson) {
|
|
|
752
580
|
var MissingToolsError = /** @class */ (function (_super) {
|
|
753
581
|
__extends(MissingToolsError, _super);
|
|
754
582
|
function MissingToolsError(message) {
|
|
755
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: You have probbably forgot to provide some tools for pipeline execution or preparation\n\n "); })) || this;
|
|
583
|
+
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: You have probbably forgot to provide some tools for pipeline execution or preparation\n\n "); })) || this;
|
|
756
584
|
_this.name = 'MissingToolsError';
|
|
757
585
|
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
758
586
|
return _this;
|
|
@@ -836,6 +664,40 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
836
664
|
});
|
|
837
665
|
}
|
|
838
666
|
|
|
667
|
+
/**
|
|
668
|
+
* @@@
|
|
669
|
+
*
|
|
670
|
+
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
671
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
672
|
+
*
|
|
673
|
+
* @returns The same object as the input, but deeply frozen
|
|
674
|
+
* @public exported from `@promptbook/utils`
|
|
675
|
+
*/
|
|
676
|
+
function $deepFreeze(objectValue) {
|
|
677
|
+
var e_1, _a;
|
|
678
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
679
|
+
try {
|
|
680
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
681
|
+
var propertyName = propertyNames_1_1.value;
|
|
682
|
+
var value = objectValue[propertyName];
|
|
683
|
+
if (value && typeof value === 'object') {
|
|
684
|
+
$deepFreeze(value);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
689
|
+
finally {
|
|
690
|
+
try {
|
|
691
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
692
|
+
}
|
|
693
|
+
finally { if (e_1) throw e_1.error; }
|
|
694
|
+
}
|
|
695
|
+
return Object.freeze(objectValue);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
699
|
+
*/
|
|
700
|
+
|
|
839
701
|
/**
|
|
840
702
|
* Represents the usage with no resources consumed
|
|
841
703
|
*
|
|
@@ -1090,6 +952,40 @@ var PipelineExecutionError = /** @class */ (function (_super) {
|
|
|
1090
952
|
return PipelineExecutionError;
|
|
1091
953
|
}(Error));
|
|
1092
954
|
|
|
955
|
+
/**
|
|
956
|
+
* Make error report URL for the given error
|
|
957
|
+
*
|
|
958
|
+
* @private !!!!!!
|
|
959
|
+
*/
|
|
960
|
+
function getErrorReportUrl(error) {
|
|
961
|
+
var report = {
|
|
962
|
+
title: "\uD83D\uDC1C Error report from ".concat(NAME),
|
|
963
|
+
body: spaceTrim(function (block) { return "\n\n\n `".concat(error.name || 'Error', "` has occurred in the [").concat(NAME, "], please look into it @").concat(ADMIN_GITHUB_NAME, ".\n\n ```\n ").concat(block(error.message || '(no error message)'), "\n ```\n\n\n ## More info:\n\n - **Promptbook engine version:** ").concat(PROMPTBOOK_ENGINE_VERSION, "\n - **Book language version:** ").concat(BOOK_LANGUAGE_VERSION, "\n - **Time:** ").concat(new Date().toISOString(), "\n\n <details>\n <summary>Stack trace:</summary>\n\n ## Stack trace:\n\n ```stacktrace\n ").concat(block(error.stack || '(empty)'), "\n ```\n </details>\n\n "); }),
|
|
964
|
+
};
|
|
965
|
+
var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
|
|
966
|
+
reportUrl.searchParams.set('labels', 'bug');
|
|
967
|
+
reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
|
|
968
|
+
reportUrl.searchParams.set('title', report.title);
|
|
969
|
+
reportUrl.searchParams.set('body', report.body);
|
|
970
|
+
return reportUrl;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
975
|
+
*
|
|
976
|
+
* @public exported from `@promptbook/core`
|
|
977
|
+
*/
|
|
978
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
979
|
+
__extends(UnexpectedError, _super);
|
|
980
|
+
function UnexpectedError(message) {
|
|
981
|
+
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n ").concat(block(getErrorReportUrl(new Error(message)).href), "\n\n Or contact us on ").concat(ADMIN_EMAIL, "\n\n "); })) || this;
|
|
982
|
+
_this.name = 'UnexpectedError';
|
|
983
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
984
|
+
return _this;
|
|
985
|
+
}
|
|
986
|
+
return UnexpectedError;
|
|
987
|
+
}(Error));
|
|
988
|
+
|
|
1093
989
|
/**
|
|
1094
990
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
1095
991
|
*
|
|
@@ -1309,7 +1205,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
1309
1205
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
1310
1206
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
1311
1207
|
// 3) ...
|
|
1312
|
-
spaceTrim
|
|
1208
|
+
spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
1313
1209
|
.map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
|
|
1314
1210
|
.join('\n')), "\n\n "); }));
|
|
1315
1211
|
}
|
|
@@ -1317,7 +1213,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
1317
1213
|
throw new PipelineExecutionError("You have not provided any `LlmExecutionTools`");
|
|
1318
1214
|
}
|
|
1319
1215
|
else {
|
|
1320
|
-
throw new PipelineExecutionError(spaceTrim
|
|
1216
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\"\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.description), "\n\n "); }));
|
|
1321
1217
|
}
|
|
1322
1218
|
}
|
|
1323
1219
|
});
|
|
@@ -1352,7 +1248,7 @@ function joinLlmExecutionTools() {
|
|
|
1352
1248
|
llmExecutionTools[_i] = arguments[_i];
|
|
1353
1249
|
}
|
|
1354
1250
|
if (llmExecutionTools.length === 0) {
|
|
1355
|
-
var warningMessage = spaceTrim
|
|
1251
|
+
var warningMessage = spaceTrim("\n You have not provided any `LlmExecutionTools`\n This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.\n\n Technically, it's not an error, but it's probably not what you want because it does not make sense to use Promptbook without language models.\n ");
|
|
1356
1252
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
1357
1253
|
console.warn(warningMessage);
|
|
1358
1254
|
/*
|
|
@@ -1600,7 +1496,7 @@ function validatePipeline(pipeline) {
|
|
|
1600
1496
|
if (!(error instanceof PipelineLogicError)) {
|
|
1601
1497
|
throw error;
|
|
1602
1498
|
}
|
|
1603
|
-
console.error(spaceTrim(function (block) { return "\n Pipeline is not valid but logic errors are temporarily disabled via `IS_PIPELINE_LOGIC_VALIDATED`\n\n ".concat(block(error.message), "\n "); }));
|
|
1499
|
+
console.error(spaceTrim$1(function (block) { return "\n Pipeline is not valid but logic errors are temporarily disabled via `IS_PIPELINE_LOGIC_VALIDATED`\n\n ".concat(block(error.message), "\n "); }));
|
|
1604
1500
|
}
|
|
1605
1501
|
}
|
|
1606
1502
|
return pipeline;
|
|
@@ -1624,35 +1520,35 @@ function validatePipelineCore(pipeline) {
|
|
|
1624
1520
|
})();
|
|
1625
1521
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
1626
1522
|
// <- Note: [🚲]
|
|
1627
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1523
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1628
1524
|
}
|
|
1629
1525
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
1630
1526
|
// <- Note: [🚲]
|
|
1631
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1527
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1632
1528
|
}
|
|
1633
1529
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
1634
1530
|
if (!Array.isArray(pipeline.parameters)) {
|
|
1635
1531
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
1636
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.parameters` expected to be an array, but got ".concat(typeof pipeline.parameters, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1532
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.parameters` expected to be an array, but got ".concat(typeof pipeline.parameters, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1637
1533
|
}
|
|
1638
1534
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
1639
1535
|
if (!Array.isArray(pipeline.tasks)) {
|
|
1640
1536
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
1641
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.tasks` expected to be an array, but got ".concat(typeof pipeline.tasks, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1537
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.tasks` expected to be an array, but got ".concat(typeof pipeline.tasks, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1642
1538
|
}
|
|
1643
1539
|
var _loop_1 = function (parameter) {
|
|
1644
1540
|
if (parameter.isInput && parameter.isOutput) {
|
|
1645
|
-
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 "); }));
|
|
1541
|
+
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 "); }));
|
|
1646
1542
|
}
|
|
1647
1543
|
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
1648
1544
|
if (!parameter.isInput &&
|
|
1649
1545
|
!parameter.isOutput &&
|
|
1650
1546
|
!pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
|
|
1651
|
-
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 "); }));
|
|
1547
|
+
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 "); }));
|
|
1652
1548
|
}
|
|
1653
1549
|
// Note: Testing that parameter is either input or result of some task
|
|
1654
1550
|
if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
|
|
1655
|
-
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 task that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1551
|
+
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 task that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1656
1552
|
}
|
|
1657
1553
|
};
|
|
1658
1554
|
try {
|
|
@@ -1680,20 +1576,20 @@ function validatePipelineCore(pipeline) {
|
|
|
1680
1576
|
var _loop_2 = function (task) {
|
|
1681
1577
|
var e_4, _h, e_5, _j;
|
|
1682
1578
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
1683
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1579
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1684
1580
|
}
|
|
1685
1581
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
1686
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter name {".concat(task.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1582
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(task.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1687
1583
|
}
|
|
1688
1584
|
definedParameters.add(task.resultingParameterName);
|
|
1689
1585
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
1690
1586
|
if (!task.format &&
|
|
1691
1587
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
1692
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Joker parameters are used for {".concat(task.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1588
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Joker parameters are used for {".concat(task.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1693
1589
|
}
|
|
1694
1590
|
var _loop_4 = function (joker) {
|
|
1695
1591
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
1696
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(task.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1592
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(task.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1697
1593
|
}
|
|
1698
1594
|
};
|
|
1699
1595
|
try {
|
|
@@ -1713,13 +1609,13 @@ function validatePipelineCore(pipeline) {
|
|
|
1713
1609
|
if (task.expectations) {
|
|
1714
1610
|
var _loop_5 = function (unit, min, max) {
|
|
1715
1611
|
if (min !== undefined && max !== undefined && min > max) {
|
|
1716
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1612
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1717
1613
|
}
|
|
1718
1614
|
if (min !== undefined && min < 0) {
|
|
1719
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Min expectation of ".concat(unit, " must be zero or positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1615
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation of ".concat(unit, " must be zero or positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1720
1616
|
}
|
|
1721
1617
|
if (max !== undefined && max <= 0) {
|
|
1722
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Max expectation of ".concat(unit, " must be positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1618
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Max expectation of ".concat(unit, " must be positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1723
1619
|
}
|
|
1724
1620
|
};
|
|
1725
1621
|
try {
|
|
@@ -1780,7 +1676,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1780
1676
|
var _loop_3 = function () {
|
|
1781
1677
|
if (loopLimit-- < 0) {
|
|
1782
1678
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1783
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
1679
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
1784
1680
|
}
|
|
1785
1681
|
var currentlyResovedTasks = unresovedTasks.filter(function (task) {
|
|
1786
1682
|
return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -1788,7 +1684,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1788
1684
|
if (currentlyResovedTasks.length === 0) {
|
|
1789
1685
|
throw new PipelineLogicError(
|
|
1790
1686
|
// TODO: [🐎] DRY
|
|
1791
|
-
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(unresovedTasks
|
|
1687
|
+
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(unresovedTasks
|
|
1792
1688
|
.map(function (_a) {
|
|
1793
1689
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1794
1690
|
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
@@ -1899,6 +1795,149 @@ function extractParameterNames(template) {
|
|
|
1899
1795
|
return parameterNames;
|
|
1900
1796
|
}
|
|
1901
1797
|
|
|
1798
|
+
/**
|
|
1799
|
+
* Checks if the value is [🚉] serializable as JSON
|
|
1800
|
+
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
1801
|
+
*
|
|
1802
|
+
* - Almost all primitives are serializable BUT:
|
|
1803
|
+
* - `undefined` is not serializable
|
|
1804
|
+
* - `NaN` is not serializable
|
|
1805
|
+
* - Objects and arrays are serializable if all their properties are serializable
|
|
1806
|
+
* - Functions are not serializable
|
|
1807
|
+
* - Circular references are not serializable
|
|
1808
|
+
* - `Date` objects are not serializable
|
|
1809
|
+
* - `Map` and `Set` objects are not serializable
|
|
1810
|
+
* - `RegExp` objects are not serializable
|
|
1811
|
+
* - `Error` objects are not serializable
|
|
1812
|
+
* - `Symbol` objects are not serializable
|
|
1813
|
+
* - And much more...
|
|
1814
|
+
*
|
|
1815
|
+
* @throws UnexpectedError if the value is not serializable as JSON
|
|
1816
|
+
* @public exported from `@promptbook/utils`
|
|
1817
|
+
*/
|
|
1818
|
+
function checkSerializableAsJson(name, value) {
|
|
1819
|
+
var e_1, _a;
|
|
1820
|
+
if (value === undefined) {
|
|
1821
|
+
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
1822
|
+
}
|
|
1823
|
+
else if (value === null) {
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
else if (typeof value === 'boolean') {
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
else if (typeof value === 'number' && !isNaN(value)) {
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1832
|
+
else if (typeof value === 'string') {
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
else if (typeof value === 'symbol') {
|
|
1836
|
+
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
1837
|
+
}
|
|
1838
|
+
else if (typeof value === 'function') {
|
|
1839
|
+
throw new UnexpectedError("".concat(name, " is function"));
|
|
1840
|
+
}
|
|
1841
|
+
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
1842
|
+
for (var i = 0; i < value.length; i++) {
|
|
1843
|
+
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
else if (typeof value === 'object') {
|
|
1847
|
+
if (value instanceof Date) {
|
|
1848
|
+
throw new UnexpectedError(spaceTrim("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
1849
|
+
}
|
|
1850
|
+
else if (value instanceof Map) {
|
|
1851
|
+
throw new UnexpectedError("".concat(name, " is Map"));
|
|
1852
|
+
}
|
|
1853
|
+
else if (value instanceof Set) {
|
|
1854
|
+
throw new UnexpectedError("".concat(name, " is Set"));
|
|
1855
|
+
}
|
|
1856
|
+
else if (value instanceof RegExp) {
|
|
1857
|
+
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
1858
|
+
}
|
|
1859
|
+
else if (value instanceof Error) {
|
|
1860
|
+
throw new UnexpectedError(spaceTrim("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
1861
|
+
}
|
|
1862
|
+
else {
|
|
1863
|
+
try {
|
|
1864
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1865
|
+
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
1866
|
+
if (subValue === undefined) {
|
|
1867
|
+
// Note: undefined in object is serializable - it is just omited
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1874
|
+
finally {
|
|
1875
|
+
try {
|
|
1876
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1877
|
+
}
|
|
1878
|
+
finally { if (e_1) throw e_1.error; }
|
|
1879
|
+
}
|
|
1880
|
+
try {
|
|
1881
|
+
JSON.stringify(value); // <- TODO: [0]
|
|
1882
|
+
}
|
|
1883
|
+
catch (error) {
|
|
1884
|
+
if (!(error instanceof Error)) {
|
|
1885
|
+
throw error;
|
|
1886
|
+
}
|
|
1887
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
1888
|
+
}
|
|
1889
|
+
/*
|
|
1890
|
+
TODO: [0] Is there some more elegant way to check circular references?
|
|
1891
|
+
const seen = new Set();
|
|
1892
|
+
const stack = [{ value }];
|
|
1893
|
+
while (stack.length > 0) {
|
|
1894
|
+
const { value } = stack.pop()!;
|
|
1895
|
+
if (typeof value === 'object' && value !== null) {
|
|
1896
|
+
if (seen.has(value)) {
|
|
1897
|
+
throw new UnexpectedError(`${name} has circular reference`);
|
|
1898
|
+
}
|
|
1899
|
+
seen.add(value);
|
|
1900
|
+
if (Array.isArray(value)) {
|
|
1901
|
+
stack.push(...value.map((value) => ({ value })));
|
|
1902
|
+
} else {
|
|
1903
|
+
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
*/
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
else {
|
|
1912
|
+
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1917
|
+
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
1918
|
+
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
1919
|
+
*/
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* @@@
|
|
1923
|
+
* @@@
|
|
1924
|
+
*
|
|
1925
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1926
|
+
*
|
|
1927
|
+
* @param name - Name of the object for debugging purposes
|
|
1928
|
+
* @param objectValue - Object to be deeply frozen
|
|
1929
|
+
* @returns The same object as the input, but deeply frozen
|
|
1930
|
+
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
1931
|
+
*/
|
|
1932
|
+
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
1933
|
+
checkSerializableAsJson(name, objectValue);
|
|
1934
|
+
return $deepFreeze(objectValue);
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1938
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1939
|
+
*/
|
|
1940
|
+
|
|
1902
1941
|
/**
|
|
1903
1942
|
* Unprepare just strips the preparation data of the pipeline
|
|
1904
1943
|
*
|
|
@@ -1952,7 +1991,7 @@ var SimplePipelineCollection = /** @class */ (function () {
|
|
|
1952
1991
|
var pipeline = pipelines_1_1.value;
|
|
1953
1992
|
// TODO: [👠] DRY
|
|
1954
1993
|
if (pipeline.pipelineUrl === undefined) {
|
|
1955
|
-
throw new PipelineUrlError(spaceTrim("\n Pipeline with name \"".concat(pipeline.title, "\" does not have defined URL\n\n File:\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines without URLs are called anonymous pipelines\n They can be used as standalone pipelines, but they cannot be referenced by other pipelines\n And also they cannot be used in the pipeline collection\n\n ")));
|
|
1994
|
+
throw new PipelineUrlError(spaceTrim$1("\n Pipeline with name \"".concat(pipeline.title, "\" does not have defined URL\n\n File:\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines without URLs are called anonymous pipelines\n They can be used as standalone pipelines, but they cannot be referenced by other pipelines\n And also they cannot be used in the pipeline collection\n\n ")));
|
|
1956
1995
|
}
|
|
1957
1996
|
// Note: [🐨]
|
|
1958
1997
|
validatePipeline(pipeline);
|
|
@@ -1964,7 +2003,7 @@ var SimplePipelineCollection = /** @class */ (function () {
|
|
|
1964
2003
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
1965
2004
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
1966
2005
|
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
1967
|
-
throw new PipelineUrlError(spaceTrim("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection \uD83C\uDF4E\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
2006
|
+
throw new PipelineUrlError(spaceTrim$1("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection \uD83C\uDF4E\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
1968
2007
|
}
|
|
1969
2008
|
// Note: [🧠] Overwrite existing pipeline with the same URL
|
|
1970
2009
|
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
@@ -1994,9 +2033,9 @@ var SimplePipelineCollection = /** @class */ (function () {
|
|
|
1994
2033
|
var pipeline = this.collection.get(url);
|
|
1995
2034
|
if (!pipeline) {
|
|
1996
2035
|
if (this.listPipelines().length === 0) {
|
|
1997
|
-
throw new NotFoundError(spaceTrim("\n Pipeline with url \"".concat(url, "\" not found\n\n No pipelines available\n ")));
|
|
2036
|
+
throw new NotFoundError(spaceTrim$1("\n Pipeline with url \"".concat(url, "\" not found\n\n No pipelines available\n ")));
|
|
1998
2037
|
}
|
|
1999
|
-
throw new NotFoundError(spaceTrim(function (block) { return "\n Pipeline with url \"".concat(url, "\" not found\n\n Available pipelines:\n ").concat(block(_this.listPipelines()
|
|
2038
|
+
throw new NotFoundError(spaceTrim$1(function (block) { return "\n Pipeline with url \"".concat(url, "\" not found\n\n Available pipelines:\n ").concat(block(_this.listPipelines()
|
|
2000
2039
|
.map(function (pipelineUrl) { return "- ".concat(pipelineUrl); })
|
|
2001
2040
|
.join('\n')), "\n\n "); }));
|
|
2002
2041
|
}
|
|
@@ -2156,7 +2195,7 @@ var LimitReachedError = /** @class */ (function (_super) {
|
|
|
2156
2195
|
var NotYetImplementedError = /** @class */ (function (_super) {
|
|
2157
2196
|
__extends(NotYetImplementedError, _super);
|
|
2158
2197
|
function NotYetImplementedError(message) {
|
|
2159
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
2198
|
+
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
2160
2199
|
_this.name = 'NotYetImplementedError';
|
|
2161
2200
|
Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
|
|
2162
2201
|
return _this;
|
|
@@ -2252,10 +2291,10 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
2252
2291
|
throw deserializeError(errors[0]);
|
|
2253
2292
|
}
|
|
2254
2293
|
else {
|
|
2255
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Multiple errors occurred during Promptbook execution\n\n ".concat(block(errors
|
|
2294
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Multiple errors occurred during Promptbook execution\n\n ".concat(block(errors
|
|
2256
2295
|
.map(function (_a, index) {
|
|
2257
2296
|
var name = _a.name, stack = _a.stack, message = _a.message;
|
|
2258
|
-
return spaceTrim(function (block) { return "\n ".concat(name, " ").concat(index + 1, ":\n ").concat(block(stack || message), "\n "); });
|
|
2297
|
+
return spaceTrim$1(function (block) { return "\n ".concat(name, " ").concat(index + 1, ":\n ").concat(block(stack || message), "\n "); });
|
|
2259
2298
|
})
|
|
2260
2299
|
.join('\n')), "\n "); }));
|
|
2261
2300
|
}
|
|
@@ -2305,7 +2344,7 @@ function isPipelinePrepared(pipeline) {
|
|
|
2305
2344
|
function serializeError(error) {
|
|
2306
2345
|
var name = error.name, message = error.message, stack = error.stack;
|
|
2307
2346
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2308
|
-
console.error(spaceTrim
|
|
2347
|
+
console.error(spaceTrim(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2309
2348
|
}
|
|
2310
2349
|
return {
|
|
2311
2350
|
name: name,
|
|
@@ -2320,10 +2359,11 @@ function serializeError(error) {
|
|
|
2320
2359
|
* @param script from which to extract the variables
|
|
2321
2360
|
* @returns the list of variable names
|
|
2322
2361
|
* @throws {ParseError} if the script is invalid
|
|
2323
|
-
* @public exported from `@promptbook/utils`
|
|
2362
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
2324
2363
|
*/
|
|
2325
|
-
function
|
|
2364
|
+
function extractVariablesFromScript(script) {
|
|
2326
2365
|
var variables = new Set();
|
|
2366
|
+
var originalScript = script;
|
|
2327
2367
|
script = "(()=>{".concat(script, "})()");
|
|
2328
2368
|
try {
|
|
2329
2369
|
for (var i = 0; i < 100 /* <- TODO: This limit to configuration */; i++)
|
|
@@ -2355,7 +2395,9 @@ function extractVariables(script) {
|
|
|
2355
2395
|
if (!(error instanceof Error)) {
|
|
2356
2396
|
throw error;
|
|
2357
2397
|
}
|
|
2358
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n
|
|
2398
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n\n\n Found variables:\n\n ").concat(Array.from(variables)
|
|
2399
|
+
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
2400
|
+
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
2359
2401
|
}
|
|
2360
2402
|
return variables;
|
|
2361
2403
|
}
|
|
@@ -2369,7 +2411,7 @@ function extractVariables(script) {
|
|
|
2369
2411
|
* @param task the task with used parameters
|
|
2370
2412
|
* @returns the set of parameter names
|
|
2371
2413
|
* @throws {ParseError} if the script is invalid
|
|
2372
|
-
* @public exported from `@promptbook/
|
|
2414
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
2373
2415
|
*/
|
|
2374
2416
|
function extractParameterNamesFromTask(task) {
|
|
2375
2417
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
@@ -2390,7 +2432,7 @@ function extractParameterNamesFromTask(task) {
|
|
|
2390
2432
|
}
|
|
2391
2433
|
if (taskType === 'SCRIPT_TASK') {
|
|
2392
2434
|
try {
|
|
2393
|
-
for (var _g = __values(
|
|
2435
|
+
for (var _g = __values(extractVariablesFromScript(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2394
2436
|
var parameterName = _h.value;
|
|
2395
2437
|
parameterNames.add(parameterName);
|
|
2396
2438
|
}
|
|
@@ -2559,7 +2601,7 @@ var CsvFormatDefinition = {
|
|
|
2559
2601
|
case 0:
|
|
2560
2602
|
csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2561
2603
|
if (csv.errors.length !== 0) {
|
|
2562
|
-
throw new CsvFormatError(spaceTrim
|
|
2604
|
+
throw new CsvFormatError(spaceTrim(function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV setings:\n ").concat(block(JSON.stringify(__assign(__assign({}, settings), MANDATORY_CSV_SETTINGS), null, 2)), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
|
|
2563
2605
|
}
|
|
2564
2606
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
2565
2607
|
var _a, _b;
|
|
@@ -2597,7 +2639,7 @@ var CsvFormatDefinition = {
|
|
|
2597
2639
|
case 0:
|
|
2598
2640
|
csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2599
2641
|
if (csv.errors.length !== 0) {
|
|
2600
|
-
throw new CsvFormatError(spaceTrim
|
|
2642
|
+
throw new CsvFormatError(spaceTrim(function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV setings:\n ").concat(block(JSON.stringify(__assign(__assign({}, settings), MANDATORY_CSV_SETTINGS), null, 2)), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
|
|
2601
2643
|
}
|
|
2602
2644
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
|
|
2603
2645
|
var _this = this;
|
|
@@ -2838,7 +2880,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
2838
2880
|
}
|
|
2839
2881
|
// Phase 2️⃣: Non-matching mapping
|
|
2840
2882
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
2841
|
-
throw new PipelineExecutionError(spaceTrim
|
|
2883
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Can not map available parameters to expected parameters\n\n Mapped parameters:\n ".concat(block(Object.keys(mappedParameters)
|
|
2842
2884
|
.map(function (parameterName) { return "- {".concat(parameterName, "}"); })
|
|
2843
2885
|
.join('\n')), "\n\n Expected parameters which can not be mapped:\n ").concat(block(Array.from(expectedParameterNames)
|
|
2844
2886
|
.map(function (parameterName) { return "- {".concat(parameterName, "}"); })
|
|
@@ -3512,14 +3554,14 @@ function executeAttempts(options) {
|
|
|
3512
3554
|
jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
|
|
3513
3555
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
3514
3556
|
if (isJokerAttempt && !jokerParameterName) {
|
|
3515
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3557
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3516
3558
|
}
|
|
3517
3559
|
$ongoingTaskResult.$result = null;
|
|
3518
3560
|
$ongoingTaskResult.$resultString = null;
|
|
3519
3561
|
$ongoingTaskResult.$expectError = null;
|
|
3520
3562
|
if (isJokerAttempt) {
|
|
3521
3563
|
if (parameters[jokerParameterName] === undefined) {
|
|
3522
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3564
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3523
3565
|
// <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
|
|
3524
3566
|
}
|
|
3525
3567
|
else {
|
|
@@ -3588,15 +3630,15 @@ function executeAttempts(options) {
|
|
|
3588
3630
|
$ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
|
|
3589
3631
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
3590
3632
|
return [3 /*break*/, 10];
|
|
3591
|
-
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 "); }));
|
|
3592
|
-
case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(task.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
3633
|
+
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 "); }));
|
|
3634
|
+
case 9: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(task.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
3593
3635
|
case 10: return [3 /*break*/, 25];
|
|
3594
3636
|
case 11:
|
|
3595
3637
|
if (arrayableToArray(tools.script).length === 0) {
|
|
3596
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3638
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3597
3639
|
}
|
|
3598
3640
|
if (!task.contentLanguage) {
|
|
3599
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TASK \"".concat(task.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3641
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT TASK \"".concat(task.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3600
3642
|
}
|
|
3601
3643
|
_t.label = 12;
|
|
3602
3644
|
case 12:
|
|
@@ -3650,13 +3692,13 @@ function executeAttempts(options) {
|
|
|
3650
3692
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
3651
3693
|
}
|
|
3652
3694
|
else {
|
|
3653
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTaskResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTaskResult.$scriptPipelineExecutionErrors
|
|
3695
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat($ongoingTaskResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTaskResult.$scriptPipelineExecutionErrors
|
|
3654
3696
|
.map(function (error) { return '- ' + error.message; })
|
|
3655
3697
|
.join('\n\n')), "\n "); }));
|
|
3656
3698
|
}
|
|
3657
3699
|
case 22:
|
|
3658
3700
|
if (tools.userInterface === undefined) {
|
|
3659
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3701
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3660
3702
|
}
|
|
3661
3703
|
// TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
|
|
3662
3704
|
_j = $ongoingTaskResult;
|
|
@@ -3672,7 +3714,7 @@ function executeAttempts(options) {
|
|
|
3672
3714
|
// TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
|
|
3673
3715
|
_j.$resultString = _t.sent();
|
|
3674
3716
|
return [3 /*break*/, 25];
|
|
3675
|
-
case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3717
|
+
case 24: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3676
3718
|
case 25:
|
|
3677
3719
|
if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
|
|
3678
3720
|
_t.label = 26;
|
|
@@ -3762,13 +3804,13 @@ function executeAttempts(options) {
|
|
|
3762
3804
|
$ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
|
|
3763
3805
|
}
|
|
3764
3806
|
catch (error) {
|
|
3765
|
-
throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
|
|
3807
|
+
throw new ExpectError(spaceTrim$1(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
|
|
3766
3808
|
/*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
|
|
3767
3809
|
}
|
|
3768
3810
|
}
|
|
3769
3811
|
}
|
|
3770
3812
|
else {
|
|
3771
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3813
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3772
3814
|
}
|
|
3773
3815
|
}
|
|
3774
3816
|
// TODO: [💝] Unite object for expecting amount and format
|
|
@@ -3802,7 +3844,7 @@ function executeAttempts(options) {
|
|
|
3802
3844
|
return [7 /*endfinally*/];
|
|
3803
3845
|
case 45:
|
|
3804
3846
|
if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
3805
|
-
throw new PipelineExecutionError(spaceTrim(function (block) {
|
|
3847
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) {
|
|
3806
3848
|
var _a, _b, _c;
|
|
3807
3849
|
return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
|
|
3808
3850
|
.split('\n')
|
|
@@ -3838,7 +3880,7 @@ function executeAttempts(options) {
|
|
|
3838
3880
|
return [3 /*break*/, 1];
|
|
3839
3881
|
case 4:
|
|
3840
3882
|
if ($ongoingTaskResult.$resultString === null) {
|
|
3841
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3883
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3842
3884
|
}
|
|
3843
3885
|
return [2 /*return*/, $ongoingTaskResult.$resultString];
|
|
3844
3886
|
}
|
|
@@ -3866,7 +3908,7 @@ function executeFormatSubvalues(options) {
|
|
|
3866
3908
|
return [2 /*return*/, /* not await */ executeAttempts(options)];
|
|
3867
3909
|
}
|
|
3868
3910
|
if (jokerParameterNames.length !== 0) {
|
|
3869
|
-
throw new UnexpectedError(spaceTrim
|
|
3911
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n JOKER parameters are not supported together with FOREACH command\n\n [\uD83E\uDDDE\u200D\u2640\uFE0F] This should be prevented in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3870
3912
|
}
|
|
3871
3913
|
parameterValue = parameters[task.foreach.parameterName] || '';
|
|
3872
3914
|
formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
|
|
@@ -3875,7 +3917,7 @@ function executeFormatSubvalues(options) {
|
|
|
3875
3917
|
if (formatDefinition === undefined) {
|
|
3876
3918
|
throw new UnexpectedError(
|
|
3877
3919
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
3878
|
-
spaceTrim
|
|
3920
|
+
spaceTrim(function (block) { return "\n Unsupported format \"".concat(task.foreach.formatName, "\"\n\n Available formats:\n ").concat(block(FORMAT_DEFINITIONS.map(function (formatDefinition) { return formatDefinition.formatName; })
|
|
3879
3921
|
.map(function (formatName) { return "- ".concat(formatName); })
|
|
3880
3922
|
.join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3881
3923
|
}
|
|
@@ -3885,7 +3927,7 @@ function executeFormatSubvalues(options) {
|
|
|
3885
3927
|
if (subvalueDefinition === undefined) {
|
|
3886
3928
|
throw new UnexpectedError(
|
|
3887
3929
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
3888
|
-
spaceTrim
|
|
3930
|
+
spaceTrim(function (block) { return "\n Unsupported subformat name \"".concat(task.foreach.subformatName, "\" for format \"").concat(task.foreach.formatName, "\"\n\n Available subformat names for format \"").concat(formatDefinition.formatName, "\":\n ").concat(block(formatDefinition.subvalueDefinitions
|
|
3889
3931
|
.map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
|
|
3890
3932
|
.map(function (subvalueName) { return "- ".concat(subvalueName); })
|
|
3891
3933
|
.join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
@@ -3911,12 +3953,12 @@ function executeFormatSubvalues(options) {
|
|
|
3911
3953
|
if (!(error instanceof PipelineExecutionError)) {
|
|
3912
3954
|
throw error;
|
|
3913
3955
|
}
|
|
3914
|
-
throw new PipelineExecutionError(spaceTrim
|
|
3956
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n ".concat(error.message, "\n\n This is error in FOREACH command\n You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command\n\n ").concat(block(pipelineIdentification), "\n Subparameter index: ").concat(index, "\n "); }));
|
|
3915
3957
|
}
|
|
3916
3958
|
allSubparameters = __assign(__assign({}, parameters), mappedParameters);
|
|
3917
3959
|
// Note: [👨👨👧] Now we can freeze `subparameters` because we are sure that all and only used parameters are defined and are not going to be changed
|
|
3918
3960
|
Object.freeze(allSubparameters);
|
|
3919
|
-
return [4 /*yield*/, executeAttempts(__assign(__assign({}, options), { priority: priority + index, parameters: allSubparameters, pipelineIdentification: spaceTrim
|
|
3961
|
+
return [4 /*yield*/, executeAttempts(__assign(__assign({}, options), { priority: priority + index, parameters: allSubparameters, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Subparameter index: ").concat(index, "\n "); }) }))];
|
|
3920
3962
|
case 1:
|
|
3921
3963
|
subresultString = _a.sent();
|
|
3922
3964
|
return [2 /*return*/, subresultString];
|
|
@@ -4009,7 +4051,7 @@ function getReservedParametersForTask(options) {
|
|
|
4009
4051
|
};
|
|
4010
4052
|
_loop_1 = function (parameterName) {
|
|
4011
4053
|
if (reservedParameters[parameterName] === undefined) {
|
|
4012
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Reserved parameter {".concat(parameterName, "} is not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4054
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Reserved parameter {".concat(parameterName, "} is not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4013
4055
|
}
|
|
4014
4056
|
};
|
|
4015
4057
|
try {
|
|
@@ -4064,7 +4106,7 @@ function executeTask(options) {
|
|
|
4064
4106
|
dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
4065
4107
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
4066
4108
|
if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
|
|
4067
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Dependent parameters are not consistent with used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames)
|
|
4109
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Dependent parameters are not consistent with used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames)
|
|
4068
4110
|
.map(function (name) { return "{".concat(name, "}"); })
|
|
4069
4111
|
.join(', '), "\n\n Used parameters:\n ").concat(Array.from(usedParameterNames)
|
|
4070
4112
|
.map(function (name) { return "{".concat(name, "}"); })
|
|
@@ -4092,7 +4134,7 @@ function executeTask(options) {
|
|
|
4092
4134
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
4093
4135
|
// Houston, we have a problem
|
|
4094
4136
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
4095
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in task \"").concat(currentTask.title || currentTask.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
4137
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in task \"").concat(currentTask.title || currentTask.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
4096
4138
|
}
|
|
4097
4139
|
};
|
|
4098
4140
|
try {
|
|
@@ -4178,7 +4220,7 @@ function filterJustOutputParameters(options) {
|
|
|
4178
4220
|
var _loop_1 = function (parameter) {
|
|
4179
4221
|
if (parametersToPass[parameter.name] === undefined) {
|
|
4180
4222
|
// [4]
|
|
4181
|
-
$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 "); })));
|
|
4223
|
+
$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 "); })));
|
|
4182
4224
|
return "continue";
|
|
4183
4225
|
}
|
|
4184
4226
|
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
@@ -4298,7 +4340,7 @@ function executePipeline(options) {
|
|
|
4298
4340
|
return name === parameterName;
|
|
4299
4341
|
});
|
|
4300
4342
|
if (!(parameter === undefined)) return [3 /*break*/, 1];
|
|
4301
|
-
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 "); })));
|
|
4343
|
+
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 "); })));
|
|
4302
4344
|
return [3 /*break*/, 4];
|
|
4303
4345
|
case 1:
|
|
4304
4346
|
if (!(parameter.isInput === false)) return [3 /*break*/, 4];
|
|
@@ -4310,10 +4352,10 @@ function executePipeline(options) {
|
|
|
4310
4352
|
// Note: Wait a short time to prevent race conditions
|
|
4311
4353
|
_h.sent();
|
|
4312
4354
|
_h.label = 3;
|
|
4313
|
-
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 "); }), {
|
|
4355
|
+
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 "); }), {
|
|
4314
4356
|
isSuccessful: false,
|
|
4315
4357
|
errors: __spreadArray([
|
|
4316
|
-
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 "); }))
|
|
4358
|
+
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 "); }))
|
|
4317
4359
|
], __read(errors), false).map(serializeError),
|
|
4318
4360
|
warnings: warnings.map(serializeError),
|
|
4319
4361
|
executionReport: executionReport,
|
|
@@ -4377,7 +4419,7 @@ function executePipeline(options) {
|
|
|
4377
4419
|
case 0:
|
|
4378
4420
|
if (loopLimit-- < 0) {
|
|
4379
4421
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
4380
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4422
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4381
4423
|
}
|
|
4382
4424
|
currentTask = unresovedTasks_1.find(function (task) {
|
|
4383
4425
|
return task.dependentParameterNames.every(function (name) {
|
|
@@ -4387,7 +4429,7 @@ function executePipeline(options) {
|
|
|
4387
4429
|
if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
4388
4430
|
throw new UnexpectedError(
|
|
4389
4431
|
// TODO: [🐎] DRY
|
|
4390
|
-
spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks_1
|
|
4432
|
+
spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks_1
|
|
4391
4433
|
.map(function (_a) {
|
|
4392
4434
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
4393
4435
|
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
@@ -4415,7 +4457,7 @@ function executePipeline(options) {
|
|
|
4415
4457
|
unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
|
|
4416
4458
|
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
|
|
4417
4459
|
if (isReturned) {
|
|
4418
|
-
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)
|
|
4460
|
+
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)
|
|
4419
4461
|
.split('\n')
|
|
4420
4462
|
.map(function (line) { return "> ".concat(line); })
|
|
4421
4463
|
.join('\n')), "\n "); }));
|
|
@@ -4423,7 +4465,7 @@ function executePipeline(options) {
|
|
|
4423
4465
|
if (onProgress) {
|
|
4424
4466
|
onProgress(progress);
|
|
4425
4467
|
}
|
|
4426
|
-
}, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
|
|
4468
|
+
}, $executionReport: executionReport, pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
|
|
4427
4469
|
.then(function (newParametersToPass) {
|
|
4428
4470
|
parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
|
|
4429
4471
|
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
|
|
@@ -4545,7 +4587,7 @@ function createPipelineExecutor(options) {
|
|
|
4545
4587
|
preparedPipeline = pipeline;
|
|
4546
4588
|
}
|
|
4547
4589
|
else if (isNotPreparedWarningSupressed !== true) {
|
|
4548
|
-
console.warn(spaceTrim(function (block) { return "\n Pipeline is not prepared\n\n ".concat(block(pipelineIdentification), "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "); }));
|
|
4590
|
+
console.warn(spaceTrim$1(function (block) { return "\n Pipeline is not prepared\n\n ".concat(block(pipelineIdentification), "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "); }));
|
|
4549
4591
|
}
|
|
4550
4592
|
var runCount = 0;
|
|
4551
4593
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -4560,7 +4602,7 @@ function createPipelineExecutor(options) {
|
|
|
4560
4602
|
inputParameters: inputParameters,
|
|
4561
4603
|
tools: tools,
|
|
4562
4604
|
onProgress: onProgress,
|
|
4563
|
-
pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
|
|
4605
|
+
pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
|
|
4564
4606
|
maxExecutionAttempts: maxExecutionAttempts,
|
|
4565
4607
|
maxParallelCount: maxParallelCount,
|
|
4566
4608
|
csvSettings: csvSettings,
|
|
@@ -4894,9 +4936,9 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4894
4936
|
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
4895
4937
|
});
|
|
4896
4938
|
if (metadata.length === 0) {
|
|
4897
|
-
return spaceTrim
|
|
4939
|
+
return spaceTrim("\n **No scrapers are available**\n\n This is a unexpected behavior, you are probably using some broken version of Promptbook\n At least there should be available the metadata of the scrapers\n ");
|
|
4898
4940
|
}
|
|
4899
|
-
return spaceTrim
|
|
4941
|
+
return spaceTrim(function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
4900
4942
|
.map(function (_a, i) {
|
|
4901
4943
|
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
4902
4944
|
var more = [];
|
|
@@ -5174,7 +5216,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5174
5216
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5175
5217
|
case 3:
|
|
5176
5218
|
if (!(_e.sent())) {
|
|
5177
|
-
throw new NotFoundError(spaceTrim
|
|
5219
|
+
throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
5178
5220
|
}
|
|
5179
5221
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
5180
5222
|
return [2 /*return*/, {
|
|
@@ -5287,7 +5329,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5287
5329
|
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
5288
5330
|
return [2 /*return*/, "break"];
|
|
5289
5331
|
}
|
|
5290
|
-
console.warn(spaceTrim
|
|
5332
|
+
console.warn(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n \n The source:\n > ").concat(block(knowledgeSource.sourceContent
|
|
5291
5333
|
.split('\n')
|
|
5292
5334
|
.map(function (line) { return "> ".concat(line); })
|
|
5293
5335
|
.join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
@@ -5325,7 +5367,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5325
5367
|
return [7 /*endfinally*/];
|
|
5326
5368
|
case 9:
|
|
5327
5369
|
if (partialPieces === null) {
|
|
5328
|
-
throw new KnowledgeScrapeError(spaceTrim
|
|
5370
|
+
throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n \n The source:\n > ".concat(block(knowledgeSource.sourceContent
|
|
5329
5371
|
.split('\n')
|
|
5330
5372
|
.map(function (line) { return "> ".concat(line); })
|
|
5331
5373
|
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
@@ -5424,7 +5466,7 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
5424
5466
|
dependentParameterNames = task.dependentParameterNames;
|
|
5425
5467
|
preparedContent = undefined;
|
|
5426
5468
|
if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
|
|
5427
|
-
preparedContent = spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
5469
|
+
preparedContent = spaceTrim$1("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
5428
5470
|
// <- TODO: [🧠][🧻] Cutomize shape/language/formatting of the addition to the prompt
|
|
5429
5471
|
dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
|
|
5430
5472
|
'knowledge',
|
|
@@ -5623,7 +5665,7 @@ var knowledgeCommandParser = {
|
|
|
5623
5665
|
*/
|
|
5624
5666
|
parse: function (input) {
|
|
5625
5667
|
var args = input.args;
|
|
5626
|
-
var sourceContent = spaceTrim
|
|
5668
|
+
var sourceContent = spaceTrim(args[0] || '');
|
|
5627
5669
|
if (sourceContent === '') {
|
|
5628
5670
|
throw new ParseError("Source is not defined");
|
|
5629
5671
|
}
|
|
@@ -5767,7 +5809,7 @@ var sectionCommandParser = {
|
|
|
5767
5809
|
return normalized.includes(sectionType.split('_TASK').join(''));
|
|
5768
5810
|
});
|
|
5769
5811
|
if (taskTypes.length !== 1) {
|
|
5770
|
-
throw new ParseError(spaceTrim
|
|
5812
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Unknown section type \"".concat(normalized, "\"\n\n Supported section types are:\n ").concat(block(SectionTypes.join(', ')), "\n "); }));
|
|
5771
5813
|
}
|
|
5772
5814
|
var taskType = taskTypes[0];
|
|
5773
5815
|
return {
|
|
@@ -5782,10 +5824,10 @@ var sectionCommandParser = {
|
|
|
5782
5824
|
*/
|
|
5783
5825
|
$applyToTaskJson: function (command, $taskJson, $pipelineJson) {
|
|
5784
5826
|
if ($taskJson.isSectionTypeSet === true) {
|
|
5785
|
-
throw new ParseError(spaceTrim
|
|
5827
|
+
throw new ParseError(spaceTrim("\n Section type is already defined in the section.\n It can be defined only once.\n "));
|
|
5786
5828
|
}
|
|
5787
5829
|
$taskJson.isSectionTypeSet = true;
|
|
5788
|
-
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
5830
|
+
// TODO: [🍧][💩] Rearrange better - but at bottom and unwrap from function
|
|
5789
5831
|
var expectResultingParameterName = function () {
|
|
5790
5832
|
if ($taskJson.resultingParameterName) {
|
|
5791
5833
|
return;
|
|
@@ -6124,7 +6166,7 @@ var expectCommandParser = {
|
|
|
6124
6166
|
/**
|
|
6125
6167
|
* Description of the FORMAT command
|
|
6126
6168
|
*/
|
|
6127
|
-
description: spaceTrim
|
|
6169
|
+
description: spaceTrim("\n Expect command describes the desired output of the task *(after post-processing)*\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
|
|
6128
6170
|
/**
|
|
6129
6171
|
* Link to documentation
|
|
6130
6172
|
*/
|
|
@@ -6208,7 +6250,7 @@ var expectCommandParser = {
|
|
|
6208
6250
|
if (!(error instanceof Error)) {
|
|
6209
6251
|
throw error;
|
|
6210
6252
|
}
|
|
6211
|
-
throw new ParseError(spaceTrim
|
|
6253
|
+
throw new ParseError(spaceTrim(function (block) {
|
|
6212
6254
|
return "\n Invalid FORMAT command\n ".concat(block(error.message), ":\n ");
|
|
6213
6255
|
}));
|
|
6214
6256
|
}
|
|
@@ -6430,7 +6472,7 @@ function validateParameterName(parameterName) {
|
|
|
6430
6472
|
if (!(error instanceof ParseError)) {
|
|
6431
6473
|
throw error;
|
|
6432
6474
|
}
|
|
6433
|
-
throw new ParseError(spaceTrim
|
|
6475
|
+
throw new ParseError(spaceTrim(function (block) { return "\n ".concat(block(error.message), "\n\n Tried to validate parameter name:\n ").concat(block(rawParameterName), "\n "); }));
|
|
6434
6476
|
}
|
|
6435
6477
|
return parameterName;
|
|
6436
6478
|
}
|
|
@@ -6488,7 +6530,7 @@ var foreachCommandParser = {
|
|
|
6488
6530
|
return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(formatName);
|
|
6489
6531
|
});
|
|
6490
6532
|
if (formatDefinition === undefined) {
|
|
6491
|
-
throw new ParseError(spaceTrim
|
|
6533
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Unsupported format \"".concat(formatName, "\"\n\n Available formats:\n ").concat(block(FORMAT_DEFINITIONS.map(function (formatDefinition) { return formatDefinition.formatName; })
|
|
6492
6534
|
.map(function (formatName) { return "- ".concat(formatName); })
|
|
6493
6535
|
.join('\n')), "\n "); }));
|
|
6494
6536
|
// <- TODO: [🏢] List all supported format names
|
|
@@ -6497,7 +6539,7 @@ var foreachCommandParser = {
|
|
|
6497
6539
|
return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(subformatName);
|
|
6498
6540
|
});
|
|
6499
6541
|
if (subvalueDefinition === undefined) {
|
|
6500
|
-
throw new ParseError(spaceTrim
|
|
6542
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Unsupported subformat name \"".concat(subformatName, "\" for format \"").concat(formatName, "\"\n\n Available subformat names for format \"").concat(formatDefinition.formatName, "\":\n ").concat(block(formatDefinition.subvalueDefinitions
|
|
6501
6543
|
.map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
|
|
6502
6544
|
.map(function (subvalueName) { return "- ".concat(subvalueName); })
|
|
6503
6545
|
.join('\n')), "\n "); }));
|
|
@@ -6540,7 +6582,7 @@ var foreachCommandParser = {
|
|
|
6540
6582
|
outputSubparameterName = 'newLine';
|
|
6541
6583
|
}
|
|
6542
6584
|
else {
|
|
6543
|
-
throw new ParseError(spaceTrim
|
|
6585
|
+
throw new ParseError(spaceTrim("\n FOREACH ".concat(formatName, " ").concat(subformatName, " must specify output subparameter\n\n Correct example:\n - FOREACH ").concat(formatName, " ").concat(subformatName, " {").concat(parameterName, "} -> {inputSubparameterName1}, {inputSubparameterName2}, +{outputSubparameterName}\n\n ")));
|
|
6544
6586
|
}
|
|
6545
6587
|
}
|
|
6546
6588
|
return {
|
|
@@ -6610,7 +6652,7 @@ var formatCommandParser = {
|
|
|
6610
6652
|
/**
|
|
6611
6653
|
* Description of the FORMAT command
|
|
6612
6654
|
*/
|
|
6613
|
-
description: spaceTrim
|
|
6655
|
+
description: spaceTrim("\n Format command describes the desired output of the task (after post-processing)\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
|
|
6614
6656
|
/**
|
|
6615
6657
|
* Link to documentation
|
|
6616
6658
|
*/
|
|
@@ -6887,7 +6929,7 @@ var formfactorCommandParser = {
|
|
|
6887
6929
|
return __spreadArray([definition.name], __read(__assign({ aliasNames: [] }, definition).aliasNames), false).includes(formfactorNameCandidate);
|
|
6888
6930
|
});
|
|
6889
6931
|
if (formfactor === undefined) {
|
|
6890
|
-
throw new ParseError(spaceTrim
|
|
6932
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Unknown formfactor name \"".concat(formfactorNameCandidate, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
|
|
6891
6933
|
var name = _a.name;
|
|
6892
6934
|
return "- ".concat(name);
|
|
6893
6935
|
}).join('\n')), "\n "); }));
|
|
@@ -7038,7 +7080,7 @@ var modelCommandParser = {
|
|
|
7038
7080
|
*/
|
|
7039
7081
|
parse: function (input) {
|
|
7040
7082
|
var args = input.args, normalized = input.normalized;
|
|
7041
|
-
var availableVariantsMessage = spaceTrim
|
|
7083
|
+
var availableVariantsMessage = spaceTrim(function (block) { return "\n Available variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) {
|
|
7042
7084
|
return "- ".concat(variantName).concat(variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)');
|
|
7043
7085
|
}).join('\n')), "\n "); });
|
|
7044
7086
|
// TODO: Make this more elegant and dynamically
|
|
@@ -7059,10 +7101,10 @@ var modelCommandParser = {
|
|
|
7059
7101
|
// <- Note: [🤖]
|
|
7060
7102
|
}
|
|
7061
7103
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
7062
|
-
spaceTrim
|
|
7104
|
+
spaceTrim(function (block) { return "\n Embedding model can not be used in pipeline\n\n ".concat(block(availableVariantsMessage), "\n "); });
|
|
7063
7105
|
}
|
|
7064
7106
|
else {
|
|
7065
|
-
throw new ParseError(spaceTrim
|
|
7107
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Unknown model variant in command:\n\n ".concat(block(availableVariantsMessage), "\n "); }));
|
|
7066
7108
|
}
|
|
7067
7109
|
}
|
|
7068
7110
|
if (normalized.startsWith('MODEL_NAME')) {
|
|
@@ -7073,7 +7115,7 @@ var modelCommandParser = {
|
|
|
7073
7115
|
};
|
|
7074
7116
|
}
|
|
7075
7117
|
else {
|
|
7076
|
-
throw new ParseError(spaceTrim
|
|
7118
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Unknown model key in command.\n\n Supported model keys are:\n ".concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
|
|
7077
7119
|
}
|
|
7078
7120
|
},
|
|
7079
7121
|
/**
|
|
@@ -7087,10 +7129,10 @@ var modelCommandParser = {
|
|
|
7087
7129
|
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
7088
7130
|
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
7089
7131
|
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
7090
|
-
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
7132
|
+
// <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
|
|
7091
7133
|
}
|
|
7092
7134
|
else {
|
|
7093
|
-
throw new ParseError(spaceTrim
|
|
7135
|
+
throw new ParseError(spaceTrim("\n Redefinition of MODEL `".concat(command.key, "` in the pipeline head\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|
|
7094
7136
|
}
|
|
7095
7137
|
}
|
|
7096
7138
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
@@ -7115,11 +7157,11 @@ var modelCommandParser = {
|
|
|
7115
7157
|
}[command.key], " ").concat(command.value, "` in the task \"").concat($taskJson.title || $taskJson.name, "\""));
|
|
7116
7158
|
}
|
|
7117
7159
|
else {
|
|
7118
|
-
throw new ParseError(spaceTrim
|
|
7160
|
+
throw new ParseError(spaceTrim("\n Redefinition of MODEL `".concat(command.key, "` in the task \"").concat($taskJson.title || $taskJson.name, "\"\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($taskJson.modelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|
|
7119
7161
|
}
|
|
7120
7162
|
}
|
|
7121
7163
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
7122
|
-
console.log(spaceTrim
|
|
7164
|
+
console.log(spaceTrim("\n Setting MODEL `".concat(command.key, "` in the task \"").concat($taskJson.title || $taskJson.name, "\" to the same value as in the pipeline head\n\n In pipeline head:\n - MODEL ").concat(command.key, " ").concat(($pipelineJson.defaultModelRequirements || {})[command.key], "\n\n But same value is used in the task:\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|
|
7123
7165
|
}
|
|
7124
7166
|
$taskJson.modelRequirements[command.key] = command.value;
|
|
7125
7167
|
},
|
|
@@ -7194,7 +7236,7 @@ var parameterCommandParser = {
|
|
|
7194
7236
|
// <- TODO: When [🥶] fixed, change to:
|
|
7195
7237
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
7196
7238
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
7197
|
-
throw new ParseError(spaceTrim
|
|
7239
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameterNameRaw, "}` can not contain another parameter in description\n\n The description:\n ").concat(block(parameterDescriptionRaw), "\n "); }));
|
|
7198
7240
|
}
|
|
7199
7241
|
var isInput = normalized.startsWith('INPUT');
|
|
7200
7242
|
var isOutput = normalized.startsWith('OUTPUT');
|
|
@@ -7371,8 +7413,8 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
7371
7413
|
persona.description = personaDescription;
|
|
7372
7414
|
return;
|
|
7373
7415
|
}
|
|
7374
|
-
console.warn(spaceTrim
|
|
7375
|
-
persona.description += spaceTrim
|
|
7416
|
+
console.warn(spaceTrim("\n\n Persona \"".concat(personaName, "\" is defined multiple times with different description:\n\n First definition:\n ").concat(persona.description, "\n\n Second definition:\n ").concat(personaDescription, "\n\n ")));
|
|
7417
|
+
persona.description += spaceTrim('\n\n' + personaDescription);
|
|
7376
7418
|
}
|
|
7377
7419
|
|
|
7378
7420
|
/**
|
|
@@ -7722,7 +7764,7 @@ var COMMANDS = [
|
|
|
7722
7764
|
personaCommandParser,
|
|
7723
7765
|
foreachCommandParser,
|
|
7724
7766
|
boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
|
|
7725
|
-
// <- Note: [♓️] This is the order of the commands in the pipeline, BUT its not used in parsing and before usage maybe it should be done better
|
|
7767
|
+
// <- Note: [♓️][💩] This is the order of the commands in the pipeline, BUT its not used in parsing and before usage maybe it should be done better
|
|
7726
7768
|
];
|
|
7727
7769
|
/**
|
|
7728
7770
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7739,7 +7781,7 @@ var COMMANDS = [
|
|
|
7739
7781
|
function getParserForCommand(command) {
|
|
7740
7782
|
var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
|
|
7741
7783
|
if (commandParser === undefined) {
|
|
7742
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found\n\n ").concat(block(JSON.stringify(command, null, 4)
|
|
7784
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " parser is not found\n\n ").concat(block(JSON.stringify(command, null, 4)
|
|
7743
7785
|
.split('\n')
|
|
7744
7786
|
.map(function (line) { return "> ".concat(line); })
|
|
7745
7787
|
.join('\n')), "\n "); }));
|
|
@@ -7811,7 +7853,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
7811
7853
|
.map(removeMarkdownFormatting)
|
|
7812
7854
|
.map(function (item) { return item.trim(); });
|
|
7813
7855
|
if (items.length === 0 || items[0] === '') {
|
|
7814
|
-
throw new ParseError(spaceTrim(function (block) {
|
|
7856
|
+
throw new ParseError(spaceTrim$1(function (block) {
|
|
7815
7857
|
return "\n Malformed command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
|
|
7816
7858
|
}));
|
|
7817
7859
|
}
|
|
@@ -7842,7 +7884,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
7842
7884
|
return command;
|
|
7843
7885
|
}
|
|
7844
7886
|
}
|
|
7845
|
-
throw new ParseError(spaceTrim(function (block) {
|
|
7887
|
+
throw new ParseError(spaceTrim$1(function (block) {
|
|
7846
7888
|
return "\n Malformed or unknown command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
|
|
7847
7889
|
}));
|
|
7848
7890
|
}
|
|
@@ -7884,7 +7926,7 @@ function parseCommandVariant(input) {
|
|
|
7884
7926
|
if (!(error instanceof ParseError)) {
|
|
7885
7927
|
throw error;
|
|
7886
7928
|
}
|
|
7887
|
-
throw new ParseError(spaceTrim(function (block) {
|
|
7929
|
+
throw new ParseError(spaceTrim$1(function (block) {
|
|
7888
7930
|
return "\n Invalid ".concat(commandName, " command:\n\n Your command:\n - ").concat(raw, "\n\n The detailed error:\n ").concat(block(error.message), "\n\n Usage of ").concat(commandName, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n All supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
|
|
7889
7931
|
}));
|
|
7890
7932
|
}
|
|
@@ -7975,7 +8017,7 @@ function extractAllListItemsFromMarkdown(markdown) {
|
|
|
7975
8017
|
function extractOneBlockFromMarkdown(markdown) {
|
|
7976
8018
|
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
7977
8019
|
if (codeBlocks.length !== 1) {
|
|
7978
|
-
throw new ParseError(spaceTrim
|
|
8020
|
+
throw new ParseError(spaceTrim(function (block) { return "\n There should be exactly 1 code block in task section, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
|
|
7979
8021
|
}
|
|
7980
8022
|
return codeBlocks[0];
|
|
7981
8023
|
}
|
|
@@ -7996,7 +8038,7 @@ function parseMarkdownSection(value) {
|
|
|
7996
8038
|
}
|
|
7997
8039
|
var title = lines[0].replace(/^#+\s*/, '');
|
|
7998
8040
|
var level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
7999
|
-
var content = spaceTrim
|
|
8041
|
+
var content = spaceTrim(lines.slice(1).join('\n'));
|
|
8000
8042
|
if (level < 1 || level > 6) {
|
|
8001
8043
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
8002
8044
|
}
|
|
@@ -8018,13 +8060,14 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
8018
8060
|
var e_1, _a;
|
|
8019
8061
|
var lines = markdown.split('\n');
|
|
8020
8062
|
var sections = [];
|
|
8063
|
+
// TODO: [🧽] DRY
|
|
8021
8064
|
var currentType = 'MARKDOWN';
|
|
8022
8065
|
var buffer = [];
|
|
8023
8066
|
var finishSection = function () {
|
|
8024
8067
|
if (buffer.length === 0) {
|
|
8025
8068
|
return;
|
|
8026
8069
|
}
|
|
8027
|
-
var section = spaceTrim
|
|
8070
|
+
var section = spaceTrim(buffer.join('\n'));
|
|
8028
8071
|
if (section === '') {
|
|
8029
8072
|
return;
|
|
8030
8073
|
}
|
|
@@ -8120,7 +8163,7 @@ function flattenMarkdown(markdown) {
|
|
|
8120
8163
|
}
|
|
8121
8164
|
finally { if (e_1) throw e_1.error; }
|
|
8122
8165
|
}
|
|
8123
|
-
return spaceTrim
|
|
8166
|
+
return spaceTrim(flattenedMarkdown);
|
|
8124
8167
|
}
|
|
8125
8168
|
/**
|
|
8126
8169
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -8138,7 +8181,7 @@ function flattenMarkdown(markdown) {
|
|
|
8138
8181
|
* @public exported from `@promptbook/markdown-utils`
|
|
8139
8182
|
*/
|
|
8140
8183
|
function removeContentComments(content) {
|
|
8141
|
-
return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
8184
|
+
return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
|
|
8142
8185
|
}
|
|
8143
8186
|
|
|
8144
8187
|
/**
|
|
@@ -8213,7 +8256,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8213
8256
|
if (pipelineString.startsWith('#!')) {
|
|
8214
8257
|
var _f = __read(pipelineString.split('\n')), shebangLine_1 = _f[0], restLines = _f.slice(1);
|
|
8215
8258
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
8216
|
-
throw new ParseError(spaceTrim(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
8259
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
8217
8260
|
}
|
|
8218
8261
|
pipelineString = restLines.join('\n');
|
|
8219
8262
|
}
|
|
@@ -8223,27 +8266,27 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8223
8266
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
8224
8267
|
var _g = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _g[0], pipelineSections = _g.slice(1); /* <- Note: [🥞] */
|
|
8225
8268
|
if (pipelineHead === undefined) {
|
|
8226
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8269
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8227
8270
|
}
|
|
8228
8271
|
if (pipelineHead.level !== 1) {
|
|
8229
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8272
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8230
8273
|
}
|
|
8231
8274
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
8232
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8275
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8233
8276
|
}
|
|
8234
8277
|
// =============================================================
|
|
8235
8278
|
///Note: 2️⃣ Function for defining parameters
|
|
8236
8279
|
var defineParam = function (parameterCommand) {
|
|
8237
8280
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
8238
8281
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
8239
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(getPipelineIdentification()), "\n "); }) /* <- TODO: [🚞] */);
|
|
8282
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(getPipelineIdentification()), "\n "); }) /* <- TODO: [🚞] */);
|
|
8240
8283
|
}
|
|
8241
8284
|
var existingParameter = $pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
8242
8285
|
if (existingParameter &&
|
|
8243
8286
|
existingParameter.description &&
|
|
8244
8287
|
existingParameter.description !== parameterDescription &&
|
|
8245
8288
|
parameterDescription) {
|
|
8246
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
8289
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameterName, "}` is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
8247
8290
|
}
|
|
8248
8291
|
if (existingParameter) {
|
|
8249
8292
|
if (parameterDescription) {
|
|
@@ -8271,7 +8314,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8271
8314
|
description = description.split(/^>.*$/gm).join('');
|
|
8272
8315
|
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
8273
8316
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
8274
|
-
description = spaceTrim(description);
|
|
8317
|
+
description = spaceTrim$1(description);
|
|
8275
8318
|
if (description === '') {
|
|
8276
8319
|
description = undefined;
|
|
8277
8320
|
}
|
|
@@ -8282,7 +8325,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8282
8325
|
var command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
8283
8326
|
var commandParser = getParserForCommand(command);
|
|
8284
8327
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
8285
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Command `".concat(command.type, "` is not allowed in the head of the pipeline ONLY at the pipeline task\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8328
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Command `".concat(command.type, "` is not allowed in the head of the pipeline ONLY at the pipeline task\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8286
8329
|
}
|
|
8287
8330
|
try {
|
|
8288
8331
|
commandParser.$applyToPipelineJson(command, $pipelineJson);
|
|
@@ -8292,7 +8335,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8292
8335
|
if (!(error instanceof ParseError)) {
|
|
8293
8336
|
throw error;
|
|
8294
8337
|
}
|
|
8295
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " failed to apply to the pipeline\n\n The error:\n ").concat(block(error.message), "\n\n Raw command:\n - ").concat(listItem, "\n\n Usage of ").concat(command.type, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8338
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " failed to apply to the pipeline\n\n The error:\n ").concat(block(error.message), "\n\n Raw command:\n - ").concat(listItem, "\n\n Usage of ").concat(command.type, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8296
8339
|
}
|
|
8297
8340
|
if (command.type === 'PARAMETER') {
|
|
8298
8341
|
defineParam(command);
|
|
@@ -8354,7 +8397,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8354
8397
|
description_1 = description_1.split(/^>.*$/gm).join('');
|
|
8355
8398
|
//Note: Remove lists and return statement - TODO: [🎾]
|
|
8356
8399
|
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
8357
|
-
description_1 = spaceTrim(description_1);
|
|
8400
|
+
description_1 = spaceTrim$1(description_1);
|
|
8358
8401
|
if (description_1 === '') {
|
|
8359
8402
|
description_1 = undefined;
|
|
8360
8403
|
}
|
|
@@ -8390,7 +8433,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8390
8433
|
var _loop_4 = function (listItem, command) {
|
|
8391
8434
|
var commandParser = getParserForCommand(command);
|
|
8392
8435
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
8393
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Command `".concat(command.type, "` is not allowed in the task of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8436
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Command `".concat(command.type, "` is not allowed in the task of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8394
8437
|
}
|
|
8395
8438
|
try {
|
|
8396
8439
|
commandParser.$applyToTaskJson(
|
|
@@ -8401,7 +8444,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8401
8444
|
if (!(error instanceof ParseError)) {
|
|
8402
8445
|
throw error;
|
|
8403
8446
|
}
|
|
8404
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Command `".concat(command.type, "` failed to apply to the task\n\n The error:\n ").concat(block(error.message), "\n\n Current state of the task:\n ").concat(block(JSON.stringify($taskJson, null, 4)), "\n *<- Maybe wrong order of commands?*\n\n Raw command:\n - ").concat(listItem, "\n\n Usage of ").concat(command.type, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8447
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Command `".concat(command.type, "` failed to apply to the task\n\n The error:\n ").concat(block(error.message), "\n\n Current state of the task:\n ").concat(block(JSON.stringify($taskJson, null, 4)), "\n *<- Maybe wrong order of commands?*\n\n Raw command:\n - ").concat(listItem, "\n\n Usage of ").concat(command.type, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8405
8448
|
}
|
|
8406
8449
|
if (command.type === 'PARAMETER') {
|
|
8407
8450
|
defineParam(command);
|
|
@@ -8425,10 +8468,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8425
8468
|
// TODO: [🍧] Should be done in SECTION command
|
|
8426
8469
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
8427
8470
|
if (!language) {
|
|
8428
|
-
throw new ParseError(spaceTrim(function (block) { return "\n You must specify the language of the script in the `SCRIPT` task\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
8471
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n You must specify the language of the script in the `SCRIPT` task\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
8429
8472
|
}
|
|
8430
8473
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
8431
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|
|
8474
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|
|
8432
8475
|
}
|
|
8433
8476
|
$taskJson.contentLanguage = language;
|
|
8434
8477
|
}
|
|
@@ -9102,7 +9145,7 @@ function $registeredLlmToolsMessage() {
|
|
|
9102
9145
|
if (metadata.length === 0) {
|
|
9103
9146
|
return "No LLM providers are available.";
|
|
9104
9147
|
}
|
|
9105
|
-
return spaceTrim
|
|
9148
|
+
return spaceTrim(function (block) { return "\n Relevant environment variables:\n ".concat(block(Object.keys(env)
|
|
9106
9149
|
.filter(function (envVariableName) {
|
|
9107
9150
|
return metadata.some(function (_a) {
|
|
9108
9151
|
var envVariables = _a.envVariables;
|
|
@@ -9146,7 +9189,7 @@ function $registeredLlmToolsMessage() {
|
|
|
9146
9189
|
morePieces.push("Not configured"); // <- Note: Can not be configured via environment variables
|
|
9147
9190
|
}
|
|
9148
9191
|
}
|
|
9149
|
-
var providerMessage = spaceTrim
|
|
9192
|
+
var providerMessage = spaceTrim("\n ".concat(i + 1, ") **").concat(title, "** `").concat(className, "` from `").concat(packageName, "`\n ").concat(morePieces.join('; '), "\n "));
|
|
9150
9193
|
if ($isRunningInNode) {
|
|
9151
9194
|
if (isInstalled && isFullyConfigured) {
|
|
9152
9195
|
providerMessage = colors.green(providerMessage);
|
|
@@ -9186,7 +9229,7 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
9186
9229
|
return llmConfiguration.packageName === packageName && llmConfiguration.className === className;
|
|
9187
9230
|
});
|
|
9188
9231
|
if (registeredItem === undefined) {
|
|
9189
|
-
throw new Error(spaceTrim
|
|
9232
|
+
throw new Error(spaceTrim(function (block) { return "\n There is no constructor for LLM provider `".concat(llmConfiguration.className, "` from `").concat(llmConfiguration.packageName, "`\n\n You have probably forgotten install and import the provider package.\n To fix this issue, you can:\n\n Install:\n\n > npm install ").concat(llmConfiguration.packageName, "\n\n And import:\n\n > import '").concat(llmConfiguration.packageName, "';\n\n\n ").concat(block($registeredLlmToolsMessage()), "\n "); }));
|
|
9190
9233
|
}
|
|
9191
9234
|
return registeredItem(__assign({ isVerbose: isVerbose, userId: userId }, llmConfiguration.options));
|
|
9192
9235
|
});
|
|
@@ -9225,7 +9268,7 @@ function $provideLlmToolsFromEnv(options) {
|
|
|
9225
9268
|
var configuration = $provideLlmToolsConfigurationFromEnv();
|
|
9226
9269
|
if (configuration.length === 0) {
|
|
9227
9270
|
// TODO: [🥃]
|
|
9228
|
-
throw new Error(spaceTrim
|
|
9271
|
+
throw new Error(spaceTrim(function (block) { return "\n No LLM tools found in the environment\n\n Please set one of environment variables:\n - OPENAI_API_KEY\n - ANTHROPIC_CLAUDE_API_KEY\n\n ".concat(block($registeredLlmToolsMessage()), "}\n "); }));
|
|
9229
9272
|
}
|
|
9230
9273
|
return createLlmToolsFromConfiguration(configuration, options);
|
|
9231
9274
|
}
|
|
@@ -9400,13 +9443,13 @@ function parseKeywordsFromString(input) {
|
|
|
9400
9443
|
* @public exported from `@promptbook/utils`
|
|
9401
9444
|
*/
|
|
9402
9445
|
function trimCodeBlock(value) {
|
|
9403
|
-
value = spaceTrim(value);
|
|
9446
|
+
value = spaceTrim$1(value);
|
|
9404
9447
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
9405
9448
|
return value;
|
|
9406
9449
|
}
|
|
9407
9450
|
value = value.replace(/^```[a-z]*/i, '');
|
|
9408
9451
|
value = value.replace(/```$/i, '');
|
|
9409
|
-
value = spaceTrim(value);
|
|
9452
|
+
value = spaceTrim$1(value);
|
|
9410
9453
|
return value;
|
|
9411
9454
|
}
|
|
9412
9455
|
|
|
@@ -9419,9 +9462,9 @@ function trimCodeBlock(value) {
|
|
|
9419
9462
|
* @public exported from `@promptbook/utils`
|
|
9420
9463
|
*/
|
|
9421
9464
|
function trimEndOfCodeBlock(value) {
|
|
9422
|
-
value = spaceTrim(value);
|
|
9465
|
+
value = spaceTrim$1(value);
|
|
9423
9466
|
value = value.replace(/```$/g, '');
|
|
9424
|
-
value = spaceTrim(value);
|
|
9467
|
+
value = spaceTrim$1(value);
|
|
9425
9468
|
return value;
|
|
9426
9469
|
}
|
|
9427
9470
|
|
|
@@ -9443,7 +9486,7 @@ function unwrapResult(text, options) {
|
|
|
9443
9486
|
var trimmedText = text;
|
|
9444
9487
|
// Remove leading and trailing spaces and newlines
|
|
9445
9488
|
if (isTrimmed) {
|
|
9446
|
-
trimmedText = spaceTrim(trimmedText);
|
|
9489
|
+
trimmedText = spaceTrim$1(trimmedText);
|
|
9447
9490
|
}
|
|
9448
9491
|
var processedText = trimmedText;
|
|
9449
9492
|
if (isIntroduceSentenceRemoved) {
|
|
@@ -9452,7 +9495,7 @@ function unwrapResult(text, options) {
|
|
|
9452
9495
|
// Remove the introduce sentence and quotes by replacing it with an empty string
|
|
9453
9496
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
9454
9497
|
}
|
|
9455
|
-
processedText = spaceTrim(processedText);
|
|
9498
|
+
processedText = spaceTrim$1(processedText);
|
|
9456
9499
|
}
|
|
9457
9500
|
if (processedText.length < 3) {
|
|
9458
9501
|
return trimmedText;
|
|
@@ -9512,10 +9555,10 @@ function preserve(func) {
|
|
|
9512
9555
|
return __generator(this, function (_a) {
|
|
9513
9556
|
switch (_a.label) {
|
|
9514
9557
|
case 0:
|
|
9515
|
-
// TODO: Change to `await forEver` or something better
|
|
9558
|
+
// TODO: [💩] Change to `await forEver` or something better
|
|
9516
9559
|
return [4 /*yield*/, forTime(100000000)];
|
|
9517
9560
|
case 1:
|
|
9518
|
-
// TODO: Change to `await forEver` or something better
|
|
9561
|
+
// TODO: [💩] Change to `await forEver` or something better
|
|
9519
9562
|
_a.sent();
|
|
9520
9563
|
_a.label = 2;
|
|
9521
9564
|
case 2:
|
|
@@ -9579,7 +9622,7 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
|
|
|
9579
9622
|
*/
|
|
9580
9623
|
JavascriptEvalExecutionTools.prototype.execute = function (options) {
|
|
9581
9624
|
return __awaiter(this, void 0, void 0, function () {
|
|
9582
|
-
var scriptLanguage, parameters, script, spaceTrim, removeQuotes$1, unwrapResult$1, trimEndOfCodeBlock$1, trimCodeBlock$1, trim, reverse, removeEmojis$1, prettifyMarkdown$1, capitalize$1, decapitalize$1, nameToUriPart$1, nameToUriParts$1, removeDiacritics$1, normalizeWhitespaces$1, normalizeToKebabCase$1, normalizeTo_camelCase$1, normalizeTo_snake_case$1, normalizeTo_PascalCase$1, parseKeywords, normalizeTo_SCREAMING_CASE$1, buildinFunctions, buildinFunctionsStatement, customFunctions, customFunctionsStatement, statementToEvaluate, result, error_1, undefinedName_1;
|
|
9625
|
+
var scriptLanguage, parameters, script, spaceTrim$1, removeQuotes$1, unwrapResult$1, trimEndOfCodeBlock$1, trimCodeBlock$1, trim, reverse, removeEmojis$1, prettifyMarkdown$1, capitalize$1, decapitalize$1, nameToUriPart$1, nameToUriParts$1, removeDiacritics$1, normalizeWhitespaces$1, normalizeToKebabCase$1, normalizeTo_camelCase$1, normalizeTo_snake_case$1, normalizeTo_PascalCase$1, parseKeywords, normalizeTo_SCREAMING_CASE$1, buildinFunctions, buildinFunctionsStatement, customFunctions, customFunctionsStatement, statementToEvaluate, result, error_1, undefinedName_1;
|
|
9583
9626
|
return __generator(this, function (_a) {
|
|
9584
9627
|
switch (_a.label) {
|
|
9585
9628
|
case 0:
|
|
@@ -9588,8 +9631,8 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
|
|
|
9588
9631
|
if (scriptLanguage !== 'javascript') {
|
|
9589
9632
|
throw new PipelineExecutionError("Script language ".concat(scriptLanguage, " not supported to be executed by JavascriptEvalExecutionTools"));
|
|
9590
9633
|
}
|
|
9591
|
-
spaceTrim = function (_) { return spaceTrim
|
|
9592
|
-
preserve(spaceTrim);
|
|
9634
|
+
spaceTrim$1 = function (_) { return spaceTrim(_); };
|
|
9635
|
+
preserve(spaceTrim$1);
|
|
9593
9636
|
removeQuotes$1 = removeQuotes;
|
|
9594
9637
|
preserve(removeQuotes$1);
|
|
9595
9638
|
unwrapResult$1 = unwrapResult;
|
|
@@ -9639,7 +9682,7 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
|
|
|
9639
9682
|
}
|
|
9640
9683
|
buildinFunctions = {
|
|
9641
9684
|
// TODO: [🍯] DRY all these functions across the file
|
|
9642
|
-
spaceTrim: spaceTrim,
|
|
9685
|
+
spaceTrim: spaceTrim$1,
|
|
9643
9686
|
removeQuotes: removeQuotes$1,
|
|
9644
9687
|
unwrapResult: unwrapResult$1,
|
|
9645
9688
|
trimEndOfCodeBlock: trimEndOfCodeBlock$1,
|
|
@@ -9675,14 +9718,14 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
|
|
|
9675
9718
|
return "const ".concat(functionName, " = customFunctions.").concat(functionName, ";");
|
|
9676
9719
|
})
|
|
9677
9720
|
.join('\n');
|
|
9678
|
-
statementToEvaluate = spaceTrim
|
|
9721
|
+
statementToEvaluate = spaceTrim(function (block) { return "\n\n // Build-in functions:\n ".concat(block(buildinFunctionsStatement), "\n\n // Custom functions:\n ").concat(block(customFunctionsStatement || '// -- No custom functions --'), "\n\n // The script:\n ").concat(block(Object.entries(parameters)
|
|
9679
9722
|
.map(function (_a) {
|
|
9680
9723
|
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
9681
9724
|
return "const ".concat(key, " = ").concat(JSON.stringify(value), ";");
|
|
9682
9725
|
})
|
|
9683
9726
|
.join('\n')), "\n (()=>{ ").concat(script, " })()\n "); });
|
|
9684
9727
|
if (this.options.isVerbose) {
|
|
9685
|
-
console.info(spaceTrim
|
|
9728
|
+
console.info(spaceTrim(function (block) { return "\n \uD83D\uDE80 Evaluating ".concat(scriptLanguage, " script:\n\n ").concat(block(statementToEvaluate)); }));
|
|
9686
9729
|
}
|
|
9687
9730
|
_a.label = 1;
|
|
9688
9731
|
case 1:
|
|
@@ -9707,12 +9750,12 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
|
|
|
9707
9750
|
To: [PipelineExecutionError: Parameter `{thing}` is not defined],
|
|
9708
9751
|
*/
|
|
9709
9752
|
if (!statementToEvaluate.includes(undefinedName_1 + '(')) {
|
|
9710
|
-
throw new PipelineExecutionError(spaceTrim
|
|
9753
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n\n Parameter `{".concat(undefinedName_1, "}` is not defined\n\n This happen during evaluation of the javascript, which has access to the following parameters as javascript variables:\n\n ").concat(block(Object.keys(parameters)
|
|
9711
9754
|
.map(function (key) { return " - ".concat(key, "\n"); })
|
|
9712
9755
|
.join('')), "\n\n The script is:\n ```javascript\n ").concat(block(script), "\n ```\n\n Original error message:\n ").concat(block(error_1.message), "\n\n\n "); }));
|
|
9713
9756
|
}
|
|
9714
9757
|
else {
|
|
9715
|
-
throw new PipelineExecutionError(spaceTrim
|
|
9758
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Function ".concat(undefinedName_1, "() is not defined\n\n - Make sure that the function is one of built-in functions\n - Or you have to defined the function during construction of JavascriptEvalExecutionTools\n\n Original error message:\n ").concat(block(error_1.message), "\n\n "); }));
|
|
9716
9759
|
}
|
|
9717
9760
|
}
|
|
9718
9761
|
throw error_1;
|
|
@@ -10115,7 +10158,7 @@ function createCollectionFromDirectory(path, tools, options) {
|
|
|
10115
10158
|
}
|
|
10116
10159
|
else {
|
|
10117
10160
|
existing = collection.get(pipeline.pipelineUrl);
|
|
10118
|
-
throw new PipelineUrlError(spaceTrim
|
|
10161
|
+
throw new PipelineUrlError(spaceTrim("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection \uD83C\uDF4F\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
10119
10162
|
}
|
|
10120
10163
|
}
|
|
10121
10164
|
}
|
|
@@ -10125,7 +10168,7 @@ function createCollectionFromDirectory(path, tools, options) {
|
|
|
10125
10168
|
if (!(error_1 instanceof Error)) {
|
|
10126
10169
|
throw error_1;
|
|
10127
10170
|
}
|
|
10128
|
-
wrappedErrorMessage = spaceTrim
|
|
10171
|
+
wrappedErrorMessage = spaceTrim(function (block) { return "\n ".concat(error_1.name, " in pipeline ").concat(fileName.split('\\').join('/'), "\u2060:\n\n ").concat(block(error_1.message), "\n\n "); });
|
|
10129
10172
|
if (isCrashedOnError) {
|
|
10130
10173
|
throw new CollectionError(wrappedErrorMessage);
|
|
10131
10174
|
}
|
|
@@ -10224,7 +10267,7 @@ function isSerializableAsJson(value) {
|
|
|
10224
10267
|
*/
|
|
10225
10268
|
function stringifyPipelineJson(pipeline) {
|
|
10226
10269
|
if (!isSerializableAsJson(pipeline)) {
|
|
10227
|
-
throw new UnexpectedError(spaceTrim
|
|
10270
|
+
throw new UnexpectedError(spaceTrim("\n Cannot stringify the pipeline, because it is not serializable as JSON\n\n There can be multiple reasons:\n 1) The pipeline contains circular references\n 2) It is not a valid PipelineJson\n "));
|
|
10228
10271
|
}
|
|
10229
10272
|
var pipelineJsonStringified = JSON.stringify(pipeline, null, 4);
|
|
10230
10273
|
for (var i = 0; i < LOOP_LIMIT; i++) {
|
|
@@ -10477,11 +10520,11 @@ function $execCommand(options) {
|
|
|
10477
10520
|
if (isVerbose) {
|
|
10478
10521
|
console.warn("Command \"".concat(humanReadableCommand, "\" exited with code ").concat(code));
|
|
10479
10522
|
}
|
|
10480
|
-
resolve(spaceTrim(output_1.join('\n')));
|
|
10523
|
+
resolve(spaceTrim$1(output_1.join('\n')));
|
|
10481
10524
|
}
|
|
10482
10525
|
}
|
|
10483
10526
|
else {
|
|
10484
|
-
resolve(spaceTrim(output_1.join('\n')));
|
|
10527
|
+
resolve(spaceTrim$1(output_1.join('\n')));
|
|
10485
10528
|
}
|
|
10486
10529
|
};
|
|
10487
10530
|
commandProcess.on('close', finishWithCode);
|
|
@@ -10498,7 +10541,7 @@ function $execCommand(options) {
|
|
|
10498
10541
|
if (isVerbose) {
|
|
10499
10542
|
console.warn(error);
|
|
10500
10543
|
}
|
|
10501
|
-
resolve(spaceTrim(output_1.join('\n')));
|
|
10544
|
+
resolve(spaceTrim$1(output_1.join('\n')));
|
|
10502
10545
|
}
|
|
10503
10546
|
});
|
|
10504
10547
|
}
|