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