@promptbook/core 0.24.0-0 → 0.24.0-2.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 +161 -97
- package/esm/index.es.js.map +1 -1
- package/esm/typings/classes/PromptTemplatePipeline.d.ts +4 -1
- package/esm/typings/classes/PromptTemplatePipelineLibrary.d.ts +8 -2
- package/esm/typings/execution/PtpExecutor.d.ts +24 -4
- package/esm/typings/execution/createPtpExecutor.d.ts +9 -0
- package/esm/typings/types/Prompt.d.ts +8 -2
- package/esm/typings/types/execution-report/ExecutionReportJson.d.ts +45 -8
- package/esm/typings/utils/markdown/prettifyMarkdown.d.ts +8 -0
- package/esm/typings/utils/markdown/prettifyMarkdown.test.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +161 -97
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/classes/PromptTemplatePipeline.d.ts +4 -1
- package/umd/typings/classes/PromptTemplatePipelineLibrary.d.ts +8 -2
- package/umd/typings/execution/PtpExecutor.d.ts +24 -4
- package/umd/typings/execution/createPtpExecutor.d.ts +9 -0
- package/umd/typings/types/Prompt.d.ts +8 -2
- package/umd/typings/types/execution-report/ExecutionReportJson.d.ts +45 -8
- package/umd/typings/utils/markdown/prettifyMarkdown.d.ts +8 -0
- package/umd/typings/utils/markdown/prettifyMarkdown.test.d.ts +1 -0
package/umd/index.umd.js
CHANGED
|
@@ -982,8 +982,11 @@
|
|
|
982
982
|
* @see https://github.com/webgptorg/promptbook#prompt-template-pipeline
|
|
983
983
|
*/
|
|
984
984
|
var PromptTemplatePipeline = /** @class */ (function () {
|
|
985
|
-
function PromptTemplatePipeline(ptbkUrl, parameters, promptTemplates) {
|
|
985
|
+
function PromptTemplatePipeline(ptbkUrl, title, ptbkVersion, description, parameters, promptTemplates) {
|
|
986
986
|
this.ptbkUrl = ptbkUrl;
|
|
987
|
+
this.title = title;
|
|
988
|
+
this.ptbkVersion = ptbkVersion;
|
|
989
|
+
this.description = description;
|
|
987
990
|
this.parameters = parameters;
|
|
988
991
|
this.promptTemplates = promptTemplates;
|
|
989
992
|
if (promptTemplates.length === 0) {
|
|
@@ -1028,7 +1031,7 @@
|
|
|
1028
1031
|
*/
|
|
1029
1032
|
PromptTemplatePipeline.fromJson = function (ptbkjson) {
|
|
1030
1033
|
validatePromptTemplatePipelineJson(ptbkjson);
|
|
1031
|
-
return new PromptTemplatePipeline(ptbkjson.ptbkUrl ? new URL(ptbkjson.ptbkUrl) : null, Object.fromEntries(ptbkjson.parameters.map(function (parameter) { return [parameter.name, parameter]; })), ptbkjson.promptTemplates);
|
|
1034
|
+
return new PromptTemplatePipeline(ptbkjson.ptbkUrl ? new URL(ptbkjson.ptbkUrl) : null, ptbkjson.title, ptbkjson.ptbkVersion, ptbkjson.ptbkVersion, Object.fromEntries(ptbkjson.parameters.map(function (parameter) { return [parameter.name, parameter]; })), ptbkjson.promptTemplates);
|
|
1032
1035
|
};
|
|
1033
1036
|
Object.defineProperty(PromptTemplatePipeline.prototype, "entryPromptTemplate", {
|
|
1034
1037
|
/**
|
|
@@ -1276,20 +1279,31 @@
|
|
|
1276
1279
|
*/
|
|
1277
1280
|
function createPtpExecutor(options) {
|
|
1278
1281
|
var _this = this;
|
|
1279
|
-
var ptp = options.ptp, tools = options.tools;
|
|
1282
|
+
var ptp = options.ptp, tools = options.tools, settings = options.settings;
|
|
1280
1283
|
var ptpExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
1281
|
-
var parametersToPass, currentTemplate, executionReport, _loop_1;
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
+
var parametersToPass, currentTemplate, executionReport, _loop_1, error_1;
|
|
1285
|
+
var _a;
|
|
1286
|
+
return __generator(this, function (_b) {
|
|
1287
|
+
switch (_b.label) {
|
|
1284
1288
|
case 0:
|
|
1285
1289
|
parametersToPass = inputParameters;
|
|
1286
1290
|
currentTemplate = ptp.entryPromptTemplate;
|
|
1287
|
-
executionReport =
|
|
1291
|
+
executionReport = {
|
|
1292
|
+
ptbkUrl: ((_a = ptp.ptbkUrl) === null || _a === void 0 ? void 0 : _a.href) || undefined,
|
|
1293
|
+
title: ptp.title || undefined,
|
|
1294
|
+
ptbkUsedVersion: PTBK_VERSION,
|
|
1295
|
+
ptbkRequestedVersion: ptp.ptbkVersion || undefined,
|
|
1296
|
+
description: ptp.description || undefined,
|
|
1297
|
+
promptExecutions: [],
|
|
1298
|
+
};
|
|
1299
|
+
_b.label = 1;
|
|
1300
|
+
case 1:
|
|
1301
|
+
_b.trys.push([1, 5, , 6]);
|
|
1288
1302
|
_loop_1 = function () {
|
|
1289
|
-
var resultingParameter, name_1, title, prompt_1, chatThread, completionResult, result, resultString, scriptExecutionErrors, isScriptExecutionSuccessful,
|
|
1290
|
-
var e_2,
|
|
1291
|
-
return __generator(this, function (
|
|
1292
|
-
switch (
|
|
1303
|
+
var resultingParameter, name_1, title, prompt_1, chatThread, completionResult, result, resultString, naturalExecutionError, scriptExecutionErrors, isScriptExecutionSuccessful, _c, attempt, _d, _e, _f, _g, unit, _h, max, min, amount, error_2, _j, _k, scriptTools, error_3, e_1_1;
|
|
1304
|
+
var e_2, _l, e_1, _m, _o;
|
|
1305
|
+
return __generator(this, function (_p) {
|
|
1306
|
+
switch (_p.label) {
|
|
1293
1307
|
case 0:
|
|
1294
1308
|
resultingParameter = ptp.getResultingParameter(currentTemplate.name);
|
|
1295
1309
|
name_1 = "ptp-executor-frame-".concat(currentTemplate.name);
|
|
@@ -1305,28 +1319,30 @@
|
|
|
1305
1319
|
parameterValue: null,
|
|
1306
1320
|
})];
|
|
1307
1321
|
case 1:
|
|
1308
|
-
|
|
1309
|
-
|
|
1322
|
+
_p.sent();
|
|
1323
|
+
_p.label = 2;
|
|
1310
1324
|
case 2:
|
|
1311
1325
|
prompt_1 = void 0;
|
|
1312
1326
|
chatThread = void 0;
|
|
1313
1327
|
completionResult = void 0;
|
|
1314
|
-
result =
|
|
1328
|
+
result = null;
|
|
1315
1329
|
resultString = null;
|
|
1330
|
+
naturalExecutionError = null;
|
|
1316
1331
|
isScriptExecutionSuccessful = void 0;
|
|
1317
|
-
|
|
1318
|
-
switch (
|
|
1332
|
+
_c = currentTemplate.executionType;
|
|
1333
|
+
switch (_c) {
|
|
1319
1334
|
case 'SIMPLE_TEMPLATE': return [3 /*break*/, 3];
|
|
1320
1335
|
case 'PROMPT_TEMPLATE': return [3 /*break*/, 4];
|
|
1321
|
-
case 'SCRIPT': return [3 /*break*/,
|
|
1322
|
-
case 'PROMPT_DIALOG': return [3 /*break*/,
|
|
1336
|
+
case 'SCRIPT': return [3 /*break*/, 18];
|
|
1337
|
+
case 'PROMPT_DIALOG': return [3 /*break*/, 29];
|
|
1323
1338
|
}
|
|
1324
|
-
return [3 /*break*/,
|
|
1339
|
+
return [3 /*break*/, 31];
|
|
1325
1340
|
case 3:
|
|
1326
1341
|
resultString = replaceParameters(currentTemplate.content, parametersToPass);
|
|
1327
|
-
return [3 /*break*/,
|
|
1342
|
+
return [3 /*break*/, 32];
|
|
1328
1343
|
case 4:
|
|
1329
1344
|
prompt_1 = {
|
|
1345
|
+
title: currentTemplate.title,
|
|
1330
1346
|
ptbkUrl: "".concat(ptp.ptbkUrl
|
|
1331
1347
|
? ptp.ptbkUrl.href
|
|
1332
1348
|
: 'anonymous' /* <- [🧠] !!!! How to deal with anonymous PTPs, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
|
|
@@ -1334,32 +1350,42 @@
|
|
|
1334
1350
|
content: replaceParameters(currentTemplate.content, parametersToPass),
|
|
1335
1351
|
modelRequirements: currentTemplate.modelRequirements,
|
|
1336
1352
|
};
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1353
|
+
attempt = 0;
|
|
1354
|
+
_p.label = 5;
|
|
1355
|
+
case 5:
|
|
1356
|
+
if (!(attempt < settings.maxNaturalExecutionAttempts)) return [3 /*break*/, 17];
|
|
1357
|
+
result = null;
|
|
1358
|
+
resultString = null;
|
|
1359
|
+
naturalExecutionError = null;
|
|
1360
|
+
_p.label = 6;
|
|
1344
1361
|
case 6:
|
|
1345
|
-
|
|
1362
|
+
_p.trys.push([6, 13, 14, 15]);
|
|
1363
|
+
_d = currentTemplate.modelRequirements.modelVariant;
|
|
1364
|
+
switch (_d) {
|
|
1365
|
+
case 'CHAT': return [3 /*break*/, 7];
|
|
1366
|
+
case 'COMPLETION': return [3 /*break*/, 9];
|
|
1367
|
+
}
|
|
1368
|
+
return [3 /*break*/, 11];
|
|
1369
|
+
case 7: return [4 /*yield*/, tools.natural.gptChat(prompt_1)];
|
|
1370
|
+
case 8:
|
|
1371
|
+
chatThread = _p.sent();
|
|
1346
1372
|
// TODO: [🍬] Destroy chatThread
|
|
1347
1373
|
result = chatThread;
|
|
1348
1374
|
resultString = chatThread.content;
|
|
1349
|
-
return [3 /*break*/,
|
|
1350
|
-
case
|
|
1351
|
-
case
|
|
1352
|
-
completionResult =
|
|
1375
|
+
return [3 /*break*/, 12];
|
|
1376
|
+
case 9: return [4 /*yield*/, tools.natural.gptComplete(prompt_1)];
|
|
1377
|
+
case 10:
|
|
1378
|
+
completionResult = _p.sent();
|
|
1353
1379
|
result = completionResult;
|
|
1354
1380
|
resultString = completionResult.content;
|
|
1355
|
-
return [3 /*break*/,
|
|
1356
|
-
case
|
|
1357
|
-
case
|
|
1381
|
+
return [3 /*break*/, 12];
|
|
1382
|
+
case 11: throw new Error("Unknown model variant \"".concat(currentTemplate.modelRequirements.modelVariant, "\""));
|
|
1383
|
+
case 12:
|
|
1358
1384
|
try {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1385
|
+
// TODO: !!!!!! Here should postprocessing happen
|
|
1386
|
+
for (_e = (e_2 = void 0, __values(Object.entries(currentTemplate.expectations))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1387
|
+
_g = __read(_f.value, 2), unit = _g[0], _h = _g[1], max = _h.max, min = _h.min;
|
|
1388
|
+
amount = CountUtils[unit.toUpperCase()](resultString);
|
|
1363
1389
|
if (min && amount < min) {
|
|
1364
1390
|
throw new Error("Expected at least ".concat(min, " ").concat(unit, " but got ").concat(amount));
|
|
1365
1391
|
} /* not else */
|
|
@@ -1371,20 +1397,41 @@
|
|
|
1371
1397
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1372
1398
|
finally {
|
|
1373
1399
|
try {
|
|
1374
|
-
if (
|
|
1400
|
+
if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
|
|
1375
1401
|
}
|
|
1376
1402
|
finally { if (e_2) throw e_2.error; }
|
|
1377
1403
|
}
|
|
1378
|
-
|
|
1404
|
+
return [3 /*break*/, 15];
|
|
1405
|
+
case 13:
|
|
1406
|
+
error_2 = _p.sent();
|
|
1407
|
+
if (!(error_2 instanceof Error)) {
|
|
1408
|
+
throw error_2;
|
|
1409
|
+
}
|
|
1410
|
+
naturalExecutionError = error_2;
|
|
1411
|
+
return [3 /*break*/, 15];
|
|
1412
|
+
case 14:
|
|
1413
|
+
executionReport.promptExecutions.push({
|
|
1379
1414
|
prompt: {
|
|
1415
|
+
title: prompt_1.title,
|
|
1380
1416
|
content: prompt_1.content,
|
|
1381
1417
|
modelRequirements: prompt_1.modelRequirements,
|
|
1382
1418
|
// <- Note: Do want to pass ONLY wanted information to the report
|
|
1383
1419
|
},
|
|
1384
|
-
result: result
|
|
1420
|
+
result: result /* <- !!!!! Look what is exposed here and probbably also filter out */ ||
|
|
1421
|
+
undefined,
|
|
1422
|
+
error: naturalExecutionError || undefined,
|
|
1385
1423
|
});
|
|
1386
|
-
return [
|
|
1387
|
-
case
|
|
1424
|
+
return [7 /*endfinally*/];
|
|
1425
|
+
case 15:
|
|
1426
|
+
if (result !== null && naturalExecutionError === null) {
|
|
1427
|
+
return [3 /*break*/, 32];
|
|
1428
|
+
}
|
|
1429
|
+
_p.label = 16;
|
|
1430
|
+
case 16:
|
|
1431
|
+
attempt++;
|
|
1432
|
+
return [3 /*break*/, 5];
|
|
1433
|
+
case 17: throw new Error(spaceTrim__default["default"](function (block) { return "\n Natural execution failed ".concat(settings.maxNaturalExecutionAttempts, "x\n\n ").concat(block((naturalExecutionError === null || naturalExecutionError === void 0 ? void 0 : naturalExecutionError.message) || ''), "\n "); }));
|
|
1434
|
+
case 18:
|
|
1388
1435
|
if (tools.script.length === 0) {
|
|
1389
1436
|
throw new Error('No script execution tools are available');
|
|
1390
1437
|
}
|
|
@@ -1393,50 +1440,50 @@
|
|
|
1393
1440
|
}
|
|
1394
1441
|
scriptExecutionErrors = [];
|
|
1395
1442
|
isScriptExecutionSuccessful = false;
|
|
1396
|
-
|
|
1397
|
-
case
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
case
|
|
1402
|
-
if (!!
|
|
1403
|
-
scriptTools =
|
|
1404
|
-
|
|
1405
|
-
case
|
|
1406
|
-
|
|
1443
|
+
_p.label = 19;
|
|
1444
|
+
case 19:
|
|
1445
|
+
_p.trys.push([19, 26, 27, 28]);
|
|
1446
|
+
_j = (e_1 = void 0, __values(tools.script)), _k = _j.next();
|
|
1447
|
+
_p.label = 20;
|
|
1448
|
+
case 20:
|
|
1449
|
+
if (!!_k.done) return [3 /*break*/, 25];
|
|
1450
|
+
scriptTools = _k.value;
|
|
1451
|
+
_p.label = 21;
|
|
1452
|
+
case 21:
|
|
1453
|
+
_p.trys.push([21, 23, , 24]);
|
|
1407
1454
|
return [4 /*yield*/, scriptTools.execute({
|
|
1408
1455
|
scriptLanguage: currentTemplate.contentLanguage,
|
|
1409
1456
|
script: currentTemplate.content,
|
|
1410
1457
|
parameters: parametersToPass,
|
|
1411
1458
|
})];
|
|
1412
|
-
case
|
|
1413
|
-
resultString =
|
|
1459
|
+
case 22:
|
|
1460
|
+
resultString = _p.sent();
|
|
1414
1461
|
isScriptExecutionSuccessful = true;
|
|
1415
|
-
return [3 /*break*/,
|
|
1416
|
-
case
|
|
1417
|
-
|
|
1418
|
-
if (!(
|
|
1419
|
-
throw
|
|
1462
|
+
return [3 /*break*/, 25];
|
|
1463
|
+
case 23:
|
|
1464
|
+
error_3 = _p.sent();
|
|
1465
|
+
if (!(error_3 instanceof Error)) {
|
|
1466
|
+
throw error_3;
|
|
1420
1467
|
}
|
|
1421
|
-
scriptExecutionErrors.push(
|
|
1422
|
-
return [3 /*break*/,
|
|
1423
|
-
case
|
|
1424
|
-
|
|
1425
|
-
return [3 /*break*/,
|
|
1426
|
-
case
|
|
1427
|
-
case
|
|
1428
|
-
e_1_1 =
|
|
1468
|
+
scriptExecutionErrors.push(error_3);
|
|
1469
|
+
return [3 /*break*/, 24];
|
|
1470
|
+
case 24:
|
|
1471
|
+
_k = _j.next();
|
|
1472
|
+
return [3 /*break*/, 20];
|
|
1473
|
+
case 25: return [3 /*break*/, 28];
|
|
1474
|
+
case 26:
|
|
1475
|
+
e_1_1 = _p.sent();
|
|
1429
1476
|
e_1 = { error: e_1_1 };
|
|
1430
|
-
return [3 /*break*/,
|
|
1431
|
-
case
|
|
1477
|
+
return [3 /*break*/, 28];
|
|
1478
|
+
case 27:
|
|
1432
1479
|
try {
|
|
1433
|
-
if (
|
|
1480
|
+
if (_k && !_k.done && (_m = _j.return)) _m.call(_j);
|
|
1434
1481
|
}
|
|
1435
1482
|
finally { if (e_1) throw e_1.error; }
|
|
1436
1483
|
return [7 /*endfinally*/];
|
|
1437
|
-
case
|
|
1484
|
+
case 28:
|
|
1438
1485
|
if (isScriptExecutionSuccessful) {
|
|
1439
|
-
return [3 /*break*/,
|
|
1486
|
+
return [3 /*break*/, 32];
|
|
1440
1487
|
}
|
|
1441
1488
|
if (scriptExecutionErrors.length === 1) {
|
|
1442
1489
|
throw scriptExecutionErrors[0];
|
|
@@ -1444,19 +1491,19 @@
|
|
|
1444
1491
|
else {
|
|
1445
1492
|
throw new Error(spaceTrim__default["default"](function (block) { return "\n Script execution failed ".concat(scriptExecutionErrors.length, " times\n\n ").concat(block(scriptExecutionErrors.map(function (error) { return '- ' + error.message; }).join('\n\n')), "\n "); }));
|
|
1446
1493
|
}
|
|
1447
|
-
case
|
|
1494
|
+
case 29: return [4 /*yield*/, tools.userInterface.promptDialog({
|
|
1448
1495
|
prompt: replaceParameters(currentTemplate.description || '', parametersToPass),
|
|
1449
1496
|
defaultValue: replaceParameters(currentTemplate.content, parametersToPass),
|
|
1450
1497
|
// TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
|
|
1451
1498
|
placeholder: undefined,
|
|
1452
1499
|
})];
|
|
1453
|
-
case
|
|
1454
|
-
resultString =
|
|
1455
|
-
return [3 /*break*/,
|
|
1456
|
-
case
|
|
1500
|
+
case 30:
|
|
1501
|
+
resultString = _p.sent();
|
|
1502
|
+
return [3 /*break*/, 32];
|
|
1503
|
+
case 31:
|
|
1457
1504
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1458
1505
|
throw new Error("Unknown execution type \"".concat(currentTemplate.executionType, "\""));
|
|
1459
|
-
case
|
|
1506
|
+
case 32:
|
|
1460
1507
|
if (resultString === null) {
|
|
1461
1508
|
// <- TODO: [🥨] Make some NeverShouldHappenError
|
|
1462
1509
|
throw new Error('Something went wrong and prompt result is null');
|
|
@@ -1472,20 +1519,37 @@
|
|
|
1472
1519
|
parameterValue: resultString,
|
|
1473
1520
|
});
|
|
1474
1521
|
}
|
|
1475
|
-
parametersToPass = __assign(__assign({}, parametersToPass), (
|
|
1522
|
+
parametersToPass = __assign(__assign({}, parametersToPass), (_o = {}, _o[resultingParameter.name] = resultString /* <- Note: Not need to detect parameter collision here because PromptTemplatePipeline checks logic consistency during construction */, _o));
|
|
1476
1523
|
currentTemplate = ptp.getFollowingPromptTemplate(currentTemplate.name);
|
|
1477
1524
|
return [2 /*return*/];
|
|
1478
1525
|
}
|
|
1479
1526
|
});
|
|
1480
1527
|
};
|
|
1481
|
-
|
|
1482
|
-
case 1:
|
|
1483
|
-
if (!(currentTemplate !== null)) return [3 /*break*/, 3];
|
|
1484
|
-
return [5 /*yield**/, _loop_1()];
|
|
1528
|
+
_b.label = 2;
|
|
1485
1529
|
case 2:
|
|
1486
|
-
|
|
1487
|
-
return [
|
|
1488
|
-
case 3:
|
|
1530
|
+
if (!(currentTemplate !== null)) return [3 /*break*/, 4];
|
|
1531
|
+
return [5 /*yield**/, _loop_1()];
|
|
1532
|
+
case 3:
|
|
1533
|
+
_b.sent();
|
|
1534
|
+
return [3 /*break*/, 2];
|
|
1535
|
+
case 4: return [3 /*break*/, 6];
|
|
1536
|
+
case 5:
|
|
1537
|
+
error_1 = _b.sent();
|
|
1538
|
+
if (!(error_1 instanceof Error)) {
|
|
1539
|
+
throw error_1;
|
|
1540
|
+
}
|
|
1541
|
+
return [2 /*return*/, {
|
|
1542
|
+
isSuccessful: false,
|
|
1543
|
+
errors: [error_1],
|
|
1544
|
+
executionReport: executionReport,
|
|
1545
|
+
outputParameters: parametersToPass,
|
|
1546
|
+
}];
|
|
1547
|
+
case 6: return [2 /*return*/, {
|
|
1548
|
+
isSuccessful: true,
|
|
1549
|
+
errors: [],
|
|
1550
|
+
executionReport: executionReport,
|
|
1551
|
+
outputParameters: parametersToPass,
|
|
1552
|
+
}];
|
|
1489
1553
|
}
|
|
1490
1554
|
});
|
|
1491
1555
|
}); };
|
|
@@ -1506,8 +1570,8 @@
|
|
|
1506
1570
|
* @see https://github.com/webgptorg/promptbook#prompt-template-pipeline-library
|
|
1507
1571
|
*/
|
|
1508
1572
|
var PromptTemplatePipelineLibrary = /** @class */ (function () {
|
|
1509
|
-
function PromptTemplatePipelineLibrary(
|
|
1510
|
-
this.
|
|
1573
|
+
function PromptTemplatePipelineLibrary(options) {
|
|
1574
|
+
this.options = options;
|
|
1511
1575
|
}
|
|
1512
1576
|
/**
|
|
1513
1577
|
* Constructs PromptTemplatePipeline from any sources
|
|
@@ -1518,13 +1582,13 @@
|
|
|
1518
1582
|
* @param ptbkSources contents of .ptbk.md or .ptbk.json files
|
|
1519
1583
|
* @returns PromptTemplatePipelineLibrary
|
|
1520
1584
|
*/
|
|
1521
|
-
PromptTemplatePipelineLibrary.fromSources = function (ptbkSources) {
|
|
1585
|
+
PromptTemplatePipelineLibrary.fromSources = function (ptbkSources, settings) {
|
|
1522
1586
|
var e_1, _a;
|
|
1523
|
-
var
|
|
1587
|
+
var library = {};
|
|
1524
1588
|
try {
|
|
1525
1589
|
for (var _b = __values(Object.entries(ptbkSources)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1526
1590
|
var _d = __read(_c.value, 2), name_1 = _d[0], source = _d[1];
|
|
1527
|
-
|
|
1591
|
+
library[name_1] = PromptTemplatePipeline.fromSource(source);
|
|
1528
1592
|
}
|
|
1529
1593
|
}
|
|
1530
1594
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -1534,13 +1598,13 @@
|
|
|
1534
1598
|
}
|
|
1535
1599
|
finally { if (e_1) throw e_1.error; }
|
|
1536
1600
|
}
|
|
1537
|
-
return new PromptTemplatePipelineLibrary(
|
|
1601
|
+
return new PromptTemplatePipelineLibrary({ library: library, settings: settings });
|
|
1538
1602
|
};
|
|
1539
1603
|
/**
|
|
1540
1604
|
* Gets prompt template pipeline by name
|
|
1541
1605
|
*/
|
|
1542
1606
|
PromptTemplatePipelineLibrary.prototype.getPtp = function (name) {
|
|
1543
|
-
var promptTemplatePipeline = this.
|
|
1607
|
+
var promptTemplatePipeline = this.options.library[name];
|
|
1544
1608
|
if (!promptTemplatePipeline) {
|
|
1545
1609
|
throw new Error("Prompt template pipeline with name \"".concat(name, "\" not found"));
|
|
1546
1610
|
}
|
|
@@ -1557,7 +1621,7 @@
|
|
|
1557
1621
|
*/
|
|
1558
1622
|
PromptTemplatePipelineLibrary.prototype.createExecutor = function (name, tools) {
|
|
1559
1623
|
var ptp = this.getPtp(name);
|
|
1560
|
-
return createPtpExecutor({ ptp: ptp, tools: tools });
|
|
1624
|
+
return createPtpExecutor({ ptp: ptp, tools: tools, settings: this.options.settings });
|
|
1561
1625
|
};
|
|
1562
1626
|
return PromptTemplatePipelineLibrary;
|
|
1563
1627
|
}());
|