@promptbook/node 0.74.0-0 → 0.74.0-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -29
- package/esm/index.es.js +336 -382
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -2
- package/esm/typings/src/_packages/azure-openai.index.d.ts +2 -2
- package/esm/typings/src/_packages/browser.index.d.ts +2 -2
- package/esm/typings/src/_packages/cli.index.d.ts +2 -2
- package/esm/typings/src/_packages/core.index.d.ts +7 -3
- package/esm/typings/src/_packages/documents.index.d.ts +2 -2
- package/esm/typings/src/_packages/execute-javascript.index.d.ts +2 -2
- package/esm/typings/src/_packages/fake-llm.index.d.ts +2 -2
- package/esm/typings/src/_packages/langtail.index.d.ts +2 -2
- package/esm/typings/src/_packages/legacy-documents.index.d.ts +2 -2
- package/esm/typings/src/_packages/markdown-utils.index.d.ts +2 -2
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/openai.index.d.ts +2 -2
- package/esm/typings/src/_packages/pdf.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-client.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -2
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/_packages/website-crawler.index.d.ts +2 -2
- package/esm/typings/src/cli/cli-commands/make.d.ts +0 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +14 -0
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
- package/esm/typings/src/cli/test/ptbk.d.ts +5 -2
- package/esm/typings/src/commands/{PROMPTBOOK_VERSION/PromptbookVersionCommand.d.ts → BOOK_VERSION/BookVersionCommand.d.ts} +4 -4
- package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
- package/esm/typings/src/commands/index.d.ts +1 -1
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
- package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
- package/esm/typings/src/version.d.ts +13 -2
- package/package.json +4 -2
- package/umd/index.umd.js +337 -382
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +0 -9
- /package/esm/typings/src/commands/{PROMPTBOOK_VERSION/promptbookVersionCommand.test.d.ts → BOOK_VERSION/bookVersionCommand.test.d.ts} +0 -0
- /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -33,10 +33,20 @@
|
|
|
33
33
|
|
|
34
34
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
35
35
|
/**
|
|
36
|
-
* The version of the
|
|
36
|
+
* The version of the Book language
|
|
37
|
+
*
|
|
38
|
+
* @see https://github.com/webgptorg/book
|
|
39
|
+
*/
|
|
40
|
+
var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
41
|
+
/**
|
|
42
|
+
* The version of the Promptbook engine
|
|
43
|
+
*
|
|
44
|
+
* @see https://github.com/webgptorg/promptbook
|
|
45
|
+
*/
|
|
46
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-10';
|
|
47
|
+
/**
|
|
48
|
+
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
37
49
|
*/
|
|
38
|
-
var PROMPTBOOK_VERSION = '0.73.0';
|
|
39
|
-
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
40
50
|
|
|
41
51
|
/*! *****************************************************************************
|
|
42
52
|
Copyright (c) Microsoft Corporation.
|
|
@@ -370,6 +380,13 @@
|
|
|
370
380
|
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
371
381
|
*/
|
|
372
382
|
|
|
383
|
+
// <- TODO: [🐊] Pick the best claim
|
|
384
|
+
/**
|
|
385
|
+
* When the title is not provided, the default title is used
|
|
386
|
+
*
|
|
387
|
+
* @public exported from `@promptbook/core`
|
|
388
|
+
*/
|
|
389
|
+
var DEFAULT_TITLE = "Untitled";
|
|
373
390
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
374
391
|
/**
|
|
375
392
|
* The maximum number of iterations for a loops
|
|
@@ -460,12 +477,6 @@
|
|
|
460
477
|
* @public exported from `@promptbook/core`
|
|
461
478
|
*/
|
|
462
479
|
var DEFAULT_IS_VERBOSE = false;
|
|
463
|
-
/**
|
|
464
|
-
* @@@
|
|
465
|
-
*
|
|
466
|
-
* @public exported from `@promptbook/core`
|
|
467
|
-
*/
|
|
468
|
-
var DEFAULT_IS_AUTO_INSTALLED = false;
|
|
469
480
|
/**
|
|
470
481
|
* @@@
|
|
471
482
|
*
|
|
@@ -870,6 +881,188 @@
|
|
|
870
881
|
},
|
|
871
882
|
});
|
|
872
883
|
|
|
884
|
+
/**
|
|
885
|
+
* @@@
|
|
886
|
+
*
|
|
887
|
+
* @public exported from `@promptbook/utils`
|
|
888
|
+
*/
|
|
889
|
+
function deepClone(objectValue) {
|
|
890
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
891
|
+
/*
|
|
892
|
+
TODO: [🧠] Is there a better implementation?
|
|
893
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
894
|
+
> for (const propertyName of propertyNames) {
|
|
895
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
896
|
+
> if (value && typeof value === 'object') {
|
|
897
|
+
> deepClone(value);
|
|
898
|
+
> }
|
|
899
|
+
> }
|
|
900
|
+
> return Object.assign({}, objectValue);
|
|
901
|
+
*/
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
905
|
+
*/
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Function `addUsage` will add multiple usages into one
|
|
909
|
+
*
|
|
910
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
911
|
+
*
|
|
912
|
+
* @public exported from `@promptbook/core`
|
|
913
|
+
*/
|
|
914
|
+
function addUsage() {
|
|
915
|
+
var usageItems = [];
|
|
916
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
917
|
+
usageItems[_i] = arguments[_i];
|
|
918
|
+
}
|
|
919
|
+
return usageItems.reduce(function (acc, item) {
|
|
920
|
+
var e_1, _a, e_2, _b;
|
|
921
|
+
var _c;
|
|
922
|
+
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
923
|
+
try {
|
|
924
|
+
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
925
|
+
var key = _e.value;
|
|
926
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
927
|
+
//@ts-ignore
|
|
928
|
+
if (item.input[key]) {
|
|
929
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
930
|
+
//@ts-ignore
|
|
931
|
+
acc.input[key].value += item.input[key].value || 0;
|
|
932
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
933
|
+
//@ts-ignore
|
|
934
|
+
if (item.input[key].isUncertain) {
|
|
935
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
936
|
+
//@ts-ignore
|
|
937
|
+
acc.input[key].isUncertain = true;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
943
|
+
finally {
|
|
944
|
+
try {
|
|
945
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
946
|
+
}
|
|
947
|
+
finally { if (e_1) throw e_1.error; }
|
|
948
|
+
}
|
|
949
|
+
try {
|
|
950
|
+
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
951
|
+
var key = _g.value;
|
|
952
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
953
|
+
//@ts-ignore
|
|
954
|
+
if (item.output[key]) {
|
|
955
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
956
|
+
//@ts-ignore
|
|
957
|
+
acc.output[key].value += item.output[key].value || 0;
|
|
958
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
959
|
+
//@ts-ignore
|
|
960
|
+
if (item.output[key].isUncertain) {
|
|
961
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
962
|
+
//@ts-ignore
|
|
963
|
+
acc.output[key].isUncertain = true;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
969
|
+
finally {
|
|
970
|
+
try {
|
|
971
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
972
|
+
}
|
|
973
|
+
finally { if (e_2) throw e_2.error; }
|
|
974
|
+
}
|
|
975
|
+
return acc;
|
|
976
|
+
}, deepClone(ZERO_USAGE));
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Intercepts LLM tools and counts total usage of the tools
|
|
981
|
+
*
|
|
982
|
+
* @param llmTools LLM tools to be intercepted with usage counting
|
|
983
|
+
* @returns LLM tools with same functionality with added total cost counting
|
|
984
|
+
* @public exported from `@promptbook/core`
|
|
985
|
+
*/
|
|
986
|
+
function countTotalUsage(llmTools) {
|
|
987
|
+
var _this = this;
|
|
988
|
+
var totalUsage = ZERO_USAGE;
|
|
989
|
+
var proxyTools = {
|
|
990
|
+
get title() {
|
|
991
|
+
// TODO: [🧠] Maybe put here some suffix
|
|
992
|
+
return llmTools.title;
|
|
993
|
+
},
|
|
994
|
+
get description() {
|
|
995
|
+
// TODO: [🧠] Maybe put here some suffix
|
|
996
|
+
return llmTools.description;
|
|
997
|
+
},
|
|
998
|
+
checkConfiguration: function () {
|
|
999
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1000
|
+
return __generator(this, function (_a) {
|
|
1001
|
+
return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
|
|
1002
|
+
});
|
|
1003
|
+
});
|
|
1004
|
+
},
|
|
1005
|
+
listModels: function () {
|
|
1006
|
+
return /* not await */ llmTools.listModels();
|
|
1007
|
+
},
|
|
1008
|
+
getTotalUsage: function () {
|
|
1009
|
+
// <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
|
|
1010
|
+
return totalUsage;
|
|
1011
|
+
},
|
|
1012
|
+
};
|
|
1013
|
+
if (llmTools.callChatModel !== undefined) {
|
|
1014
|
+
proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1015
|
+
var promptResult;
|
|
1016
|
+
return __generator(this, function (_a) {
|
|
1017
|
+
switch (_a.label) {
|
|
1018
|
+
case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
|
|
1019
|
+
case 1:
|
|
1020
|
+
promptResult = _a.sent();
|
|
1021
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1022
|
+
return [2 /*return*/, promptResult];
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
}); };
|
|
1026
|
+
}
|
|
1027
|
+
if (llmTools.callCompletionModel !== undefined) {
|
|
1028
|
+
proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1029
|
+
var promptResult;
|
|
1030
|
+
return __generator(this, function (_a) {
|
|
1031
|
+
switch (_a.label) {
|
|
1032
|
+
case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
|
|
1033
|
+
case 1:
|
|
1034
|
+
promptResult = _a.sent();
|
|
1035
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1036
|
+
return [2 /*return*/, promptResult];
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
}); };
|
|
1040
|
+
}
|
|
1041
|
+
if (llmTools.callEmbeddingModel !== undefined) {
|
|
1042
|
+
proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1043
|
+
var promptResult;
|
|
1044
|
+
return __generator(this, function (_a) {
|
|
1045
|
+
switch (_a.label) {
|
|
1046
|
+
case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
|
|
1047
|
+
case 1:
|
|
1048
|
+
promptResult = _a.sent();
|
|
1049
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1050
|
+
return [2 /*return*/, promptResult];
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}); };
|
|
1054
|
+
}
|
|
1055
|
+
// <- Note: [🤖]
|
|
1056
|
+
return proxyTools;
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
1060
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
1061
|
+
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
1062
|
+
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
1063
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
1064
|
+
*/
|
|
1065
|
+
|
|
873
1066
|
/**
|
|
874
1067
|
* This error indicates errors during the execution of the pipeline
|
|
875
1068
|
*
|
|
@@ -1178,188 +1371,6 @@
|
|
|
1178
1371
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
1179
1372
|
*/
|
|
1180
1373
|
|
|
1181
|
-
/**
|
|
1182
|
-
* @@@
|
|
1183
|
-
*
|
|
1184
|
-
* @public exported from `@promptbook/utils`
|
|
1185
|
-
*/
|
|
1186
|
-
function deepClone(objectValue) {
|
|
1187
|
-
return JSON.parse(JSON.stringify(objectValue));
|
|
1188
|
-
/*
|
|
1189
|
-
TODO: [🧠] Is there a better implementation?
|
|
1190
|
-
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1191
|
-
> for (const propertyName of propertyNames) {
|
|
1192
|
-
> const value = (objectValue as really_any)[propertyName];
|
|
1193
|
-
> if (value && typeof value === 'object') {
|
|
1194
|
-
> deepClone(value);
|
|
1195
|
-
> }
|
|
1196
|
-
> }
|
|
1197
|
-
> return Object.assign({}, objectValue);
|
|
1198
|
-
*/
|
|
1199
|
-
}
|
|
1200
|
-
/**
|
|
1201
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1202
|
-
*/
|
|
1203
|
-
|
|
1204
|
-
/**
|
|
1205
|
-
* Function `addUsage` will add multiple usages into one
|
|
1206
|
-
*
|
|
1207
|
-
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
1208
|
-
*
|
|
1209
|
-
* @public exported from `@promptbook/core`
|
|
1210
|
-
*/
|
|
1211
|
-
function addUsage() {
|
|
1212
|
-
var usageItems = [];
|
|
1213
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1214
|
-
usageItems[_i] = arguments[_i];
|
|
1215
|
-
}
|
|
1216
|
-
return usageItems.reduce(function (acc, item) {
|
|
1217
|
-
var e_1, _a, e_2, _b;
|
|
1218
|
-
var _c;
|
|
1219
|
-
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
1220
|
-
try {
|
|
1221
|
-
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1222
|
-
var key = _e.value;
|
|
1223
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1224
|
-
//@ts-ignore
|
|
1225
|
-
if (item.input[key]) {
|
|
1226
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1227
|
-
//@ts-ignore
|
|
1228
|
-
acc.input[key].value += item.input[key].value || 0;
|
|
1229
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1230
|
-
//@ts-ignore
|
|
1231
|
-
if (item.input[key].isUncertain) {
|
|
1232
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1233
|
-
//@ts-ignore
|
|
1234
|
-
acc.input[key].isUncertain = true;
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1240
|
-
finally {
|
|
1241
|
-
try {
|
|
1242
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1243
|
-
}
|
|
1244
|
-
finally { if (e_1) throw e_1.error; }
|
|
1245
|
-
}
|
|
1246
|
-
try {
|
|
1247
|
-
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1248
|
-
var key = _g.value;
|
|
1249
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1250
|
-
//@ts-ignore
|
|
1251
|
-
if (item.output[key]) {
|
|
1252
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1253
|
-
//@ts-ignore
|
|
1254
|
-
acc.output[key].value += item.output[key].value || 0;
|
|
1255
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1256
|
-
//@ts-ignore
|
|
1257
|
-
if (item.output[key].isUncertain) {
|
|
1258
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1259
|
-
//@ts-ignore
|
|
1260
|
-
acc.output[key].isUncertain = true;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1266
|
-
finally {
|
|
1267
|
-
try {
|
|
1268
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1269
|
-
}
|
|
1270
|
-
finally { if (e_2) throw e_2.error; }
|
|
1271
|
-
}
|
|
1272
|
-
return acc;
|
|
1273
|
-
}, deepClone(ZERO_USAGE));
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
/**
|
|
1277
|
-
* Intercepts LLM tools and counts total usage of the tools
|
|
1278
|
-
*
|
|
1279
|
-
* @param llmTools LLM tools to be intercepted with usage counting
|
|
1280
|
-
* @returns LLM tools with same functionality with added total cost counting
|
|
1281
|
-
* @public exported from `@promptbook/core`
|
|
1282
|
-
*/
|
|
1283
|
-
function countTotalUsage(llmTools) {
|
|
1284
|
-
var _this = this;
|
|
1285
|
-
var totalUsage = ZERO_USAGE;
|
|
1286
|
-
var proxyTools = {
|
|
1287
|
-
get title() {
|
|
1288
|
-
// TODO: [🧠] Maybe put here some suffix
|
|
1289
|
-
return llmTools.title;
|
|
1290
|
-
},
|
|
1291
|
-
get description() {
|
|
1292
|
-
// TODO: [🧠] Maybe put here some suffix
|
|
1293
|
-
return llmTools.description;
|
|
1294
|
-
},
|
|
1295
|
-
checkConfiguration: function () {
|
|
1296
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1297
|
-
return __generator(this, function (_a) {
|
|
1298
|
-
return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
|
|
1299
|
-
});
|
|
1300
|
-
});
|
|
1301
|
-
},
|
|
1302
|
-
listModels: function () {
|
|
1303
|
-
return /* not await */ llmTools.listModels();
|
|
1304
|
-
},
|
|
1305
|
-
getTotalUsage: function () {
|
|
1306
|
-
// <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
|
|
1307
|
-
return totalUsage;
|
|
1308
|
-
},
|
|
1309
|
-
};
|
|
1310
|
-
if (llmTools.callChatModel !== undefined) {
|
|
1311
|
-
proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1312
|
-
var promptResult;
|
|
1313
|
-
return __generator(this, function (_a) {
|
|
1314
|
-
switch (_a.label) {
|
|
1315
|
-
case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
|
|
1316
|
-
case 1:
|
|
1317
|
-
promptResult = _a.sent();
|
|
1318
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1319
|
-
return [2 /*return*/, promptResult];
|
|
1320
|
-
}
|
|
1321
|
-
});
|
|
1322
|
-
}); };
|
|
1323
|
-
}
|
|
1324
|
-
if (llmTools.callCompletionModel !== undefined) {
|
|
1325
|
-
proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1326
|
-
var promptResult;
|
|
1327
|
-
return __generator(this, function (_a) {
|
|
1328
|
-
switch (_a.label) {
|
|
1329
|
-
case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
|
|
1330
|
-
case 1:
|
|
1331
|
-
promptResult = _a.sent();
|
|
1332
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1333
|
-
return [2 /*return*/, promptResult];
|
|
1334
|
-
}
|
|
1335
|
-
});
|
|
1336
|
-
}); };
|
|
1337
|
-
}
|
|
1338
|
-
if (llmTools.callEmbeddingModel !== undefined) {
|
|
1339
|
-
proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1340
|
-
var promptResult;
|
|
1341
|
-
return __generator(this, function (_a) {
|
|
1342
|
-
switch (_a.label) {
|
|
1343
|
-
case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
|
|
1344
|
-
case 1:
|
|
1345
|
-
promptResult = _a.sent();
|
|
1346
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1347
|
-
return [2 /*return*/, promptResult];
|
|
1348
|
-
}
|
|
1349
|
-
});
|
|
1350
|
-
}); };
|
|
1351
|
-
}
|
|
1352
|
-
// <- Note: [🤖]
|
|
1353
|
-
return proxyTools;
|
|
1354
|
-
}
|
|
1355
|
-
/**
|
|
1356
|
-
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
1357
|
-
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
1358
|
-
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
1359
|
-
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
1360
|
-
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
1361
|
-
*/
|
|
1362
|
-
|
|
1363
1374
|
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",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}],templates:[{templateType:"PROMPT_TEMPLATE",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:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1364
1375
|
|
|
1365
1376
|
/**
|
|
@@ -1435,7 +1446,7 @@
|
|
|
1435
1446
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
1436
1447
|
return false;
|
|
1437
1448
|
}
|
|
1438
|
-
// <- TODO: [main] !!! Check isValidPromptbookVersion against
|
|
1449
|
+
// <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
|
|
1439
1450
|
return true;
|
|
1440
1451
|
}
|
|
1441
1452
|
|
|
@@ -1535,7 +1546,7 @@
|
|
|
1535
1546
|
if (!url.startsWith('https://')) {
|
|
1536
1547
|
return false;
|
|
1537
1548
|
}
|
|
1538
|
-
if (!url.endsWith('.ptbk.md')) {
|
|
1549
|
+
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
|
|
1539
1550
|
return false;
|
|
1540
1551
|
}
|
|
1541
1552
|
if (url.includes('#')) {
|
|
@@ -2400,23 +2411,6 @@
|
|
|
2400
2411
|
return union;
|
|
2401
2412
|
}
|
|
2402
2413
|
|
|
2403
|
-
/**
|
|
2404
|
-
* Just marks a place of place where should be something implemented
|
|
2405
|
-
* No side effects.
|
|
2406
|
-
*
|
|
2407
|
-
* Note: It can be usefull suppressing eslint errors of unused variables
|
|
2408
|
-
*
|
|
2409
|
-
* @param value any values
|
|
2410
|
-
* @returns void
|
|
2411
|
-
* @private within the repository
|
|
2412
|
-
*/
|
|
2413
|
-
function TODO_USE() {
|
|
2414
|
-
var value = [];
|
|
2415
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2416
|
-
value[_i] = arguments[_i];
|
|
2417
|
-
}
|
|
2418
|
-
}
|
|
2419
|
-
|
|
2420
2414
|
/**
|
|
2421
2415
|
* This error indicates problems parsing the format value
|
|
2422
2416
|
*
|
|
@@ -2473,22 +2467,12 @@
|
|
|
2473
2467
|
formatName: 'CSV',
|
|
2474
2468
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
2475
2469
|
isValid: function (value, settings, schema) {
|
|
2476
|
-
// TODO: Implement CSV validation
|
|
2477
|
-
TODO_USE(value /* <- TODO: Use value here */);
|
|
2478
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2479
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2480
2470
|
return true;
|
|
2481
2471
|
},
|
|
2482
2472
|
canBeValid: function (partialValue, settings, schema) {
|
|
2483
|
-
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
2484
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2485
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2486
2473
|
return true;
|
|
2487
2474
|
},
|
|
2488
2475
|
heal: function (value, settings, schema) {
|
|
2489
|
-
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
2490
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2491
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2492
2476
|
throw new Error('Not implemented');
|
|
2493
2477
|
},
|
|
2494
2478
|
subvalueDefinitions: [
|
|
@@ -2607,20 +2591,12 @@
|
|
|
2607
2591
|
formatName: 'JSON',
|
|
2608
2592
|
mimeType: 'application/json',
|
|
2609
2593
|
isValid: function (value, settings, schema) {
|
|
2610
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2611
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2612
2594
|
return isValidJsonString(value);
|
|
2613
2595
|
},
|
|
2614
2596
|
canBeValid: function (partialValue, settings, schema) {
|
|
2615
|
-
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
2616
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2617
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2618
2597
|
return true;
|
|
2619
2598
|
},
|
|
2620
2599
|
heal: function (value, settings, schema) {
|
|
2621
|
-
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
2622
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2623
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2624
2600
|
throw new Error('Not implemented');
|
|
2625
2601
|
},
|
|
2626
2602
|
subvalueDefinitions: [],
|
|
@@ -2702,21 +2678,12 @@
|
|
|
2702
2678
|
formatName: 'XML',
|
|
2703
2679
|
mimeType: 'application/xml',
|
|
2704
2680
|
isValid: function (value, settings, schema) {
|
|
2705
|
-
TODO_USE(value /* <- TODO: Use value here */);
|
|
2706
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2707
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2708
2681
|
return true;
|
|
2709
2682
|
},
|
|
2710
2683
|
canBeValid: function (partialValue, settings, schema) {
|
|
2711
|
-
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
2712
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2713
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2714
2684
|
return true;
|
|
2715
2685
|
},
|
|
2716
2686
|
heal: function (value, settings, schema) {
|
|
2717
|
-
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
2718
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2719
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2720
2687
|
throw new Error('Not implemented');
|
|
2721
2688
|
},
|
|
2722
2689
|
subvalueDefinitions: [],
|
|
@@ -2949,27 +2916,6 @@
|
|
|
2949
2916
|
return [input];
|
|
2950
2917
|
}
|
|
2951
2918
|
|
|
2952
|
-
/**
|
|
2953
|
-
* Just says that the variable is not used but should be kept
|
|
2954
|
-
* No side effects.
|
|
2955
|
-
*
|
|
2956
|
-
* Note: It can be usefull for:
|
|
2957
|
-
*
|
|
2958
|
-
* 1) Suppressing eager optimization of unused imports
|
|
2959
|
-
* 2) Suppressing eslint errors of unused variables in the tests
|
|
2960
|
-
* 3) Keeping the type of the variable for type testing
|
|
2961
|
-
*
|
|
2962
|
-
* @param value any values
|
|
2963
|
-
* @returns void
|
|
2964
|
-
* @private within the repository
|
|
2965
|
-
*/
|
|
2966
|
-
function keepUnused() {
|
|
2967
|
-
var valuesToKeep = [];
|
|
2968
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2969
|
-
valuesToKeep[_i] = arguments[_i];
|
|
2970
|
-
}
|
|
2971
|
-
}
|
|
2972
|
-
|
|
2973
2919
|
/**
|
|
2974
2920
|
* Replaces parameters in template with values from parameters object
|
|
2975
2921
|
*
|
|
@@ -3082,10 +3028,12 @@
|
|
|
3082
3028
|
* @public exported from `@promptbook/utils`
|
|
3083
3029
|
*/
|
|
3084
3030
|
function countPages(text) {
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3031
|
+
if (text === '') {
|
|
3032
|
+
return 0;
|
|
3033
|
+
}
|
|
3034
|
+
var pagesByLinesCount = Math.ceil(countLines(text) / 44);
|
|
3035
|
+
var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
|
|
3036
|
+
return Math.max(pagesByLinesCount, pagesByCharactersCount);
|
|
3089
3037
|
}
|
|
3090
3038
|
|
|
3091
3039
|
/**
|
|
@@ -3724,7 +3672,6 @@
|
|
|
3724
3672
|
$ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
|
|
3725
3673
|
}
|
|
3726
3674
|
catch (error) {
|
|
3727
|
-
keepUnused(error);
|
|
3728
3675
|
throw new ExpectError(spaceTrim.spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
|
|
3729
3676
|
/*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
|
|
3730
3677
|
}
|
|
@@ -3902,7 +3849,6 @@
|
|
|
3902
3849
|
function getContextForTemplate(template) {
|
|
3903
3850
|
return __awaiter(this, void 0, void 0, function () {
|
|
3904
3851
|
return __generator(this, function (_a) {
|
|
3905
|
-
TODO_USE(template);
|
|
3906
3852
|
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
|
|
3907
3853
|
});
|
|
3908
3854
|
});
|
|
@@ -3915,11 +3861,9 @@
|
|
|
3915
3861
|
*/
|
|
3916
3862
|
function getKnowledgeForTemplate(options) {
|
|
3917
3863
|
return __awaiter(this, void 0, void 0, function () {
|
|
3918
|
-
var preparedPipeline
|
|
3864
|
+
var preparedPipeline;
|
|
3919
3865
|
return __generator(this, function (_a) {
|
|
3920
|
-
preparedPipeline = options.preparedPipeline,
|
|
3921
|
-
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {examples}
|
|
3922
|
-
TODO_USE(template);
|
|
3866
|
+
preparedPipeline = options.preparedPipeline, options.template;
|
|
3923
3867
|
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
3924
3868
|
var content = _a.content;
|
|
3925
3869
|
return "- ".concat(content);
|
|
@@ -3936,8 +3880,6 @@
|
|
|
3936
3880
|
function getExamplesForTemplate(template) {
|
|
3937
3881
|
return __awaiter(this, void 0, void 0, function () {
|
|
3938
3882
|
return __generator(this, function (_a) {
|
|
3939
|
-
// TODO: [♨] Implement Better - use real index and keyword search
|
|
3940
|
-
TODO_USE(template);
|
|
3941
3883
|
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
|
|
3942
3884
|
});
|
|
3943
3885
|
});
|
|
@@ -3956,13 +3898,13 @@
|
|
|
3956
3898
|
switch (_b.label) {
|
|
3957
3899
|
case 0:
|
|
3958
3900
|
preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
|
|
3959
|
-
return [4 /*yield*/, getContextForTemplate(
|
|
3901
|
+
return [4 /*yield*/, getContextForTemplate()];
|
|
3960
3902
|
case 1:
|
|
3961
3903
|
context = _b.sent();
|
|
3962
3904
|
return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
|
|
3963
3905
|
case 2:
|
|
3964
3906
|
knowledge = _b.sent();
|
|
3965
|
-
return [4 /*yield*/, getExamplesForTemplate(
|
|
3907
|
+
return [4 /*yield*/, getExamplesForTemplate()];
|
|
3966
3908
|
case 3:
|
|
3967
3909
|
examples = _b.sent();
|
|
3968
3910
|
currentDate = new Date().toISOString();
|
|
@@ -4197,7 +4139,7 @@
|
|
|
4197
4139
|
executionReport = {
|
|
4198
4140
|
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
4199
4141
|
title: preparedPipeline.title,
|
|
4200
|
-
promptbookUsedVersion:
|
|
4142
|
+
promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
4201
4143
|
promptbookRequestedVersion: preparedPipeline.promptbookVersion,
|
|
4202
4144
|
description: preparedPipeline.description,
|
|
4203
4145
|
promptExecutions: [],
|
|
@@ -5044,16 +4986,13 @@
|
|
|
5044
4986
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5045
4987
|
var _a;
|
|
5046
4988
|
return __awaiter(this, void 0, void 0, function () {
|
|
5047
|
-
var sourceContent, name, _b, _c, rootDirname,
|
|
5048
|
-
// <- TODO: process.cwd() if running in Node.js
|
|
5049
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
4989
|
+
var sourceContent, name, _b, _c, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5050
4990
|
return __generator(this, function (_e) {
|
|
5051
4991
|
switch (_e.label) {
|
|
5052
4992
|
case 0:
|
|
5053
4993
|
sourceContent = knowledgeSource.sourceContent;
|
|
5054
4994
|
name = knowledgeSource.name;
|
|
5055
|
-
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c,
|
|
5056
|
-
TODO_USE(isVerbose);
|
|
4995
|
+
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _b.isVerbose;
|
|
5057
4996
|
if (!name) {
|
|
5058
4997
|
name = sourceContentToName(sourceContent);
|
|
5059
4998
|
}
|
|
@@ -5333,15 +5272,13 @@
|
|
|
5333
5272
|
*/
|
|
5334
5273
|
function prepareTemplates(pipeline, tools, options) {
|
|
5335
5274
|
return __awaiter(this, void 0, void 0, function () {
|
|
5336
|
-
var _a, maxParallelCount, templates,
|
|
5275
|
+
var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
|
|
5337
5276
|
var _this = this;
|
|
5338
5277
|
return __generator(this, function (_b) {
|
|
5339
5278
|
switch (_b.label) {
|
|
5340
5279
|
case 0:
|
|
5341
5280
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
5342
|
-
templates = pipeline.templates,
|
|
5343
|
-
// TODO: [main] !! Apply examples to each template (if missing and is for the template defined)
|
|
5344
|
-
TODO_USE(parameters);
|
|
5281
|
+
templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5345
5282
|
templatesPrepared = new Array(templates.length);
|
|
5346
5283
|
return [4 /*yield*/, forEachAsync(templates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
5347
5284
|
var dependentParameterNames, preparedContent, preparedTemplate;
|
|
@@ -5411,7 +5348,7 @@
|
|
|
5411
5348
|
currentPreparation = {
|
|
5412
5349
|
id: 1,
|
|
5413
5350
|
// TODO: [🍥]> date: $currentDate(),
|
|
5414
|
-
promptbookVersion:
|
|
5351
|
+
promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
5415
5352
|
usage: ZERO_USAGE,
|
|
5416
5353
|
};
|
|
5417
5354
|
preparations = [
|
|
@@ -5551,7 +5488,6 @@
|
|
|
5551
5488
|
* Note: This is used in `pipelineJsonToString` utility
|
|
5552
5489
|
*/
|
|
5553
5490
|
stringify: function (command) {
|
|
5554
|
-
keepUnused(command);
|
|
5555
5491
|
return "---"; // <- TODO: [🛋] Implement
|
|
5556
5492
|
},
|
|
5557
5493
|
/**
|
|
@@ -5560,7 +5496,6 @@
|
|
|
5560
5496
|
* Note: This is used in `pipelineJsonToString` utility
|
|
5561
5497
|
*/
|
|
5562
5498
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5563
|
-
keepUnused(pipelineJson);
|
|
5564
5499
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5565
5500
|
},
|
|
5566
5501
|
};
|
|
@@ -5743,7 +5678,6 @@
|
|
|
5743
5678
|
* Note: This is used in `pipelineJsonToString` utility
|
|
5744
5679
|
*/
|
|
5745
5680
|
stringify: function (command) {
|
|
5746
|
-
keepUnused(command);
|
|
5747
5681
|
return "---"; // <- TODO: [🛋] Implement
|
|
5748
5682
|
},
|
|
5749
5683
|
/**
|
|
@@ -5752,7 +5686,6 @@
|
|
|
5752
5686
|
* Note: This is used in `pipelineJsonToString` utility
|
|
5753
5687
|
*/
|
|
5754
5688
|
takeFromTemplateJson: function ($templateJson) {
|
|
5755
|
-
keepUnused($templateJson);
|
|
5756
5689
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5757
5690
|
},
|
|
5758
5691
|
};
|
|
@@ -5984,7 +5917,6 @@
|
|
|
5984
5917
|
* Note: This is used in `pipelineJsonToString` utility
|
|
5985
5918
|
*/
|
|
5986
5919
|
stringify: function (command) {
|
|
5987
|
-
keepUnused(command);
|
|
5988
5920
|
return "---"; // <- TODO: [🛋] Implement
|
|
5989
5921
|
},
|
|
5990
5922
|
/**
|
|
@@ -5993,7 +5925,6 @@
|
|
|
5993
5925
|
* Note: This is used in `pipelineJsonToString` utility
|
|
5994
5926
|
*/
|
|
5995
5927
|
takeFromTemplateJson: function ($templateJson) {
|
|
5996
|
-
keepUnused($templateJson);
|
|
5997
5928
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5998
5929
|
},
|
|
5999
5930
|
};
|
|
@@ -6312,7 +6243,6 @@
|
|
|
6312
6243
|
inputSubparameterNames: inputSubparameterNames,
|
|
6313
6244
|
outputSubparameterName: outputSubparameterName,
|
|
6314
6245
|
};
|
|
6315
|
-
keepUnused($pipelineJson); // <- TODO: [🧠] Maybe register subparameter from foreach into parameters of the pipeline
|
|
6316
6246
|
// Note: [🍭] FOREACH apply has some sideeffects on different places in codebase
|
|
6317
6247
|
},
|
|
6318
6248
|
/**
|
|
@@ -6321,7 +6251,6 @@
|
|
|
6321
6251
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6322
6252
|
*/
|
|
6323
6253
|
stringify: function (command) {
|
|
6324
|
-
keepUnused(command);
|
|
6325
6254
|
return "---"; // <- TODO: [🛋] Implement
|
|
6326
6255
|
},
|
|
6327
6256
|
/**
|
|
@@ -6330,7 +6259,6 @@
|
|
|
6330
6259
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6331
6260
|
*/
|
|
6332
6261
|
takeFromTemplateJson: function ($templateJson) {
|
|
6333
|
-
keepUnused($templateJson);
|
|
6334
6262
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6335
6263
|
},
|
|
6336
6264
|
};
|
|
@@ -6398,7 +6326,6 @@
|
|
|
6398
6326
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6399
6327
|
*/
|
|
6400
6328
|
stringify: function (command) {
|
|
6401
|
-
keepUnused(command);
|
|
6402
6329
|
return "---"; // <- TODO: [🛋] Implement
|
|
6403
6330
|
},
|
|
6404
6331
|
/**
|
|
@@ -6407,7 +6334,6 @@
|
|
|
6407
6334
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6408
6335
|
*/
|
|
6409
6336
|
takeFromTemplateJson: function ($templateJson) {
|
|
6410
|
-
keepUnused($templateJson);
|
|
6411
6337
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6412
6338
|
},
|
|
6413
6339
|
};
|
|
@@ -6470,7 +6396,6 @@
|
|
|
6470
6396
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6471
6397
|
*/
|
|
6472
6398
|
stringify: function (command) {
|
|
6473
|
-
keepUnused(command);
|
|
6474
6399
|
return "---"; // <- TODO: [🛋] Implement
|
|
6475
6400
|
},
|
|
6476
6401
|
/**
|
|
@@ -6479,7 +6404,6 @@
|
|
|
6479
6404
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6480
6405
|
*/
|
|
6481
6406
|
takeFromTemplateJson: function ($templateJson) {
|
|
6482
|
-
keepUnused($templateJson);
|
|
6483
6407
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6484
6408
|
},
|
|
6485
6409
|
};
|
|
@@ -6615,7 +6539,6 @@
|
|
|
6615
6539
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6616
6540
|
*/
|
|
6617
6541
|
stringify: function (command) {
|
|
6618
|
-
keepUnused(command);
|
|
6619
6542
|
return "---"; // <- TODO: [🛋] Implement
|
|
6620
6543
|
},
|
|
6621
6544
|
/**
|
|
@@ -6624,7 +6547,6 @@
|
|
|
6624
6547
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6625
6548
|
*/
|
|
6626
6549
|
takeFromPipelineJson: function (pipelineJson) {
|
|
6627
|
-
keepUnused(pipelineJson);
|
|
6628
6550
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6629
6551
|
},
|
|
6630
6552
|
/**
|
|
@@ -6633,7 +6555,6 @@
|
|
|
6633
6555
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6634
6556
|
*/
|
|
6635
6557
|
takeFromTemplateJson: function ($templateJson) {
|
|
6636
|
-
keepUnused($templateJson);
|
|
6637
6558
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6638
6559
|
},
|
|
6639
6560
|
};
|
|
@@ -6707,7 +6628,6 @@
|
|
|
6707
6628
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
6708
6629
|
*/
|
|
6709
6630
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
6710
|
-
keepUnused(command, $pipelineJson);
|
|
6711
6631
|
// Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
|
|
6712
6632
|
},
|
|
6713
6633
|
/**
|
|
@@ -6716,7 +6636,6 @@
|
|
|
6716
6636
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
6717
6637
|
*/
|
|
6718
6638
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
6719
|
-
keepUnused(command, $templateJson, $pipelineJson);
|
|
6720
6639
|
// Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
|
|
6721
6640
|
},
|
|
6722
6641
|
/**
|
|
@@ -6725,7 +6644,6 @@
|
|
|
6725
6644
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6726
6645
|
*/
|
|
6727
6646
|
stringify: function (command) {
|
|
6728
|
-
keepUnused(command);
|
|
6729
6647
|
return "---"; // <- TODO: [🛋] Implement
|
|
6730
6648
|
},
|
|
6731
6649
|
/**
|
|
@@ -6734,7 +6652,6 @@
|
|
|
6734
6652
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6735
6653
|
*/
|
|
6736
6654
|
takeFromPipelineJson: function (pipelineJson) {
|
|
6737
|
-
keepUnused(pipelineJson);
|
|
6738
6655
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6739
6656
|
},
|
|
6740
6657
|
/**
|
|
@@ -6743,7 +6660,6 @@
|
|
|
6743
6660
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6744
6661
|
*/
|
|
6745
6662
|
takeFromTemplateJson: function ($templateJson) {
|
|
6746
|
-
keepUnused($templateJson);
|
|
6747
6663
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6748
6664
|
},
|
|
6749
6665
|
};
|
|
@@ -6815,7 +6731,6 @@
|
|
|
6815
6731
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6816
6732
|
*/
|
|
6817
6733
|
stringify: function (command) {
|
|
6818
|
-
keepUnused(command);
|
|
6819
6734
|
return "---"; // <- TODO: [🛋] Implement
|
|
6820
6735
|
},
|
|
6821
6736
|
/**
|
|
@@ -6824,7 +6739,6 @@
|
|
|
6824
6739
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6825
6740
|
*/
|
|
6826
6741
|
takeFromPipelineJson: function (pipelineJson) {
|
|
6827
|
-
keepUnused(pipelineJson);
|
|
6828
6742
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6829
6743
|
},
|
|
6830
6744
|
/**
|
|
@@ -6833,7 +6747,6 @@
|
|
|
6833
6747
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6834
6748
|
*/
|
|
6835
6749
|
takeFromTemplateJson: function ($templateJson) {
|
|
6836
|
-
keepUnused($templateJson);
|
|
6837
6750
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6838
6751
|
},
|
|
6839
6752
|
};
|
|
@@ -6952,7 +6865,6 @@
|
|
|
6952
6865
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6953
6866
|
*/
|
|
6954
6867
|
stringify: function (command) {
|
|
6955
|
-
keepUnused(command);
|
|
6956
6868
|
return "---"; // <- TODO: [🛋] Implement
|
|
6957
6869
|
},
|
|
6958
6870
|
/**
|
|
@@ -6961,42 +6873,41 @@
|
|
|
6961
6873
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6962
6874
|
*/
|
|
6963
6875
|
takeFromTemplateJson: function ($templateJson) {
|
|
6964
|
-
keepUnused($templateJson);
|
|
6965
6876
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6966
6877
|
},
|
|
6967
6878
|
};
|
|
6968
6879
|
|
|
6969
6880
|
/**
|
|
6970
|
-
* Parses the
|
|
6881
|
+
* Parses the BOOK_VERSION command
|
|
6971
6882
|
*
|
|
6972
6883
|
* @see `documentationUrl` for more details
|
|
6973
6884
|
* @private within the commands folder
|
|
6974
6885
|
*/
|
|
6975
|
-
var
|
|
6886
|
+
var bookVersionCommandParser = {
|
|
6976
6887
|
/**
|
|
6977
6888
|
* Name of the command
|
|
6978
6889
|
*/
|
|
6979
|
-
name: '
|
|
6980
|
-
aliasNames: ['PTBK_VERSION', '
|
|
6890
|
+
name: 'BOOK_VERSION',
|
|
6891
|
+
aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
|
|
6981
6892
|
/**
|
|
6982
6893
|
* BOILERPLATE command can be used in:
|
|
6983
6894
|
*/
|
|
6984
6895
|
isUsedInPipelineHead: true,
|
|
6985
6896
|
isUsedInPipelineTemplate: false,
|
|
6986
6897
|
/**
|
|
6987
|
-
* Description of the
|
|
6898
|
+
* Description of the BOOK_VERSION command
|
|
6988
6899
|
*/
|
|
6989
|
-
description: "Which version of the
|
|
6900
|
+
description: "Which version of the Book language is the .ptbk.md using",
|
|
6990
6901
|
/**
|
|
6991
6902
|
* Link to documentation
|
|
6992
6903
|
*/
|
|
6993
6904
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
|
|
6994
6905
|
/**
|
|
6995
|
-
* Example usages of the
|
|
6906
|
+
* Example usages of the BOOK_VERSION command
|
|
6996
6907
|
*/
|
|
6997
|
-
examples: ["
|
|
6908
|
+
examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
|
|
6998
6909
|
/**
|
|
6999
|
-
* Parses the
|
|
6910
|
+
* Parses the BOOK_VERSION command
|
|
7000
6911
|
*/
|
|
7001
6912
|
parse: function (input) {
|
|
7002
6913
|
var args = input.args;
|
|
@@ -7007,16 +6918,16 @@
|
|
|
7007
6918
|
if (!isValidPromptbookVersion(promptbookVersion)) {
|
|
7008
6919
|
throw new ParseError("Invalid Promptbook version \"".concat(promptbookVersion, "\""));
|
|
7009
6920
|
}
|
|
7010
|
-
if (args.length > 0) {
|
|
6921
|
+
if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
|
|
7011
6922
|
throw new ParseError("Can not have more than one Promptbook version");
|
|
7012
6923
|
}
|
|
7013
6924
|
return {
|
|
7014
|
-
type: '
|
|
6925
|
+
type: 'BOOK_VERSION',
|
|
7015
6926
|
promptbookVersion: promptbookVersion,
|
|
7016
6927
|
};
|
|
7017
6928
|
},
|
|
7018
6929
|
/**
|
|
7019
|
-
* Apply the
|
|
6930
|
+
* Apply the BOOK_VERSION command to the `pipelineJson`
|
|
7020
6931
|
*
|
|
7021
6932
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7022
6933
|
*/
|
|
@@ -7025,21 +6936,19 @@
|
|
|
7025
6936
|
$pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
7026
6937
|
},
|
|
7027
6938
|
/**
|
|
7028
|
-
* Converts the
|
|
6939
|
+
* Converts the BOOK_VERSION command back to string
|
|
7029
6940
|
*
|
|
7030
6941
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7031
6942
|
*/
|
|
7032
6943
|
stringify: function (command) {
|
|
7033
|
-
keepUnused(command);
|
|
7034
6944
|
return "---"; // <- TODO: [🛋] Implement
|
|
7035
6945
|
},
|
|
7036
6946
|
/**
|
|
7037
|
-
* Reads the
|
|
6947
|
+
* Reads the BOOK_VERSION command from the `PipelineJson`
|
|
7038
6948
|
*
|
|
7039
6949
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7040
6950
|
*/
|
|
7041
6951
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7042
|
-
keepUnused(pipelineJson);
|
|
7043
6952
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7044
6953
|
},
|
|
7045
6954
|
};
|
|
@@ -7133,7 +7042,6 @@
|
|
|
7133
7042
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7134
7043
|
*/
|
|
7135
7044
|
stringify: function (command) {
|
|
7136
|
-
keepUnused(command);
|
|
7137
7045
|
return "---"; // <- TODO: [🛋] Implement
|
|
7138
7046
|
},
|
|
7139
7047
|
/**
|
|
@@ -7142,7 +7050,6 @@
|
|
|
7142
7050
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7143
7051
|
*/
|
|
7144
7052
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7145
|
-
keepUnused(pipelineJson);
|
|
7146
7053
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7147
7054
|
},
|
|
7148
7055
|
};
|
|
@@ -7179,8 +7086,7 @@
|
|
|
7179
7086
|
* Parses the ACTION command
|
|
7180
7087
|
*/
|
|
7181
7088
|
parse: function (input) {
|
|
7182
|
-
|
|
7183
|
-
TODO_USE(args);
|
|
7089
|
+
input.args;
|
|
7184
7090
|
return {
|
|
7185
7091
|
type: 'ACTION',
|
|
7186
7092
|
};
|
|
@@ -7191,7 +7097,6 @@
|
|
|
7191
7097
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7192
7098
|
*/
|
|
7193
7099
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7194
|
-
keepUnused(command, $pipelineJson);
|
|
7195
7100
|
console.error(new NotYetImplementedError('[🛠] Actions are not implemented yet'));
|
|
7196
7101
|
},
|
|
7197
7102
|
/**
|
|
@@ -7200,7 +7105,6 @@
|
|
|
7200
7105
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7201
7106
|
*/
|
|
7202
7107
|
stringify: function (command) {
|
|
7203
|
-
keepUnused(command);
|
|
7204
7108
|
throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
|
|
7205
7109
|
},
|
|
7206
7110
|
/**
|
|
@@ -7209,7 +7113,6 @@
|
|
|
7209
7113
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7210
7114
|
*/
|
|
7211
7115
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7212
|
-
keepUnused(pipelineJson);
|
|
7213
7116
|
throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
|
|
7214
7117
|
},
|
|
7215
7118
|
};
|
|
@@ -7249,9 +7152,7 @@
|
|
|
7249
7152
|
* Parses the INSTRUMENT command
|
|
7250
7153
|
*/
|
|
7251
7154
|
parse: function (input) {
|
|
7252
|
-
|
|
7253
|
-
// TODO: [🛠] Implement
|
|
7254
|
-
TODO_USE(args);
|
|
7155
|
+
input.args;
|
|
7255
7156
|
return {
|
|
7256
7157
|
type: 'INSTRUMENT',
|
|
7257
7158
|
};
|
|
@@ -7262,7 +7163,6 @@
|
|
|
7262
7163
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7263
7164
|
*/
|
|
7264
7165
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7265
|
-
keepUnused(command, $pipelineJson);
|
|
7266
7166
|
console.error(new NotYetImplementedError('[🛠] Instruments are not implemented yet'));
|
|
7267
7167
|
},
|
|
7268
7168
|
/**
|
|
@@ -7271,7 +7171,6 @@
|
|
|
7271
7171
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7272
7172
|
*/
|
|
7273
7173
|
stringify: function (command) {
|
|
7274
|
-
keepUnused(command);
|
|
7275
7174
|
throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
|
|
7276
7175
|
},
|
|
7277
7176
|
/**
|
|
@@ -7280,7 +7179,6 @@
|
|
|
7280
7179
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7281
7180
|
*/
|
|
7282
7181
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7283
|
-
keepUnused(pipelineJson);
|
|
7284
7182
|
throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
|
|
7285
7183
|
},
|
|
7286
7184
|
};
|
|
@@ -7345,7 +7243,6 @@
|
|
|
7345
7243
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7346
7244
|
*/
|
|
7347
7245
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7348
|
-
keepUnused(command, $pipelineJson);
|
|
7349
7246
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7350
7247
|
},
|
|
7351
7248
|
/**
|
|
@@ -7354,7 +7251,6 @@
|
|
|
7354
7251
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
7355
7252
|
*/
|
|
7356
7253
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
7357
|
-
keepUnused(command, $templateJson, $pipelineJson);
|
|
7358
7254
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7359
7255
|
},
|
|
7360
7256
|
/**
|
|
@@ -7363,7 +7259,6 @@
|
|
|
7363
7259
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7364
7260
|
*/
|
|
7365
7261
|
stringify: function (command) {
|
|
7366
|
-
keepUnused(command);
|
|
7367
7262
|
return "---"; // <- TODO: [🛋] Implement
|
|
7368
7263
|
},
|
|
7369
7264
|
/**
|
|
@@ -7372,7 +7267,6 @@
|
|
|
7372
7267
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7373
7268
|
*/
|
|
7374
7269
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7375
|
-
keepUnused(pipelineJson);
|
|
7376
7270
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7377
7271
|
},
|
|
7378
7272
|
/**
|
|
@@ -7381,7 +7275,6 @@
|
|
|
7381
7275
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7382
7276
|
*/
|
|
7383
7277
|
takeFromTemplateJson: function ($templateJson) {
|
|
7384
|
-
keepUnused($templateJson);
|
|
7385
7278
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7386
7279
|
},
|
|
7387
7280
|
};
|
|
@@ -7399,7 +7292,7 @@
|
|
|
7399
7292
|
modelCommandParser,
|
|
7400
7293
|
parameterCommandParser,
|
|
7401
7294
|
postprocessCommandParser,
|
|
7402
|
-
|
|
7295
|
+
bookVersionCommandParser,
|
|
7403
7296
|
urlCommandParser,
|
|
7404
7297
|
knowledgeCommandParser,
|
|
7405
7298
|
actionCommandParser,
|
|
@@ -7551,9 +7444,7 @@
|
|
|
7551
7444
|
var _loop_1 = function (commandParser) {
|
|
7552
7445
|
// <- Note: [🦦] Its strange that this type assertion is needed
|
|
7553
7446
|
var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTemplate = commandParser.isUsedInPipelineTemplate, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
|
|
7554
|
-
if (just(false))
|
|
7555
|
-
keepUnused( /* for better indentation */);
|
|
7556
|
-
}
|
|
7447
|
+
if (just(false)) ;
|
|
7557
7448
|
else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
|
|
7558
7449
|
return "continue";
|
|
7559
7450
|
}
|
|
@@ -7713,7 +7604,7 @@
|
|
|
7713
7604
|
return;
|
|
7714
7605
|
}
|
|
7715
7606
|
if (!section.startsWith('#')) {
|
|
7716
|
-
section = "#
|
|
7607
|
+
section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
|
|
7717
7608
|
}
|
|
7718
7609
|
sections.push(section);
|
|
7719
7610
|
buffer = [];
|
|
@@ -7777,7 +7668,7 @@
|
|
|
7777
7668
|
var e_1, _a;
|
|
7778
7669
|
var sections = splitMarkdownIntoSections(markdown);
|
|
7779
7670
|
if (sections.length === 0) {
|
|
7780
|
-
return
|
|
7671
|
+
return "# ".concat(DEFAULT_TITLE);
|
|
7781
7672
|
}
|
|
7782
7673
|
var flattenedMarkdown = '';
|
|
7783
7674
|
var parsedSections = sections.map(parseMarkdownSection);
|
|
@@ -7788,7 +7679,7 @@
|
|
|
7788
7679
|
}
|
|
7789
7680
|
else {
|
|
7790
7681
|
parsedSections.unshift(firstSection);
|
|
7791
|
-
flattenedMarkdown += "#
|
|
7682
|
+
flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
|
|
7792
7683
|
}
|
|
7793
7684
|
try {
|
|
7794
7685
|
for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
|
|
@@ -7866,7 +7757,7 @@
|
|
|
7866
7757
|
* @public exported from `@promptbook/core`
|
|
7867
7758
|
*/
|
|
7868
7759
|
function pipelineStringToJsonSync(pipelineString) {
|
|
7869
|
-
var e_1, _a, e_2, _b;
|
|
7760
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
7870
7761
|
var $pipelineJson = {
|
|
7871
7762
|
title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
|
|
7872
7763
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
@@ -7893,11 +7784,18 @@
|
|
|
7893
7784
|
}
|
|
7894
7785
|
// =============================================================
|
|
7895
7786
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
7787
|
+
if (pipelineString.startsWith('#!')) {
|
|
7788
|
+
var _e = __read(pipelineString.split('\n')), shebangLine_1 = _e[0], restLines = _e.slice(1);
|
|
7789
|
+
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
7790
|
+
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
7791
|
+
}
|
|
7792
|
+
pipelineString = restLines.join('\n');
|
|
7793
|
+
}
|
|
7896
7794
|
pipelineString = removeContentComments(pipelineString);
|
|
7897
7795
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
7898
7796
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
7899
7797
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
7900
|
-
var
|
|
7798
|
+
var _f = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _f[0], pipelineSections = _f.slice(1); /* <- Note: [🥞] */
|
|
7901
7799
|
if (pipelineHead === undefined) {
|
|
7902
7800
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
7903
7801
|
}
|
|
@@ -7925,6 +7823,8 @@
|
|
|
7925
7823
|
if (parameterDescription) {
|
|
7926
7824
|
existingParameter.description = parameterDescription;
|
|
7927
7825
|
}
|
|
7826
|
+
existingParameter.isInput = existingParameter.isInput || isInput;
|
|
7827
|
+
existingParameter.isOutput = existingParameter.isOutput || isOutput;
|
|
7928
7828
|
}
|
|
7929
7829
|
else {
|
|
7930
7830
|
$pipelineJson.parameters.push({
|
|
@@ -7987,10 +7887,10 @@
|
|
|
7987
7887
|
finally { if (e_1) throw e_1.error; }
|
|
7988
7888
|
}
|
|
7989
7889
|
var _loop_2 = function (section) {
|
|
7990
|
-
var
|
|
7890
|
+
var e_5, _l, e_6, _m;
|
|
7991
7891
|
// TODO: Parse template description (the content out of the codeblock and lists)
|
|
7992
7892
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
7993
|
-
var
|
|
7893
|
+
var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
|
|
7994
7894
|
// TODO: [🎾][1] DRY description
|
|
7995
7895
|
var description_1 = section.content;
|
|
7996
7896
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -8031,7 +7931,7 @@
|
|
|
8031
7931
|
}) === false) {
|
|
8032
7932
|
templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
|
|
8033
7933
|
}
|
|
8034
|
-
var
|
|
7934
|
+
var _loop_4 = function (listItem, command) {
|
|
8035
7935
|
var commandParser = getParserForCommand(command);
|
|
8036
7936
|
if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
|
|
8037
7937
|
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the template of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
@@ -8054,17 +7954,17 @@
|
|
|
8054
7954
|
};
|
|
8055
7955
|
try {
|
|
8056
7956
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
8057
|
-
for (var commands_1 = (
|
|
8058
|
-
var
|
|
8059
|
-
|
|
7957
|
+
for (var commands_1 = (e_5 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
7958
|
+
var _p = commands_1_1.value, listItem = _p.listItem, command = _p.command;
|
|
7959
|
+
_loop_4(listItem, command);
|
|
8060
7960
|
}
|
|
8061
7961
|
}
|
|
8062
|
-
catch (
|
|
7962
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
8063
7963
|
finally {
|
|
8064
7964
|
try {
|
|
8065
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
7965
|
+
if (commands_1_1 && !commands_1_1.done && (_l = commands_1.return)) _l.call(commands_1);
|
|
8066
7966
|
}
|
|
8067
|
-
finally { if (
|
|
7967
|
+
finally { if (e_5) throw e_5.error; }
|
|
8068
7968
|
}
|
|
8069
7969
|
// TODO: [🍧] Should be done in TEMPLATE command
|
|
8070
7970
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
@@ -8078,6 +7978,26 @@
|
|
|
8078
7978
|
language;
|
|
8079
7979
|
}
|
|
8080
7980
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
7981
|
+
try {
|
|
7982
|
+
for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
7983
|
+
var parameterName = _r.value;
|
|
7984
|
+
// TODO: [🧠] This definition should be made first in the template
|
|
7985
|
+
defineParam({
|
|
7986
|
+
parameterName: parameterName,
|
|
7987
|
+
parameterDescription: null,
|
|
7988
|
+
isInput: false,
|
|
7989
|
+
isOutput: false,
|
|
7990
|
+
// <- Note: In this case null+false+false means that we do not know yet if it is input or output and we will set it later
|
|
7991
|
+
});
|
|
7992
|
+
}
|
|
7993
|
+
}
|
|
7994
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
7995
|
+
finally {
|
|
7996
|
+
try {
|
|
7997
|
+
if (_r && !_r.done && (_m = _q.return)) _m.call(_q);
|
|
7998
|
+
}
|
|
7999
|
+
finally { if (e_6) throw e_6.error; }
|
|
8000
|
+
}
|
|
8081
8001
|
/*
|
|
8082
8002
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
8083
8003
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
@@ -8119,9 +8039,51 @@
|
|
|
8119
8039
|
finally { if (e_2) throw e_2.error; }
|
|
8120
8040
|
}
|
|
8121
8041
|
// =============================================================
|
|
8122
|
-
// Note: 5️⃣
|
|
8042
|
+
// Note: 5️⃣ Mark parameters as INPUT if not explicitly set
|
|
8043
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
8044
|
+
var _loop_3 = function (parameter) {
|
|
8045
|
+
var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
|
|
8046
|
+
if (!isThisParameterResulting) {
|
|
8047
|
+
parameter.isInput = true;
|
|
8048
|
+
}
|
|
8049
|
+
};
|
|
8050
|
+
try {
|
|
8051
|
+
for (var _g = __values($pipelineJson.parameters), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
8052
|
+
var parameter = _h.value;
|
|
8053
|
+
_loop_3(parameter);
|
|
8054
|
+
}
|
|
8055
|
+
}
|
|
8056
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
8057
|
+
finally {
|
|
8058
|
+
try {
|
|
8059
|
+
if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
|
|
8060
|
+
}
|
|
8061
|
+
finally { if (e_3) throw e_3.error; }
|
|
8062
|
+
}
|
|
8063
|
+
}
|
|
8064
|
+
// =============================================================
|
|
8065
|
+
// Note: 6️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
8066
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
8067
|
+
try {
|
|
8068
|
+
for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
8069
|
+
var parameter = _k.value;
|
|
8070
|
+
if (!parameter.isInput) {
|
|
8071
|
+
parameter.isOutput = true;
|
|
8072
|
+
}
|
|
8073
|
+
}
|
|
8074
|
+
}
|
|
8075
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
8076
|
+
finally {
|
|
8077
|
+
try {
|
|
8078
|
+
if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
|
|
8079
|
+
}
|
|
8080
|
+
finally { if (e_4) throw e_4.error; }
|
|
8081
|
+
}
|
|
8082
|
+
}
|
|
8083
|
+
// =============================================================
|
|
8084
|
+
// Note: 7️⃣ Cleanup of undefined values
|
|
8123
8085
|
$pipelineJson.templates.forEach(function (templates) {
|
|
8124
|
-
var
|
|
8086
|
+
var e_7, _a;
|
|
8125
8087
|
try {
|
|
8126
8088
|
for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8127
8089
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8130,16 +8092,16 @@
|
|
|
8130
8092
|
}
|
|
8131
8093
|
}
|
|
8132
8094
|
}
|
|
8133
|
-
catch (
|
|
8095
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
8134
8096
|
finally {
|
|
8135
8097
|
try {
|
|
8136
8098
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8137
8099
|
}
|
|
8138
|
-
finally { if (
|
|
8100
|
+
finally { if (e_7) throw e_7.error; }
|
|
8139
8101
|
}
|
|
8140
8102
|
});
|
|
8141
8103
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
8142
|
-
var
|
|
8104
|
+
var e_8, _a;
|
|
8143
8105
|
try {
|
|
8144
8106
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8145
8107
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8148,12 +8110,12 @@
|
|
|
8148
8110
|
}
|
|
8149
8111
|
}
|
|
8150
8112
|
}
|
|
8151
|
-
catch (
|
|
8113
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
8152
8114
|
finally {
|
|
8153
8115
|
try {
|
|
8154
8116
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8155
8117
|
}
|
|
8156
|
-
finally { if (
|
|
8118
|
+
finally { if (e_8) throw e_8.error; }
|
|
8157
8119
|
}
|
|
8158
8120
|
});
|
|
8159
8121
|
// =============================================================
|
|
@@ -8272,8 +8234,7 @@
|
|
|
8272
8234
|
if (!$isRunningInNode()) {
|
|
8273
8235
|
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8274
8236
|
}
|
|
8275
|
-
|
|
8276
|
-
TODO_USE(isVerbose);
|
|
8237
|
+
(options || {}).isVerbose;
|
|
8277
8238
|
return {
|
|
8278
8239
|
stat: promises.stat,
|
|
8279
8240
|
access: promises.access,
|
|
@@ -8519,7 +8480,7 @@
|
|
|
8519
8480
|
*/
|
|
8520
8481
|
function $provideExecutablesForNode(options) {
|
|
8521
8482
|
return __awaiter(this, void 0, void 0, function () {
|
|
8522
|
-
var _a
|
|
8483
|
+
var _a;
|
|
8523
8484
|
var _d;
|
|
8524
8485
|
return __generator(this, function (_e) {
|
|
8525
8486
|
switch (_e.label) {
|
|
@@ -8527,9 +8488,7 @@
|
|
|
8527
8488
|
if (!$isRunningInNode()) {
|
|
8528
8489
|
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8529
8490
|
}
|
|
8530
|
-
_a = options || {},
|
|
8531
|
-
TODO_USE(isAutoInstalled); // <- TODO: [🔱][🧠] Auto-install the executables
|
|
8532
|
-
TODO_USE(isVerbose);
|
|
8491
|
+
_a = options || {}, _a.isAutoInstalled, _a.isVerbose;
|
|
8533
8492
|
_d = {};
|
|
8534
8493
|
return [4 /*yield*/, locatePandoc()];
|
|
8535
8494
|
case 1:
|
|
@@ -8786,7 +8745,7 @@
|
|
|
8786
8745
|
*/
|
|
8787
8746
|
function $provideScrapersForNode(tools, options) {
|
|
8788
8747
|
return __awaiter(this, void 0, void 0, function () {
|
|
8789
|
-
var _a,
|
|
8748
|
+
var _a, scrapers, _d, _e, scraperFactory, scraper, e_1_1;
|
|
8790
8749
|
var e_1, _f;
|
|
8791
8750
|
return __generator(this, function (_g) {
|
|
8792
8751
|
switch (_g.label) {
|
|
@@ -8794,9 +8753,7 @@
|
|
|
8794
8753
|
if (!$isRunningInNode()) {
|
|
8795
8754
|
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8796
8755
|
}
|
|
8797
|
-
_a = options || {},
|
|
8798
|
-
TODO_USE(isAutoInstalled);
|
|
8799
|
-
TODO_USE(isVerbose);
|
|
8756
|
+
_a = options || {}, _a.isAutoInstalled, _a.isVerbose;
|
|
8800
8757
|
scrapers = [];
|
|
8801
8758
|
_g.label = 1;
|
|
8802
8759
|
case 1:
|
|
@@ -9937,12 +9894,9 @@
|
|
|
9937
9894
|
})
|
|
9938
9895
|
.filter(function (arg) { return arg !== ''; });
|
|
9939
9896
|
if (_.length > 1) {
|
|
9940
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9941
9897
|
_a = __read(_), command = _a[0], args = _a.slice(1);
|
|
9942
9898
|
}
|
|
9943
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9944
9899
|
if (options.args) {
|
|
9945
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9946
9900
|
args = __spreadArray(__spreadArray([], __read(args), false), __read(options.args), false);
|
|
9947
9901
|
}
|
|
9948
9902
|
var humanReadableCommand = !['npx', 'npm'].includes(command) ? command : args[0];
|
|
@@ -10113,8 +10067,9 @@
|
|
|
10113
10067
|
exports.$provideLlmToolsConfigurationFromEnv = $provideLlmToolsConfigurationFromEnv;
|
|
10114
10068
|
exports.$provideLlmToolsFromEnv = $provideLlmToolsFromEnv;
|
|
10115
10069
|
exports.$provideScrapersForNode = $provideScrapersForNode;
|
|
10070
|
+
exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
|
|
10116
10071
|
exports.FileCacheStorage = FileCacheStorage;
|
|
10117
|
-
exports.
|
|
10072
|
+
exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
|
|
10118
10073
|
exports.createCollectionFromDirectory = createCollectionFromDirectory;
|
|
10119
10074
|
|
|
10120
10075
|
Object.defineProperty(exports, '__esModule', { value: true });
|