@promptbook/legacy-documents 0.78.4 → 0.80.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/esm/index.es.js +391 -312
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +6 -6
- package/esm/typings/src/_packages/core.index.d.ts +4 -2
- package/esm/typings/src/_packages/types.index.d.ts +10 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -2
- package/esm/typings/src/config.d.ts +0 -25
- package/esm/typings/src/constants.d.ts +35 -0
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
- package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +6 -1
- package/esm/typings/src/formfactors/index.d.ts +12 -2
- package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +6 -1
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
- package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
- package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
- package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +1 -1
- package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
- package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
- package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
- package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
- package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
- package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
- package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
- package/package.json +2 -2
- package/umd/index.umd.js +391 -312
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
package/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
26
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.79.0';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -228,41 +228,6 @@
|
|
|
228
228
|
* @public exported from `@promptbook/core`
|
|
229
229
|
*/
|
|
230
230
|
var DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
|
|
231
|
-
/**
|
|
232
|
-
* Nonce which is used for replacing things in strings
|
|
233
|
-
*
|
|
234
|
-
* @private within the repository
|
|
235
|
-
*/
|
|
236
|
-
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
237
|
-
/**
|
|
238
|
-
* The names of the parameters that are reserved for special purposes
|
|
239
|
-
*
|
|
240
|
-
* @public exported from `@promptbook/core`
|
|
241
|
-
*/
|
|
242
|
-
var RESERVED_PARAMETER_NAMES =
|
|
243
|
-
/* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
|
|
244
|
-
'content',
|
|
245
|
-
'context',
|
|
246
|
-
'knowledge',
|
|
247
|
-
'examples',
|
|
248
|
-
'modelName',
|
|
249
|
-
'currentDate',
|
|
250
|
-
// <- TODO: list here all command names
|
|
251
|
-
// <- TODO: Add more like 'date', 'modelName',...
|
|
252
|
-
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
253
|
-
];
|
|
254
|
-
/**
|
|
255
|
-
* @@@
|
|
256
|
-
*
|
|
257
|
-
* @private within the repository
|
|
258
|
-
*/
|
|
259
|
-
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
260
|
-
/**
|
|
261
|
-
* @@@
|
|
262
|
-
*
|
|
263
|
-
* @private within the repository
|
|
264
|
-
*/
|
|
265
|
-
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
266
231
|
// <- TODO: [🧜♂️]
|
|
267
232
|
/**
|
|
268
233
|
* @@@
|
|
@@ -297,7 +262,6 @@
|
|
|
297
262
|
// Note: In normal situations, we check the pipeline logic:
|
|
298
263
|
true);
|
|
299
264
|
/**
|
|
300
|
-
* TODO: Extract `constants.ts` from `config.ts`
|
|
301
265
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
302
266
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
303
267
|
*/
|
|
@@ -1099,7 +1063,7 @@
|
|
|
1099
1063
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1100
1064
|
*/
|
|
1101
1065
|
|
|
1102
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],
|
|
1066
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
1103
1067
|
|
|
1104
1068
|
/**
|
|
1105
1069
|
* Prettify the html code
|
|
@@ -1147,6 +1111,7 @@
|
|
|
1147
1111
|
/**
|
|
1148
1112
|
* Converts promptbook in JSON format to string format
|
|
1149
1113
|
*
|
|
1114
|
+
* @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
|
|
1150
1115
|
* @param pipelineJson Promptbook in JSON format (.book.json)
|
|
1151
1116
|
* @returns Promptbook in string format (.book.md)
|
|
1152
1117
|
* @public exported from `@promptbook/core`
|
|
@@ -1350,6 +1315,298 @@
|
|
|
1350
1315
|
* TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
1351
1316
|
*/
|
|
1352
1317
|
|
|
1318
|
+
/**
|
|
1319
|
+
* Orders JSON object by keys
|
|
1320
|
+
*
|
|
1321
|
+
* @returns The same type of object as the input re-ordered
|
|
1322
|
+
* @public exported from `@promptbook/utils`
|
|
1323
|
+
*/
|
|
1324
|
+
function orderJson(options) {
|
|
1325
|
+
var value = options.value, order = options.order;
|
|
1326
|
+
var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
|
|
1327
|
+
return orderedValue;
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Freezes the given object and all its nested objects recursively
|
|
1332
|
+
*
|
|
1333
|
+
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
1334
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1335
|
+
*
|
|
1336
|
+
* @returns The same object as the input, but deeply frozen
|
|
1337
|
+
* @public exported from `@promptbook/utils`
|
|
1338
|
+
*/
|
|
1339
|
+
function $deepFreeze(objectValue) {
|
|
1340
|
+
var e_1, _a;
|
|
1341
|
+
if (Array.isArray(objectValue)) {
|
|
1342
|
+
return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
|
|
1343
|
+
}
|
|
1344
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1345
|
+
try {
|
|
1346
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
1347
|
+
var propertyName = propertyNames_1_1.value;
|
|
1348
|
+
var value = objectValue[propertyName];
|
|
1349
|
+
if (value && typeof value === 'object') {
|
|
1350
|
+
$deepFreeze(value);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1355
|
+
finally {
|
|
1356
|
+
try {
|
|
1357
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
1358
|
+
}
|
|
1359
|
+
finally { if (e_1) throw e_1.error; }
|
|
1360
|
+
}
|
|
1361
|
+
Object.freeze(objectValue);
|
|
1362
|
+
return objectValue;
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1366
|
+
*/
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* Checks if the value is [🚉] serializable as JSON
|
|
1370
|
+
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
1371
|
+
*
|
|
1372
|
+
* - Almost all primitives are serializable BUT:
|
|
1373
|
+
* - `undefined` is not serializable
|
|
1374
|
+
* - `NaN` is not serializable
|
|
1375
|
+
* - Objects and arrays are serializable if all their properties are serializable
|
|
1376
|
+
* - Functions are not serializable
|
|
1377
|
+
* - Circular references are not serializable
|
|
1378
|
+
* - `Date` objects are not serializable
|
|
1379
|
+
* - `Map` and `Set` objects are not serializable
|
|
1380
|
+
* - `RegExp` objects are not serializable
|
|
1381
|
+
* - `Error` objects are not serializable
|
|
1382
|
+
* - `Symbol` objects are not serializable
|
|
1383
|
+
* - And much more...
|
|
1384
|
+
*
|
|
1385
|
+
* @throws UnexpectedError if the value is not serializable as JSON
|
|
1386
|
+
* @public exported from `@promptbook/utils`
|
|
1387
|
+
*/
|
|
1388
|
+
function checkSerializableAsJson(options) {
|
|
1389
|
+
var e_1, _a;
|
|
1390
|
+
var value = options.value, name = options.name, message = options.message;
|
|
1391
|
+
if (value === undefined) {
|
|
1392
|
+
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
1393
|
+
}
|
|
1394
|
+
else if (value === null) {
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
else if (typeof value === 'boolean') {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
else if (typeof value === 'number' && !isNaN(value)) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
else if (typeof value === 'string') {
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
else if (typeof value === 'symbol') {
|
|
1407
|
+
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
1408
|
+
}
|
|
1409
|
+
else if (typeof value === 'function') {
|
|
1410
|
+
throw new UnexpectedError("".concat(name, " is function"));
|
|
1411
|
+
}
|
|
1412
|
+
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
1413
|
+
for (var i = 0; i < value.length; i++) {
|
|
1414
|
+
checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
else if (typeof value === 'object') {
|
|
1418
|
+
if (value instanceof Date) {
|
|
1419
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is Date\n\n Use `string_date_iso8601` instead\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
|
|
1420
|
+
}
|
|
1421
|
+
else if (value instanceof Map) {
|
|
1422
|
+
throw new UnexpectedError("".concat(name, " is Map"));
|
|
1423
|
+
}
|
|
1424
|
+
else if (value instanceof Set) {
|
|
1425
|
+
throw new UnexpectedError("".concat(name, " is Set"));
|
|
1426
|
+
}
|
|
1427
|
+
else if (value instanceof RegExp) {
|
|
1428
|
+
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
1429
|
+
}
|
|
1430
|
+
else if (value instanceof Error) {
|
|
1431
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is unserialized Error\n\n Use function `serializeError`\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n\n "); }));
|
|
1432
|
+
}
|
|
1433
|
+
else {
|
|
1434
|
+
try {
|
|
1435
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1436
|
+
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
1437
|
+
if (subValue === undefined) {
|
|
1438
|
+
// Note: undefined in object is serializable - it is just omited
|
|
1439
|
+
continue;
|
|
1440
|
+
}
|
|
1441
|
+
checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1445
|
+
finally {
|
|
1446
|
+
try {
|
|
1447
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1448
|
+
}
|
|
1449
|
+
finally { if (e_1) throw e_1.error; }
|
|
1450
|
+
}
|
|
1451
|
+
try {
|
|
1452
|
+
JSON.stringify(value); // <- TODO: [0]
|
|
1453
|
+
}
|
|
1454
|
+
catch (error) {
|
|
1455
|
+
if (!(error instanceof Error)) {
|
|
1456
|
+
throw error;
|
|
1457
|
+
}
|
|
1458
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.toString()), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
|
|
1459
|
+
}
|
|
1460
|
+
/*
|
|
1461
|
+
TODO: [0] Is there some more elegant way to check circular references?
|
|
1462
|
+
const seen = new Set();
|
|
1463
|
+
const stack = [{ value }];
|
|
1464
|
+
while (stack.length > 0) {
|
|
1465
|
+
const { value } = stack.pop()!;
|
|
1466
|
+
if (typeof value === 'object' && value !== null) {
|
|
1467
|
+
if (seen.has(value)) {
|
|
1468
|
+
throw new UnexpectedError(`${name} has circular reference`);
|
|
1469
|
+
}
|
|
1470
|
+
seen.add(value);
|
|
1471
|
+
if (Array.isArray(value)) {
|
|
1472
|
+
stack.push(...value.map((value) => ({ value })));
|
|
1473
|
+
} else {
|
|
1474
|
+
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
*/
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
else {
|
|
1483
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
|
|
1488
|
+
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
1489
|
+
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
1490
|
+
*/
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* @@@
|
|
1494
|
+
*
|
|
1495
|
+
* @public exported from `@promptbook/utils`
|
|
1496
|
+
*/
|
|
1497
|
+
function deepClone(objectValue) {
|
|
1498
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
1499
|
+
/*
|
|
1500
|
+
!!!!!!!!
|
|
1501
|
+
TODO: [🧠] Is there a better implementation?
|
|
1502
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1503
|
+
> for (const propertyName of propertyNames) {
|
|
1504
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
1505
|
+
> if (value && typeof value === 'object') {
|
|
1506
|
+
> deepClone(value);
|
|
1507
|
+
> }
|
|
1508
|
+
> }
|
|
1509
|
+
> return Object.assign({}, objectValue);
|
|
1510
|
+
*/
|
|
1511
|
+
}
|
|
1512
|
+
/**
|
|
1513
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1514
|
+
*/
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* Utility to export a JSON object from a function
|
|
1518
|
+
*
|
|
1519
|
+
* 1) Checks if the value is serializable as JSON
|
|
1520
|
+
* 2) Makes a deep clone of the object
|
|
1521
|
+
* 2) Orders the object properties
|
|
1522
|
+
* 2) Deeply freezes the cloned object
|
|
1523
|
+
*
|
|
1524
|
+
* Note: This function does not mutates the given object
|
|
1525
|
+
*
|
|
1526
|
+
* @returns The same type of object as the input but read-only and re-ordered
|
|
1527
|
+
* @public exported from `@promptbook/utils`
|
|
1528
|
+
*/
|
|
1529
|
+
function exportJson(options) {
|
|
1530
|
+
var name = options.name, value = options.value, order = options.order, message = options.message;
|
|
1531
|
+
checkSerializableAsJson({ name: name, value: value, message: message });
|
|
1532
|
+
var orderedValue =
|
|
1533
|
+
// TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
|
|
1534
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1535
|
+
// @ts-ignore
|
|
1536
|
+
order === undefined
|
|
1537
|
+
? deepClone(value)
|
|
1538
|
+
: orderJson({
|
|
1539
|
+
value: value,
|
|
1540
|
+
// <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
|
|
1541
|
+
order: order,
|
|
1542
|
+
});
|
|
1543
|
+
$deepFreeze(orderedValue);
|
|
1544
|
+
return orderedValue;
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1548
|
+
*/
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Order of keys in the pipeline JSON
|
|
1552
|
+
*
|
|
1553
|
+
* @public exported from `@promptbook/core`
|
|
1554
|
+
*/
|
|
1555
|
+
var ORDER_OF_PIPELINE_JSON = [
|
|
1556
|
+
'title',
|
|
1557
|
+
'pipelineUrl',
|
|
1558
|
+
'bookVersion',
|
|
1559
|
+
'description',
|
|
1560
|
+
'formfactorName',
|
|
1561
|
+
'parameters',
|
|
1562
|
+
'tasks',
|
|
1563
|
+
'personas',
|
|
1564
|
+
'preparations',
|
|
1565
|
+
'knowledgeSources',
|
|
1566
|
+
'knowledgePieces',
|
|
1567
|
+
];
|
|
1568
|
+
/**
|
|
1569
|
+
* Nonce which is used for replacing things in strings
|
|
1570
|
+
*
|
|
1571
|
+
* @private within the repository
|
|
1572
|
+
*/
|
|
1573
|
+
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
1574
|
+
/**
|
|
1575
|
+
* @@@
|
|
1576
|
+
*
|
|
1577
|
+
* @private within the repository
|
|
1578
|
+
*/
|
|
1579
|
+
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
1580
|
+
/**
|
|
1581
|
+
* @@@
|
|
1582
|
+
*
|
|
1583
|
+
* @private within the repository
|
|
1584
|
+
*/
|
|
1585
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
1586
|
+
/**
|
|
1587
|
+
* The names of the parameters that are reserved for special purposes
|
|
1588
|
+
*
|
|
1589
|
+
* @public exported from `@promptbook/core`
|
|
1590
|
+
*/
|
|
1591
|
+
var RESERVED_PARAMETER_NAMES = exportJson({
|
|
1592
|
+
name: 'RESERVED_PARAMETER_NAMES',
|
|
1593
|
+
message: "The names of the parameters that are reserved for special purposes",
|
|
1594
|
+
value: [
|
|
1595
|
+
'content',
|
|
1596
|
+
'context',
|
|
1597
|
+
'knowledge',
|
|
1598
|
+
'examples',
|
|
1599
|
+
'modelName',
|
|
1600
|
+
'currentDate',
|
|
1601
|
+
// <- TODO: list here all command names
|
|
1602
|
+
// <- TODO: Add more like 'date', 'modelName',...
|
|
1603
|
+
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
1604
|
+
],
|
|
1605
|
+
});
|
|
1606
|
+
/**
|
|
1607
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1608
|
+
*/
|
|
1609
|
+
|
|
1353
1610
|
/**
|
|
1354
1611
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
1355
1612
|
*
|
|
@@ -1593,6 +1850,21 @@
|
|
|
1593
1850
|
}
|
|
1594
1851
|
};
|
|
1595
1852
|
try {
|
|
1853
|
+
/*
|
|
1854
|
+
TODO: [🧠][🅾] Should be empty pipeline valid or not
|
|
1855
|
+
// Note: Check that pipeline has some tasks
|
|
1856
|
+
if (pipeline.tasks.length === 0) {
|
|
1857
|
+
throw new PipelineLogicError(
|
|
1858
|
+
spaceTrim(
|
|
1859
|
+
(block) => `
|
|
1860
|
+
Pipeline must have at least one task
|
|
1861
|
+
|
|
1862
|
+
${block(pipelineIdentification)}
|
|
1863
|
+
`,
|
|
1864
|
+
),
|
|
1865
|
+
);
|
|
1866
|
+
}
|
|
1867
|
+
*/
|
|
1596
1868
|
// Note: Check each parameter individually
|
|
1597
1869
|
for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1598
1870
|
var parameter = _e.value;
|
|
@@ -1753,6 +2025,9 @@
|
|
|
1753
2025
|
while (unresovedTasks.length > 0) {
|
|
1754
2026
|
_loop_3();
|
|
1755
2027
|
}
|
|
2028
|
+
// Note: Check that formfactor is corresponding to the pipeline interface
|
|
2029
|
+
// TODO: !!!!!! Implement this
|
|
2030
|
+
// pipeline.formfactorName
|
|
1756
2031
|
}
|
|
1757
2032
|
/**
|
|
1758
2033
|
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
@@ -1836,183 +2111,6 @@
|
|
|
1836
2111
|
return parameterNames;
|
|
1837
2112
|
}
|
|
1838
2113
|
|
|
1839
|
-
/**
|
|
1840
|
-
* @@@
|
|
1841
|
-
*
|
|
1842
|
-
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
1843
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1844
|
-
*
|
|
1845
|
-
* @returns The same object as the input, but deeply frozen
|
|
1846
|
-
* @public exported from `@promptbook/utils`
|
|
1847
|
-
*/
|
|
1848
|
-
function $deepFreeze(objectValue) {
|
|
1849
|
-
var e_1, _a;
|
|
1850
|
-
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1851
|
-
try {
|
|
1852
|
-
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
1853
|
-
var propertyName = propertyNames_1_1.value;
|
|
1854
|
-
var value = objectValue[propertyName];
|
|
1855
|
-
if (value && typeof value === 'object') {
|
|
1856
|
-
$deepFreeze(value);
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1861
|
-
finally {
|
|
1862
|
-
try {
|
|
1863
|
-
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
1864
|
-
}
|
|
1865
|
-
finally { if (e_1) throw e_1.error; }
|
|
1866
|
-
}
|
|
1867
|
-
return Object.freeze(objectValue);
|
|
1868
|
-
}
|
|
1869
|
-
/**
|
|
1870
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1871
|
-
*/
|
|
1872
|
-
|
|
1873
|
-
/**
|
|
1874
|
-
* Checks if the value is [🚉] serializable as JSON
|
|
1875
|
-
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
1876
|
-
*
|
|
1877
|
-
* - Almost all primitives are serializable BUT:
|
|
1878
|
-
* - `undefined` is not serializable
|
|
1879
|
-
* - `NaN` is not serializable
|
|
1880
|
-
* - Objects and arrays are serializable if all their properties are serializable
|
|
1881
|
-
* - Functions are not serializable
|
|
1882
|
-
* - Circular references are not serializable
|
|
1883
|
-
* - `Date` objects are not serializable
|
|
1884
|
-
* - `Map` and `Set` objects are not serializable
|
|
1885
|
-
* - `RegExp` objects are not serializable
|
|
1886
|
-
* - `Error` objects are not serializable
|
|
1887
|
-
* - `Symbol` objects are not serializable
|
|
1888
|
-
* - And much more...
|
|
1889
|
-
*
|
|
1890
|
-
* @throws UnexpectedError if the value is not serializable as JSON
|
|
1891
|
-
* @public exported from `@promptbook/utils`
|
|
1892
|
-
*/
|
|
1893
|
-
function checkSerializableAsJson(name, value) {
|
|
1894
|
-
var e_1, _a;
|
|
1895
|
-
if (value === undefined) {
|
|
1896
|
-
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
1897
|
-
}
|
|
1898
|
-
else if (value === null) {
|
|
1899
|
-
return;
|
|
1900
|
-
}
|
|
1901
|
-
else if (typeof value === 'boolean') {
|
|
1902
|
-
return;
|
|
1903
|
-
}
|
|
1904
|
-
else if (typeof value === 'number' && !isNaN(value)) {
|
|
1905
|
-
return;
|
|
1906
|
-
}
|
|
1907
|
-
else if (typeof value === 'string') {
|
|
1908
|
-
return;
|
|
1909
|
-
}
|
|
1910
|
-
else if (typeof value === 'symbol') {
|
|
1911
|
-
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
1912
|
-
}
|
|
1913
|
-
else if (typeof value === 'function') {
|
|
1914
|
-
throw new UnexpectedError("".concat(name, " is function"));
|
|
1915
|
-
}
|
|
1916
|
-
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
1917
|
-
for (var i = 0; i < value.length; i++) {
|
|
1918
|
-
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
else if (typeof value === 'object') {
|
|
1922
|
-
if (value instanceof Date) {
|
|
1923
|
-
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
1924
|
-
}
|
|
1925
|
-
else if (value instanceof Map) {
|
|
1926
|
-
throw new UnexpectedError("".concat(name, " is Map"));
|
|
1927
|
-
}
|
|
1928
|
-
else if (value instanceof Set) {
|
|
1929
|
-
throw new UnexpectedError("".concat(name, " is Set"));
|
|
1930
|
-
}
|
|
1931
|
-
else if (value instanceof RegExp) {
|
|
1932
|
-
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
1933
|
-
}
|
|
1934
|
-
else if (value instanceof Error) {
|
|
1935
|
-
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
1936
|
-
}
|
|
1937
|
-
else {
|
|
1938
|
-
try {
|
|
1939
|
-
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1940
|
-
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
1941
|
-
if (subValue === undefined) {
|
|
1942
|
-
// Note: undefined in object is serializable - it is just omited
|
|
1943
|
-
continue;
|
|
1944
|
-
}
|
|
1945
|
-
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1949
|
-
finally {
|
|
1950
|
-
try {
|
|
1951
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1952
|
-
}
|
|
1953
|
-
finally { if (e_1) throw e_1.error; }
|
|
1954
|
-
}
|
|
1955
|
-
try {
|
|
1956
|
-
JSON.stringify(value); // <- TODO: [0]
|
|
1957
|
-
}
|
|
1958
|
-
catch (error) {
|
|
1959
|
-
if (!(error instanceof Error)) {
|
|
1960
|
-
throw error;
|
|
1961
|
-
}
|
|
1962
|
-
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
1963
|
-
}
|
|
1964
|
-
/*
|
|
1965
|
-
TODO: [0] Is there some more elegant way to check circular references?
|
|
1966
|
-
const seen = new Set();
|
|
1967
|
-
const stack = [{ value }];
|
|
1968
|
-
while (stack.length > 0) {
|
|
1969
|
-
const { value } = stack.pop()!;
|
|
1970
|
-
if (typeof value === 'object' && value !== null) {
|
|
1971
|
-
if (seen.has(value)) {
|
|
1972
|
-
throw new UnexpectedError(`${name} has circular reference`);
|
|
1973
|
-
}
|
|
1974
|
-
seen.add(value);
|
|
1975
|
-
if (Array.isArray(value)) {
|
|
1976
|
-
stack.push(...value.map((value) => ({ value })));
|
|
1977
|
-
} else {
|
|
1978
|
-
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
*/
|
|
1983
|
-
return;
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
else {
|
|
1987
|
-
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
/**
|
|
1991
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1992
|
-
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
1993
|
-
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
1994
|
-
*/
|
|
1995
|
-
|
|
1996
|
-
/**
|
|
1997
|
-
* @@@
|
|
1998
|
-
* @@@
|
|
1999
|
-
*
|
|
2000
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
2001
|
-
*
|
|
2002
|
-
* @param name - Name of the object for debugging purposes
|
|
2003
|
-
* @param objectValue - Object to be deeply frozen
|
|
2004
|
-
* @returns The same object as the input, but deeply frozen
|
|
2005
|
-
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
2006
|
-
*/
|
|
2007
|
-
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
2008
|
-
checkSerializableAsJson(name, objectValue);
|
|
2009
|
-
return $deepFreeze(objectValue);
|
|
2010
|
-
}
|
|
2011
|
-
/**
|
|
2012
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
2013
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
2014
|
-
*/
|
|
2015
|
-
|
|
2016
2114
|
/**
|
|
2017
2115
|
* Unprepare just strips the preparation data of the pipeline
|
|
2018
2116
|
*
|
|
@@ -2030,7 +2128,12 @@
|
|
|
2030
2128
|
delete taskUnprepared.preparedContent;
|
|
2031
2129
|
return taskUnprepared;
|
|
2032
2130
|
});
|
|
2033
|
-
return
|
|
2131
|
+
return exportJson({
|
|
2132
|
+
name: 'pipelineJson',
|
|
2133
|
+
message: "Result of `unpreparePipeline`",
|
|
2134
|
+
order: ORDER_OF_PIPELINE_JSON,
|
|
2135
|
+
value: __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }),
|
|
2136
|
+
});
|
|
2034
2137
|
}
|
|
2035
2138
|
/**
|
|
2036
2139
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
@@ -2544,29 +2647,6 @@
|
|
|
2544
2647
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2545
2648
|
*/
|
|
2546
2649
|
|
|
2547
|
-
/**
|
|
2548
|
-
* @@@
|
|
2549
|
-
*
|
|
2550
|
-
* @public exported from `@promptbook/utils`
|
|
2551
|
-
*/
|
|
2552
|
-
function deepClone(objectValue) {
|
|
2553
|
-
return JSON.parse(JSON.stringify(objectValue));
|
|
2554
|
-
/*
|
|
2555
|
-
TODO: [🧠] Is there a better implementation?
|
|
2556
|
-
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
2557
|
-
> for (const propertyName of propertyNames) {
|
|
2558
|
-
> const value = (objectValue as really_any)[propertyName];
|
|
2559
|
-
> if (value && typeof value === 'object') {
|
|
2560
|
-
> deepClone(value);
|
|
2561
|
-
> }
|
|
2562
|
-
> }
|
|
2563
|
-
> return Object.assign({}, objectValue);
|
|
2564
|
-
*/
|
|
2565
|
-
}
|
|
2566
|
-
/**
|
|
2567
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
2568
|
-
*/
|
|
2569
|
-
|
|
2570
2650
|
/**
|
|
2571
2651
|
* Function `addUsage` will add multiple usages into one
|
|
2572
2652
|
*
|
|
@@ -3697,36 +3777,6 @@
|
|
|
3697
3777
|
* [ ] One piece can have multiple sources
|
|
3698
3778
|
*/
|
|
3699
3779
|
|
|
3700
|
-
/**
|
|
3701
|
-
* @@@
|
|
3702
|
-
*
|
|
3703
|
-
* Note: It is usefull @@@
|
|
3704
|
-
*
|
|
3705
|
-
* @param pipeline
|
|
3706
|
-
* @public exported from `@promptbook/utils`
|
|
3707
|
-
*/
|
|
3708
|
-
function clonePipeline(pipeline) {
|
|
3709
|
-
// Note: Not using spread operator (...) because @@@
|
|
3710
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
3711
|
-
return {
|
|
3712
|
-
pipelineUrl: pipelineUrl,
|
|
3713
|
-
sourceFile: sourceFile,
|
|
3714
|
-
title: title,
|
|
3715
|
-
bookVersion: bookVersion,
|
|
3716
|
-
description: description,
|
|
3717
|
-
formfactorName: formfactorName,
|
|
3718
|
-
parameters: parameters,
|
|
3719
|
-
tasks: tasks,
|
|
3720
|
-
knowledgeSources: knowledgeSources,
|
|
3721
|
-
knowledgePieces: knowledgePieces,
|
|
3722
|
-
personas: personas,
|
|
3723
|
-
preparations: preparations,
|
|
3724
|
-
};
|
|
3725
|
-
}
|
|
3726
|
-
/**
|
|
3727
|
-
* TODO: [🍙] Make some standard order of json properties
|
|
3728
|
-
*/
|
|
3729
|
-
|
|
3730
3780
|
/**
|
|
3731
3781
|
* @@@
|
|
3732
3782
|
*
|
|
@@ -3767,6 +3817,7 @@
|
|
|
3767
3817
|
});
|
|
3768
3818
|
}
|
|
3769
3819
|
/**
|
|
3820
|
+
* TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
|
|
3770
3821
|
* TODO: [🧠] Add context to each task (if missing)
|
|
3771
3822
|
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
3772
3823
|
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
@@ -3855,11 +3906,19 @@
|
|
|
3855
3906
|
case 3:
|
|
3856
3907
|
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
3857
3908
|
// ----- /Tasks preparation -----
|
|
3909
|
+
// TODO: [😂] Use here all `AsyncHighLevelAbstraction`
|
|
3858
3910
|
// Note: Count total usage
|
|
3859
3911
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3860
|
-
return [2 /*return*/,
|
|
3861
|
-
|
|
3862
|
-
|
|
3912
|
+
return [2 /*return*/, exportJson({
|
|
3913
|
+
name: 'pipelineJson',
|
|
3914
|
+
message: "Result of `preparePipeline`",
|
|
3915
|
+
order: ORDER_OF_PIPELINE_JSON,
|
|
3916
|
+
value: __assign(__assign({}, pipeline), {
|
|
3917
|
+
// <- TODO: Probbably deeply clone the pipeline because `$exportJson` freezes the subobjects
|
|
3918
|
+
knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
3919
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
|
|
3920
|
+
personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }),
|
|
3921
|
+
})];
|
|
3863
3922
|
}
|
|
3864
3923
|
});
|
|
3865
3924
|
});
|
|
@@ -5556,16 +5615,21 @@
|
|
|
5556
5615
|
// Note: Wait a short time to prevent race conditions
|
|
5557
5616
|
_g.sent();
|
|
5558
5617
|
_g.label = 6;
|
|
5559
|
-
case 6: return [2 /*return*/,
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5618
|
+
case 6: return [2 /*return*/, exportJson({
|
|
5619
|
+
name: "executionReport",
|
|
5620
|
+
message: "Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"),
|
|
5621
|
+
order: [],
|
|
5622
|
+
value: {
|
|
5623
|
+
isSuccessful: false,
|
|
5624
|
+
errors: __spreadArray([
|
|
5625
|
+
new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
|
|
5626
|
+
], __read(errors), false).map(serializeError),
|
|
5627
|
+
warnings: [],
|
|
5628
|
+
executionReport: executionReport,
|
|
5629
|
+
outputParameters: {},
|
|
5630
|
+
usage: ZERO_USAGE,
|
|
5631
|
+
preparedPipeline: preparedPipeline,
|
|
5632
|
+
},
|
|
5569
5633
|
})];
|
|
5570
5634
|
case 7:
|
|
5571
5635
|
_b = _a.next();
|
|
@@ -5604,16 +5668,21 @@
|
|
|
5604
5668
|
// Note: Wait a short time to prevent race conditions
|
|
5605
5669
|
_h.sent();
|
|
5606
5670
|
_h.label = 3;
|
|
5607
|
-
case 3: return [2 /*return*/, { value:
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5671
|
+
case 3: return [2 /*return*/, { value: exportJson({
|
|
5672
|
+
name: 'pipelineExecutorResult',
|
|
5673
|
+
message: spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }),
|
|
5674
|
+
order: [],
|
|
5675
|
+
value: {
|
|
5676
|
+
isSuccessful: false,
|
|
5677
|
+
errors: __spreadArray([
|
|
5678
|
+
new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
5679
|
+
], __read(errors), false).map(serializeError),
|
|
5680
|
+
warnings: warnings.map(serializeError),
|
|
5681
|
+
executionReport: executionReport,
|
|
5682
|
+
outputParameters: {},
|
|
5683
|
+
usage: ZERO_USAGE,
|
|
5684
|
+
preparedPipeline: preparedPipeline,
|
|
5685
|
+
},
|
|
5617
5686
|
}) }];
|
|
5618
5687
|
case 4: return [2 /*return*/];
|
|
5619
5688
|
}
|
|
@@ -5767,14 +5836,19 @@
|
|
|
5767
5836
|
// Note: Wait a short time to prevent race conditions
|
|
5768
5837
|
_g.sent();
|
|
5769
5838
|
_g.label = 27;
|
|
5770
|
-
case 27: return [2 /*return*/,
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5839
|
+
case 27: return [2 /*return*/, exportJson({
|
|
5840
|
+
name: 'pipelineExecutorResult',
|
|
5841
|
+
message: "Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult",
|
|
5842
|
+
order: [],
|
|
5843
|
+
value: {
|
|
5844
|
+
isSuccessful: false,
|
|
5845
|
+
errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
|
|
5846
|
+
warnings: warnings.map(serializeError),
|
|
5847
|
+
usage: usage_1,
|
|
5848
|
+
executionReport: executionReport,
|
|
5849
|
+
outputParameters: outputParameters_1,
|
|
5850
|
+
preparedPipeline: preparedPipeline,
|
|
5851
|
+
},
|
|
5778
5852
|
})];
|
|
5779
5853
|
case 28:
|
|
5780
5854
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
@@ -5795,14 +5869,19 @@
|
|
|
5795
5869
|
// Note: Wait a short time to prevent race conditions
|
|
5796
5870
|
_g.sent();
|
|
5797
5871
|
_g.label = 30;
|
|
5798
|
-
case 30: return [2 /*return*/,
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5872
|
+
case 30: return [2 /*return*/, exportJson({
|
|
5873
|
+
name: 'pipelineExecutorResult',
|
|
5874
|
+
message: "Successful PipelineExecutorResult",
|
|
5875
|
+
order: [],
|
|
5876
|
+
value: {
|
|
5877
|
+
isSuccessful: true,
|
|
5878
|
+
errors: errors.map(serializeError),
|
|
5879
|
+
warnings: warnings.map(serializeError),
|
|
5880
|
+
usage: usage,
|
|
5881
|
+
executionReport: executionReport,
|
|
5882
|
+
outputParameters: outputParameters,
|
|
5883
|
+
preparedPipeline: preparedPipeline,
|
|
5884
|
+
},
|
|
5806
5885
|
})];
|
|
5807
5886
|
}
|
|
5808
5887
|
});
|
|
@@ -5886,7 +5965,7 @@
|
|
|
5886
5965
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
5887
5966
|
isAvilableInBrowser: true,
|
|
5888
5967
|
requiredExecutables: [],
|
|
5889
|
-
}); /* <-
|
|
5968
|
+
}); /* <- Note: [🤛] */
|
|
5890
5969
|
/**
|
|
5891
5970
|
* Registration of known scraper metadata
|
|
5892
5971
|
*
|
|
@@ -6083,7 +6162,7 @@
|
|
|
6083
6162
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
6084
6163
|
isAvilableInBrowser: false,
|
|
6085
6164
|
requiredExecutables: ['Pandoc'],
|
|
6086
|
-
}); /* <-
|
|
6165
|
+
}); /* <- Note: [🤛] */
|
|
6087
6166
|
/**
|
|
6088
6167
|
* Registration of known scraper metadata
|
|
6089
6168
|
*
|
|
@@ -6250,7 +6329,7 @@
|
|
|
6250
6329
|
'LibreOffice',
|
|
6251
6330
|
// <- TODO: [🧠] Should be 'LibreOffice' here, its dependency of dependency
|
|
6252
6331
|
],
|
|
6253
|
-
}); /* <-
|
|
6332
|
+
}); /* <- Note: [🤛] */
|
|
6254
6333
|
/**
|
|
6255
6334
|
* Registration of known scraper metadata
|
|
6256
6335
|
*
|
|
@@ -6416,7 +6495,7 @@
|
|
|
6416
6495
|
*/
|
|
6417
6496
|
var createLegacyDocumentScraper = Object.assign(function (tools, options) {
|
|
6418
6497
|
return new LegacyDocumentScraper(tools, options);
|
|
6419
|
-
}, legacyDocumentScraperMetadata); /* <-
|
|
6498
|
+
}, legacyDocumentScraperMetadata); /* <- Note: [🤛] */
|
|
6420
6499
|
/**
|
|
6421
6500
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
6422
6501
|
*/
|