@promptbook/node 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/umd/index.umd.js
CHANGED
|
@@ -208,200 +208,6 @@
|
|
|
208
208
|
* TODO: [🔼] Export all to core
|
|
209
209
|
*/
|
|
210
210
|
|
|
211
|
-
/**
|
|
212
|
-
* @@@
|
|
213
|
-
*/
|
|
214
|
-
function deepClone(objectValue) {
|
|
215
|
-
return JSON.parse(JSON.stringify(objectValue));
|
|
216
|
-
/*
|
|
217
|
-
TODO: [🧠] Is there a better implementation?
|
|
218
|
-
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
219
|
-
> for (const propertyName of propertyNames) {
|
|
220
|
-
> const value = (objectValue as really_any)[propertyName];
|
|
221
|
-
> if (value && typeof value === 'object') {
|
|
222
|
-
> deepClone(value);
|
|
223
|
-
> }
|
|
224
|
-
> }
|
|
225
|
-
> return Object.assign({}, objectValue);
|
|
226
|
-
*/
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* TODO: [🔼] Export from `@promptbook/utils`
|
|
230
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
231
|
-
*/
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* @@@
|
|
235
|
-
*
|
|
236
|
-
* TODO: [🔼] Export with addUsage
|
|
237
|
-
*/
|
|
238
|
-
var ZERO_USAGE = deepFreeze({
|
|
239
|
-
price: { value: 0 },
|
|
240
|
-
input: {
|
|
241
|
-
tokensCount: { value: 0 },
|
|
242
|
-
charactersCount: { value: 0 },
|
|
243
|
-
wordsCount: { value: 0 },
|
|
244
|
-
sentencesCount: { value: 0 },
|
|
245
|
-
linesCount: { value: 0 },
|
|
246
|
-
paragraphsCount: { value: 0 },
|
|
247
|
-
pagesCount: { value: 0 },
|
|
248
|
-
},
|
|
249
|
-
output: {
|
|
250
|
-
tokensCount: { value: 0 },
|
|
251
|
-
charactersCount: { value: 0 },
|
|
252
|
-
wordsCount: { value: 0 },
|
|
253
|
-
sentencesCount: { value: 0 },
|
|
254
|
-
linesCount: { value: 0 },
|
|
255
|
-
paragraphsCount: { value: 0 },
|
|
256
|
-
pagesCount: { value: 0 },
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
/**
|
|
260
|
-
* Function `addUsage` will add multiple usages into one
|
|
261
|
-
*
|
|
262
|
-
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
263
|
-
*/
|
|
264
|
-
function addUsage() {
|
|
265
|
-
var usageItems = [];
|
|
266
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
267
|
-
usageItems[_i] = arguments[_i];
|
|
268
|
-
}
|
|
269
|
-
return usageItems.reduce(function (acc, item) {
|
|
270
|
-
var e_1, _a, e_2, _b;
|
|
271
|
-
var _c;
|
|
272
|
-
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
273
|
-
try {
|
|
274
|
-
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
275
|
-
var key = _e.value;
|
|
276
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
277
|
-
//@ts-ignore
|
|
278
|
-
if (item.input[key]) {
|
|
279
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
280
|
-
//@ts-ignore
|
|
281
|
-
acc.input[key].value += item.input[key].value || 0;
|
|
282
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
283
|
-
//@ts-ignore
|
|
284
|
-
if (item.input[key].isUncertain) {
|
|
285
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
286
|
-
//@ts-ignore
|
|
287
|
-
acc.input[key].isUncertain = true;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
293
|
-
finally {
|
|
294
|
-
try {
|
|
295
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
296
|
-
}
|
|
297
|
-
finally { if (e_1) throw e_1.error; }
|
|
298
|
-
}
|
|
299
|
-
try {
|
|
300
|
-
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
301
|
-
var key = _g.value;
|
|
302
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
303
|
-
//@ts-ignore
|
|
304
|
-
if (item.output[key]) {
|
|
305
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
306
|
-
//@ts-ignore
|
|
307
|
-
acc.output[key].value += item.output[key].value || 0;
|
|
308
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
309
|
-
//@ts-ignore
|
|
310
|
-
if (item.output[key].isUncertain) {
|
|
311
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
312
|
-
//@ts-ignore
|
|
313
|
-
acc.output[key].isUncertain = true;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
319
|
-
finally {
|
|
320
|
-
try {
|
|
321
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
322
|
-
}
|
|
323
|
-
finally { if (e_2) throw e_2.error; }
|
|
324
|
-
}
|
|
325
|
-
return acc;
|
|
326
|
-
}, deepClone(ZERO_USAGE));
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Async version of Array.forEach
|
|
331
|
-
*
|
|
332
|
-
* @param array - Array to iterate over
|
|
333
|
-
* @param options - Options for the function
|
|
334
|
-
* @param callbackfunction - Function to call for each item
|
|
335
|
-
*/
|
|
336
|
-
function forEachAsync(array, options, callbackfunction) {
|
|
337
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
338
|
-
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
339
|
-
var e_1, _d;
|
|
340
|
-
return __generator(this, function (_e) {
|
|
341
|
-
switch (_e.label) {
|
|
342
|
-
case 0:
|
|
343
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
344
|
-
index = 0;
|
|
345
|
-
runningTasks = [];
|
|
346
|
-
tasks = [];
|
|
347
|
-
_loop_1 = function (item) {
|
|
348
|
-
var currentIndex, task;
|
|
349
|
-
return __generator(this, function (_f) {
|
|
350
|
-
switch (_f.label) {
|
|
351
|
-
case 0:
|
|
352
|
-
currentIndex = index++;
|
|
353
|
-
task = callbackfunction(item, currentIndex, array);
|
|
354
|
-
tasks.push(task);
|
|
355
|
-
runningTasks.push(task);
|
|
356
|
-
/* not await */ Promise.resolve(task).then(function () {
|
|
357
|
-
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
358
|
-
});
|
|
359
|
-
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
360
|
-
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
361
|
-
case 1:
|
|
362
|
-
_f.sent();
|
|
363
|
-
_f.label = 2;
|
|
364
|
-
case 2: return [2 /*return*/];
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
|
-
_e.label = 1;
|
|
369
|
-
case 1:
|
|
370
|
-
_e.trys.push([1, 6, 7, 8]);
|
|
371
|
-
_b = __values(array), _c = _b.next();
|
|
372
|
-
_e.label = 2;
|
|
373
|
-
case 2:
|
|
374
|
-
if (!!_c.done) return [3 /*break*/, 5];
|
|
375
|
-
item = _c.value;
|
|
376
|
-
return [5 /*yield**/, _loop_1(item)];
|
|
377
|
-
case 3:
|
|
378
|
-
_e.sent();
|
|
379
|
-
_e.label = 4;
|
|
380
|
-
case 4:
|
|
381
|
-
_c = _b.next();
|
|
382
|
-
return [3 /*break*/, 2];
|
|
383
|
-
case 5: return [3 /*break*/, 8];
|
|
384
|
-
case 6:
|
|
385
|
-
e_1_1 = _e.sent();
|
|
386
|
-
e_1 = { error: e_1_1 };
|
|
387
|
-
return [3 /*break*/, 8];
|
|
388
|
-
case 7:
|
|
389
|
-
try {
|
|
390
|
-
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
391
|
-
}
|
|
392
|
-
finally { if (e_1) throw e_1.error; }
|
|
393
|
-
return [7 /*endfinally*/];
|
|
394
|
-
case 8: return [4 /*yield*/, Promise.all(tasks)];
|
|
395
|
-
case 9:
|
|
396
|
-
_e.sent();
|
|
397
|
-
return [2 /*return*/];
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
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"}];
|
|
404
|
-
|
|
405
211
|
/**
|
|
406
212
|
* Prettify the html code
|
|
407
213
|
*
|
|
@@ -618,32 +424,226 @@
|
|
|
618
424
|
pipelineString += '\n\n';
|
|
619
425
|
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
|
|
620
426
|
}
|
|
621
|
-
}
|
|
622
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
623
|
-
finally {
|
|
624
|
-
try {
|
|
625
|
-
if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_c = promptTemplates_1.return)) _c.call(promptTemplates_1);
|
|
427
|
+
}
|
|
428
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
429
|
+
finally {
|
|
430
|
+
try {
|
|
431
|
+
if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_c = promptTemplates_1.return)) _c.call(promptTemplates_1);
|
|
432
|
+
}
|
|
433
|
+
finally { if (e_3) throw e_3.error; }
|
|
434
|
+
}
|
|
435
|
+
return pipelineString;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* @private internal util of pipelineJsonToString
|
|
439
|
+
*/
|
|
440
|
+
function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
|
|
441
|
+
var name = promptTemplateParameterJson.name, description = promptTemplateParameterJson.description;
|
|
442
|
+
var parameterString = "{".concat(name, "}");
|
|
443
|
+
if (description) {
|
|
444
|
+
parameterString = "".concat(parameterString, " ").concat(description);
|
|
445
|
+
}
|
|
446
|
+
return parameterString;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* TODO: !!!! Implement new features and commands into `promptTemplateParameterJsonToString`
|
|
450
|
+
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
451
|
+
* TODO: Escape all
|
|
452
|
+
*/
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* @@@
|
|
456
|
+
*/
|
|
457
|
+
function deepClone(objectValue) {
|
|
458
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
459
|
+
/*
|
|
460
|
+
TODO: [🧠] Is there a better implementation?
|
|
461
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
462
|
+
> for (const propertyName of propertyNames) {
|
|
463
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
464
|
+
> if (value && typeof value === 'object') {
|
|
465
|
+
> deepClone(value);
|
|
466
|
+
> }
|
|
467
|
+
> }
|
|
468
|
+
> return Object.assign({}, objectValue);
|
|
469
|
+
*/
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
473
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
474
|
+
*/
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* @@@
|
|
478
|
+
*
|
|
479
|
+
* TODO: [🔼] Export with addUsage
|
|
480
|
+
*/
|
|
481
|
+
var ZERO_USAGE = deepFreeze({
|
|
482
|
+
price: { value: 0 },
|
|
483
|
+
input: {
|
|
484
|
+
tokensCount: { value: 0 },
|
|
485
|
+
charactersCount: { value: 0 },
|
|
486
|
+
wordsCount: { value: 0 },
|
|
487
|
+
sentencesCount: { value: 0 },
|
|
488
|
+
linesCount: { value: 0 },
|
|
489
|
+
paragraphsCount: { value: 0 },
|
|
490
|
+
pagesCount: { value: 0 },
|
|
491
|
+
},
|
|
492
|
+
output: {
|
|
493
|
+
tokensCount: { value: 0 },
|
|
494
|
+
charactersCount: { value: 0 },
|
|
495
|
+
wordsCount: { value: 0 },
|
|
496
|
+
sentencesCount: { value: 0 },
|
|
497
|
+
linesCount: { value: 0 },
|
|
498
|
+
paragraphsCount: { value: 0 },
|
|
499
|
+
pagesCount: { value: 0 },
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
/**
|
|
503
|
+
* Function `addUsage` will add multiple usages into one
|
|
504
|
+
*
|
|
505
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
506
|
+
*/
|
|
507
|
+
function addUsage() {
|
|
508
|
+
var usageItems = [];
|
|
509
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
510
|
+
usageItems[_i] = arguments[_i];
|
|
511
|
+
}
|
|
512
|
+
return usageItems.reduce(function (acc, item) {
|
|
513
|
+
var e_1, _a, e_2, _b;
|
|
514
|
+
var _c;
|
|
515
|
+
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
516
|
+
try {
|
|
517
|
+
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
518
|
+
var key = _e.value;
|
|
519
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
520
|
+
//@ts-ignore
|
|
521
|
+
if (item.input[key]) {
|
|
522
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
523
|
+
//@ts-ignore
|
|
524
|
+
acc.input[key].value += item.input[key].value || 0;
|
|
525
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
526
|
+
//@ts-ignore
|
|
527
|
+
if (item.input[key].isUncertain) {
|
|
528
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
529
|
+
//@ts-ignore
|
|
530
|
+
acc.input[key].isUncertain = true;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
536
|
+
finally {
|
|
537
|
+
try {
|
|
538
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
539
|
+
}
|
|
540
|
+
finally { if (e_1) throw e_1.error; }
|
|
541
|
+
}
|
|
542
|
+
try {
|
|
543
|
+
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
544
|
+
var key = _g.value;
|
|
545
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
546
|
+
//@ts-ignore
|
|
547
|
+
if (item.output[key]) {
|
|
548
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
549
|
+
//@ts-ignore
|
|
550
|
+
acc.output[key].value += item.output[key].value || 0;
|
|
551
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
552
|
+
//@ts-ignore
|
|
553
|
+
if (item.output[key].isUncertain) {
|
|
554
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
555
|
+
//@ts-ignore
|
|
556
|
+
acc.output[key].isUncertain = true;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
562
|
+
finally {
|
|
563
|
+
try {
|
|
564
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
565
|
+
}
|
|
566
|
+
finally { if (e_2) throw e_2.error; }
|
|
626
567
|
}
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
return pipelineString;
|
|
568
|
+
return acc;
|
|
569
|
+
}, deepClone(ZERO_USAGE));
|
|
630
570
|
}
|
|
571
|
+
|
|
631
572
|
/**
|
|
632
|
-
*
|
|
573
|
+
* Async version of Array.forEach
|
|
574
|
+
*
|
|
575
|
+
* @param array - Array to iterate over
|
|
576
|
+
* @param options - Options for the function
|
|
577
|
+
* @param callbackfunction - Function to call for each item
|
|
633
578
|
*/
|
|
634
|
-
function
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
579
|
+
function forEachAsync(array, options, callbackfunction) {
|
|
580
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
581
|
+
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
582
|
+
var e_1, _d;
|
|
583
|
+
return __generator(this, function (_e) {
|
|
584
|
+
switch (_e.label) {
|
|
585
|
+
case 0:
|
|
586
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
587
|
+
index = 0;
|
|
588
|
+
runningTasks = [];
|
|
589
|
+
tasks = [];
|
|
590
|
+
_loop_1 = function (item) {
|
|
591
|
+
var currentIndex, task;
|
|
592
|
+
return __generator(this, function (_f) {
|
|
593
|
+
switch (_f.label) {
|
|
594
|
+
case 0:
|
|
595
|
+
currentIndex = index++;
|
|
596
|
+
task = callbackfunction(item, currentIndex, array);
|
|
597
|
+
tasks.push(task);
|
|
598
|
+
runningTasks.push(task);
|
|
599
|
+
/* not await */ Promise.resolve(task).then(function () {
|
|
600
|
+
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
601
|
+
});
|
|
602
|
+
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
603
|
+
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
604
|
+
case 1:
|
|
605
|
+
_f.sent();
|
|
606
|
+
_f.label = 2;
|
|
607
|
+
case 2: return [2 /*return*/];
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
_e.label = 1;
|
|
612
|
+
case 1:
|
|
613
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
614
|
+
_b = __values(array), _c = _b.next();
|
|
615
|
+
_e.label = 2;
|
|
616
|
+
case 2:
|
|
617
|
+
if (!!_c.done) return [3 /*break*/, 5];
|
|
618
|
+
item = _c.value;
|
|
619
|
+
return [5 /*yield**/, _loop_1(item)];
|
|
620
|
+
case 3:
|
|
621
|
+
_e.sent();
|
|
622
|
+
_e.label = 4;
|
|
623
|
+
case 4:
|
|
624
|
+
_c = _b.next();
|
|
625
|
+
return [3 /*break*/, 2];
|
|
626
|
+
case 5: return [3 /*break*/, 8];
|
|
627
|
+
case 6:
|
|
628
|
+
e_1_1 = _e.sent();
|
|
629
|
+
e_1 = { error: e_1_1 };
|
|
630
|
+
return [3 /*break*/, 8];
|
|
631
|
+
case 7:
|
|
632
|
+
try {
|
|
633
|
+
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
634
|
+
}
|
|
635
|
+
finally { if (e_1) throw e_1.error; }
|
|
636
|
+
return [7 /*endfinally*/];
|
|
637
|
+
case 8: return [4 /*yield*/, Promise.all(tasks)];
|
|
638
|
+
case 9:
|
|
639
|
+
_e.sent();
|
|
640
|
+
return [2 /*return*/];
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
});
|
|
641
644
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
645
|
-
* TODO: Escape all
|
|
646
|
-
*/
|
|
645
|
+
|
|
646
|
+
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"}];
|
|
647
647
|
|
|
648
648
|
/**
|
|
649
649
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1116,17 +1116,23 @@
|
|
|
1116
1116
|
try {
|
|
1117
1117
|
for (var pipelines_1 = __values(pipelines), pipelines_1_1 = pipelines_1.next(); !pipelines_1_1.done; pipelines_1_1 = pipelines_1.next()) {
|
|
1118
1118
|
var pipeline = pipelines_1_1.value;
|
|
1119
|
+
// TODO: [👠] DRY
|
|
1119
1120
|
if (pipeline.pipelineUrl === undefined) {
|
|
1120
1121
|
throw new ReferenceError$1(spaceTrim.spaceTrim("\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 ")));
|
|
1121
1122
|
}
|
|
1123
|
+
// Note: [🐨]
|
|
1122
1124
|
validatePipeline(pipeline);
|
|
1125
|
+
// TODO: [🦄] DRY
|
|
1123
1126
|
// Note: [🦄]
|
|
1124
|
-
if (
|
|
1127
|
+
if (
|
|
1128
|
+
// TODO: [🐽]
|
|
1129
|
+
this.collection.has(pipeline.pipelineUrl) &&
|
|
1125
1130
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
1126
1131
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
1127
1132
|
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
1128
1133
|
throw new ReferenceError$1(spaceTrim.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 ")));
|
|
1129
1134
|
}
|
|
1135
|
+
// Note: [🧠] Overwrite existing pipeline with the same URL
|
|
1130
1136
|
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
1131
1137
|
}
|
|
1132
1138
|
}
|
|
@@ -1566,39 +1572,6 @@
|
|
|
1566
1572
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1567
1573
|
*/
|
|
1568
1574
|
|
|
1569
|
-
/**
|
|
1570
|
-
* Create difference set of two sets.
|
|
1571
|
-
*
|
|
1572
|
-
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
1573
|
-
*/
|
|
1574
|
-
function difference(a, b, isEqual) {
|
|
1575
|
-
var e_1, _a;
|
|
1576
|
-
if (isEqual === void 0) { isEqual = function (a, b) { return a === b; }; }
|
|
1577
|
-
var diff = new Set();
|
|
1578
|
-
var _loop_1 = function (itemA) {
|
|
1579
|
-
if (!Array.from(b).some(function (itemB) { return isEqual(itemA, itemB); })) {
|
|
1580
|
-
diff.add(itemA);
|
|
1581
|
-
}
|
|
1582
|
-
};
|
|
1583
|
-
try {
|
|
1584
|
-
for (var _b = __values(Array.from(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1585
|
-
var itemA = _c.value;
|
|
1586
|
-
_loop_1(itemA);
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1590
|
-
finally {
|
|
1591
|
-
try {
|
|
1592
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1593
|
-
}
|
|
1594
|
-
finally { if (e_1) throw e_1.error; }
|
|
1595
|
-
}
|
|
1596
|
-
return diff;
|
|
1597
|
-
}
|
|
1598
|
-
/**
|
|
1599
|
-
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
1600
|
-
*/
|
|
1601
|
-
|
|
1602
1575
|
/**
|
|
1603
1576
|
* Parses the template and returns the list of all parameter names
|
|
1604
1577
|
*
|
|
@@ -1732,46 +1705,6 @@
|
|
|
1732
1705
|
* TODO: [🔣] If script require contentLanguage
|
|
1733
1706
|
*/
|
|
1734
1707
|
|
|
1735
|
-
/**
|
|
1736
|
-
* Creates a new set with all elements that are present in either set
|
|
1737
|
-
*
|
|
1738
|
-
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
1739
|
-
*/
|
|
1740
|
-
function union() {
|
|
1741
|
-
var e_1, _a, e_2, _b;
|
|
1742
|
-
var sets = [];
|
|
1743
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1744
|
-
sets[_i] = arguments[_i];
|
|
1745
|
-
}
|
|
1746
|
-
var union = new Set();
|
|
1747
|
-
try {
|
|
1748
|
-
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
1749
|
-
var set = sets_1_1.value;
|
|
1750
|
-
try {
|
|
1751
|
-
for (var _c = (e_2 = void 0, __values(Array.from(set))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1752
|
-
var item = _d.value;
|
|
1753
|
-
union.add(item);
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1757
|
-
finally {
|
|
1758
|
-
try {
|
|
1759
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1760
|
-
}
|
|
1761
|
-
finally { if (e_2) throw e_2.error; }
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1766
|
-
finally {
|
|
1767
|
-
try {
|
|
1768
|
-
if (sets_1_1 && !sets_1_1.done && (_a = sets_1.return)) _a.call(sets_1);
|
|
1769
|
-
}
|
|
1770
|
-
finally { if (e_1) throw e_1.error; }
|
|
1771
|
-
}
|
|
1772
|
-
return union;
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
1708
|
/**
|
|
1776
1709
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
1777
1710
|
*
|
|
@@ -2177,10 +2110,83 @@
|
|
|
2177
2110
|
return replacedTemplate;
|
|
2178
2111
|
}
|
|
2179
2112
|
|
|
2113
|
+
/**
|
|
2114
|
+
* Create difference set of two sets.
|
|
2115
|
+
*
|
|
2116
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2117
|
+
*/
|
|
2118
|
+
function difference(a, b, isEqual) {
|
|
2119
|
+
var e_1, _a;
|
|
2120
|
+
if (isEqual === void 0) { isEqual = function (a, b) { return a === b; }; }
|
|
2121
|
+
var diff = new Set();
|
|
2122
|
+
var _loop_1 = function (itemA) {
|
|
2123
|
+
if (!Array.from(b).some(function (itemB) { return isEqual(itemA, itemB); })) {
|
|
2124
|
+
diff.add(itemA);
|
|
2125
|
+
}
|
|
2126
|
+
};
|
|
2127
|
+
try {
|
|
2128
|
+
for (var _b = __values(Array.from(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2129
|
+
var itemA = _c.value;
|
|
2130
|
+
_loop_1(itemA);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2134
|
+
finally {
|
|
2135
|
+
try {
|
|
2136
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2137
|
+
}
|
|
2138
|
+
finally { if (e_1) throw e_1.error; }
|
|
2139
|
+
}
|
|
2140
|
+
return diff;
|
|
2141
|
+
}
|
|
2142
|
+
/**
|
|
2143
|
+
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
2144
|
+
*/
|
|
2145
|
+
|
|
2146
|
+
/**
|
|
2147
|
+
* Creates a new set with all elements that are present in either set
|
|
2148
|
+
*
|
|
2149
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2150
|
+
*/
|
|
2151
|
+
function union() {
|
|
2152
|
+
var e_1, _a, e_2, _b;
|
|
2153
|
+
var sets = [];
|
|
2154
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2155
|
+
sets[_i] = arguments[_i];
|
|
2156
|
+
}
|
|
2157
|
+
var union = new Set();
|
|
2158
|
+
try {
|
|
2159
|
+
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
2160
|
+
var set = sets_1_1.value;
|
|
2161
|
+
try {
|
|
2162
|
+
for (var _c = (e_2 = void 0, __values(Array.from(set))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2163
|
+
var item = _d.value;
|
|
2164
|
+
union.add(item);
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2168
|
+
finally {
|
|
2169
|
+
try {
|
|
2170
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2171
|
+
}
|
|
2172
|
+
finally { if (e_2) throw e_2.error; }
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2177
|
+
finally {
|
|
2178
|
+
try {
|
|
2179
|
+
if (sets_1_1 && !sets_1_1.done && (_a = sets_1.return)) _a.call(sets_1);
|
|
2180
|
+
}
|
|
2181
|
+
finally { if (e_1) throw e_1.error; }
|
|
2182
|
+
}
|
|
2183
|
+
return union;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2180
2186
|
/**
|
|
2181
2187
|
* The version of the Promptbook library
|
|
2182
2188
|
*/
|
|
2183
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2189
|
+
var PROMPTBOOK_VERSION = '0.61.0-18';
|
|
2184
2190
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2185
2191
|
|
|
2186
2192
|
/**
|
|
@@ -2310,7 +2316,7 @@
|
|
|
2310
2316
|
pipeline = rawPipeline;
|
|
2311
2317
|
}
|
|
2312
2318
|
else {
|
|
2313
|
-
console.warn(spaceTrim.spaceTrim("\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 "));
|
|
2319
|
+
console.warn(spaceTrim.spaceTrim("\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 ")));
|
|
2314
2320
|
}
|
|
2315
2321
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2316
2322
|
function getContextForTemplate(// <- TODO: [🧠][🥜]
|
|
@@ -5438,7 +5444,7 @@
|
|
|
5438
5444
|
}
|
|
5439
5445
|
_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;
|
|
5440
5446
|
collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5441
|
-
var fileNames,
|
|
5447
|
+
var fileNames, collection, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
|
|
5442
5448
|
var e_1, _a;
|
|
5443
5449
|
return __generator(this, function (_b) {
|
|
5444
5450
|
switch (_b.label) {
|
|
@@ -5460,9 +5466,9 @@
|
|
|
5460
5466
|
}
|
|
5461
5467
|
return 0;
|
|
5462
5468
|
});
|
|
5463
|
-
|
|
5469
|
+
collection = new Map();
|
|
5464
5470
|
_loop_1 = function (fileName) {
|
|
5465
|
-
var sourceFile, pipeline, pipelineString, _c, _d, error_1, wrappedErrorMessage;
|
|
5471
|
+
var sourceFile, pipeline, pipelineString, _c, _d, existing, error_1, wrappedErrorMessage;
|
|
5466
5472
|
return __generator(this, function (_e) {
|
|
5467
5473
|
switch (_e.label) {
|
|
5468
5474
|
case 0:
|
|
@@ -5498,7 +5504,8 @@
|
|
|
5498
5504
|
case 7:
|
|
5499
5505
|
// ---
|
|
5500
5506
|
if (pipeline !== null) {
|
|
5501
|
-
|
|
5507
|
+
// TODO: [👠] DRY
|
|
5508
|
+
if (pipeline.pipelineUrl === undefined) {
|
|
5502
5509
|
if (isVerbose) {
|
|
5503
5510
|
console.info(colors__default["default"].red("Can not load pipeline from ".concat(fileName
|
|
5504
5511
|
.split('\\')
|
|
@@ -5506,16 +5513,30 @@
|
|
|
5506
5513
|
}
|
|
5507
5514
|
}
|
|
5508
5515
|
else {
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5516
|
+
// Note: [🐨] Pipeline is checked multiple times
|
|
5517
|
+
// TODO: Maybe once is enough BUT be sure to check it - better to check it multiple times than not at all
|
|
5518
|
+
validatePipeline(pipeline);
|
|
5519
|
+
if (
|
|
5520
|
+
// TODO: [🐽] comparePipelines(pipeline1,pipeline2): 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
|
|
5521
|
+
!collection.has(pipeline.pipelineUrl)) {
|
|
5522
|
+
if (isVerbose) {
|
|
5523
|
+
console.info(colors__default["default"].gray("Loaded pipeline ".concat(fileName.split('\\').join('/'), "\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060")));
|
|
5524
|
+
}
|
|
5525
|
+
// Note: [🦄] Pipeline with same url uniqueness will be double-checked automatically in SimplePipelineCollection
|
|
5526
|
+
collection.set(pipeline.pipelineUrl, pipeline);
|
|
5513
5527
|
}
|
|
5514
|
-
if (
|
|
5515
|
-
|
|
5528
|
+
else if (pipelineJsonToString(unpreparePipeline(pipeline)) ===
|
|
5529
|
+
pipelineJsonToString(unpreparePipeline(collection.get(pipeline.pipelineUrl)))) {
|
|
5530
|
+
if (isVerbose) {
|
|
5531
|
+
console.info(colors__default["default"].gray("Skipped pipeline ".concat(fileName
|
|
5532
|
+
.split('\\')
|
|
5533
|
+
.join('/'), " \u2013\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060 identical pipeline in the collection")));
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
else {
|
|
5537
|
+
existing = collection.get(pipeline.pipelineUrl);
|
|
5538
|
+
throw new ReferenceError(spaceTrim__default["default"]("\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 ")));
|
|
5516
5539
|
}
|
|
5517
|
-
// Note: [🦄] Pipeline with same url uniqueness will be checked automatically in SimplePipelineCollection
|
|
5518
|
-
pipelines.push(pipeline);
|
|
5519
5540
|
}
|
|
5520
5541
|
}
|
|
5521
5542
|
return [3 /*break*/, 9];
|
|
@@ -5524,7 +5545,7 @@
|
|
|
5524
5545
|
if (!(error_1 instanceof Error)) {
|
|
5525
5546
|
throw error_1;
|
|
5526
5547
|
}
|
|
5527
|
-
wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n
|
|
5548
|
+
wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n ".concat(error_1.name, " in pipeline ").concat(fileName.split('\\').join('/'), "\u2060:\n\n ").concat(block(error_1.message), "\n\n "); });
|
|
5528
5549
|
if (isCrashedOnError) {
|
|
5529
5550
|
throw new CollectionError(wrappedErrorMessage);
|
|
5530
5551
|
}
|
|
@@ -5561,7 +5582,7 @@
|
|
|
5561
5582
|
}
|
|
5562
5583
|
finally { if (e_1) throw e_1.error; }
|
|
5563
5584
|
return [7 /*endfinally*/];
|
|
5564
|
-
case 9: return [2 /*return*/,
|
|
5585
|
+
case 9: return [2 /*return*/, Array.from(collection.values())];
|
|
5565
5586
|
}
|
|
5566
5587
|
});
|
|
5567
5588
|
}); });
|