@promptbook/cli 0.61.0-18 → 0.61.0-19
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 +326 -305
- package/esm/index.es.js.map +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +326 -305
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -150,7 +150,7 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
|
|
|
150
150
|
/**
|
|
151
151
|
* The version of the Promptbook library
|
|
152
152
|
*/
|
|
153
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
153
|
+
var PROMPTBOOK_VERSION = '0.61.0-18';
|
|
154
154
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
155
155
|
|
|
156
156
|
/**
|
|
@@ -300,200 +300,6 @@ TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
|
|
|
300
300
|
* TODO: [🔼] Export all to core
|
|
301
301
|
*/
|
|
302
302
|
|
|
303
|
-
/**
|
|
304
|
-
* @@@
|
|
305
|
-
*/
|
|
306
|
-
function deepClone(objectValue) {
|
|
307
|
-
return JSON.parse(JSON.stringify(objectValue));
|
|
308
|
-
/*
|
|
309
|
-
TODO: [🧠] Is there a better implementation?
|
|
310
|
-
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
311
|
-
> for (const propertyName of propertyNames) {
|
|
312
|
-
> const value = (objectValue as really_any)[propertyName];
|
|
313
|
-
> if (value && typeof value === 'object') {
|
|
314
|
-
> deepClone(value);
|
|
315
|
-
> }
|
|
316
|
-
> }
|
|
317
|
-
> return Object.assign({}, objectValue);
|
|
318
|
-
*/
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* TODO: [🔼] Export from `@promptbook/utils`
|
|
322
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
323
|
-
*/
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* @@@
|
|
327
|
-
*
|
|
328
|
-
* TODO: [🔼] Export with addUsage
|
|
329
|
-
*/
|
|
330
|
-
var ZERO_USAGE = deepFreeze({
|
|
331
|
-
price: { value: 0 },
|
|
332
|
-
input: {
|
|
333
|
-
tokensCount: { value: 0 },
|
|
334
|
-
charactersCount: { value: 0 },
|
|
335
|
-
wordsCount: { value: 0 },
|
|
336
|
-
sentencesCount: { value: 0 },
|
|
337
|
-
linesCount: { value: 0 },
|
|
338
|
-
paragraphsCount: { value: 0 },
|
|
339
|
-
pagesCount: { value: 0 },
|
|
340
|
-
},
|
|
341
|
-
output: {
|
|
342
|
-
tokensCount: { value: 0 },
|
|
343
|
-
charactersCount: { value: 0 },
|
|
344
|
-
wordsCount: { value: 0 },
|
|
345
|
-
sentencesCount: { value: 0 },
|
|
346
|
-
linesCount: { value: 0 },
|
|
347
|
-
paragraphsCount: { value: 0 },
|
|
348
|
-
pagesCount: { value: 0 },
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
/**
|
|
352
|
-
* Function `addUsage` will add multiple usages into one
|
|
353
|
-
*
|
|
354
|
-
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
355
|
-
*/
|
|
356
|
-
function addUsage() {
|
|
357
|
-
var usageItems = [];
|
|
358
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
359
|
-
usageItems[_i] = arguments[_i];
|
|
360
|
-
}
|
|
361
|
-
return usageItems.reduce(function (acc, item) {
|
|
362
|
-
var e_1, _a, e_2, _b;
|
|
363
|
-
var _c;
|
|
364
|
-
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
365
|
-
try {
|
|
366
|
-
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
367
|
-
var key = _e.value;
|
|
368
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
369
|
-
//@ts-ignore
|
|
370
|
-
if (item.input[key]) {
|
|
371
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
372
|
-
//@ts-ignore
|
|
373
|
-
acc.input[key].value += item.input[key].value || 0;
|
|
374
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
375
|
-
//@ts-ignore
|
|
376
|
-
if (item.input[key].isUncertain) {
|
|
377
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
378
|
-
//@ts-ignore
|
|
379
|
-
acc.input[key].isUncertain = true;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
385
|
-
finally {
|
|
386
|
-
try {
|
|
387
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
388
|
-
}
|
|
389
|
-
finally { if (e_1) throw e_1.error; }
|
|
390
|
-
}
|
|
391
|
-
try {
|
|
392
|
-
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
393
|
-
var key = _g.value;
|
|
394
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
395
|
-
//@ts-ignore
|
|
396
|
-
if (item.output[key]) {
|
|
397
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
398
|
-
//@ts-ignore
|
|
399
|
-
acc.output[key].value += item.output[key].value || 0;
|
|
400
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
401
|
-
//@ts-ignore
|
|
402
|
-
if (item.output[key].isUncertain) {
|
|
403
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
404
|
-
//@ts-ignore
|
|
405
|
-
acc.output[key].isUncertain = true;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
411
|
-
finally {
|
|
412
|
-
try {
|
|
413
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
414
|
-
}
|
|
415
|
-
finally { if (e_2) throw e_2.error; }
|
|
416
|
-
}
|
|
417
|
-
return acc;
|
|
418
|
-
}, deepClone(ZERO_USAGE));
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Async version of Array.forEach
|
|
423
|
-
*
|
|
424
|
-
* @param array - Array to iterate over
|
|
425
|
-
* @param options - Options for the function
|
|
426
|
-
* @param callbackfunction - Function to call for each item
|
|
427
|
-
*/
|
|
428
|
-
function forEachAsync(array, options, callbackfunction) {
|
|
429
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
430
|
-
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
431
|
-
var e_1, _d;
|
|
432
|
-
return __generator(this, function (_e) {
|
|
433
|
-
switch (_e.label) {
|
|
434
|
-
case 0:
|
|
435
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
436
|
-
index = 0;
|
|
437
|
-
runningTasks = [];
|
|
438
|
-
tasks = [];
|
|
439
|
-
_loop_1 = function (item) {
|
|
440
|
-
var currentIndex, task;
|
|
441
|
-
return __generator(this, function (_f) {
|
|
442
|
-
switch (_f.label) {
|
|
443
|
-
case 0:
|
|
444
|
-
currentIndex = index++;
|
|
445
|
-
task = callbackfunction(item, currentIndex, array);
|
|
446
|
-
tasks.push(task);
|
|
447
|
-
runningTasks.push(task);
|
|
448
|
-
/* not await */ Promise.resolve(task).then(function () {
|
|
449
|
-
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
450
|
-
});
|
|
451
|
-
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
452
|
-
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
453
|
-
case 1:
|
|
454
|
-
_f.sent();
|
|
455
|
-
_f.label = 2;
|
|
456
|
-
case 2: return [2 /*return*/];
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
};
|
|
460
|
-
_e.label = 1;
|
|
461
|
-
case 1:
|
|
462
|
-
_e.trys.push([1, 6, 7, 8]);
|
|
463
|
-
_b = __values(array), _c = _b.next();
|
|
464
|
-
_e.label = 2;
|
|
465
|
-
case 2:
|
|
466
|
-
if (!!_c.done) return [3 /*break*/, 5];
|
|
467
|
-
item = _c.value;
|
|
468
|
-
return [5 /*yield**/, _loop_1(item)];
|
|
469
|
-
case 3:
|
|
470
|
-
_e.sent();
|
|
471
|
-
_e.label = 4;
|
|
472
|
-
case 4:
|
|
473
|
-
_c = _b.next();
|
|
474
|
-
return [3 /*break*/, 2];
|
|
475
|
-
case 5: return [3 /*break*/, 8];
|
|
476
|
-
case 6:
|
|
477
|
-
e_1_1 = _e.sent();
|
|
478
|
-
e_1 = { error: e_1_1 };
|
|
479
|
-
return [3 /*break*/, 8];
|
|
480
|
-
case 7:
|
|
481
|
-
try {
|
|
482
|
-
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
483
|
-
}
|
|
484
|
-
finally { if (e_1) throw e_1.error; }
|
|
485
|
-
return [7 /*endfinally*/];
|
|
486
|
-
case 8: return [4 /*yield*/, Promise.all(tasks)];
|
|
487
|
-
case 9:
|
|
488
|
-
_e.sent();
|
|
489
|
-
return [2 /*return*/];
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-17",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",dependentParameterNames:["content"],resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-17",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-17",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-17",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-17",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-17",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-17",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\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### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `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### Option `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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-17",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
496
|
-
|
|
497
303
|
/**
|
|
498
304
|
* Prettify the html code
|
|
499
305
|
*
|
|
@@ -710,32 +516,226 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
710
516
|
pipelineString += '\n\n';
|
|
711
517
|
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
|
|
712
518
|
}
|
|
713
|
-
}
|
|
714
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
715
|
-
finally {
|
|
716
|
-
try {
|
|
717
|
-
if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_c = promptTemplates_1.return)) _c.call(promptTemplates_1);
|
|
519
|
+
}
|
|
520
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
521
|
+
finally {
|
|
522
|
+
try {
|
|
523
|
+
if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_c = promptTemplates_1.return)) _c.call(promptTemplates_1);
|
|
524
|
+
}
|
|
525
|
+
finally { if (e_3) throw e_3.error; }
|
|
526
|
+
}
|
|
527
|
+
return pipelineString;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* @private internal util of pipelineJsonToString
|
|
531
|
+
*/
|
|
532
|
+
function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
|
|
533
|
+
var name = promptTemplateParameterJson.name, description = promptTemplateParameterJson.description;
|
|
534
|
+
var parameterString = "{".concat(name, "}");
|
|
535
|
+
if (description) {
|
|
536
|
+
parameterString = "".concat(parameterString, " ").concat(description);
|
|
537
|
+
}
|
|
538
|
+
return parameterString;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* TODO: !!!! Implement new features and commands into `promptTemplateParameterJsonToString`
|
|
542
|
+
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
543
|
+
* TODO: Escape all
|
|
544
|
+
*/
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* @@@
|
|
548
|
+
*/
|
|
549
|
+
function deepClone(objectValue) {
|
|
550
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
551
|
+
/*
|
|
552
|
+
TODO: [🧠] Is there a better implementation?
|
|
553
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
554
|
+
> for (const propertyName of propertyNames) {
|
|
555
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
556
|
+
> if (value && typeof value === 'object') {
|
|
557
|
+
> deepClone(value);
|
|
558
|
+
> }
|
|
559
|
+
> }
|
|
560
|
+
> return Object.assign({}, objectValue);
|
|
561
|
+
*/
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
565
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
566
|
+
*/
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* @@@
|
|
570
|
+
*
|
|
571
|
+
* TODO: [🔼] Export with addUsage
|
|
572
|
+
*/
|
|
573
|
+
var ZERO_USAGE = deepFreeze({
|
|
574
|
+
price: { value: 0 },
|
|
575
|
+
input: {
|
|
576
|
+
tokensCount: { value: 0 },
|
|
577
|
+
charactersCount: { value: 0 },
|
|
578
|
+
wordsCount: { value: 0 },
|
|
579
|
+
sentencesCount: { value: 0 },
|
|
580
|
+
linesCount: { value: 0 },
|
|
581
|
+
paragraphsCount: { value: 0 },
|
|
582
|
+
pagesCount: { value: 0 },
|
|
583
|
+
},
|
|
584
|
+
output: {
|
|
585
|
+
tokensCount: { value: 0 },
|
|
586
|
+
charactersCount: { value: 0 },
|
|
587
|
+
wordsCount: { value: 0 },
|
|
588
|
+
sentencesCount: { value: 0 },
|
|
589
|
+
linesCount: { value: 0 },
|
|
590
|
+
paragraphsCount: { value: 0 },
|
|
591
|
+
pagesCount: { value: 0 },
|
|
592
|
+
},
|
|
593
|
+
});
|
|
594
|
+
/**
|
|
595
|
+
* Function `addUsage` will add multiple usages into one
|
|
596
|
+
*
|
|
597
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
598
|
+
*/
|
|
599
|
+
function addUsage() {
|
|
600
|
+
var usageItems = [];
|
|
601
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
602
|
+
usageItems[_i] = arguments[_i];
|
|
603
|
+
}
|
|
604
|
+
return usageItems.reduce(function (acc, item) {
|
|
605
|
+
var e_1, _a, e_2, _b;
|
|
606
|
+
var _c;
|
|
607
|
+
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
608
|
+
try {
|
|
609
|
+
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
610
|
+
var key = _e.value;
|
|
611
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
612
|
+
//@ts-ignore
|
|
613
|
+
if (item.input[key]) {
|
|
614
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
615
|
+
//@ts-ignore
|
|
616
|
+
acc.input[key].value += item.input[key].value || 0;
|
|
617
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
618
|
+
//@ts-ignore
|
|
619
|
+
if (item.input[key].isUncertain) {
|
|
620
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
621
|
+
//@ts-ignore
|
|
622
|
+
acc.input[key].isUncertain = true;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
628
|
+
finally {
|
|
629
|
+
try {
|
|
630
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
631
|
+
}
|
|
632
|
+
finally { if (e_1) throw e_1.error; }
|
|
633
|
+
}
|
|
634
|
+
try {
|
|
635
|
+
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
636
|
+
var key = _g.value;
|
|
637
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
638
|
+
//@ts-ignore
|
|
639
|
+
if (item.output[key]) {
|
|
640
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
641
|
+
//@ts-ignore
|
|
642
|
+
acc.output[key].value += item.output[key].value || 0;
|
|
643
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
644
|
+
//@ts-ignore
|
|
645
|
+
if (item.output[key].isUncertain) {
|
|
646
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
647
|
+
//@ts-ignore
|
|
648
|
+
acc.output[key].isUncertain = true;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
654
|
+
finally {
|
|
655
|
+
try {
|
|
656
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
657
|
+
}
|
|
658
|
+
finally { if (e_2) throw e_2.error; }
|
|
718
659
|
}
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
return pipelineString;
|
|
660
|
+
return acc;
|
|
661
|
+
}, deepClone(ZERO_USAGE));
|
|
722
662
|
}
|
|
663
|
+
|
|
723
664
|
/**
|
|
724
|
-
*
|
|
665
|
+
* Async version of Array.forEach
|
|
666
|
+
*
|
|
667
|
+
* @param array - Array to iterate over
|
|
668
|
+
* @param options - Options for the function
|
|
669
|
+
* @param callbackfunction - Function to call for each item
|
|
725
670
|
*/
|
|
726
|
-
function
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
671
|
+
function forEachAsync(array, options, callbackfunction) {
|
|
672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
673
|
+
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
674
|
+
var e_1, _d;
|
|
675
|
+
return __generator(this, function (_e) {
|
|
676
|
+
switch (_e.label) {
|
|
677
|
+
case 0:
|
|
678
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
679
|
+
index = 0;
|
|
680
|
+
runningTasks = [];
|
|
681
|
+
tasks = [];
|
|
682
|
+
_loop_1 = function (item) {
|
|
683
|
+
var currentIndex, task;
|
|
684
|
+
return __generator(this, function (_f) {
|
|
685
|
+
switch (_f.label) {
|
|
686
|
+
case 0:
|
|
687
|
+
currentIndex = index++;
|
|
688
|
+
task = callbackfunction(item, currentIndex, array);
|
|
689
|
+
tasks.push(task);
|
|
690
|
+
runningTasks.push(task);
|
|
691
|
+
/* not await */ Promise.resolve(task).then(function () {
|
|
692
|
+
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
693
|
+
});
|
|
694
|
+
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
695
|
+
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
696
|
+
case 1:
|
|
697
|
+
_f.sent();
|
|
698
|
+
_f.label = 2;
|
|
699
|
+
case 2: return [2 /*return*/];
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
};
|
|
703
|
+
_e.label = 1;
|
|
704
|
+
case 1:
|
|
705
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
706
|
+
_b = __values(array), _c = _b.next();
|
|
707
|
+
_e.label = 2;
|
|
708
|
+
case 2:
|
|
709
|
+
if (!!_c.done) return [3 /*break*/, 5];
|
|
710
|
+
item = _c.value;
|
|
711
|
+
return [5 /*yield**/, _loop_1(item)];
|
|
712
|
+
case 3:
|
|
713
|
+
_e.sent();
|
|
714
|
+
_e.label = 4;
|
|
715
|
+
case 4:
|
|
716
|
+
_c = _b.next();
|
|
717
|
+
return [3 /*break*/, 2];
|
|
718
|
+
case 5: return [3 /*break*/, 8];
|
|
719
|
+
case 6:
|
|
720
|
+
e_1_1 = _e.sent();
|
|
721
|
+
e_1 = { error: e_1_1 };
|
|
722
|
+
return [3 /*break*/, 8];
|
|
723
|
+
case 7:
|
|
724
|
+
try {
|
|
725
|
+
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
726
|
+
}
|
|
727
|
+
finally { if (e_1) throw e_1.error; }
|
|
728
|
+
return [7 /*endfinally*/];
|
|
729
|
+
case 8: return [4 /*yield*/, Promise.all(tasks)];
|
|
730
|
+
case 9:
|
|
731
|
+
_e.sent();
|
|
732
|
+
return [2 /*return*/];
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
});
|
|
733
736
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
737
|
-
* TODO: Escape all
|
|
738
|
-
*/
|
|
737
|
+
|
|
738
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-18",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",dependentParameterNames:["content"],resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-18",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-18",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-18",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\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### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `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### Option `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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
739
739
|
|
|
740
740
|
/**
|
|
741
741
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1208,17 +1208,23 @@ var SimplePipelineCollection = /** @class */ (function () {
|
|
|
1208
1208
|
try {
|
|
1209
1209
|
for (var pipelines_1 = __values(pipelines), pipelines_1_1 = pipelines_1.next(); !pipelines_1_1.done; pipelines_1_1 = pipelines_1.next()) {
|
|
1210
1210
|
var pipeline = pipelines_1_1.value;
|
|
1211
|
+
// TODO: [👠] DRY
|
|
1211
1212
|
if (pipeline.pipelineUrl === undefined) {
|
|
1212
1213
|
throw new ReferenceError$1(spaceTrim$1("\n Pipeline with name \"".concat(pipeline.title, "\" does not have defined URL\n\n File:\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines without URLs are called anonymous pipelines\n They can be used as standalone pipelines, but they cannot be referenced by other pipelines\n And also they cannot be used in the pipeline collection\n\n ")));
|
|
1213
1214
|
}
|
|
1215
|
+
// Note: [🐨]
|
|
1214
1216
|
validatePipeline(pipeline);
|
|
1217
|
+
// TODO: [🦄] DRY
|
|
1215
1218
|
// Note: [🦄]
|
|
1216
|
-
if (
|
|
1219
|
+
if (
|
|
1220
|
+
// TODO: [🐽]
|
|
1221
|
+
this.collection.has(pipeline.pipelineUrl) &&
|
|
1217
1222
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
1218
1223
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
1219
1224
|
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
1220
1225
|
throw new ReferenceError$1(spaceTrim$1("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
1221
1226
|
}
|
|
1227
|
+
// Note: [🧠] Overwrite existing pipeline with the same URL
|
|
1222
1228
|
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
1223
1229
|
}
|
|
1224
1230
|
}
|
|
@@ -1658,39 +1664,6 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
1658
1664
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1659
1665
|
*/
|
|
1660
1666
|
|
|
1661
|
-
/**
|
|
1662
|
-
* Create difference set of two sets.
|
|
1663
|
-
*
|
|
1664
|
-
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
1665
|
-
*/
|
|
1666
|
-
function difference(a, b, isEqual) {
|
|
1667
|
-
var e_1, _a;
|
|
1668
|
-
if (isEqual === void 0) { isEqual = function (a, b) { return a === b; }; }
|
|
1669
|
-
var diff = new Set();
|
|
1670
|
-
var _loop_1 = function (itemA) {
|
|
1671
|
-
if (!Array.from(b).some(function (itemB) { return isEqual(itemA, itemB); })) {
|
|
1672
|
-
diff.add(itemA);
|
|
1673
|
-
}
|
|
1674
|
-
};
|
|
1675
|
-
try {
|
|
1676
|
-
for (var _b = __values(Array.from(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1677
|
-
var itemA = _c.value;
|
|
1678
|
-
_loop_1(itemA);
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1682
|
-
finally {
|
|
1683
|
-
try {
|
|
1684
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1685
|
-
}
|
|
1686
|
-
finally { if (e_1) throw e_1.error; }
|
|
1687
|
-
}
|
|
1688
|
-
return diff;
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
1692
|
-
*/
|
|
1693
|
-
|
|
1694
1667
|
/**
|
|
1695
1668
|
* Parses the template and returns the list of all parameter names
|
|
1696
1669
|
*
|
|
@@ -1824,46 +1797,6 @@ function extractParametersFromPromptTemplate(promptTemplate) {
|
|
|
1824
1797
|
* TODO: [🔣] If script require contentLanguage
|
|
1825
1798
|
*/
|
|
1826
1799
|
|
|
1827
|
-
/**
|
|
1828
|
-
* Creates a new set with all elements that are present in either set
|
|
1829
|
-
*
|
|
1830
|
-
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
1831
|
-
*/
|
|
1832
|
-
function union() {
|
|
1833
|
-
var e_1, _a, e_2, _b;
|
|
1834
|
-
var sets = [];
|
|
1835
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1836
|
-
sets[_i] = arguments[_i];
|
|
1837
|
-
}
|
|
1838
|
-
var union = new Set();
|
|
1839
|
-
try {
|
|
1840
|
-
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
1841
|
-
var set = sets_1_1.value;
|
|
1842
|
-
try {
|
|
1843
|
-
for (var _c = (e_2 = void 0, __values(Array.from(set))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1844
|
-
var item = _d.value;
|
|
1845
|
-
union.add(item);
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1849
|
-
finally {
|
|
1850
|
-
try {
|
|
1851
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1852
|
-
}
|
|
1853
|
-
finally { if (e_2) throw e_2.error; }
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1858
|
-
finally {
|
|
1859
|
-
try {
|
|
1860
|
-
if (sets_1_1 && !sets_1_1.done && (_a = sets_1.return)) _a.call(sets_1);
|
|
1861
|
-
}
|
|
1862
|
-
finally { if (e_1) throw e_1.error; }
|
|
1863
|
-
}
|
|
1864
|
-
return union;
|
|
1865
|
-
}
|
|
1866
|
-
|
|
1867
1800
|
/**
|
|
1868
1801
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
1869
1802
|
*
|
|
@@ -2269,6 +2202,79 @@ function replaceParameters(template, parameters) {
|
|
|
2269
2202
|
return replacedTemplate;
|
|
2270
2203
|
}
|
|
2271
2204
|
|
|
2205
|
+
/**
|
|
2206
|
+
* Create difference set of two sets.
|
|
2207
|
+
*
|
|
2208
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2209
|
+
*/
|
|
2210
|
+
function difference(a, b, isEqual) {
|
|
2211
|
+
var e_1, _a;
|
|
2212
|
+
if (isEqual === void 0) { isEqual = function (a, b) { return a === b; }; }
|
|
2213
|
+
var diff = new Set();
|
|
2214
|
+
var _loop_1 = function (itemA) {
|
|
2215
|
+
if (!Array.from(b).some(function (itemB) { return isEqual(itemA, itemB); })) {
|
|
2216
|
+
diff.add(itemA);
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
try {
|
|
2220
|
+
for (var _b = __values(Array.from(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2221
|
+
var itemA = _c.value;
|
|
2222
|
+
_loop_1(itemA);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2226
|
+
finally {
|
|
2227
|
+
try {
|
|
2228
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2229
|
+
}
|
|
2230
|
+
finally { if (e_1) throw e_1.error; }
|
|
2231
|
+
}
|
|
2232
|
+
return diff;
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
2236
|
+
*/
|
|
2237
|
+
|
|
2238
|
+
/**
|
|
2239
|
+
* Creates a new set with all elements that are present in either set
|
|
2240
|
+
*
|
|
2241
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2242
|
+
*/
|
|
2243
|
+
function union() {
|
|
2244
|
+
var e_1, _a, e_2, _b;
|
|
2245
|
+
var sets = [];
|
|
2246
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2247
|
+
sets[_i] = arguments[_i];
|
|
2248
|
+
}
|
|
2249
|
+
var union = new Set();
|
|
2250
|
+
try {
|
|
2251
|
+
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
2252
|
+
var set = sets_1_1.value;
|
|
2253
|
+
try {
|
|
2254
|
+
for (var _c = (e_2 = void 0, __values(Array.from(set))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2255
|
+
var item = _d.value;
|
|
2256
|
+
union.add(item);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2260
|
+
finally {
|
|
2261
|
+
try {
|
|
2262
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2263
|
+
}
|
|
2264
|
+
finally { if (e_2) throw e_2.error; }
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2269
|
+
finally {
|
|
2270
|
+
try {
|
|
2271
|
+
if (sets_1_1 && !sets_1_1.done && (_a = sets_1.return)) _a.call(sets_1);
|
|
2272
|
+
}
|
|
2273
|
+
finally { if (e_1) throw e_1.error; }
|
|
2274
|
+
}
|
|
2275
|
+
return union;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2272
2278
|
/**
|
|
2273
2279
|
* Counts number of characters in the text
|
|
2274
2280
|
*/
|
|
@@ -2396,7 +2402,7 @@ function createPipelineExecutor(options) {
|
|
|
2396
2402
|
pipeline = rawPipeline;
|
|
2397
2403
|
}
|
|
2398
2404
|
else {
|
|
2399
|
-
console.warn(spaceTrim$1("\n Pipeline is not prepared\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "));
|
|
2405
|
+
console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
|
|
2400
2406
|
}
|
|
2401
2407
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2402
2408
|
function getContextForTemplate(// <- TODO: [🧠][🥜]
|
|
@@ -5508,7 +5514,7 @@ function createCollectionFromDirectory(path, options) {
|
|
|
5508
5514
|
}
|
|
5509
5515
|
_a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? false : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashedOnError, isCrashedOnError = _e === void 0 ? true : _e;
|
|
5510
5516
|
collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5511
|
-
var fileNames,
|
|
5517
|
+
var fileNames, collection, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
|
|
5512
5518
|
var e_1, _a;
|
|
5513
5519
|
return __generator(this, function (_b) {
|
|
5514
5520
|
switch (_b.label) {
|
|
@@ -5530,9 +5536,9 @@ function createCollectionFromDirectory(path, options) {
|
|
|
5530
5536
|
}
|
|
5531
5537
|
return 0;
|
|
5532
5538
|
});
|
|
5533
|
-
|
|
5539
|
+
collection = new Map();
|
|
5534
5540
|
_loop_1 = function (fileName) {
|
|
5535
|
-
var sourceFile, pipeline, pipelineString, _c, _d, error_1, wrappedErrorMessage;
|
|
5541
|
+
var sourceFile, pipeline, pipelineString, _c, _d, existing, error_1, wrappedErrorMessage;
|
|
5536
5542
|
return __generator(this, function (_e) {
|
|
5537
5543
|
switch (_e.label) {
|
|
5538
5544
|
case 0:
|
|
@@ -5568,7 +5574,8 @@ function createCollectionFromDirectory(path, options) {
|
|
|
5568
5574
|
case 7:
|
|
5569
5575
|
// ---
|
|
5570
5576
|
if (pipeline !== null) {
|
|
5571
|
-
|
|
5577
|
+
// TODO: [👠] DRY
|
|
5578
|
+
if (pipeline.pipelineUrl === undefined) {
|
|
5572
5579
|
if (isVerbose) {
|
|
5573
5580
|
console.info(colors.red("Can not load pipeline from ".concat(fileName
|
|
5574
5581
|
.split('\\')
|
|
@@ -5576,16 +5583,30 @@ function createCollectionFromDirectory(path, options) {
|
|
|
5576
5583
|
}
|
|
5577
5584
|
}
|
|
5578
5585
|
else {
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5586
|
+
// Note: [🐨] Pipeline is checked multiple times
|
|
5587
|
+
// TODO: Maybe once is enough BUT be sure to check it - better to check it multiple times than not at all
|
|
5588
|
+
validatePipeline(pipeline);
|
|
5589
|
+
if (
|
|
5590
|
+
// TODO: [🐽] comparePipelines(pipeline1,pipeline2): 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
|
|
5591
|
+
!collection.has(pipeline.pipelineUrl)) {
|
|
5592
|
+
if (isVerbose) {
|
|
5593
|
+
console.info(colors.gray("Loaded pipeline ".concat(fileName.split('\\').join('/'), "\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060")));
|
|
5594
|
+
}
|
|
5595
|
+
// Note: [🦄] Pipeline with same url uniqueness will be double-checked automatically in SimplePipelineCollection
|
|
5596
|
+
collection.set(pipeline.pipelineUrl, pipeline);
|
|
5583
5597
|
}
|
|
5584
|
-
if (
|
|
5585
|
-
|
|
5598
|
+
else if (pipelineJsonToString(unpreparePipeline(pipeline)) ===
|
|
5599
|
+
pipelineJsonToString(unpreparePipeline(collection.get(pipeline.pipelineUrl)))) {
|
|
5600
|
+
if (isVerbose) {
|
|
5601
|
+
console.info(colors.gray("Skipped pipeline ".concat(fileName
|
|
5602
|
+
.split('\\')
|
|
5603
|
+
.join('/'), " \u2013\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060 identical pipeline in the collection")));
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
else {
|
|
5607
|
+
existing = collection.get(pipeline.pipelineUrl);
|
|
5608
|
+
throw new ReferenceError(spaceTrim("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
5586
5609
|
}
|
|
5587
|
-
// Note: [🦄] Pipeline with same url uniqueness will be checked automatically in SimplePipelineCollection
|
|
5588
|
-
pipelines.push(pipeline);
|
|
5589
5610
|
}
|
|
5590
5611
|
}
|
|
5591
5612
|
return [3 /*break*/, 9];
|
|
@@ -5594,7 +5615,7 @@ function createCollectionFromDirectory(path, options) {
|
|
|
5594
5615
|
if (!(error_1 instanceof Error)) {
|
|
5595
5616
|
throw error_1;
|
|
5596
5617
|
}
|
|
5597
|
-
wrappedErrorMessage = spaceTrim(function (block) { return "\n
|
|
5618
|
+
wrappedErrorMessage = spaceTrim(function (block) { return "\n ".concat(error_1.name, " in pipeline ").concat(fileName.split('\\').join('/'), "\u2060:\n\n ").concat(block(error_1.message), "\n\n "); });
|
|
5598
5619
|
if (isCrashedOnError) {
|
|
5599
5620
|
throw new CollectionError(wrappedErrorMessage);
|
|
5600
5621
|
}
|
|
@@ -5631,7 +5652,7 @@ function createCollectionFromDirectory(path, options) {
|
|
|
5631
5652
|
}
|
|
5632
5653
|
finally { if (e_1) throw e_1.error; }
|
|
5633
5654
|
return [7 /*endfinally*/];
|
|
5634
|
-
case 9: return [2 /*return*/,
|
|
5655
|
+
case 9: return [2 /*return*/, Array.from(collection.values())];
|
|
5635
5656
|
}
|
|
5636
5657
|
});
|
|
5637
5658
|
}); });
|