@promptbook/core 0.36.3 → 0.37.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.
- package/esm/index.es.js +117 -62
- package/esm/index.es.js.map +1 -1
- package/esm/typings/_packages/wizzard.index.d.ts +3 -0
- package/esm/typings/classes/PromptbookLibrary.d.ts +1 -1
- package/esm/typings/execution/createPromptbookExecutor.d.ts +1 -0
- package/esm/typings/types/Command.d.ts +2 -1
- package/esm/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +4 -2
- package/esm/typings/wizzard/Wizzard.d.ts +3 -0
- package/esm/typings/wizzard/sample.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +117 -62
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/_packages/wizzard.index.d.ts +3 -0
- package/umd/typings/classes/PromptbookLibrary.d.ts +1 -1
- package/umd/typings/execution/createPromptbookExecutor.d.ts +1 -0
- package/umd/typings/types/Command.d.ts +2 -1
- package/umd/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +4 -2
- package/umd/typings/wizzard/Wizzard.d.ts +3 -0
- package/umd/typings/wizzard/sample.d.ts +1 -0
package/esm/index.es.js
CHANGED
|
@@ -423,7 +423,7 @@ function removeContentComments(content) {
|
|
|
423
423
|
/**
|
|
424
424
|
* The version of the Promptbook library
|
|
425
425
|
*/
|
|
426
|
-
var PROMPTBOOK_VERSION = '0.36.
|
|
426
|
+
var PROMPTBOOK_VERSION = '0.36.4';
|
|
427
427
|
|
|
428
428
|
/**
|
|
429
429
|
* Execution type describes the way how the block is executed
|
|
@@ -636,12 +636,14 @@ function parseCommand(listItem) {
|
|
|
636
636
|
if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
|
|
637
637
|
throw new Error(spaceTrim("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
|
|
638
638
|
}
|
|
639
|
-
var
|
|
639
|
+
var isInput = type.startsWith('INPUT');
|
|
640
|
+
var isOutput = type.startsWith('OUTPUT');
|
|
640
641
|
return {
|
|
641
642
|
type: 'PARAMETER',
|
|
642
643
|
parameterName: parameterName,
|
|
643
644
|
parameterDescription: parameterDescription.trim() || null,
|
|
644
|
-
|
|
645
|
+
isInput: isInput,
|
|
646
|
+
isOutput: isOutput,
|
|
645
647
|
};
|
|
646
648
|
}
|
|
647
649
|
else if (type.startsWith('JOKER')) {
|
|
@@ -773,7 +775,7 @@ function promptbookStringToJson(promptbookString) {
|
|
|
773
775
|
// =============================================================
|
|
774
776
|
///Note: 2️⃣ Function for adding parameters
|
|
775
777
|
var addParam = function (parameterCommand) {
|
|
776
|
-
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription,
|
|
778
|
+
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
777
779
|
var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
778
780
|
if (existingParameter &&
|
|
779
781
|
existingParameter.description &&
|
|
@@ -790,7 +792,8 @@ function promptbookStringToJson(promptbookString) {
|
|
|
790
792
|
promptbookJson.parameters.push({
|
|
791
793
|
name: parameterName,
|
|
792
794
|
description: parameterDescription || undefined,
|
|
793
|
-
isInput:
|
|
795
|
+
isInput: isInput,
|
|
796
|
+
isOutput: isOutput,
|
|
794
797
|
});
|
|
795
798
|
}
|
|
796
799
|
};
|
|
@@ -1037,7 +1040,7 @@ function promptbookStringToJson(promptbookString) {
|
|
|
1037
1040
|
* @throws {Error} if invalid
|
|
1038
1041
|
*/
|
|
1039
1042
|
function validatePromptbookJson(promptbook) {
|
|
1040
|
-
var e_1, _a, e_2, _b, e_3, _c;
|
|
1043
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
1041
1044
|
var definedParameters = new Set(promptbook.parameters.filter(function (_a) {
|
|
1042
1045
|
var isInput = _a.isInput;
|
|
1043
1046
|
return isInput;
|
|
@@ -1045,10 +1048,40 @@ function validatePromptbookJson(promptbook) {
|
|
|
1045
1048
|
var name = _a.name;
|
|
1046
1049
|
return name;
|
|
1047
1050
|
}));
|
|
1051
|
+
var _loop_1 = function (parameter) {
|
|
1052
|
+
if (parameter.isInput && parameter.isOutput) {
|
|
1053
|
+
throw new Error("Parameter {".concat(parameter.name, "} can not be both input and output"));
|
|
1054
|
+
}
|
|
1055
|
+
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
1056
|
+
if (!parameter.isInput &&
|
|
1057
|
+
!parameter.isOutput &&
|
|
1058
|
+
!promptbook.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
|
|
1059
|
+
throw new Error(spaceTrim("\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ")));
|
|
1060
|
+
}
|
|
1061
|
+
// Note: Testing that parameter is either input or result of some template
|
|
1062
|
+
if (!parameter.isInput &&
|
|
1063
|
+
!promptbook.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
|
|
1064
|
+
throw new Error(spaceTrim("\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ")));
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
try {
|
|
1068
|
+
// Note: Check each parameter individually
|
|
1069
|
+
for (var _e = __values(promptbook.parameters), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1070
|
+
var parameter = _f.value;
|
|
1071
|
+
_loop_1(parameter);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1075
|
+
finally {
|
|
1076
|
+
try {
|
|
1077
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
1078
|
+
}
|
|
1079
|
+
finally { if (e_1) throw e_1.error; }
|
|
1080
|
+
}
|
|
1048
1081
|
try {
|
|
1049
1082
|
// Note: Check each template individually
|
|
1050
|
-
for (var
|
|
1051
|
-
var template =
|
|
1083
|
+
for (var _g = __values(promptbook.promptTemplates), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
1084
|
+
var template = _h.value;
|
|
1052
1085
|
if (definedParameters.has(template.resultingParameterName)) {
|
|
1053
1086
|
throw new Error("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
|
|
1054
1087
|
}
|
|
@@ -1063,25 +1096,25 @@ function validatePromptbookJson(promptbook) {
|
|
|
1063
1096
|
throw new Error("Joker parameters are used but no expectations are defined");
|
|
1064
1097
|
}
|
|
1065
1098
|
try {
|
|
1066
|
-
for (var
|
|
1067
|
-
var joker =
|
|
1099
|
+
for (var _j = (e_3 = void 0, __values(template.jokers)), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
1100
|
+
var joker = _k.value;
|
|
1068
1101
|
if (!template.dependentParameterNames.includes(joker)) {
|
|
1069
1102
|
throw new Error("Parameter {".concat(joker, "} is used as joker but not in dependentParameterNames"));
|
|
1070
1103
|
}
|
|
1071
1104
|
}
|
|
1072
1105
|
}
|
|
1073
|
-
catch (
|
|
1106
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1074
1107
|
finally {
|
|
1075
1108
|
try {
|
|
1076
|
-
if (
|
|
1109
|
+
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
1077
1110
|
}
|
|
1078
|
-
finally { if (
|
|
1111
|
+
finally { if (e_3) throw e_3.error; }
|
|
1079
1112
|
}
|
|
1080
1113
|
}
|
|
1081
1114
|
if (template.expectAmount) {
|
|
1082
1115
|
try {
|
|
1083
|
-
for (var
|
|
1084
|
-
var
|
|
1116
|
+
for (var _l = (e_4 = void 0, __values(Object.entries(template.expectAmount))), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
1117
|
+
var _o = __read(_m.value, 2), unit = _o[0], _p = _o[1], min = _p.min, max = _p.max;
|
|
1085
1118
|
if (min !== undefined && max !== undefined && min > max) {
|
|
1086
1119
|
throw new Error("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
|
|
1087
1120
|
}
|
|
@@ -1093,23 +1126,23 @@ function validatePromptbookJson(promptbook) {
|
|
|
1093
1126
|
}
|
|
1094
1127
|
}
|
|
1095
1128
|
}
|
|
1096
|
-
catch (
|
|
1129
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1097
1130
|
finally {
|
|
1098
1131
|
try {
|
|
1099
|
-
if (
|
|
1132
|
+
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
|
1100
1133
|
}
|
|
1101
|
-
finally { if (
|
|
1134
|
+
finally { if (e_4) throw e_4.error; }
|
|
1102
1135
|
}
|
|
1103
1136
|
}
|
|
1104
1137
|
definedParameters.add(template.resultingParameterName);
|
|
1105
1138
|
}
|
|
1106
1139
|
}
|
|
1107
|
-
catch (
|
|
1140
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1108
1141
|
finally {
|
|
1109
1142
|
try {
|
|
1110
|
-
if (
|
|
1143
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
1111
1144
|
}
|
|
1112
|
-
finally { if (
|
|
1145
|
+
finally { if (e_2) throw e_2.error; }
|
|
1113
1146
|
}
|
|
1114
1147
|
// Note: Detect circular dependencies
|
|
1115
1148
|
var resovedParameters = promptbook.parameters
|
|
@@ -1122,7 +1155,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
1122
1155
|
return name;
|
|
1123
1156
|
});
|
|
1124
1157
|
var unresovedTemplates = __spreadArray([], __read(promptbook.promptTemplates), false);
|
|
1125
|
-
var
|
|
1158
|
+
var _loop_2 = function () {
|
|
1126
1159
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
1127
1160
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1128
1161
|
});
|
|
@@ -1143,7 +1176,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
1143
1176
|
unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
|
|
1144
1177
|
};
|
|
1145
1178
|
while (unresovedTemplates.length > 0) {
|
|
1146
|
-
|
|
1179
|
+
_loop_2();
|
|
1147
1180
|
}
|
|
1148
1181
|
}
|
|
1149
1182
|
/**
|
|
@@ -1324,15 +1357,15 @@ function createPromptbookExecutor(options) {
|
|
|
1324
1357
|
var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
1325
1358
|
function executeSingleTemplate(currentTemplate) {
|
|
1326
1359
|
return __awaiter(this, void 0, void 0, function () {
|
|
1327
|
-
var name, title, priority, prompt, chatThread, completionResult, result, resultString, expectError, scriptExecutionErrors, maxAttempts, jokers, attempt, isJokerAttempt, joker, _a, _b, _c, _d, scriptTools, error_2,
|
|
1328
|
-
var
|
|
1360
|
+
var name, title, priority, prompt, chatThread, completionResult, result, resultString, expectError, scriptExecutionErrors, maxAttempts, jokers, attempt, isJokerAttempt, joker, _a, _b, _c, _d, scriptTools, error_2, e_2_1, _e, _f, functionName, postprocessingError, _g, _h, scriptTools, error_3, e_3_1, e_4_1, _j, _k, _l, unit, _m, max, min, amount, error_4;
|
|
1361
|
+
var e_2, _o, e_4, _p, e_3, _q, e_5, _r, _s;
|
|
1329
1362
|
return __generator(this, function (_t) {
|
|
1330
1363
|
switch (_t.label) {
|
|
1331
1364
|
case 0:
|
|
1332
1365
|
name = "promptbook-executor-frame-".concat(currentTemplate.name);
|
|
1333
1366
|
title = currentTemplate.title;
|
|
1334
1367
|
priority = promptbook.promptTemplates.length - promptbook.promptTemplates.indexOf(currentTemplate);
|
|
1335
|
-
if (!onProgress) return [3 /*break*/, 2];
|
|
1368
|
+
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
1336
1369
|
return [4 /*yield*/, onProgress({
|
|
1337
1370
|
name: name,
|
|
1338
1371
|
title: title,
|
|
@@ -1341,6 +1374,7 @@ function createPromptbookExecutor(options) {
|
|
|
1341
1374
|
executionType: currentTemplate.executionType,
|
|
1342
1375
|
parameterName: currentTemplate.resultingParameterName,
|
|
1343
1376
|
parameterValue: null,
|
|
1377
|
+
// <- [3]
|
|
1344
1378
|
})];
|
|
1345
1379
|
case 1:
|
|
1346
1380
|
_t.sent();
|
|
@@ -1428,7 +1462,7 @@ function createPromptbookExecutor(options) {
|
|
|
1428
1462
|
_t.label = 14;
|
|
1429
1463
|
case 14:
|
|
1430
1464
|
_t.trys.push([14, 21, 22, 23]);
|
|
1431
|
-
_c = (
|
|
1465
|
+
_c = (e_2 = void 0, __values(tools.script)), _d = _c.next();
|
|
1432
1466
|
_t.label = 15;
|
|
1433
1467
|
case 15:
|
|
1434
1468
|
if (!!_d.done) return [3 /*break*/, 20];
|
|
@@ -1456,14 +1490,14 @@ function createPromptbookExecutor(options) {
|
|
|
1456
1490
|
return [3 /*break*/, 15];
|
|
1457
1491
|
case 20: return [3 /*break*/, 23];
|
|
1458
1492
|
case 21:
|
|
1459
|
-
|
|
1460
|
-
|
|
1493
|
+
e_2_1 = _t.sent();
|
|
1494
|
+
e_2 = { error: e_2_1 };
|
|
1461
1495
|
return [3 /*break*/, 23];
|
|
1462
1496
|
case 22:
|
|
1463
1497
|
try {
|
|
1464
1498
|
if (_d && !_d.done && (_o = _c.return)) _o.call(_c);
|
|
1465
1499
|
}
|
|
1466
|
-
finally { if (
|
|
1500
|
+
finally { if (e_2) throw e_2.error; }
|
|
1467
1501
|
return [7 /*endfinally*/];
|
|
1468
1502
|
case 23:
|
|
1469
1503
|
if (resultString) {
|
|
@@ -1497,7 +1531,7 @@ function createPromptbookExecutor(options) {
|
|
|
1497
1531
|
_t.label = 28;
|
|
1498
1532
|
case 28:
|
|
1499
1533
|
_t.trys.push([28, 42, 43, 44]);
|
|
1500
|
-
_e = (
|
|
1534
|
+
_e = (e_4 = void 0, __values(currentTemplate.postprocessing)), _f = _e.next();
|
|
1501
1535
|
_t.label = 29;
|
|
1502
1536
|
case 29:
|
|
1503
1537
|
if (!!_f.done) return [3 /*break*/, 41];
|
|
@@ -1508,7 +1542,7 @@ function createPromptbookExecutor(options) {
|
|
|
1508
1542
|
_t.label = 30;
|
|
1509
1543
|
case 30:
|
|
1510
1544
|
_t.trys.push([30, 37, 38, 39]);
|
|
1511
|
-
_g = (
|
|
1545
|
+
_g = (e_3 = void 0, __values(tools.script)), _h = _g.next();
|
|
1512
1546
|
_t.label = 31;
|
|
1513
1547
|
case 31:
|
|
1514
1548
|
if (!!_h.done) return [3 /*break*/, 36];
|
|
@@ -1538,14 +1572,14 @@ function createPromptbookExecutor(options) {
|
|
|
1538
1572
|
return [3 /*break*/, 31];
|
|
1539
1573
|
case 36: return [3 /*break*/, 39];
|
|
1540
1574
|
case 37:
|
|
1541
|
-
|
|
1542
|
-
|
|
1575
|
+
e_3_1 = _t.sent();
|
|
1576
|
+
e_3 = { error: e_3_1 };
|
|
1543
1577
|
return [3 /*break*/, 39];
|
|
1544
1578
|
case 38:
|
|
1545
1579
|
try {
|
|
1546
1580
|
if (_h && !_h.done && (_q = _g.return)) _q.call(_g);
|
|
1547
1581
|
}
|
|
1548
|
-
finally { if (
|
|
1582
|
+
finally { if (e_3) throw e_3.error; }
|
|
1549
1583
|
return [7 /*endfinally*/];
|
|
1550
1584
|
case 39:
|
|
1551
1585
|
if (postprocessingError) {
|
|
@@ -1557,14 +1591,14 @@ function createPromptbookExecutor(options) {
|
|
|
1557
1591
|
return [3 /*break*/, 29];
|
|
1558
1592
|
case 41: return [3 /*break*/, 44];
|
|
1559
1593
|
case 42:
|
|
1560
|
-
|
|
1561
|
-
|
|
1594
|
+
e_4_1 = _t.sent();
|
|
1595
|
+
e_4 = { error: e_4_1 };
|
|
1562
1596
|
return [3 /*break*/, 44];
|
|
1563
1597
|
case 43:
|
|
1564
1598
|
try {
|
|
1565
1599
|
if (_f && !_f.done && (_p = _e.return)) _p.call(_e);
|
|
1566
1600
|
}
|
|
1567
|
-
finally { if (
|
|
1601
|
+
finally { if (e_4) throw e_4.error; }
|
|
1568
1602
|
return [7 /*endfinally*/];
|
|
1569
1603
|
case 44:
|
|
1570
1604
|
if (currentTemplate.expectFormat) {
|
|
@@ -1576,7 +1610,7 @@ function createPromptbookExecutor(options) {
|
|
|
1576
1610
|
}
|
|
1577
1611
|
if (currentTemplate.expectAmount) {
|
|
1578
1612
|
try {
|
|
1579
|
-
for (_j = (
|
|
1613
|
+
for (_j = (e_5 = void 0, __values(Object.entries(currentTemplate.expectAmount))), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
1580
1614
|
_l = __read(_k.value, 2), unit = _l[0], _m = _l[1], max = _m.max, min = _m.min;
|
|
1581
1615
|
amount = CountUtils[unit.toUpperCase()](resultString || '');
|
|
1582
1616
|
if (min && amount < min) {
|
|
@@ -1587,12 +1621,12 @@ function createPromptbookExecutor(options) {
|
|
|
1587
1621
|
}
|
|
1588
1622
|
}
|
|
1589
1623
|
}
|
|
1590
|
-
catch (
|
|
1624
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1591
1625
|
finally {
|
|
1592
1626
|
try {
|
|
1593
1627
|
if (_k && !_k.done && (_r = _j.return)) _r.call(_j);
|
|
1594
1628
|
}
|
|
1595
|
-
finally { if (
|
|
1629
|
+
finally { if (e_5) throw e_5.error; }
|
|
1596
1630
|
}
|
|
1597
1631
|
}
|
|
1598
1632
|
return [3 /*break*/, 49];
|
|
@@ -1636,7 +1670,7 @@ function createPromptbookExecutor(options) {
|
|
|
1636
1670
|
// <- TODO: [🥨] Make some NeverShouldHappenError
|
|
1637
1671
|
throw new Error('Something went wrong and prompt result is null');
|
|
1638
1672
|
}
|
|
1639
|
-
if (onProgress) {
|
|
1673
|
+
if (onProgress /* <- [3] */) {
|
|
1640
1674
|
onProgress({
|
|
1641
1675
|
name: name,
|
|
1642
1676
|
title: title,
|
|
@@ -1645,6 +1679,7 @@ function createPromptbookExecutor(options) {
|
|
|
1645
1679
|
executionType: currentTemplate.executionType,
|
|
1646
1680
|
parameterName: currentTemplate.resultingParameterName,
|
|
1647
1681
|
parameterValue: resultString,
|
|
1682
|
+
// <- [3]
|
|
1648
1683
|
});
|
|
1649
1684
|
}
|
|
1650
1685
|
parametersToPass = __assign(__assign({}, parametersToPass), (_s = {}, _s[currentTemplate.resultingParameterName] = resultString /* <- Note: Not need to detect parameter collision here because Promptbook checks logic consistency during construction */, _s));
|
|
@@ -1653,9 +1688,10 @@ function createPromptbookExecutor(options) {
|
|
|
1653
1688
|
});
|
|
1654
1689
|
});
|
|
1655
1690
|
}
|
|
1656
|
-
var parametersToPass, executionReport, resovedParameters_1, unresovedTemplates, resolving_1, _loop_1, error_1;
|
|
1657
|
-
|
|
1658
|
-
|
|
1691
|
+
var parametersToPass, executionReport, resovedParameters_1, unresovedTemplates, resolving_1, _loop_1, error_1, _a, _b, parameter;
|
|
1692
|
+
var e_1, _c;
|
|
1693
|
+
return __generator(this, function (_d) {
|
|
1694
|
+
switch (_d.label) {
|
|
1659
1695
|
case 0:
|
|
1660
1696
|
parametersToPass = inputParameters;
|
|
1661
1697
|
executionReport = {
|
|
@@ -1666,9 +1702,9 @@ function createPromptbookExecutor(options) {
|
|
|
1666
1702
|
description: promptbook.description,
|
|
1667
1703
|
promptExecutions: [],
|
|
1668
1704
|
};
|
|
1669
|
-
|
|
1705
|
+
_d.label = 1;
|
|
1670
1706
|
case 1:
|
|
1671
|
-
|
|
1707
|
+
_d.trys.push([1, 6, , 7]);
|
|
1672
1708
|
resovedParameters_1 = promptbook.parameters
|
|
1673
1709
|
.filter(function (_a) {
|
|
1674
1710
|
var isInput = _a.isInput;
|
|
@@ -1682,8 +1718,8 @@ function createPromptbookExecutor(options) {
|
|
|
1682
1718
|
resolving_1 = [];
|
|
1683
1719
|
_loop_1 = function () {
|
|
1684
1720
|
var currentTemplate, work_1;
|
|
1685
|
-
return __generator(this, function (
|
|
1686
|
-
switch (
|
|
1721
|
+
return __generator(this, function (_e) {
|
|
1722
|
+
switch (_e.label) {
|
|
1687
1723
|
case 0:
|
|
1688
1724
|
currentTemplate = unresovedTemplates.find(function (template) {
|
|
1689
1725
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
@@ -1694,7 +1730,7 @@ function createPromptbookExecutor(options) {
|
|
|
1694
1730
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
1695
1731
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
1696
1732
|
case 2:
|
|
1697
|
-
/* [5] */
|
|
1733
|
+
/* [5] */ _e.sent();
|
|
1698
1734
|
return [3 /*break*/, 4];
|
|
1699
1735
|
case 3:
|
|
1700
1736
|
unresovedTemplates = unresovedTemplates.filter(function (template) { return template !== currentTemplate; });
|
|
@@ -1706,24 +1742,24 @@ function createPromptbookExecutor(options) {
|
|
|
1706
1742
|
resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
|
|
1707
1743
|
});
|
|
1708
1744
|
resolving_1.push(work_1);
|
|
1709
|
-
|
|
1745
|
+
_e.label = 4;
|
|
1710
1746
|
case 4: return [2 /*return*/];
|
|
1711
1747
|
}
|
|
1712
1748
|
});
|
|
1713
1749
|
};
|
|
1714
|
-
|
|
1750
|
+
_d.label = 2;
|
|
1715
1751
|
case 2:
|
|
1716
1752
|
if (!(unresovedTemplates.length > 0)) return [3 /*break*/, 4];
|
|
1717
1753
|
return [5 /*yield**/, _loop_1()];
|
|
1718
1754
|
case 3:
|
|
1719
|
-
|
|
1755
|
+
_d.sent();
|
|
1720
1756
|
return [3 /*break*/, 2];
|
|
1721
1757
|
case 4: return [4 /*yield*/, Promise.all(resolving_1)];
|
|
1722
1758
|
case 5:
|
|
1723
|
-
|
|
1759
|
+
_d.sent();
|
|
1724
1760
|
return [3 /*break*/, 7];
|
|
1725
1761
|
case 6:
|
|
1726
|
-
error_1 =
|
|
1762
|
+
error_1 = _d.sent();
|
|
1727
1763
|
if (!(error_1 instanceof Error)) {
|
|
1728
1764
|
throw error_1;
|
|
1729
1765
|
}
|
|
@@ -1733,12 +1769,30 @@ function createPromptbookExecutor(options) {
|
|
|
1733
1769
|
executionReport: executionReport,
|
|
1734
1770
|
outputParameters: parametersToPass,
|
|
1735
1771
|
}];
|
|
1736
|
-
case 7:
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1772
|
+
case 7:
|
|
1773
|
+
try {
|
|
1774
|
+
// Note: Filter ONLY output parameters
|
|
1775
|
+
for (_a = __values(promptbook.parameters), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
1776
|
+
parameter = _b.value;
|
|
1777
|
+
if (parameter.isOutput) {
|
|
1778
|
+
continue;
|
|
1779
|
+
}
|
|
1780
|
+
delete parametersToPass[parameter.name];
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1784
|
+
finally {
|
|
1785
|
+
try {
|
|
1786
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1787
|
+
}
|
|
1788
|
+
finally { if (e_1) throw e_1.error; }
|
|
1789
|
+
}
|
|
1790
|
+
return [2 /*return*/, {
|
|
1791
|
+
isSuccessful: true,
|
|
1792
|
+
errors: [],
|
|
1793
|
+
executionReport: executionReport,
|
|
1794
|
+
outputParameters: parametersToPass,
|
|
1795
|
+
}];
|
|
1742
1796
|
}
|
|
1743
1797
|
});
|
|
1744
1798
|
}); };
|
|
@@ -1748,6 +1802,7 @@ function createPromptbookExecutor(options) {
|
|
|
1748
1802
|
* TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
|
|
1749
1803
|
* TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
|
|
1750
1804
|
* Note: CreatePromptbookExecutorOptions are just connected to PromptbookExecutor so do not extract to types folder
|
|
1805
|
+
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
1751
1806
|
*/
|
|
1752
1807
|
|
|
1753
1808
|
/**
|
|
@@ -1762,7 +1817,7 @@ function createPromptbookExecutor(options) {
|
|
|
1762
1817
|
var PromptbookLibrary = /** @class */ (function () {
|
|
1763
1818
|
function PromptbookLibrary(options) {
|
|
1764
1819
|
this.options = options;
|
|
1765
|
-
// <- Note: Options can not be private
|
|
1820
|
+
// <- Note: Options can not be private or protected because of the following error:
|
|
1766
1821
|
// > Type 'import("node_modules/@promptbook/core/esm/typings/classes/PromptbookLibrary").PromptbookLibrary' is not assignable
|
|
1767
1822
|
// > to type 'import("node_modules/@promptbook/remote-server/esm/typings/classes/PromptbookLibrary").PromptbookLibrary'.
|
|
1768
1823
|
// > Types have separate declarations of a private property 'options'.ts(2322)
|