@promptbook/core 0.78.4 → 0.80.0-0

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.
Files changed (36) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +856 -568
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +4 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
  9. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -2
  10. package/esm/typings/src/config.d.ts +0 -25
  11. package/esm/typings/src/constants.d.ts +35 -0
  12. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  13. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  14. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +6 -1
  15. package/esm/typings/src/formfactors/index.d.ts +12 -2
  16. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +6 -1
  17. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
  18. package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
  19. package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
  20. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
  21. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  22. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  23. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
  24. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  25. package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
  26. package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
  27. package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
  28. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  29. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
  30. package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
  31. package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
  32. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
  33. package/package.json +2 -1
  34. package/umd/index.umd.js +856 -567
  35. package/umd/index.umd.js.map +1 -1
  36. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
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.78.3';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.79.0';
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
@@ -221,6 +221,7 @@ function capitalize(word) {
221
221
  /**
222
222
  * Converts promptbook in JSON format to string format
223
223
  *
224
+ * @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
224
225
  * @param pipelineJson Promptbook in JSON format (.book.json)
225
226
  * @returns Promptbook in string format (.book.md)
226
227
  * @public exported from `@promptbook/core`
@@ -582,41 +583,6 @@ var DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
582
583
  * @public exported from `@promptbook/core`
583
584
  */
584
585
  var DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
585
- /**
586
- * Nonce which is used for replacing things in strings
587
- *
588
- * @private within the repository
589
- */
590
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
591
- /**
592
- * The names of the parameters that are reserved for special purposes
593
- *
594
- * @public exported from `@promptbook/core`
595
- */
596
- var RESERVED_PARAMETER_NAMES =
597
- /* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
598
- 'content',
599
- 'context',
600
- 'knowledge',
601
- 'examples',
602
- 'modelName',
603
- 'currentDate',
604
- // <- TODO: list here all command names
605
- // <- TODO: Add more like 'date', 'modelName',...
606
- // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
607
- ];
608
- /**
609
- * @@@
610
- *
611
- * @private within the repository
612
- */
613
- var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
614
- /**
615
- * @@@
616
- *
617
- * @private within the repository
618
- */
619
- var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
620
586
  /**
621
587
  * The thresholds for the relative time in the `moment` NPM package.
622
588
  *
@@ -682,45 +648,59 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
682
648
  // Note: In normal situations, we check the pipeline logic:
683
649
  true);
684
650
  /**
685
- * TODO: Extract `constants.ts` from `config.ts`
686
651
  * Note: [💞] Ignore a discrepancy between file name and entity name
687
652
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
688
653
  */
689
654
 
690
655
  /**
691
- * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
656
+ * Orders JSON object by keys
692
657
  *
693
- * @public exported from `@promptbook/core`
694
- */
695
- var ParseError = /** @class */ (function (_super) {
696
- __extends(ParseError, _super);
697
- function ParseError(message) {
698
- var _this = _super.call(this, message) || this;
699
- _this.name = 'ParseError';
700
- Object.setPrototypeOf(_this, ParseError.prototype);
701
- return _this;
702
- }
703
- return ParseError;
704
- }(Error));
705
- /**
706
- * TODO: Maybe split `ParseError` and `ApplyError`
658
+ * @returns The same type of object as the input re-ordered
659
+ * @public exported from `@promptbook/utils`
707
660
  */
661
+ function orderJson(options) {
662
+ var value = options.value, order = options.order;
663
+ var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
664
+ return orderedValue;
665
+ }
708
666
 
709
667
  /**
710
- * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
668
+ * Freezes the given object and all its nested objects recursively
711
669
  *
712
- * @public exported from `@promptbook/core`
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`
713
675
  */
714
- var PipelineLogicError = /** @class */ (function (_super) {
715
- __extends(PipelineLogicError, _super);
716
- function PipelineLogicError(message) {
717
- var _this = _super.call(this, message) || this;
718
- _this.name = 'PipelineLogicError';
719
- Object.setPrototypeOf(_this, PipelineLogicError.prototype);
720
- return _this;
676
+ function $deepFreeze(objectValue) {
677
+ var e_1, _a;
678
+ if (Array.isArray(objectValue)) {
679
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
721
680
  }
722
- return PipelineLogicError;
723
- }(Error));
681
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
682
+ try {
683
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
684
+ var propertyName = propertyNames_1_1.value;
685
+ var value = objectValue[propertyName];
686
+ if (value && typeof value === 'object') {
687
+ $deepFreeze(value);
688
+ }
689
+ }
690
+ }
691
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
692
+ finally {
693
+ try {
694
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
695
+ }
696
+ finally { if (e_1) throw e_1.error; }
697
+ }
698
+ Object.freeze(objectValue);
699
+ return objectValue;
700
+ }
701
+ /**
702
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
703
+ */
724
704
 
725
705
  /**
726
706
  * Make error report URL for the given error
@@ -756,6 +736,283 @@ var UnexpectedError = /** @class */ (function (_super) {
756
736
  return UnexpectedError;
757
737
  }(Error));
758
738
 
739
+ /**
740
+ * Checks if the value is [🚉] serializable as JSON
741
+ * If not, throws an UnexpectedError with a rich error message and tracking
742
+ *
743
+ * - Almost all primitives are serializable BUT:
744
+ * - `undefined` is not serializable
745
+ * - `NaN` is not serializable
746
+ * - Objects and arrays are serializable if all their properties are serializable
747
+ * - Functions are not serializable
748
+ * - Circular references are not serializable
749
+ * - `Date` objects are not serializable
750
+ * - `Map` and `Set` objects are not serializable
751
+ * - `RegExp` objects are not serializable
752
+ * - `Error` objects are not serializable
753
+ * - `Symbol` objects are not serializable
754
+ * - And much more...
755
+ *
756
+ * @throws UnexpectedError if the value is not serializable as JSON
757
+ * @public exported from `@promptbook/utils`
758
+ */
759
+ function checkSerializableAsJson(options) {
760
+ var e_1, _a;
761
+ var value = options.value, name = options.name, message = options.message;
762
+ if (value === undefined) {
763
+ throw new UnexpectedError("".concat(name, " is undefined"));
764
+ }
765
+ else if (value === null) {
766
+ return;
767
+ }
768
+ else if (typeof value === 'boolean') {
769
+ return;
770
+ }
771
+ else if (typeof value === 'number' && !isNaN(value)) {
772
+ return;
773
+ }
774
+ else if (typeof value === 'string') {
775
+ return;
776
+ }
777
+ else if (typeof value === 'symbol') {
778
+ throw new UnexpectedError("".concat(name, " is symbol"));
779
+ }
780
+ else if (typeof value === 'function') {
781
+ throw new UnexpectedError("".concat(name, " is function"));
782
+ }
783
+ else if (typeof value === 'object' && Array.isArray(value)) {
784
+ for (var i = 0; i < value.length; i++) {
785
+ checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
786
+ }
787
+ }
788
+ else if (typeof value === 'object') {
789
+ if (value instanceof Date) {
790
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is Date\n\n Use `string_date_iso8601` instead\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
791
+ }
792
+ else if (value instanceof Map) {
793
+ throw new UnexpectedError("".concat(name, " is Map"));
794
+ }
795
+ else if (value instanceof Set) {
796
+ throw new UnexpectedError("".concat(name, " is Set"));
797
+ }
798
+ else if (value instanceof RegExp) {
799
+ throw new UnexpectedError("".concat(name, " is RegExp"));
800
+ }
801
+ else if (value instanceof Error) {
802
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is unserialized Error\n\n Use function `serializeError`\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n\n "); }));
803
+ }
804
+ else {
805
+ try {
806
+ for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
807
+ var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
808
+ if (subValue === undefined) {
809
+ // Note: undefined in object is serializable - it is just omited
810
+ continue;
811
+ }
812
+ checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
813
+ }
814
+ }
815
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
816
+ finally {
817
+ try {
818
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
819
+ }
820
+ finally { if (e_1) throw e_1.error; }
821
+ }
822
+ try {
823
+ JSON.stringify(value); // <- TODO: [0]
824
+ }
825
+ catch (error) {
826
+ if (!(error instanceof Error)) {
827
+ throw error;
828
+ }
829
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.toString()), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
830
+ }
831
+ /*
832
+ TODO: [0] Is there some more elegant way to check circular references?
833
+ const seen = new Set();
834
+ const stack = [{ value }];
835
+ while (stack.length > 0) {
836
+ const { value } = stack.pop()!;
837
+ if (typeof value === 'object' && value !== null) {
838
+ if (seen.has(value)) {
839
+ throw new UnexpectedError(`${name} has circular reference`);
840
+ }
841
+ seen.add(value);
842
+ if (Array.isArray(value)) {
843
+ stack.push(...value.map((value) => ({ value })));
844
+ } else {
845
+ stack.push(...Object.values(value).map((value) => ({ value })));
846
+ }
847
+ }
848
+ }
849
+ */
850
+ return;
851
+ }
852
+ }
853
+ else {
854
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
855
+ }
856
+ }
857
+ /**
858
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
859
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
860
+ * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
861
+ */
862
+
863
+ /**
864
+ * @@@
865
+ *
866
+ * @public exported from `@promptbook/utils`
867
+ */
868
+ function deepClone(objectValue) {
869
+ return JSON.parse(JSON.stringify(objectValue));
870
+ /*
871
+ !!!!!!!!
872
+ TODO: [🧠] Is there a better implementation?
873
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
874
+ > for (const propertyName of propertyNames) {
875
+ > const value = (objectValue as really_any)[propertyName];
876
+ > if (value && typeof value === 'object') {
877
+ > deepClone(value);
878
+ > }
879
+ > }
880
+ > return Object.assign({}, objectValue);
881
+ */
882
+ }
883
+ /**
884
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
885
+ */
886
+
887
+ /**
888
+ * Utility to export a JSON object from a function
889
+ *
890
+ * 1) Checks if the value is serializable as JSON
891
+ * 2) Makes a deep clone of the object
892
+ * 2) Orders the object properties
893
+ * 2) Deeply freezes the cloned object
894
+ *
895
+ * Note: This function does not mutates the given object
896
+ *
897
+ * @returns The same type of object as the input but read-only and re-ordered
898
+ * @public exported from `@promptbook/utils`
899
+ */
900
+ function exportJson(options) {
901
+ var name = options.name, value = options.value, order = options.order, message = options.message;
902
+ checkSerializableAsJson({ name: name, value: value, message: message });
903
+ var orderedValue =
904
+ // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
905
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
906
+ // @ts-ignore
907
+ order === undefined
908
+ ? deepClone(value)
909
+ : orderJson({
910
+ value: value,
911
+ // <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
912
+ order: order,
913
+ });
914
+ $deepFreeze(orderedValue);
915
+ return orderedValue;
916
+ }
917
+ /**
918
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
919
+ */
920
+
921
+ /**
922
+ * Order of keys in the pipeline JSON
923
+ *
924
+ * @public exported from `@promptbook/core`
925
+ */
926
+ var ORDER_OF_PIPELINE_JSON = [
927
+ 'title',
928
+ 'pipelineUrl',
929
+ 'bookVersion',
930
+ 'description',
931
+ 'formfactorName',
932
+ 'parameters',
933
+ 'tasks',
934
+ 'personas',
935
+ 'preparations',
936
+ 'knowledgeSources',
937
+ 'knowledgePieces',
938
+ ];
939
+ /**
940
+ * Nonce which is used for replacing things in strings
941
+ *
942
+ * @private within the repository
943
+ */
944
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
945
+ /**
946
+ * @@@
947
+ *
948
+ * @private within the repository
949
+ */
950
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
951
+ /**
952
+ * @@@
953
+ *
954
+ * @private within the repository
955
+ */
956
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
957
+ /**
958
+ * The names of the parameters that are reserved for special purposes
959
+ *
960
+ * @public exported from `@promptbook/core`
961
+ */
962
+ var RESERVED_PARAMETER_NAMES = exportJson({
963
+ name: 'RESERVED_PARAMETER_NAMES',
964
+ message: "The names of the parameters that are reserved for special purposes",
965
+ value: [
966
+ 'content',
967
+ 'context',
968
+ 'knowledge',
969
+ 'examples',
970
+ 'modelName',
971
+ 'currentDate',
972
+ // <- TODO: list here all command names
973
+ // <- TODO: Add more like 'date', 'modelName',...
974
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
975
+ ],
976
+ });
977
+ /**
978
+ * Note: [💞] Ignore a discrepancy between file name and entity name
979
+ */
980
+
981
+ /**
982
+ * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
983
+ *
984
+ * @public exported from `@promptbook/core`
985
+ */
986
+ var ParseError = /** @class */ (function (_super) {
987
+ __extends(ParseError, _super);
988
+ function ParseError(message) {
989
+ var _this = _super.call(this, message) || this;
990
+ _this.name = 'ParseError';
991
+ Object.setPrototypeOf(_this, ParseError.prototype);
992
+ return _this;
993
+ }
994
+ return ParseError;
995
+ }(Error));
996
+ /**
997
+ * TODO: Maybe split `ParseError` and `ApplyError`
998
+ */
999
+
1000
+ /**
1001
+ * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
1002
+ *
1003
+ * @public exported from `@promptbook/core`
1004
+ */
1005
+ var PipelineLogicError = /** @class */ (function (_super) {
1006
+ __extends(PipelineLogicError, _super);
1007
+ function PipelineLogicError(message) {
1008
+ var _this = _super.call(this, message) || this;
1009
+ _this.name = 'PipelineLogicError';
1010
+ Object.setPrototypeOf(_this, PipelineLogicError.prototype);
1011
+ return _this;
1012
+ }
1013
+ return PipelineLogicError;
1014
+ }(Error));
1015
+
759
1016
  /**
760
1017
  * Tests if given string is valid semantic version
761
1018
  *
@@ -993,6 +1250,21 @@ function validatePipelineCore(pipeline) {
993
1250
  }
994
1251
  };
995
1252
  try {
1253
+ /*
1254
+ TODO: [🧠][🅾] Should be empty pipeline valid or not
1255
+ // Note: Check that pipeline has some tasks
1256
+ if (pipeline.tasks.length === 0) {
1257
+ throw new PipelineLogicError(
1258
+ spaceTrim(
1259
+ (block) => `
1260
+ Pipeline must have at least one task
1261
+
1262
+ ${block(pipelineIdentification)}
1263
+ `,
1264
+ ),
1265
+ );
1266
+ }
1267
+ */
996
1268
  // Note: Check each parameter individually
997
1269
  for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
998
1270
  var parameter = _e.value;
@@ -1153,6 +1425,9 @@ function validatePipelineCore(pipeline) {
1153
1425
  while (unresovedTasks.length > 0) {
1154
1426
  _loop_3();
1155
1427
  }
1428
+ // Note: Check that formfactor is corresponding to the pipeline interface
1429
+ // TODO: !!!!!! Implement this
1430
+ // pipeline.formfactorName
1156
1431
  }
1157
1432
  /**
1158
1433
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -1223,195 +1498,18 @@ function extractParameterNames(template) {
1223
1498
  for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
1224
1499
  var match = matches_1_1.value;
1225
1500
  var parameterName = match[0].slice(1, -1);
1226
- parameterNames.add(parameterName);
1227
- }
1228
- }
1229
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1230
- finally {
1231
- try {
1232
- if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
1233
- }
1234
- finally { if (e_1) throw e_1.error; }
1235
- }
1236
- return parameterNames;
1237
- }
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;
1501
+ parameterNames.add(parameterName);
1384
1502
  }
1385
1503
  }
1386
- else {
1387
- throw new UnexpectedError("".concat(name, " is unknown"));
1504
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1505
+ finally {
1506
+ try {
1507
+ if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
1508
+ }
1509
+ finally { if (e_1) throw e_1.error; }
1388
1510
  }
1511
+ return parameterNames;
1389
1512
  }
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
1513
 
1416
1514
  /**
1417
1515
  * Unprepare just strips the preparation data of the pipeline
@@ -1430,7 +1528,12 @@ function unpreparePipeline(pipeline) {
1430
1528
  delete taskUnprepared.preparedContent;
1431
1529
  return taskUnprepared;
1432
1530
  });
1433
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1531
+ return exportJson({
1532
+ name: 'pipelineJson',
1533
+ message: "Result of `unpreparePipeline`",
1534
+ order: ORDER_OF_PIPELINE_JSON,
1535
+ value: __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }),
1536
+ });
1434
1537
  }
1435
1538
  /**
1436
1539
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -1893,29 +1996,6 @@ var UNCERTAIN_USAGE = $deepFreeze({
1893
1996
  * Note: [💞] Ignore a discrepancy between file name and entity name
1894
1997
  */
1895
1998
 
1896
- /**
1897
- * @@@
1898
- *
1899
- * @public exported from `@promptbook/utils`
1900
- */
1901
- function deepClone(objectValue) {
1902
- return JSON.parse(JSON.stringify(objectValue));
1903
- /*
1904
- TODO: [🧠] Is there a better implementation?
1905
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
1906
- > for (const propertyName of propertyNames) {
1907
- > const value = (objectValue as really_any)[propertyName];
1908
- > if (value && typeof value === 'object') {
1909
- > deepClone(value);
1910
- > }
1911
- > }
1912
- > return Object.assign({}, objectValue);
1913
- */
1914
- }
1915
- /**
1916
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1917
- */
1918
-
1919
1999
  /**
1920
2000
  * Function `addUsage` will add multiple usages into one
1921
2001
  *
@@ -2383,7 +2463,7 @@ function joinLlmExecutionTools() {
2383
2463
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2384
2464
  */
2385
2465
 
2386
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-persona.book.md"}];
2466
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-persona.book.md"}];
2387
2467
 
2388
2468
  /**
2389
2469
  * This error indicates problems parsing the format value
@@ -4655,16 +4735,21 @@ function executePipeline(options) {
4655
4735
  // Note: Wait a short time to prevent race conditions
4656
4736
  _g.sent();
4657
4737
  _g.label = 6;
4658
- case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
4659
- isSuccessful: false,
4660
- errors: __spreadArray([
4661
- new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
4662
- ], __read(errors), false).map(serializeError),
4663
- warnings: [],
4664
- executionReport: executionReport,
4665
- outputParameters: {},
4666
- usage: ZERO_USAGE,
4667
- preparedPipeline: preparedPipeline,
4738
+ case 6: return [2 /*return*/, exportJson({
4739
+ name: "executionReport",
4740
+ message: "Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"),
4741
+ order: [],
4742
+ value: {
4743
+ isSuccessful: false,
4744
+ errors: __spreadArray([
4745
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
4746
+ ], __read(errors), false).map(serializeError),
4747
+ warnings: [],
4748
+ executionReport: executionReport,
4749
+ outputParameters: {},
4750
+ usage: ZERO_USAGE,
4751
+ preparedPipeline: preparedPipeline,
4752
+ },
4668
4753
  })];
4669
4754
  case 7:
4670
4755
  _b = _a.next();
@@ -4703,16 +4788,21 @@ function executePipeline(options) {
4703
4788
  // Note: Wait a short time to prevent race conditions
4704
4789
  _h.sent();
4705
4790
  _h.label = 3;
4706
- 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 "); }), {
4707
- isSuccessful: false,
4708
- errors: __spreadArray([
4709
- 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 "); }))
4710
- ], __read(errors), false).map(serializeError),
4711
- warnings: warnings.map(serializeError),
4712
- executionReport: executionReport,
4713
- outputParameters: {},
4714
- usage: ZERO_USAGE,
4715
- preparedPipeline: preparedPipeline,
4791
+ case 3: return [2 /*return*/, { value: exportJson({
4792
+ name: 'pipelineExecutorResult',
4793
+ message: spaceTrim$1(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }),
4794
+ order: [],
4795
+ value: {
4796
+ isSuccessful: false,
4797
+ errors: __spreadArray([
4798
+ 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 "); }))
4799
+ ], __read(errors), false).map(serializeError),
4800
+ warnings: warnings.map(serializeError),
4801
+ executionReport: executionReport,
4802
+ outputParameters: {},
4803
+ usage: ZERO_USAGE,
4804
+ preparedPipeline: preparedPipeline,
4805
+ },
4716
4806
  }) }];
4717
4807
  case 4: return [2 /*return*/];
4718
4808
  }
@@ -4866,14 +4956,19 @@ function executePipeline(options) {
4866
4956
  // Note: Wait a short time to prevent race conditions
4867
4957
  _g.sent();
4868
4958
  _g.label = 27;
4869
- case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
4870
- isSuccessful: false,
4871
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
4872
- warnings: warnings.map(serializeError),
4873
- usage: usage_1,
4874
- executionReport: executionReport,
4875
- outputParameters: outputParameters_1,
4876
- preparedPipeline: preparedPipeline,
4959
+ case 27: return [2 /*return*/, exportJson({
4960
+ name: 'pipelineExecutorResult',
4961
+ message: "Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult",
4962
+ order: [],
4963
+ value: {
4964
+ isSuccessful: false,
4965
+ errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
4966
+ warnings: warnings.map(serializeError),
4967
+ usage: usage_1,
4968
+ executionReport: executionReport,
4969
+ outputParameters: outputParameters_1,
4970
+ preparedPipeline: preparedPipeline,
4971
+ },
4877
4972
  })];
4878
4973
  case 28:
4879
4974
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
@@ -4894,14 +4989,19 @@ function executePipeline(options) {
4894
4989
  // Note: Wait a short time to prevent race conditions
4895
4990
  _g.sent();
4896
4991
  _g.label = 30;
4897
- case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
4898
- isSuccessful: true,
4899
- errors: errors.map(serializeError),
4900
- warnings: warnings.map(serializeError),
4901
- usage: usage,
4902
- executionReport: executionReport,
4903
- outputParameters: outputParameters,
4904
- preparedPipeline: preparedPipeline,
4992
+ case 30: return [2 /*return*/, exportJson({
4993
+ name: 'pipelineExecutorResult',
4994
+ message: "Successful PipelineExecutorResult",
4995
+ order: [],
4996
+ value: {
4997
+ isSuccessful: true,
4998
+ errors: errors.map(serializeError),
4999
+ warnings: warnings.map(serializeError),
5000
+ usage: usage,
5001
+ executionReport: executionReport,
5002
+ outputParameters: outputParameters,
5003
+ preparedPipeline: preparedPipeline,
5004
+ },
4905
5005
  })];
4906
5006
  }
4907
5007
  });
@@ -5772,36 +5872,6 @@ TODO: [🧊] This is how it can look in future
5772
5872
  * [ ] One piece can have multiple sources
5773
5873
  */
5774
5874
 
5775
- /**
5776
- * @@@
5777
- *
5778
- * Note: It is usefull @@@
5779
- *
5780
- * @param pipeline
5781
- * @public exported from `@promptbook/utils`
5782
- */
5783
- function clonePipeline(pipeline) {
5784
- // Note: Not using spread operator (...) because @@@
5785
- var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
5786
- return {
5787
- pipelineUrl: pipelineUrl,
5788
- sourceFile: sourceFile,
5789
- title: title,
5790
- bookVersion: bookVersion,
5791
- description: description,
5792
- formfactorName: formfactorName,
5793
- parameters: parameters,
5794
- tasks: tasks,
5795
- knowledgeSources: knowledgeSources,
5796
- knowledgePieces: knowledgePieces,
5797
- personas: personas,
5798
- preparations: preparations,
5799
- };
5800
- }
5801
- /**
5802
- * TODO: [🍙] Make some standard order of json properties
5803
- */
5804
-
5805
5875
  /**
5806
5876
  * @@@
5807
5877
  *
@@ -5842,6 +5912,7 @@ function prepareTasks(pipeline, tools, options) {
5842
5912
  });
5843
5913
  }
5844
5914
  /**
5915
+ * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
5845
5916
  * TODO: [🧠] Add context to each task (if missing)
5846
5917
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
5847
5918
  * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
@@ -5930,11 +6001,19 @@ function preparePipeline(pipeline, tools, options) {
5930
6001
  case 3:
5931
6002
  tasksPrepared = (_c.sent()).tasksPrepared;
5932
6003
  // ----- /Tasks preparation -----
6004
+ // TODO: [😂] Use here all `AsyncHighLevelAbstraction`
5933
6005
  // Note: Count total usage
5934
6006
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
5935
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
5936
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
5937
- knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
6007
+ return [2 /*return*/, exportJson({
6008
+ name: 'pipelineJson',
6009
+ message: "Result of `preparePipeline`",
6010
+ order: ORDER_OF_PIPELINE_JSON,
6011
+ value: __assign(__assign({}, pipeline), {
6012
+ // <- TODO: Probbably deeply clone the pipeline because `$exportJson` freezes the subobjects
6013
+ knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
6014
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
6015
+ personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }),
6016
+ })];
5938
6017
  }
5939
6018
  });
5940
6019
  });
@@ -6198,7 +6277,8 @@ var sectionCommandParser = {
6198
6277
  expectResultingParameterName();
6199
6278
  var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $taskJson.resultingParameterName; });
6200
6279
  if (parameter === undefined) {
6201
- throw new ParseError("Can not find parameter {".concat($taskJson.resultingParameterName, "} to assign example value on it"));
6280
+ // TODO: !!!!!! Change to logic error for higher level abstractions to work
6281
+ throw new ParseError("Parameter `{".concat($taskJson.resultingParameterName, "}` is not defined so can not define example value of it"));
6202
6282
  }
6203
6283
  parameter.exampleValues = parameter.exampleValues || [];
6204
6284
  parameter.exampleValues.push($taskJson.content);
@@ -7107,7 +7187,13 @@ var GeneratorFormfactorDefinition = {
7107
7187
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
7108
7188
  pipelineInterface: {
7109
7189
  inputParameters: [
7110
- /* @@@ */
7190
+ /* @@@ */
7191
+ {
7192
+ name: 'nonce',
7193
+ description: 'Just to prevent GENERATOR to be set as implicit formfactor',
7194
+ isInput: true,
7195
+ isOutput: false,
7196
+ },
7111
7197
  ],
7112
7198
  outputParameters: [
7113
7199
  /* @@@ */
@@ -7153,7 +7239,13 @@ var MatcherFormfactorDefinition = {
7153
7239
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
7154
7240
  pipelineInterface: {
7155
7241
  inputParameters: [
7156
- /* @@@ */
7242
+ /* @@@ */
7243
+ {
7244
+ name: 'nonce',
7245
+ description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
7246
+ isInput: true,
7247
+ isOutput: false,
7248
+ },
7157
7249
  ],
7158
7250
  outputParameters: [
7159
7251
  /* @@@ */
@@ -7302,6 +7394,9 @@ var formfactorCommandParser = {
7302
7394
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7303
7395
  */
7304
7396
  $applyToPipelineJson: function (command, $pipelineJson) {
7397
+ if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
7398
+ throw new ParseError(spaceTrim("\n Redefinition of `FORMFACTOR` in the pipeline head\n\n You have used:\n 1) FORMFACTOR `".concat($pipelineJson.formfactorName, "`\n 2) FORMFACTOR `").concat(command.formfactorName, "`\n ")));
7399
+ }
7305
7400
  $pipelineJson.formfactorName = command.formfactorName;
7306
7401
  },
7307
7402
  /**
@@ -7489,7 +7584,7 @@ var modelCommandParser = {
7489
7584
  // <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
7490
7585
  }
7491
7586
  else {
7492
- 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 ")));
7587
+ throw new ParseError(spaceTrim("\n Redefinition of `MODEL ".concat(command.key, "` in the pipeline head\n\n You have used:\n 1) `MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "`\n 2) `MODEL ").concat(command.key, " ").concat(command.value, "`\n ")));
7493
7588
  }
7494
7589
  }
7495
7590
  $pipelineJson.defaultModelRequirements[command.key] = command.value;
@@ -8241,71 +8336,360 @@ function parseCommand(raw, usagePlace) {
8241
8336
  return command;
8242
8337
  }
8243
8338
  }
8244
- throw new ParseError(spaceTrim$1(function (block) {
8245
- return "\n Malformed or unknown command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
8246
- }));
8339
+ throw new ParseError(spaceTrim$1(function (block) {
8340
+ return "\n Malformed or unknown command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
8341
+ }));
8342
+ }
8343
+ /**
8344
+ * @@@
8345
+ */
8346
+ function getSupportedCommandsMessage() {
8347
+ return COMMANDS.flatMap(function (_a) {
8348
+ var name = _a.name, aliasNames = _a.aliasNames, description = _a.description, documentationUrl = _a.documentationUrl;
8349
+ // <- Note: [🦦] Its strange that this type assertion is needed
8350
+ return __spreadArray([
8351
+ "- **".concat(name, "** ").concat(description, ", see [discussion](").concat(documentationUrl, ")")
8352
+ ], __read((aliasNames || []).map(function (aliasName) { return " - **".concat(aliasName, "** Alias for **").concat(name, "**"); })), false);
8353
+ }).join('\n');
8354
+ }
8355
+ /**
8356
+ * @@@
8357
+ */
8358
+ function parseCommandVariant(input) {
8359
+ var e_1, _a;
8360
+ var commandNameRaw = input.commandNameRaw, usagePlace = input.usagePlace, normalized = input.normalized, args = input.args, raw = input.raw, rawArgs = input.rawArgs;
8361
+ var commandName = normalizeTo_SCREAMING_CASE(commandNameRaw);
8362
+ var _loop_1 = function (commandParser) {
8363
+ // <- Note: [🦦] Its strange that this type assertion is needed
8364
+ var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTask = commandParser.isUsedInPipelineTask, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
8365
+ if (just(false)) ;
8366
+ else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
8367
+ return "continue";
8368
+ }
8369
+ else if (usagePlace === 'PIPELINE_TASK' && !isUsedInPipelineTask) {
8370
+ return "continue";
8371
+ }
8372
+ var names = __spreadArray(__spreadArray([name_1], __read((aliasNames || [])), false), __read((deprecatedNames || [])), false);
8373
+ if (names.includes(commandName)) {
8374
+ try {
8375
+ return { value: parse({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args }) };
8376
+ }
8377
+ catch (error) {
8378
+ if (!(error instanceof ParseError)) {
8379
+ throw error;
8380
+ }
8381
+ throw new ParseError(spaceTrim$1(function (block) {
8382
+ 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 ");
8383
+ }));
8384
+ }
8385
+ }
8386
+ };
8387
+ try {
8388
+ for (var _b = __values(COMMANDS), _c = _b.next(); !_c.done; _c = _b.next()) {
8389
+ var commandParser = _c.value;
8390
+ var state_1 = _loop_1(commandParser);
8391
+ if (typeof state_1 === "object")
8392
+ return state_1.value;
8393
+ }
8394
+ }
8395
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8396
+ finally {
8397
+ try {
8398
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8399
+ }
8400
+ finally { if (e_1) throw e_1.error; }
8401
+ }
8402
+ return null;
8403
+ }
8404
+
8405
+ /**
8406
+ * @@@
8407
+ *
8408
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
8409
+ * @see https://github.com/webgptorg/promptbook/discussions/171
8410
+ *
8411
+ * @public exported from `@promptbook/core`
8412
+ */
8413
+ function getPipelineInterface(pipeline) {
8414
+ var e_1, _a, e_2, _b;
8415
+ var pipelineInterface = {
8416
+ inputParameters: [],
8417
+ outputParameters: [],
8418
+ };
8419
+ try {
8420
+ for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
8421
+ var parameter = _d.value;
8422
+ var isInput = parameter.isInput, isOutput = parameter.isOutput;
8423
+ if (isInput) {
8424
+ pipelineInterface.inputParameters.push(deepClone(parameter));
8425
+ }
8426
+ if (isOutput) {
8427
+ pipelineInterface.outputParameters.push(deepClone(parameter));
8428
+ }
8429
+ }
8430
+ }
8431
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8432
+ finally {
8433
+ try {
8434
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
8435
+ }
8436
+ finally { if (e_1) throw e_1.error; }
8437
+ }
8438
+ try {
8439
+ for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
8440
+ var key = _f.value;
8441
+ pipelineInterface[key].sort(function (_a, _b) {
8442
+ var name1 = _a.name;
8443
+ var name2 = _b.name;
8444
+ return name1.localeCompare(name2);
8445
+ });
8446
+ }
8447
+ }
8448
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
8449
+ finally {
8450
+ try {
8451
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
8452
+ }
8453
+ finally { if (e_2) throw e_2.error; }
8454
+ }
8455
+ return exportJson({
8456
+ name: "pipelineInterface",
8457
+ message: "Result of `getPipelineInterface`",
8458
+ order: ['inputParameters', 'outputParameters'],
8459
+ value: pipelineInterface,
8460
+ });
8461
+ }
8462
+
8463
+ /**
8464
+ * @@@
8465
+ *
8466
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
8467
+ * @see https://github.com/webgptorg/promptbook/discussions/171
8468
+ *
8469
+ * @public exported from `@promptbook/core`
8470
+ */
8471
+ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
8472
+ var e_1, _a, e_2, _b;
8473
+ try {
8474
+ for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
8475
+ var whichParameters = _d.value;
8476
+ var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
8477
+ var parameters2 = pipelineInterface2[whichParameters];
8478
+ if (parameters1.length !== parameters2.length) {
8479
+ return false;
8480
+ }
8481
+ var _loop_1 = function (parameter) {
8482
+ var matchingParameter = parameters2.find(function (_a) {
8483
+ var name = _a.name;
8484
+ return name === parameter.name;
8485
+ });
8486
+ if (!matchingParameter) {
8487
+ return { value: false };
8488
+ }
8489
+ // Note: Do not compare description, it is not relevant for compatibility
8490
+ if (matchingParameter.isInput !== parameter.isInput) {
8491
+ return { value: false };
8492
+ }
8493
+ if (matchingParameter.isOutput !== parameter.isOutput) {
8494
+ return { value: false };
8495
+ }
8496
+ };
8497
+ try {
8498
+ for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
8499
+ var parameter = parameters1_1_1.value;
8500
+ var state_1 = _loop_1(parameter);
8501
+ if (typeof state_1 === "object")
8502
+ return state_1.value;
8503
+ }
8504
+ }
8505
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
8506
+ finally {
8507
+ try {
8508
+ if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
8509
+ }
8510
+ finally { if (e_2) throw e_2.error; }
8511
+ }
8512
+ }
8513
+ }
8514
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8515
+ finally {
8516
+ try {
8517
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
8518
+ }
8519
+ finally { if (e_1) throw e_1.error; }
8520
+ }
8521
+ return true;
8247
8522
  }
8523
+
8248
8524
  /**
8249
8525
  * @@@
8526
+ *
8527
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
8528
+ * @see https://github.com/webgptorg/promptbook/discussions/171
8529
+ *
8530
+ * @public exported from `@promptbook/core`
8250
8531
  */
8251
- function getSupportedCommandsMessage() {
8252
- return COMMANDS.flatMap(function (_a) {
8253
- var name = _a.name, aliasNames = _a.aliasNames, description = _a.description, documentationUrl = _a.documentationUrl;
8254
- // <- Note: [🦦] Its strange that this type assertion is needed
8255
- return __spreadArray([
8256
- "- **".concat(name, "** ").concat(description, ", see [discussion](").concat(documentationUrl, ")")
8257
- ], __read((aliasNames || []).map(function (aliasName) { return " - **".concat(aliasName, "** Alias for **").concat(name, "**"); })), false);
8258
- }).join('\n');
8532
+ function isPipelineImplementingInterface(options) {
8533
+ var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
8534
+ return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
8259
8535
  }
8536
+
8260
8537
  /**
8261
- * @@@
8538
+ * Set formfactor based on the pipeline interface e
8539
+ *
8540
+ * @private
8262
8541
  */
8263
- function parseCommandVariant(input) {
8264
- var e_1, _a;
8265
- var commandNameRaw = input.commandNameRaw, usagePlace = input.usagePlace, normalized = input.normalized, args = input.args, raw = input.raw, rawArgs = input.rawArgs;
8266
- var commandName = normalizeTo_SCREAMING_CASE(commandNameRaw);
8267
- var _loop_1 = function (commandParser) {
8268
- // <- Note: [🦦] Its strange that this type assertion is needed
8269
- var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTask = commandParser.isUsedInPipelineTask, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
8270
- if (just(false)) ;
8271
- else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
8272
- return "continue";
8542
+ var ImplicitFormfactorHla = {
8543
+ type: 'SYNC',
8544
+ $applyToPipelineJson: function ($pipelineJson) {
8545
+ var e_1, _a;
8546
+ if ($pipelineJson.formfactorName !== undefined) {
8547
+ // Note: When formfactor is already set, do nothing
8548
+ return;
8273
8549
  }
8274
- else if (usagePlace === 'PIPELINE_TASK' && !isUsedInPipelineTask) {
8275
- return "continue";
8550
+ try {
8551
+ for (var _b = __values(FORMFACTOR_DEFINITIONS.filter(function (_a) {
8552
+ var name = _a.name;
8553
+ return name !== 'GENERIC';
8554
+ })), _c = _b.next(); !_c.done; _c = _b.next()) {
8555
+ var formfactorDefinition = _c.value;
8556
+ // <- Note: [♓️][💩] This is the order of the formfactors, make some explicit priority
8557
+ var name_1 = formfactorDefinition.name, pipelineInterface = formfactorDefinition.pipelineInterface;
8558
+ var isCompatible = isPipelineImplementingInterface({
8559
+ pipeline: __assign({ formfactorName: name_1 }, $pipelineJson),
8560
+ pipelineInterface: pipelineInterface,
8561
+ });
8562
+ /*/
8563
+ console.log({
8564
+ subject: `${$pipelineJson.title} implements ${name}`,
8565
+ pipelineTitle: $pipelineJson.title,
8566
+ formfactorName: name,
8567
+ isCompatible,
8568
+ formfactorInterface: pipelineInterface,
8569
+ pipelineInterface: getPipelineInterface($pipelineJson as PipelineJson),
8570
+ });
8571
+ /**/
8572
+ if (isCompatible) {
8573
+ $pipelineJson.formfactorName = name_1;
8574
+ return;
8575
+ }
8576
+ }
8276
8577
  }
8277
- var names = __spreadArray(__spreadArray([name_1], __read((aliasNames || [])), false), __read((deprecatedNames || [])), false);
8278
- if (names.includes(commandName)) {
8578
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8579
+ finally {
8279
8580
  try {
8280
- return { value: parse({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args }) };
8281
- }
8282
- catch (error) {
8283
- if (!(error instanceof ParseError)) {
8284
- throw error;
8285
- }
8286
- throw new ParseError(spaceTrim$1(function (block) {
8287
- 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 ");
8288
- }));
8581
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8289
8582
  }
8583
+ finally { if (e_1) throw e_1.error; }
8290
8584
  }
8291
- };
8292
- try {
8293
- for (var _b = __values(COMMANDS), _c = _b.next(); !_c.done; _c = _b.next()) {
8294
- var commandParser = _c.value;
8295
- var state_1 = _loop_1(commandParser);
8296
- if (typeof state_1 === "object")
8297
- return state_1.value;
8585
+ },
8586
+ };
8587
+
8588
+ /**
8589
+ * Allow to define chatbot with no need to write full interface
8590
+ *
8591
+ * @private
8592
+ */
8593
+ var QuickChatbotHla = {
8594
+ type: 'SYNC',
8595
+ $applyToPipelineJson: function ($pipelineJson) {
8596
+ if ($pipelineJson.tasks.length !== 0) {
8597
+ // Note: When there are already tasks, do nothing
8598
+ return;
8298
8599
  }
8299
- }
8300
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
8301
- finally {
8302
- try {
8303
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8600
+ if ($pipelineJson.parameters.length !== 0) {
8601
+ // Note: When there are already parameters, do nothing
8602
+ return;
8304
8603
  }
8305
- finally { if (e_1) throw e_1.error; }
8306
- }
8307
- return null;
8308
- }
8604
+ if ($pipelineJson.personas.length === 0) {
8605
+ // Note: When no personas defined, do nothing
8606
+ return;
8607
+ }
8608
+ var personaName = $pipelineJson.personas[0].name;
8609
+ $pipelineJson.formfactorName = 'CHATBOT';
8610
+ $pipelineJson.parameters.push({
8611
+ name: 'previousTitle',
8612
+ description: 'Previous title of the conversation',
8613
+ isInput: true,
8614
+ isOutput: false,
8615
+ }, {
8616
+ name: 'previousConversationSummary',
8617
+ description: 'Previous conversation summary',
8618
+ isInput: true,
8619
+ isOutput: false,
8620
+ }, {
8621
+ name: 'userMessage',
8622
+ description: 'User message',
8623
+ isInput: true,
8624
+ isOutput: false,
8625
+ }, {
8626
+ name: 'title',
8627
+ description: 'Title of the conversation',
8628
+ isInput: false,
8629
+ isOutput: true,
8630
+ }, {
8631
+ name: 'conversationSummary',
8632
+ description: 'Summary of the conversation',
8633
+ isInput: false,
8634
+ isOutput: true,
8635
+ }, {
8636
+ name: 'chatbotResponse',
8637
+ description: 'Chatbot response',
8638
+ isInput: false,
8639
+ isOutput: true,
8640
+ exampleValues: ['Hello, I am a Pavol`s virtual avatar. How can I help you?'],
8641
+ });
8642
+ // TODO: !!!!!! spaceTrim
8643
+ $pipelineJson.tasks.push({
8644
+ taskType: 'PROMPT_TASK',
8645
+ name: 'create-an-answer',
8646
+ title: 'Create an answer',
8647
+ content: 'Write a response to the user message:\n\n**Question from user**\n\n> {userMessage}\n\n**Previous conversation**\n\n> {previousConversationSummary}',
8648
+ resultingParameterName: 'chatbotResponse',
8649
+ personaName: personaName,
8650
+ dependentParameterNames: ['userMessage', 'previousConversationSummary' /* !!!!!!, 'knowledge'*/],
8651
+ // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8652
+ }, {
8653
+ taskType: 'PROMPT_TASK',
8654
+ name: 'summarize-the-conversation',
8655
+ title: 'Summarize the conversation',
8656
+ content: 'Summarize the conversation in a few words:\n\n## Rules\n\n- Summarise the text of the conversation in a few words\n- Convert the text to its basic idea\n- Imagine you are writing the headline or subject line of an email\n- Respond with a few words of summary only\n\n## Conversation\n\n**User:**\n\n> {userMessage}\n\n**You:**\n\n> {chatbotResponse}',
8657
+ resultingParameterName: 'conversationSummary',
8658
+ personaName: personaName,
8659
+ expectations: {
8660
+ words: {
8661
+ min: 1,
8662
+ max: 10,
8663
+ },
8664
+ },
8665
+ dependentParameterNames: ['userMessage', 'chatbotResponse' /* !!!!!!, 'knowledge'*/],
8666
+ // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8667
+ }, {
8668
+ taskType: 'SIMPLE_TASK',
8669
+ name: 'title',
8670
+ title: 'Title',
8671
+ content: '{conversationSummary}',
8672
+ resultingParameterName: 'title',
8673
+ dependentParameterNames: ['conversationSummary' /* !!!!!!, 'knowledge'*/],
8674
+ // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8675
+ });
8676
+ },
8677
+ };
8678
+
8679
+ /**
8680
+ * All high-level abstractions
8681
+ *
8682
+ * @private internal index of `pipelineStringToJsonSync` (= used for sync) and `preparePipeline` (= used for async)
8683
+ */
8684
+ var HIGH_LEVEL_ABSTRACTIONS = [
8685
+ ImplicitFormfactorHla,
8686
+ QuickChatbotHla,
8687
+ // <- Note: [♓️][💩] This is the order of the application of high-level abstractions application on pipeline JSON
8688
+ ];
8689
+ /**
8690
+ * TODO: Test that all sync high-level abstractions are before async high-level abstractions
8691
+ * Note: [💞] Ignore a discrepancy between file name and entity name
8692
+ */
8309
8693
 
8310
8694
  /**
8311
8695
  * Supported script languages
@@ -8582,20 +8966,15 @@ function titleToName(value) {
8582
8966
  * @public exported from `@promptbook/core`
8583
8967
  */
8584
8968
  function pipelineStringToJsonSync(pipelineString) {
8585
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
8969
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
8586
8970
  var $pipelineJson = {
8587
- title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
8588
- pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
8589
- bookVersion: undefined /* <- Note: By default no explicit version */,
8590
- description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
8591
- formfactorName: 'GENERIC',
8971
+ title: DEFAULT_TITLE,
8592
8972
  parameters: [],
8593
8973
  tasks: [],
8594
8974
  knowledgeSources: [],
8595
8975
  knowledgePieces: [],
8596
8976
  personas: [],
8597
8977
  preparations: [],
8598
- // <- TODO: [🍙] Some standard order of properties
8599
8978
  };
8600
8979
  function getPipelineIdentification() {
8601
8980
  // Note: This is a 😐 implementation of [🚞]
@@ -8611,7 +8990,7 @@ function pipelineStringToJsonSync(pipelineString) {
8611
8990
  // =============================================================
8612
8991
  // Note: 1️⃣ Parsing of the markdown into object
8613
8992
  if (pipelineString.startsWith('#!')) {
8614
- var _f = __read(pipelineString.split('\n')), shebangLine_1 = _f[0], restLines = _f.slice(1);
8993
+ var _g = __read(pipelineString.split('\n')), shebangLine_1 = _g[0], restLines = _g.slice(1);
8615
8994
  if (!(shebangLine_1 || '').includes('ptbk')) {
8616
8995
  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 "); }));
8617
8996
  }
@@ -8621,7 +9000,7 @@ function pipelineStringToJsonSync(pipelineString) {
8621
9000
  pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
8622
9001
  pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
8623
9002
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
8624
- var _g = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _g[0], pipelineSections = _g.slice(1); /* <- Note: [🥞] */
9003
+ var _h = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _h[0], pipelineSections = _h.slice(1); /* <- Note: [🥞] */
8625
9004
  if (pipelineHead === undefined) {
8626
9005
  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 "); }));
8627
9006
  }
@@ -8686,7 +9065,7 @@ function pipelineStringToJsonSync(pipelineString) {
8686
9065
  }
8687
9066
  try {
8688
9067
  commandParser.$applyToPipelineJson(command, $pipelineJson);
8689
- // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitelly
9068
+ // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitly
8690
9069
  }
8691
9070
  catch (error) {
8692
9071
  if (!(error instanceof ParseError)) {
@@ -8743,10 +9122,10 @@ function pipelineStringToJsonSync(pipelineString) {
8743
9122
  return nameWithSuffix;
8744
9123
  };
8745
9124
  var _loop_2 = function (section) {
8746
- var e_6, _m, e_7, _o;
9125
+ var e_7, _q, e_8, _r;
8747
9126
  // TODO: Parse section's description (the content out of the codeblock and lists)
8748
9127
  var listItems_2 = extractAllListItemsFromMarkdown(section.content);
8749
- var _p = extractOneBlockFromMarkdown(section.content), language = _p.language, content = _p.content;
9128
+ var _s = extractOneBlockFromMarkdown(section.content), language = _s.language, content = _s.content;
8750
9129
  // TODO: [🎾][1] DRY description
8751
9130
  var description_1 = section.content;
8752
9131
  // Note: Remove codeblocks - TODO: [🎾]
@@ -8794,7 +9173,7 @@ function pipelineStringToJsonSync(pipelineString) {
8794
9173
  }
8795
9174
  try {
8796
9175
  commandParser.$applyToTaskJson(
8797
- // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitelly
9176
+ // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitly
8798
9177
  command, $taskJson, $pipelineJson);
8799
9178
  }
8800
9179
  catch (error) {
@@ -8810,17 +9189,17 @@ function pipelineStringToJsonSync(pipelineString) {
8810
9189
  };
8811
9190
  try {
8812
9191
  // TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
8813
- for (var commands_1 = (e_6 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
8814
- var _q = commands_1_1.value, listItem = _q.listItem, command = _q.command;
9192
+ for (var commands_1 = (e_7 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
9193
+ var _t = commands_1_1.value, listItem = _t.listItem, command = _t.command;
8815
9194
  _loop_4(listItem, command);
8816
9195
  }
8817
9196
  }
8818
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
9197
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
8819
9198
  finally {
8820
9199
  try {
8821
- if (commands_1_1 && !commands_1_1.done && (_m = commands_1.return)) _m.call(commands_1);
9200
+ if (commands_1_1 && !commands_1_1.done && (_q = commands_1.return)) _q.call(commands_1);
8822
9201
  }
8823
- finally { if (e_6) throw e_6.error; }
9202
+ finally { if (e_7) throw e_7.error; }
8824
9203
  }
8825
9204
  // TODO: [🍧] Should be done in SECTION command
8826
9205
  if ($taskJson.taskType === 'SCRIPT_TASK') {
@@ -8834,8 +9213,8 @@ function pipelineStringToJsonSync(pipelineString) {
8834
9213
  }
8835
9214
  $taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
8836
9215
  try {
8837
- for (var _r = (e_7 = void 0, __values($taskJson.dependentParameterNames)), _s = _r.next(); !_s.done; _s = _r.next()) {
8838
- var parameterName = _s.value;
9216
+ for (var _u = (e_8 = void 0, __values($taskJson.dependentParameterNames)), _v = _u.next(); !_v.done; _v = _u.next()) {
9217
+ var parameterName = _v.value;
8839
9218
  // TODO: [🧠] This definition should be made first in the task
8840
9219
  defineParam({
8841
9220
  parameterName: parameterName,
@@ -8846,12 +9225,12 @@ function pipelineStringToJsonSync(pipelineString) {
8846
9225
  });
8847
9226
  }
8848
9227
  }
8849
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
9228
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
8850
9229
  finally {
8851
9230
  try {
8852
- if (_s && !_s.done && (_o = _r.return)) _o.call(_r);
9231
+ if (_v && !_v.done && (_r = _u.return)) _r.call(_u);
8853
9232
  }
8854
- finally { if (e_7) throw e_7.error; }
9233
+ finally { if (e_8) throw e_8.error; }
8855
9234
  }
8856
9235
  /*
8857
9236
  // TODO: [🍧] This should be checked in `MODEL` command + better error message
@@ -8900,18 +9279,22 @@ function pipelineStringToJsonSync(pipelineString) {
8900
9279
  var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
8901
9280
  if (!isThisParameterResulting) {
8902
9281
  parameter.isInput = true;
9282
+ // <- TODO: [💔] Why this is making typescript error in vscode but not in cli
9283
+ // > Type 'true' is not assignable to type 'false'.ts(2322)
9284
+ // > (property) isInput: false
9285
+ // > The parameter is input of the pipeline The parameter is NOT input of the pipeline
8903
9286
  }
8904
9287
  };
8905
9288
  try {
8906
- for (var _h = __values($pipelineJson.parameters), _j = _h.next(); !_j.done; _j = _h.next()) {
8907
- var parameter = _j.value;
9289
+ for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
9290
+ var parameter = _k.value;
8908
9291
  _loop_3(parameter);
8909
9292
  }
8910
9293
  }
8911
9294
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
8912
9295
  finally {
8913
9296
  try {
8914
- if (_j && !_j.done && (_d = _h.return)) _d.call(_h);
9297
+ if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
8915
9298
  }
8916
9299
  finally { if (e_4) throw e_4.error; }
8917
9300
  }
@@ -8920,17 +9303,18 @@ function pipelineStringToJsonSync(pipelineString) {
8920
9303
  // Note: 7️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
8921
9304
  if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
8922
9305
  try {
8923
- for (var _k = __values($pipelineJson.parameters), _l = _k.next(); !_l.done; _l = _k.next()) {
8924
- var parameter = _l.value;
9306
+ for (var _l = __values($pipelineJson.parameters), _m = _l.next(); !_m.done; _m = _l.next()) {
9307
+ var parameter = _m.value;
8925
9308
  if (!parameter.isInput) {
8926
9309
  parameter.isOutput = true;
9310
+ // <- TODO: [💔]
8927
9311
  }
8928
9312
  }
8929
9313
  }
8930
9314
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
8931
9315
  finally {
8932
9316
  try {
8933
- if (_l && !_l.done && (_e = _k.return)) _e.call(_k);
9317
+ if (_m && !_m.done && (_e = _l.return)) _e.call(_l);
8934
9318
  }
8935
9319
  finally { if (e_5) throw e_5.error; }
8936
9320
  }
@@ -8938,7 +9322,7 @@ function pipelineStringToJsonSync(pipelineString) {
8938
9322
  // =============================================================
8939
9323
  // Note: 8️⃣ Cleanup of undefined values
8940
9324
  $pipelineJson.tasks.forEach(function (tasks) {
8941
- var e_8, _a;
9325
+ var e_9, _a;
8942
9326
  try {
8943
9327
  for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
8944
9328
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -8947,16 +9331,16 @@ function pipelineStringToJsonSync(pipelineString) {
8947
9331
  }
8948
9332
  }
8949
9333
  }
8950
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
9334
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
8951
9335
  finally {
8952
9336
  try {
8953
9337
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8954
9338
  }
8955
- finally { if (e_8) throw e_8.error; }
9339
+ finally { if (e_9) throw e_9.error; }
8956
9340
  }
8957
9341
  });
8958
9342
  $pipelineJson.parameters.forEach(function (parameter) {
8959
- var e_9, _a;
9343
+ var e_10, _a;
8960
9344
  try {
8961
9345
  for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
8962
9346
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -8965,19 +9349,49 @@ function pipelineStringToJsonSync(pipelineString) {
8965
9349
  }
8966
9350
  }
8967
9351
  }
8968
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
9352
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
8969
9353
  finally {
8970
9354
  try {
8971
9355
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8972
9356
  }
8973
- finally { if (e_9) throw e_9.error; }
9357
+ finally { if (e_10) throw e_10.error; }
8974
9358
  }
8975
9359
  });
9360
+ try {
9361
+ // =============================================================
9362
+ // Note: 9️⃣ Apply sync high-level abstractions
9363
+ for (var _o = __values(HIGH_LEVEL_ABSTRACTIONS.filter(function (_a) {
9364
+ var type = _a.type;
9365
+ return type === 'SYNC';
9366
+ })), _p = _o.next(); !_p.done; _p = _o.next()) {
9367
+ var highLevelAbstraction = _p.value;
9368
+ highLevelAbstraction.$applyToPipelineJson($pipelineJson);
9369
+ }
9370
+ }
9371
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
9372
+ finally {
9373
+ try {
9374
+ if (_p && !_p.done && (_f = _o.return)) _f.call(_o);
9375
+ }
9376
+ finally { if (e_6) throw e_6.error; }
9377
+ }
9378
+ // =============================================================
9379
+ // Note: 🔟 Default formfactor
9380
+ // Note: [🔆] If formfactor is still not set, set it to 'GENERIC'
9381
+ if ($pipelineJson.formfactorName === undefined) {
9382
+ $pipelineJson.formfactorName = 'GENERIC';
9383
+ }
8976
9384
  // =============================================================
8977
9385
  // TODO: [🍙] Maybe do reorder of `$pipelineJson` here
8978
- return $asDeeplyFrozenSerializableJson('pipelineJson', $pipelineJson);
9386
+ return exportJson({
9387
+ name: 'pipelineJson',
9388
+ message: "Result of `pipelineStringToJsonSync`",
9389
+ order: ORDER_OF_PIPELINE_JSON,
9390
+ value: __assign({ formfactorName: 'GENERIC' }, $pipelineJson),
9391
+ });
8979
9392
  }
8980
9393
  /**
9394
+ * TODO: [🧠] Maybe more things here can be refactored as high-level abstractions
8981
9395
  * TODO: [main] !!!! Warn if used only sync version
8982
9396
  * TODO: [🚞] Report here line/column of error
8983
9397
  * TODO: Use spaceTrim more effectively
@@ -9021,7 +9435,7 @@ function pipelineStringToJson(pipelineString, tools, options) {
9021
9435
  pipelineJson = _a.sent();
9022
9436
  _a.label = 2;
9023
9437
  case 2:
9024
- // Note: No need to use `$asDeeplyFrozenSerializableJson` because `pipelineStringToJsonSync` and `preparePipeline` already do that
9438
+ // Note: No need to use `$exportJson` because `pipelineStringToJsonSync` and `preparePipeline` already do that
9025
9439
  return [2 /*return*/, pipelineJson];
9026
9440
  }
9027
9441
  });
@@ -9275,6 +9689,7 @@ function renamePipelineParameter(options) {
9275
9689
  return renamedPipeline;
9276
9690
  }
9277
9691
 
9692
+ // <- TODO: !!!!!!! Auto convert to type `import { ... } from 'type-fest';`
9278
9693
  /**
9279
9694
  * Tests if the value is [🚉] serializable as JSON
9280
9695
  *
@@ -9296,7 +9711,7 @@ function renamePipelineParameter(options) {
9296
9711
  */
9297
9712
  function isSerializableAsJson(value) {
9298
9713
  try {
9299
- checkSerializableAsJson('', value);
9714
+ checkSerializableAsJson({ value: value });
9300
9715
  return true;
9301
9716
  }
9302
9717
  catch (error) {
@@ -10494,133 +10909,6 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
10494
10909
  * Note: [💞] Ignore a discrepancy between file name and entity name
10495
10910
  */
10496
10911
 
10497
- /**
10498
- * @@@
10499
- *
10500
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
10501
- * @see https://github.com/webgptorg/promptbook/discussions/171
10502
- *
10503
- * @public exported from `@promptbook/core`
10504
- */
10505
- function getPipelineInterface(pipeline) {
10506
- var e_1, _a, e_2, _b;
10507
- var pipelineInterface = {
10508
- inputParameters: [],
10509
- outputParameters: [],
10510
- };
10511
- try {
10512
- for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
10513
- var parameter = _d.value;
10514
- var isInput = parameter.isInput, isOutput = parameter.isOutput;
10515
- if (isInput) {
10516
- pipelineInterface.inputParameters.push(parameter);
10517
- }
10518
- if (isOutput) {
10519
- pipelineInterface.outputParameters.push(parameter);
10520
- }
10521
- }
10522
- }
10523
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
10524
- finally {
10525
- try {
10526
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
10527
- }
10528
- finally { if (e_1) throw e_1.error; }
10529
- }
10530
- try {
10531
- for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
10532
- var key = _f.value;
10533
- pipelineInterface[key].sort(function (_a, _b) {
10534
- var name1 = _a.name;
10535
- var name2 = _b.name;
10536
- return name1.localeCompare(name2);
10537
- });
10538
- }
10539
- }
10540
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
10541
- finally {
10542
- try {
10543
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
10544
- }
10545
- finally { if (e_2) throw e_2.error; }
10546
- }
10547
- return $deepFreeze(pipelineInterface);
10548
- }
10549
-
10550
- /**
10551
- * @@@
10552
- *
10553
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
10554
- * @see https://github.com/webgptorg/promptbook/discussions/171
10555
- *
10556
- * @public exported from `@promptbook/core`
10557
- */
10558
- function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
10559
- var e_1, _a, e_2, _b;
10560
- try {
10561
- for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
10562
- var whichParameters = _d.value;
10563
- var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
10564
- var parameters2 = pipelineInterface2[whichParameters];
10565
- if (parameters1.length !== parameters2.length) {
10566
- return false;
10567
- }
10568
- var _loop_1 = function (parameter) {
10569
- var matchingParameter = parameters2.find(function (_a) {
10570
- var name = _a.name;
10571
- return name === parameter.name;
10572
- });
10573
- if (!matchingParameter) {
10574
- return { value: false };
10575
- }
10576
- // Note: Do not compare description, it is not relevant for compatibility
10577
- if (matchingParameter.isInput !== parameter.isInput) {
10578
- return { value: false };
10579
- }
10580
- if (matchingParameter.isOutput !== parameter.isOutput) {
10581
- return { value: false };
10582
- }
10583
- };
10584
- try {
10585
- for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
10586
- var parameter = parameters1_1_1.value;
10587
- var state_1 = _loop_1(parameter);
10588
- if (typeof state_1 === "object")
10589
- return state_1.value;
10590
- }
10591
- }
10592
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
10593
- finally {
10594
- try {
10595
- if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
10596
- }
10597
- finally { if (e_2) throw e_2.error; }
10598
- }
10599
- }
10600
- }
10601
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
10602
- finally {
10603
- try {
10604
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
10605
- }
10606
- finally { if (e_1) throw e_1.error; }
10607
- }
10608
- return true;
10609
- }
10610
-
10611
- /**
10612
- * @@@
10613
- *
10614
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
10615
- * @see https://github.com/webgptorg/promptbook/discussions/171
10616
- *
10617
- * @public exported from `@promptbook/core`
10618
- */
10619
- function isPipelineImplementingInterface(options) {
10620
- var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
10621
- return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
10622
- }
10623
-
10624
10912
  /**
10625
10913
  * Metadata of the scraper
10626
10914
  *
@@ -10638,7 +10926,7 @@ var legacyDocumentScraperMetadata = $deepFreeze({
10638
10926
  'LibreOffice',
10639
10927
  // <- TODO: [🧠] Should be 'LibreOffice' here, its dependency of dependency
10640
10928
  ],
10641
- }); /* <- TODO: [🤛] */
10929
+ }); /* <- Note: [🤛] */
10642
10930
  /**
10643
10931
  * Registration of known scraper metadata
10644
10932
  *
@@ -10665,7 +10953,7 @@ var documentScraperMetadata = $deepFreeze({
10665
10953
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
10666
10954
  isAvilableInBrowser: false,
10667
10955
  requiredExecutables: ['Pandoc'],
10668
- }); /* <- TODO: [🤛] */
10956
+ }); /* <- Note: [🤛] */
10669
10957
  /**
10670
10958
  * Registration of known scraper metadata
10671
10959
  *
@@ -10692,7 +10980,7 @@ var markdownScraperMetadata = $deepFreeze({
10692
10980
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
10693
10981
  isAvilableInBrowser: true,
10694
10982
  requiredExecutables: [],
10695
- }); /* <- TODO: [🤛] */
10983
+ }); /* <- Note: [🤛] */
10696
10984
  /**
10697
10985
  * Registration of known scraper metadata
10698
10986
  *
@@ -10719,7 +11007,7 @@ var pdfScraperMetadata = $deepFreeze({
10719
11007
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
10720
11008
  isAvilableInBrowser: true,
10721
11009
  requiredExecutables: [],
10722
- }); /* <- TODO: [🤛] */
11010
+ }); /* <- Note: [🤛] */
10723
11011
  /**
10724
11012
  * Registration of known scraper metadata
10725
11013
  *
@@ -10746,7 +11034,7 @@ var websiteScraperMetadata = $deepFreeze({
10746
11034
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
10747
11035
  isAvilableInBrowser: false,
10748
11036
  requiredExecutables: [],
10749
- }); /* <- TODO: [🤛] */
11037
+ }); /* <- Note: [🤛] */
10750
11038
  /**
10751
11039
  * Registration of known scraper metadata
10752
11040
  *
@@ -10841,5 +11129,5 @@ var PrefixStorage = /** @class */ (function () {
10841
11129
  return PrefixStorage;
10842
11130
  }());
10843
11131
 
10844
- 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 };
11132
+ 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, ORDER_OF_PIPELINE_JSON, 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 };
10845
11133
  //# sourceMappingURL=index.es.js.map