@promptbook/core 0.78.0-0 → 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/README.md +0 -4
- package/esm/index.es.js +239 -205
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/config.d.ts +14 -0
- 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/package.json +1 -1
- package/umd/index.umd.js +240 -204
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
<blockquote style="color: #ff8811">
|
|
27
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
-
</blockquote>
|
|
29
|
-
|
|
30
26
|
## 📦 Package `@promptbook/core`
|
|
31
27
|
|
|
32
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
26
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.78.1';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -444,199 +444,6 @@ function just(value) {
|
|
|
444
444
|
return value;
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
/**
|
|
448
|
-
* @@@
|
|
449
|
-
*
|
|
450
|
-
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
451
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
452
|
-
*
|
|
453
|
-
* @returns The same object as the input, but deeply frozen
|
|
454
|
-
* @public exported from `@promptbook/utils`
|
|
455
|
-
*/
|
|
456
|
-
function $deepFreeze(objectValue) {
|
|
457
|
-
var e_1, _a;
|
|
458
|
-
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
459
|
-
try {
|
|
460
|
-
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
461
|
-
var propertyName = propertyNames_1_1.value;
|
|
462
|
-
var value = objectValue[propertyName];
|
|
463
|
-
if (value && typeof value === 'object') {
|
|
464
|
-
$deepFreeze(value);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
469
|
-
finally {
|
|
470
|
-
try {
|
|
471
|
-
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
472
|
-
}
|
|
473
|
-
finally { if (e_1) throw e_1.error; }
|
|
474
|
-
}
|
|
475
|
-
return Object.freeze(objectValue);
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
479
|
-
*/
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
483
|
-
*
|
|
484
|
-
* @public exported from `@promptbook/core`
|
|
485
|
-
*/
|
|
486
|
-
var UnexpectedError = /** @class */ (function (_super) {
|
|
487
|
-
__extends(UnexpectedError, _super);
|
|
488
|
-
function UnexpectedError(message) {
|
|
489
|
-
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 https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
490
|
-
_this.name = 'UnexpectedError';
|
|
491
|
-
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
492
|
-
return _this;
|
|
493
|
-
}
|
|
494
|
-
return UnexpectedError;
|
|
495
|
-
}(Error));
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Checks if the value is [🚉] serializable as JSON
|
|
499
|
-
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
500
|
-
*
|
|
501
|
-
* - Almost all primitives are serializable BUT:
|
|
502
|
-
* - `undefined` is not serializable
|
|
503
|
-
* - `NaN` is not serializable
|
|
504
|
-
* - Objects and arrays are serializable if all their properties are serializable
|
|
505
|
-
* - Functions are not serializable
|
|
506
|
-
* - Circular references are not serializable
|
|
507
|
-
* - `Date` objects are not serializable
|
|
508
|
-
* - `Map` and `Set` objects are not serializable
|
|
509
|
-
* - `RegExp` objects are not serializable
|
|
510
|
-
* - `Error` objects are not serializable
|
|
511
|
-
* - `Symbol` objects are not serializable
|
|
512
|
-
* - And much more...
|
|
513
|
-
*
|
|
514
|
-
* @throws UnexpectedError if the value is not serializable as JSON
|
|
515
|
-
* @public exported from `@promptbook/utils`
|
|
516
|
-
*/
|
|
517
|
-
function checkSerializableAsJson(name, value) {
|
|
518
|
-
var e_1, _a;
|
|
519
|
-
if (value === undefined) {
|
|
520
|
-
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
521
|
-
}
|
|
522
|
-
else if (value === null) {
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
else if (typeof value === 'boolean') {
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
else if (typeof value === 'number' && !isNaN(value)) {
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
else if (typeof value === 'string') {
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
else if (typeof value === 'symbol') {
|
|
535
|
-
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
536
|
-
}
|
|
537
|
-
else if (typeof value === 'function') {
|
|
538
|
-
throw new UnexpectedError("".concat(name, " is function"));
|
|
539
|
-
}
|
|
540
|
-
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
541
|
-
for (var i = 0; i < value.length; i++) {
|
|
542
|
-
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
else if (typeof value === 'object') {
|
|
546
|
-
if (value instanceof Date) {
|
|
547
|
-
throw new UnexpectedError(spaceTrim("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
548
|
-
}
|
|
549
|
-
else if (value instanceof Map) {
|
|
550
|
-
throw new UnexpectedError("".concat(name, " is Map"));
|
|
551
|
-
}
|
|
552
|
-
else if (value instanceof Set) {
|
|
553
|
-
throw new UnexpectedError("".concat(name, " is Set"));
|
|
554
|
-
}
|
|
555
|
-
else if (value instanceof RegExp) {
|
|
556
|
-
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
557
|
-
}
|
|
558
|
-
else if (value instanceof Error) {
|
|
559
|
-
throw new UnexpectedError(spaceTrim("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
try {
|
|
563
|
-
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
564
|
-
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
565
|
-
if (subValue === undefined) {
|
|
566
|
-
// Note: undefined in object is serializable - it is just omited
|
|
567
|
-
continue;
|
|
568
|
-
}
|
|
569
|
-
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
573
|
-
finally {
|
|
574
|
-
try {
|
|
575
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
576
|
-
}
|
|
577
|
-
finally { if (e_1) throw e_1.error; }
|
|
578
|
-
}
|
|
579
|
-
try {
|
|
580
|
-
JSON.stringify(value); // <- TODO: [0]
|
|
581
|
-
}
|
|
582
|
-
catch (error) {
|
|
583
|
-
if (!(error instanceof Error)) {
|
|
584
|
-
throw error;
|
|
585
|
-
}
|
|
586
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
587
|
-
}
|
|
588
|
-
/*
|
|
589
|
-
TODO: [0] Is there some more elegant way to check circular references?
|
|
590
|
-
const seen = new Set();
|
|
591
|
-
const stack = [{ value }];
|
|
592
|
-
while (stack.length > 0) {
|
|
593
|
-
const { value } = stack.pop()!;
|
|
594
|
-
if (typeof value === 'object' && value !== null) {
|
|
595
|
-
if (seen.has(value)) {
|
|
596
|
-
throw new UnexpectedError(`${name} has circular reference`);
|
|
597
|
-
}
|
|
598
|
-
seen.add(value);
|
|
599
|
-
if (Array.isArray(value)) {
|
|
600
|
-
stack.push(...value.map((value) => ({ value })));
|
|
601
|
-
} else {
|
|
602
|
-
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
*/
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
616
|
-
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
617
|
-
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
618
|
-
*/
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* @@@
|
|
622
|
-
* @@@
|
|
623
|
-
*
|
|
624
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
625
|
-
*
|
|
626
|
-
* @param name - Name of the object for debugging purposes
|
|
627
|
-
* @param objectValue - Object to be deeply frozen
|
|
628
|
-
* @returns The same object as the input, but deeply frozen
|
|
629
|
-
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
630
|
-
*/
|
|
631
|
-
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
632
|
-
checkSerializableAsJson(name, objectValue);
|
|
633
|
-
return $deepFreeze(objectValue);
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
637
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
638
|
-
*/
|
|
639
|
-
|
|
640
447
|
/**
|
|
641
448
|
* Warning message for the generated sections and files files
|
|
642
449
|
*
|
|
@@ -651,6 +458,18 @@ var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so t
|
|
|
651
458
|
* @public exported from `@promptbook/core`
|
|
652
459
|
*/
|
|
653
460
|
var NAME = "Promptbook";
|
|
461
|
+
/**
|
|
462
|
+
* Email of the responsible person
|
|
463
|
+
*
|
|
464
|
+
* @public exported from `@promptbook/core`
|
|
465
|
+
*/
|
|
466
|
+
var ADMIN_EMAIL = 'me@pavolhejny.com';
|
|
467
|
+
/**
|
|
468
|
+
* Name of the responsible person for the Promptbook on GitHub
|
|
469
|
+
*
|
|
470
|
+
* @public exported from `@promptbook/core`
|
|
471
|
+
*/
|
|
472
|
+
var ADMIN_GITHUB_NAME = 'hejny';
|
|
654
473
|
/**
|
|
655
474
|
* Claim for the Promptbook
|
|
656
475
|
*
|
|
@@ -774,7 +593,8 @@ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
|
774
593
|
*
|
|
775
594
|
* @public exported from `@promptbook/core`
|
|
776
595
|
*/
|
|
777
|
-
var RESERVED_PARAMETER_NAMES =
|
|
596
|
+
var RESERVED_PARAMETER_NAMES =
|
|
597
|
+
/* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
|
|
778
598
|
'content',
|
|
779
599
|
'context',
|
|
780
600
|
'knowledge',
|
|
@@ -784,7 +604,7 @@ var RESERVED_PARAMETER_NAMES = $asDeeplyFrozenSerializableJson('RESERVED_PARAMET
|
|
|
784
604
|
// <- TODO: list here all command names
|
|
785
605
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
786
606
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
787
|
-
]
|
|
607
|
+
];
|
|
788
608
|
/**
|
|
789
609
|
* @@@
|
|
790
610
|
*
|
|
@@ -902,6 +722,40 @@ var PipelineLogicError = /** @class */ (function (_super) {
|
|
|
902
722
|
return PipelineLogicError;
|
|
903
723
|
}(Error));
|
|
904
724
|
|
|
725
|
+
/**
|
|
726
|
+
* Make error report URL for the given error
|
|
727
|
+
*
|
|
728
|
+
* @private !!!!!!
|
|
729
|
+
*/
|
|
730
|
+
function getErrorReportUrl(error) {
|
|
731
|
+
var report = {
|
|
732
|
+
title: "\uD83D\uDC1C Error report from ".concat(NAME),
|
|
733
|
+
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 "); }),
|
|
734
|
+
};
|
|
735
|
+
var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
|
|
736
|
+
reportUrl.searchParams.set('labels', 'bug');
|
|
737
|
+
reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
|
|
738
|
+
reportUrl.searchParams.set('title', report.title);
|
|
739
|
+
reportUrl.searchParams.set('body', report.body);
|
|
740
|
+
return reportUrl;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
745
|
+
*
|
|
746
|
+
* @public exported from `@promptbook/core`
|
|
747
|
+
*/
|
|
748
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
749
|
+
__extends(UnexpectedError, _super);
|
|
750
|
+
function UnexpectedError(message) {
|
|
751
|
+
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;
|
|
752
|
+
_this.name = 'UnexpectedError';
|
|
753
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
754
|
+
return _this;
|
|
755
|
+
}
|
|
756
|
+
return UnexpectedError;
|
|
757
|
+
}(Error));
|
|
758
|
+
|
|
905
759
|
/**
|
|
906
760
|
* Tests if given string is valid semantic version
|
|
907
761
|
*
|
|
@@ -1382,6 +1236,183 @@ function extractParameterNames(template) {
|
|
|
1382
1236
|
return parameterNames;
|
|
1383
1237
|
}
|
|
1384
1238
|
|
|
1239
|
+
/**
|
|
1240
|
+
* @@@
|
|
1241
|
+
*
|
|
1242
|
+
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
1243
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1244
|
+
*
|
|
1245
|
+
* @returns The same object as the input, but deeply frozen
|
|
1246
|
+
* @public exported from `@promptbook/utils`
|
|
1247
|
+
*/
|
|
1248
|
+
function $deepFreeze(objectValue) {
|
|
1249
|
+
var e_1, _a;
|
|
1250
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1251
|
+
try {
|
|
1252
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
1253
|
+
var propertyName = propertyNames_1_1.value;
|
|
1254
|
+
var value = objectValue[propertyName];
|
|
1255
|
+
if (value && typeof value === 'object') {
|
|
1256
|
+
$deepFreeze(value);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1261
|
+
finally {
|
|
1262
|
+
try {
|
|
1263
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
1264
|
+
}
|
|
1265
|
+
finally { if (e_1) throw e_1.error; }
|
|
1266
|
+
}
|
|
1267
|
+
return Object.freeze(objectValue);
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1271
|
+
*/
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* Checks if the value is [🚉] serializable as JSON
|
|
1275
|
+
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
1276
|
+
*
|
|
1277
|
+
* - Almost all primitives are serializable BUT:
|
|
1278
|
+
* - `undefined` is not serializable
|
|
1279
|
+
* - `NaN` is not serializable
|
|
1280
|
+
* - Objects and arrays are serializable if all their properties are serializable
|
|
1281
|
+
* - Functions are not serializable
|
|
1282
|
+
* - Circular references are not serializable
|
|
1283
|
+
* - `Date` objects are not serializable
|
|
1284
|
+
* - `Map` and `Set` objects are not serializable
|
|
1285
|
+
* - `RegExp` objects are not serializable
|
|
1286
|
+
* - `Error` objects are not serializable
|
|
1287
|
+
* - `Symbol` objects are not serializable
|
|
1288
|
+
* - And much more...
|
|
1289
|
+
*
|
|
1290
|
+
* @throws UnexpectedError if the value is not serializable as JSON
|
|
1291
|
+
* @public exported from `@promptbook/utils`
|
|
1292
|
+
*/
|
|
1293
|
+
function checkSerializableAsJson(name, value) {
|
|
1294
|
+
var e_1, _a;
|
|
1295
|
+
if (value === undefined) {
|
|
1296
|
+
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
1297
|
+
}
|
|
1298
|
+
else if (value === null) {
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
else if (typeof value === 'boolean') {
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
else if (typeof value === 'number' && !isNaN(value)) {
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
else if (typeof value === 'string') {
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
else if (typeof value === 'symbol') {
|
|
1311
|
+
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
1312
|
+
}
|
|
1313
|
+
else if (typeof value === 'function') {
|
|
1314
|
+
throw new UnexpectedError("".concat(name, " is function"));
|
|
1315
|
+
}
|
|
1316
|
+
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
1317
|
+
for (var i = 0; i < value.length; i++) {
|
|
1318
|
+
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
else if (typeof value === 'object') {
|
|
1322
|
+
if (value instanceof Date) {
|
|
1323
|
+
throw new UnexpectedError(spaceTrim("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
1324
|
+
}
|
|
1325
|
+
else if (value instanceof Map) {
|
|
1326
|
+
throw new UnexpectedError("".concat(name, " is Map"));
|
|
1327
|
+
}
|
|
1328
|
+
else if (value instanceof Set) {
|
|
1329
|
+
throw new UnexpectedError("".concat(name, " is Set"));
|
|
1330
|
+
}
|
|
1331
|
+
else if (value instanceof RegExp) {
|
|
1332
|
+
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
1333
|
+
}
|
|
1334
|
+
else if (value instanceof Error) {
|
|
1335
|
+
throw new UnexpectedError(spaceTrim("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
1336
|
+
}
|
|
1337
|
+
else {
|
|
1338
|
+
try {
|
|
1339
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1340
|
+
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
1341
|
+
if (subValue === undefined) {
|
|
1342
|
+
// Note: undefined in object is serializable - it is just omited
|
|
1343
|
+
continue;
|
|
1344
|
+
}
|
|
1345
|
+
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1349
|
+
finally {
|
|
1350
|
+
try {
|
|
1351
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1352
|
+
}
|
|
1353
|
+
finally { if (e_1) throw e_1.error; }
|
|
1354
|
+
}
|
|
1355
|
+
try {
|
|
1356
|
+
JSON.stringify(value); // <- TODO: [0]
|
|
1357
|
+
}
|
|
1358
|
+
catch (error) {
|
|
1359
|
+
if (!(error instanceof Error)) {
|
|
1360
|
+
throw error;
|
|
1361
|
+
}
|
|
1362
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
1363
|
+
}
|
|
1364
|
+
/*
|
|
1365
|
+
TODO: [0] Is there some more elegant way to check circular references?
|
|
1366
|
+
const seen = new Set();
|
|
1367
|
+
const stack = [{ value }];
|
|
1368
|
+
while (stack.length > 0) {
|
|
1369
|
+
const { value } = stack.pop()!;
|
|
1370
|
+
if (typeof value === 'object' && value !== null) {
|
|
1371
|
+
if (seen.has(value)) {
|
|
1372
|
+
throw new UnexpectedError(`${name} has circular reference`);
|
|
1373
|
+
}
|
|
1374
|
+
seen.add(value);
|
|
1375
|
+
if (Array.isArray(value)) {
|
|
1376
|
+
stack.push(...value.map((value) => ({ value })));
|
|
1377
|
+
} else {
|
|
1378
|
+
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
*/
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
else {
|
|
1387
|
+
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1392
|
+
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
1393
|
+
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
1394
|
+
*/
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* @@@
|
|
1398
|
+
* @@@
|
|
1399
|
+
*
|
|
1400
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1401
|
+
*
|
|
1402
|
+
* @param name - Name of the object for debugging purposes
|
|
1403
|
+
* @param objectValue - Object to be deeply frozen
|
|
1404
|
+
* @returns The same object as the input, but deeply frozen
|
|
1405
|
+
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
1406
|
+
*/
|
|
1407
|
+
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
1408
|
+
checkSerializableAsJson(name, objectValue);
|
|
1409
|
+
return $deepFreeze(objectValue);
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1413
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1414
|
+
*/
|
|
1415
|
+
|
|
1385
1416
|
/**
|
|
1386
1417
|
* Unprepare just strips the preparation data of the pipeline
|
|
1387
1418
|
*
|
|
@@ -2649,6 +2680,7 @@ function serializeError(error) {
|
|
|
2649
2680
|
*/
|
|
2650
2681
|
function extractVariablesFromScript(script) {
|
|
2651
2682
|
var variables = new Set();
|
|
2683
|
+
var originalScript = script;
|
|
2652
2684
|
script = "(()=>{".concat(script, "})()");
|
|
2653
2685
|
try {
|
|
2654
2686
|
for (var i = 0; i < 100 /* <- TODO: This limit to configuration */; i++)
|
|
@@ -2680,7 +2712,9 @@ function extractVariablesFromScript(script) {
|
|
|
2680
2712
|
if (!(error instanceof Error)) {
|
|
2681
2713
|
throw error;
|
|
2682
2714
|
}
|
|
2683
|
-
throw new ParseError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n
|
|
2715
|
+
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)
|
|
2716
|
+
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
2717
|
+
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
2684
2718
|
}
|
|
2685
2719
|
return variables;
|
|
2686
2720
|
}
|
|
@@ -6138,7 +6172,7 @@ var sectionCommandParser = {
|
|
|
6138
6172
|
throw new ParseError(spaceTrim("\n Section type is already defined in the section.\n It can be defined only once.\n "));
|
|
6139
6173
|
}
|
|
6140
6174
|
$taskJson.isSectionTypeSet = true;
|
|
6141
|
-
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
6175
|
+
// TODO: [🍧][💩] Rearrange better - but at bottom and unwrap from function
|
|
6142
6176
|
var expectResultingParameterName = function () {
|
|
6143
6177
|
if ($taskJson.resultingParameterName) {
|
|
6144
6178
|
return;
|
|
@@ -7440,7 +7474,7 @@ var modelCommandParser = {
|
|
|
7440
7474
|
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
7441
7475
|
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
7442
7476
|
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
7443
|
-
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
7477
|
+
// <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
|
|
7444
7478
|
}
|
|
7445
7479
|
else {
|
|
7446
7480
|
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 ")));
|
|
@@ -8075,7 +8109,7 @@ var COMMANDS = [
|
|
|
8075
8109
|
personaCommandParser,
|
|
8076
8110
|
foreachCommandParser,
|
|
8077
8111
|
boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
|
|
8078
|
-
// <- 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
|
|
8112
|
+
// <- 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
|
|
8079
8113
|
];
|
|
8080
8114
|
/**
|
|
8081
8115
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -9005,11 +9039,11 @@ function addAutoGeneratedSection(content, options) {
|
|
|
9005
9039
|
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
9006
9040
|
if (placeForSection !== null) {
|
|
9007
9041
|
var _a = __read(placeForSection, 1), heading_1 = _a[0];
|
|
9008
|
-
return content.replace(heading_1, spaceTrim$1(function (block) { return "\n ".concat(block(contentToInsert), "\n
|
|
9042
|
+
return content.replace(heading_1, spaceTrim$1(function (block) { return "\n ".concat(block(contentToInsert), "\n\n ").concat(block(heading_1), "\n "); }));
|
|
9009
9043
|
}
|
|
9010
9044
|
console.warn("No place where to put the section <!--".concat(sectionName, "-->, using the end of the file"));
|
|
9011
|
-
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
9012
|
-
return spaceTrim$1(function (block) { return "\n ".concat(block(content), "\n
|
|
9045
|
+
// <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
|
|
9046
|
+
return spaceTrim$1(function (block) { return "\n ".concat(block(content), "\n\n ").concat(block(contentToInsert), "\n "); });
|
|
9013
9047
|
}
|
|
9014
9048
|
/**
|
|
9015
9049
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -9560,7 +9594,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
9560
9594
|
'\n\n' +
|
|
9561
9595
|
executionReportJson.promptExecutions
|
|
9562
9596
|
.map(function (promptExecution) {
|
|
9563
|
-
// TODO: Make some better system to convert
|
|
9597
|
+
// TODO: [💩] Make some better system to convert headings to links
|
|
9564
9598
|
var hash = normalizeToKebabCase(promptExecution.prompt.title);
|
|
9565
9599
|
if (/^\s*\p{Extended_Pictographic}/u.test(promptExecution.prompt.title)) {
|
|
9566
9600
|
hash = '-' + hash;
|
|
@@ -10795,5 +10829,5 @@ var PrefixStorage = /** @class */ (function () {
|
|
|
10795
10829
|
return PrefixStorage;
|
|
10796
10830
|
}());
|
|
10797
10831
|
|
|
10798
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, removePipelineCommand, renamePipelineParameter, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
10832
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, removePipelineCommand, renamePipelineParameter, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
10799
10833
|
//# sourceMappingURL=index.es.js.map
|