@promptbook/pdf 0.84.0 โ 0.85.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/esm/index.es.js +213 -160
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +0 -2
- package/esm/typings/src/_packages/types.index.d.ts +14 -2
- package/esm/typings/src/_packages/utils.index.d.ts +0 -2
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +13 -0
- package/esm/typings/src/cli/cli-commands/start-server.d.ts +13 -0
- package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/execution/AbstractTaskResult.d.ts +25 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +71 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -5
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -15
- package/esm/typings/src/execution/PromptbookFetch.d.ts +8 -1
- package/esm/typings/src/execution/{assertsExecutionSuccessful.d.ts โ assertsTaskSuccessful.d.ts} +2 -3
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +0 -3
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -6
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +3 -6
- package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +2 -0
- package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +2 -2
- package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +2 -2
- package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +2 -2
- package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +2 -1
- package/esm/typings/src/utils/random/$randomToken.d.ts +13 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +2 -3
- package/package.json +4 -2
- package/umd/index.umd.js +215 -164
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Progress.d.ts +0 -10
- package/esm/typings/src/types/TaskProgress.d.ts +0 -43
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-html'), require('waitasecond'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-html', 'waitasecond', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-pdf"] = {}, global.promises, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.prettier, global.parserHtml, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
-
})(this, (function (exports, promises, spaceTrim, cryptoJs, hexEncoder, path, prettier, parserHtml, waitasecond, sha256, mimeTypes, papaparse) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('crypto'), require('waitasecond'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'waitasecond', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-pdf"] = {}, global.promises, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, spaceTrim, cryptoJs, hexEncoder, path, prettier, parserHtml, rxjs, crypto, waitasecond, sha256, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.84.0
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.84.0';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -390,7 +390,7 @@
|
|
|
390
390
|
*/
|
|
391
391
|
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
392
392
|
/**
|
|
393
|
-
* TODO: [
|
|
393
|
+
* TODO: [๐บ]
|
|
394
394
|
*/
|
|
395
395
|
|
|
396
396
|
/**
|
|
@@ -2242,6 +2242,58 @@
|
|
|
2242
2242
|
return PipelineExecutionError;
|
|
2243
2243
|
}(Error));
|
|
2244
2244
|
|
|
2245
|
+
/**
|
|
2246
|
+
* Determine if the pipeline is fully prepared
|
|
2247
|
+
*
|
|
2248
|
+
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
2249
|
+
*
|
|
2250
|
+
* @public exported from `@promptbook/core`
|
|
2251
|
+
*/
|
|
2252
|
+
function isPipelinePrepared(pipeline) {
|
|
2253
|
+
// Note: Ignoring `pipeline.preparations` @@@
|
|
2254
|
+
// Note: Ignoring `pipeline.knowledgePieces` @@@
|
|
2255
|
+
if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
|
|
2256
|
+
return false;
|
|
2257
|
+
}
|
|
2258
|
+
if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
|
|
2259
|
+
return false;
|
|
2260
|
+
}
|
|
2261
|
+
if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
|
|
2262
|
+
return false;
|
|
2263
|
+
}
|
|
2264
|
+
/*
|
|
2265
|
+
TODO: [๐ง ][๐ซ] `tasks` can not be determined if they are fully prepared SO ignoring them
|
|
2266
|
+
> if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
|
|
2267
|
+
> return false;
|
|
2268
|
+
> }
|
|
2269
|
+
*/
|
|
2270
|
+
return true;
|
|
2271
|
+
}
|
|
2272
|
+
/**
|
|
2273
|
+
* TODO: [๐][main] If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2274
|
+
* TODO: [๐ ] Maybe base this on `makeValidator`
|
|
2275
|
+
* TODO: [๐ง] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2276
|
+
* TODO: [๐งฟ] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2277
|
+
* - [๐] ? Is context in each task
|
|
2278
|
+
* - [โจ] Are examples prepared
|
|
2279
|
+
* - [โจ] Are tasks prepared
|
|
2280
|
+
*/
|
|
2281
|
+
|
|
2282
|
+
/**
|
|
2283
|
+
* Generates random token
|
|
2284
|
+
*
|
|
2285
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2286
|
+
*
|
|
2287
|
+
* @private internal helper function
|
|
2288
|
+
* @returns secure random token
|
|
2289
|
+
*/
|
|
2290
|
+
function $randomToken(randomness) {
|
|
2291
|
+
return crypto.randomBytes(randomness).toString('hex');
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2295
|
+
*/
|
|
2296
|
+
|
|
2245
2297
|
/**
|
|
2246
2298
|
* This error indicates problems parsing the format value
|
|
2247
2299
|
*
|
|
@@ -2427,9 +2479,9 @@
|
|
|
2427
2479
|
*
|
|
2428
2480
|
* @param executionResult - The partial result of the Promptbook execution
|
|
2429
2481
|
* @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2430
|
-
* @
|
|
2482
|
+
* @private internal helper function of `asPromise` method of `ExecutionTask`
|
|
2431
2483
|
*/
|
|
2432
|
-
function
|
|
2484
|
+
function assertsTaskSuccessful(executionResult) {
|
|
2433
2485
|
var e_1, _a;
|
|
2434
2486
|
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
|
|
2435
2487
|
try {
|
|
@@ -2464,121 +2516,54 @@
|
|
|
2464
2516
|
}
|
|
2465
2517
|
}
|
|
2466
2518
|
/**
|
|
2467
|
-
* TODO: [๐] This function should be removed OR changed OR be completely rewritten
|
|
2468
2519
|
* TODO: [๐ง ] Can this return type be better typed than void
|
|
2469
2520
|
*/
|
|
2470
2521
|
|
|
2471
2522
|
/**
|
|
2472
|
-
*
|
|
2473
|
-
*
|
|
2474
|
-
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
2475
|
-
*
|
|
2476
|
-
* @public exported from `@promptbook/core`
|
|
2477
|
-
*/
|
|
2478
|
-
function isPipelinePrepared(pipeline) {
|
|
2479
|
-
// Note: Ignoring `pipeline.preparations` @@@
|
|
2480
|
-
// Note: Ignoring `pipeline.knowledgePieces` @@@
|
|
2481
|
-
if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
|
|
2482
|
-
return false;
|
|
2483
|
-
}
|
|
2484
|
-
if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
|
|
2485
|
-
return false;
|
|
2486
|
-
}
|
|
2487
|
-
if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
|
|
2488
|
-
return false;
|
|
2489
|
-
}
|
|
2490
|
-
/*
|
|
2491
|
-
TODO: [๐ง ][๐ซ] `tasks` can not be determined if they are fully prepared SO ignoring them
|
|
2492
|
-
> if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
|
|
2493
|
-
> return false;
|
|
2494
|
-
> }
|
|
2495
|
-
*/
|
|
2496
|
-
return true;
|
|
2497
|
-
}
|
|
2498
|
-
/**
|
|
2499
|
-
* TODO: [๐][main] If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2500
|
-
* TODO: [๐ ] Maybe base this on `makeValidator`
|
|
2501
|
-
* TODO: [๐ง] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2502
|
-
* TODO: [๐งฟ] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2503
|
-
* - [๐] ? Is context in each task
|
|
2504
|
-
* - [โจ] Are examples prepared
|
|
2505
|
-
* - [โจ] Are tasks prepared
|
|
2506
|
-
*/
|
|
2507
|
-
|
|
2508
|
-
/**
|
|
2509
|
-
* Format either small or big number
|
|
2523
|
+
* Helper to create a new task
|
|
2510
2524
|
*
|
|
2511
|
-
* @
|
|
2525
|
+
* @private internal helper function
|
|
2512
2526
|
*/
|
|
2513
|
-
function
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
}
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
return
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2527
|
+
function createTask(options) {
|
|
2528
|
+
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2529
|
+
var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
|
|
2530
|
+
var resultSubject = new rxjs.BehaviorSubject({});
|
|
2531
|
+
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2532
|
+
resultSubject.next(newOngoingResult);
|
|
2533
|
+
});
|
|
2534
|
+
function asPromise(options) {
|
|
2535
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2536
|
+
var _a, isCrashedOnError, finalResult;
|
|
2537
|
+
return __generator(this, function (_b) {
|
|
2538
|
+
switch (_b.label) {
|
|
2539
|
+
case 0:
|
|
2540
|
+
_a = (options || {}).isCrashedOnError, isCrashedOnError = _a === void 0 ? true : _a;
|
|
2541
|
+
return [4 /*yield*/, finalResultPromise];
|
|
2542
|
+
case 1:
|
|
2543
|
+
finalResult = _b.sent();
|
|
2544
|
+
if (isCrashedOnError) {
|
|
2545
|
+
assertsTaskSuccessful(finalResult);
|
|
2546
|
+
}
|
|
2547
|
+
return [2 /*return*/, finalResult];
|
|
2548
|
+
}
|
|
2549
|
+
});
|
|
2550
|
+
});
|
|
2532
2551
|
}
|
|
2533
|
-
return
|
|
2552
|
+
return {
|
|
2553
|
+
taskType: taskType,
|
|
2554
|
+
taskId: taskId,
|
|
2555
|
+
asPromise: asPromise,
|
|
2556
|
+
asObservable: function () {
|
|
2557
|
+
return rxjs.concat(resultSubject.asObservable(), rxjs.from(asPromise({
|
|
2558
|
+
isCrashedOnError: true,
|
|
2559
|
+
})));
|
|
2560
|
+
},
|
|
2561
|
+
};
|
|
2534
2562
|
}
|
|
2535
|
-
|
|
2536
2563
|
/**
|
|
2537
|
-
*
|
|
2538
|
-
*
|
|
2539
|
-
*
|
|
2540
|
-
* Note: This function is not just calling `toString` method
|
|
2541
|
-
* It's more complex and can handle this conversion specifically for LLM models
|
|
2542
|
-
* See `VALUE_STRINGS`
|
|
2543
|
-
*
|
|
2544
|
-
* Note: There are 2 similar functions
|
|
2545
|
-
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
2546
|
-
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
2547
|
-
*
|
|
2548
|
-
* @public exported from `@promptbook/utils`
|
|
2564
|
+
* TODO: Maybe allow to terminate the task and add getter `isFinished` or `status`
|
|
2565
|
+
* TODO: [๐] Split into more files and make `PrepareTask` & `RemoteTask` + split the function
|
|
2549
2566
|
*/
|
|
2550
|
-
function valueToString(value) {
|
|
2551
|
-
try {
|
|
2552
|
-
if (value === '') {
|
|
2553
|
-
return VALUE_STRINGS.empty;
|
|
2554
|
-
}
|
|
2555
|
-
else if (value === null) {
|
|
2556
|
-
return VALUE_STRINGS.null;
|
|
2557
|
-
}
|
|
2558
|
-
else if (value === undefined) {
|
|
2559
|
-
return VALUE_STRINGS.undefined;
|
|
2560
|
-
}
|
|
2561
|
-
else if (typeof value === 'string') {
|
|
2562
|
-
return value;
|
|
2563
|
-
}
|
|
2564
|
-
else if (typeof value === 'number') {
|
|
2565
|
-
return numberToString(value);
|
|
2566
|
-
}
|
|
2567
|
-
else if (value instanceof Date) {
|
|
2568
|
-
return value.toISOString();
|
|
2569
|
-
}
|
|
2570
|
-
else {
|
|
2571
|
-
return JSON.stringify(value);
|
|
2572
|
-
}
|
|
2573
|
-
}
|
|
2574
|
-
catch (error) {
|
|
2575
|
-
if (!(error instanceof Error)) {
|
|
2576
|
-
throw error;
|
|
2577
|
-
}
|
|
2578
|
-
console.error(error);
|
|
2579
|
-
return VALUE_STRINGS.unserializable;
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
2567
|
|
|
2583
2568
|
/**
|
|
2584
2569
|
* Serializes an error into a [๐] JSON-serializable object
|
|
@@ -3242,10 +3227,9 @@
|
|
|
3242
3227
|
return modelName;
|
|
3243
3228
|
})
|
|
3244
3229
|
.join(',');
|
|
3245
|
-
return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription })];
|
|
3230
|
+
return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription }).asPromise()];
|
|
3246
3231
|
case 3:
|
|
3247
3232
|
result = _d.sent();
|
|
3248
|
-
assertsExecutionSuccessful(result);
|
|
3249
3233
|
outputParameters = result.outputParameters;
|
|
3250
3234
|
modelRequirementsRaw = outputParameters.modelRequirements;
|
|
3251
3235
|
modelRequirements = JSON.parse(modelRequirementsRaw);
|
|
@@ -4043,10 +4027,9 @@
|
|
|
4043
4027
|
var content = _a.content;
|
|
4044
4028
|
return content;
|
|
4045
4029
|
}).join('\n\n'),
|
|
4046
|
-
})];
|
|
4030
|
+
}).asPromise()];
|
|
4047
4031
|
case 2:
|
|
4048
4032
|
result = _e.sent();
|
|
4049
|
-
assertsExecutionSuccessful(result);
|
|
4050
4033
|
outputParameters = result.outputParameters;
|
|
4051
4034
|
titleRaw = outputParameters.title;
|
|
4052
4035
|
if (isVerbose) {
|
|
@@ -4118,6 +4101,81 @@
|
|
|
4118
4101
|
* @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
|
|
4119
4102
|
*/
|
|
4120
4103
|
|
|
4104
|
+
/**
|
|
4105
|
+
* Format either small or big number
|
|
4106
|
+
*
|
|
4107
|
+
* @public exported from `@promptbook/utils`
|
|
4108
|
+
*/
|
|
4109
|
+
function numberToString(value) {
|
|
4110
|
+
if (value === 0) {
|
|
4111
|
+
return '0';
|
|
4112
|
+
}
|
|
4113
|
+
else if (Number.isNaN(value)) {
|
|
4114
|
+
return VALUE_STRINGS.nan;
|
|
4115
|
+
}
|
|
4116
|
+
else if (value === Infinity) {
|
|
4117
|
+
return VALUE_STRINGS.infinity;
|
|
4118
|
+
}
|
|
4119
|
+
else if (value === -Infinity) {
|
|
4120
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
4121
|
+
}
|
|
4122
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
4123
|
+
var factor = Math.pow(10, exponent);
|
|
4124
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
4125
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
4126
|
+
return valueRounded.toFixed(exponent);
|
|
4127
|
+
}
|
|
4128
|
+
}
|
|
4129
|
+
return value.toString();
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
/**
|
|
4133
|
+
* Function `valueToString` will convert the given value to string
|
|
4134
|
+
* This is useful and used in the `templateParameters` function
|
|
4135
|
+
*
|
|
4136
|
+
* Note: This function is not just calling `toString` method
|
|
4137
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
4138
|
+
* See `VALUE_STRINGS`
|
|
4139
|
+
*
|
|
4140
|
+
* Note: There are 2 similar functions
|
|
4141
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
4142
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
4143
|
+
*
|
|
4144
|
+
* @public exported from `@promptbook/utils`
|
|
4145
|
+
*/
|
|
4146
|
+
function valueToString(value) {
|
|
4147
|
+
try {
|
|
4148
|
+
if (value === '') {
|
|
4149
|
+
return VALUE_STRINGS.empty;
|
|
4150
|
+
}
|
|
4151
|
+
else if (value === null) {
|
|
4152
|
+
return VALUE_STRINGS.null;
|
|
4153
|
+
}
|
|
4154
|
+
else if (value === undefined) {
|
|
4155
|
+
return VALUE_STRINGS.undefined;
|
|
4156
|
+
}
|
|
4157
|
+
else if (typeof value === 'string') {
|
|
4158
|
+
return value;
|
|
4159
|
+
}
|
|
4160
|
+
else if (typeof value === 'number') {
|
|
4161
|
+
return numberToString(value);
|
|
4162
|
+
}
|
|
4163
|
+
else if (value instanceof Date) {
|
|
4164
|
+
return value.toISOString();
|
|
4165
|
+
}
|
|
4166
|
+
else {
|
|
4167
|
+
return JSON.stringify(value);
|
|
4168
|
+
}
|
|
4169
|
+
}
|
|
4170
|
+
catch (error) {
|
|
4171
|
+
if (!(error instanceof Error)) {
|
|
4172
|
+
throw error;
|
|
4173
|
+
}
|
|
4174
|
+
console.error(error);
|
|
4175
|
+
return VALUE_STRINGS.unserializable;
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
|
|
4121
4179
|
/**
|
|
4122
4180
|
* Parses the given script and returns the list of all used variables that are not defined in the script
|
|
4123
4181
|
*
|
|
@@ -5562,27 +5620,20 @@
|
|
|
5562
5620
|
*/
|
|
5563
5621
|
function executeTask(options) {
|
|
5564
5622
|
return __awaiter(this, void 0, void 0, function () {
|
|
5565
|
-
var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed,
|
|
5566
|
-
var e_1,
|
|
5567
|
-
return __generator(this, function (
|
|
5568
|
-
switch (
|
|
5623
|
+
var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_1, _d, _e, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
|
|
5624
|
+
var _f, e_1, _g, _h, _j;
|
|
5625
|
+
return __generator(this, function (_k) {
|
|
5626
|
+
switch (_k.label) {
|
|
5569
5627
|
case 0:
|
|
5570
5628
|
currentTask = options.currentTask, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts, maxParallelCount = options.maxParallelCount, csvSettings = options.csvSettings, isVerbose = options.isVerbose, rootDirname = options.rootDirname, cacheDirname = options.cacheDirname, intermediateFilesStrategy = options.intermediateFilesStrategy, isAutoInstalled = options.isAutoInstalled, isNotPreparedWarningSupressed = options.isNotPreparedWarningSupressed;
|
|
5571
|
-
name = "pipeline-executor-frame-".concat(currentTask.name);
|
|
5572
|
-
title = currentTask.title;
|
|
5573
5629
|
priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5574
5630
|
return [4 /*yield*/, onProgress({
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
isDone: false,
|
|
5579
|
-
taskType: currentTask.taskType,
|
|
5580
|
-
parameterName: currentTask.resultingParameterName,
|
|
5581
|
-
parameterValue: null,
|
|
5582
|
-
// <- [๐ธ]
|
|
5631
|
+
outputParameters: (_f = {},
|
|
5632
|
+
_f[currentTask.resultingParameterName] = '',
|
|
5633
|
+
_f),
|
|
5583
5634
|
})];
|
|
5584
5635
|
case 1:
|
|
5585
|
-
|
|
5636
|
+
_k.sent();
|
|
5586
5637
|
usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
5587
5638
|
dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
5588
5639
|
// TODO: [๐ฉ๐พโ๐คโ๐ฉ๐ป] Use here `mapAvailableToExpectedParameters`
|
|
@@ -5601,7 +5652,7 @@
|
|
|
5601
5652
|
pipelineIdentification: pipelineIdentification,
|
|
5602
5653
|
})];
|
|
5603
5654
|
case 2:
|
|
5604
|
-
definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(
|
|
5655
|
+
definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_k.sent())])), parametersToPass])]);
|
|
5605
5656
|
definedParameterNames = new Set(Object.keys(definedParameters));
|
|
5606
5657
|
parameters = {};
|
|
5607
5658
|
_loop_1 = function (parameterName) {
|
|
@@ -5629,7 +5680,7 @@
|
|
|
5629
5680
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5630
5681
|
finally {
|
|
5631
5682
|
try {
|
|
5632
|
-
if (_e && !_e.done && (
|
|
5683
|
+
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
5633
5684
|
}
|
|
5634
5685
|
finally { if (e_1) throw e_1.error; }
|
|
5635
5686
|
}
|
|
@@ -5660,24 +5711,19 @@
|
|
|
5660
5711
|
isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
|
|
5661
5712
|
})];
|
|
5662
5713
|
case 3:
|
|
5663
|
-
resultString =
|
|
5714
|
+
resultString = _k.sent();
|
|
5664
5715
|
return [4 /*yield*/, onProgress({
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
isDone: true,
|
|
5669
|
-
taskType: currentTask.taskType,
|
|
5670
|
-
parameterName: currentTask.resultingParameterName,
|
|
5671
|
-
parameterValue: resultString,
|
|
5672
|
-
// <- [๐ธ]
|
|
5716
|
+
outputParameters: (_h = {},
|
|
5717
|
+
_h[currentTask.resultingParameterName] = resultString,
|
|
5718
|
+
_h),
|
|
5673
5719
|
})];
|
|
5674
5720
|
case 4:
|
|
5675
|
-
|
|
5676
|
-
return [2 /*return*/, Object.freeze((
|
|
5677
|
-
|
|
5721
|
+
_k.sent();
|
|
5722
|
+
return [2 /*return*/, Object.freeze((_j = {},
|
|
5723
|
+
_j[currentTask.resultingParameterName] =
|
|
5678
5724
|
// <- Note: [๐ฉโ๐ฉโ๐ง] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5679
5725
|
resultString,
|
|
5680
|
-
|
|
5726
|
+
_j))];
|
|
5681
5727
|
}
|
|
5682
5728
|
});
|
|
5683
5729
|
});
|
|
@@ -5685,9 +5731,6 @@
|
|
|
5685
5731
|
/**
|
|
5686
5732
|
* TODO: [๐คนโโ๏ธ]
|
|
5687
5733
|
*/
|
|
5688
|
-
/**
|
|
5689
|
-
* TODO: [๐] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
5690
|
-
*/
|
|
5691
5734
|
|
|
5692
5735
|
/**
|
|
5693
5736
|
* @@@
|
|
@@ -5949,15 +5992,15 @@
|
|
|
5949
5992
|
return [3 /*break*/, 4];
|
|
5950
5993
|
case 3:
|
|
5951
5994
|
unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
|
|
5952
|
-
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (
|
|
5995
|
+
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (newOngoingResult) {
|
|
5953
5996
|
if (isReturned) {
|
|
5954
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(
|
|
5997
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(newOngoingResult, null, 4)
|
|
5955
5998
|
.split('\n')
|
|
5956
5999
|
.map(function (line) { return "> ".concat(line); })
|
|
5957
6000
|
.join('\n')), "\n "); }));
|
|
5958
6001
|
}
|
|
5959
6002
|
if (onProgress) {
|
|
5960
|
-
onProgress(
|
|
6003
|
+
onProgress(newOngoingResult);
|
|
5961
6004
|
}
|
|
5962
6005
|
}, $executionReport: executionReport, pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
|
|
5963
6006
|
.then(function (newParametersToPass) {
|
|
@@ -6060,9 +6103,6 @@
|
|
|
6060
6103
|
});
|
|
6061
6104
|
});
|
|
6062
6105
|
}
|
|
6063
|
-
/**
|
|
6064
|
-
* TODO: [๐] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
6065
|
-
*/
|
|
6066
6106
|
|
|
6067
6107
|
/**
|
|
6068
6108
|
* Creates executor function from pipeline and execution tools.
|
|
@@ -6094,7 +6134,7 @@
|
|
|
6094
6134
|
console.warn(spaceTrim.spaceTrim(function (block) { return "\n Pipeline is not prepared\n\n ".concat(block(pipelineIdentification), "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "); }));
|
|
6095
6135
|
}
|
|
6096
6136
|
var runCount = 0;
|
|
6097
|
-
var
|
|
6137
|
+
var pipelineExecutorWithCallback = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
6098
6138
|
return __generator(this, function (_a) {
|
|
6099
6139
|
runCount++;
|
|
6100
6140
|
return [2 /*return*/, /* not await */ executePipeline({
|
|
@@ -6119,11 +6159,23 @@
|
|
|
6119
6159
|
})];
|
|
6120
6160
|
});
|
|
6121
6161
|
}); };
|
|
6162
|
+
var pipelineExecutor = function (inputParameters) {
|
|
6163
|
+
return createTask({
|
|
6164
|
+
taskType: 'EXECUTION',
|
|
6165
|
+
taskProcessCallback: function (updateOngoingResult) {
|
|
6166
|
+
var _this = this;
|
|
6167
|
+
return pipelineExecutorWithCallback(inputParameters, function (newOngoingResult) { return __awaiter(_this, void 0, void 0, function () {
|
|
6168
|
+
return __generator(this, function (_a) {
|
|
6169
|
+
updateOngoingResult(newOngoingResult);
|
|
6170
|
+
return [2 /*return*/];
|
|
6171
|
+
});
|
|
6172
|
+
}); });
|
|
6173
|
+
},
|
|
6174
|
+
});
|
|
6175
|
+
};
|
|
6176
|
+
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6122
6177
|
return pipelineExecutor;
|
|
6123
6178
|
}
|
|
6124
|
-
/**
|
|
6125
|
-
* TODO: [๐] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
6126
|
-
*/
|
|
6127
6179
|
|
|
6128
6180
|
/**
|
|
6129
6181
|
* Metadata of the scraper
|
|
@@ -6225,10 +6277,9 @@
|
|
|
6225
6277
|
return [4 /*yield*/, source.asText()];
|
|
6226
6278
|
case 4:
|
|
6227
6279
|
knowledgeContent = _k.sent();
|
|
6228
|
-
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent })];
|
|
6280
|
+
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent }).asPromise()];
|
|
6229
6281
|
case 5:
|
|
6230
6282
|
result = _k.sent();
|
|
6231
|
-
assertsExecutionSuccessful(result);
|
|
6232
6283
|
outputParameters = result.outputParameters;
|
|
6233
6284
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
6234
6285
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6251,13 +6302,13 @@
|
|
|
6251
6302
|
_c.label = 1;
|
|
6252
6303
|
case 1:
|
|
6253
6304
|
_c.trys.push([1, 7, , 8]);
|
|
6254
|
-
return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent })];
|
|
6305
|
+
return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent }).asPromise()];
|
|
6255
6306
|
case 2:
|
|
6256
6307
|
titleResult = _c.sent();
|
|
6257
6308
|
_a = titleResult.outputParameters.title, titleRaw = _a === void 0 ? 'Untitled' : _a;
|
|
6258
6309
|
title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6259
6310
|
name = titleToName(title);
|
|
6260
|
-
return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent })];
|
|
6311
|
+
return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent }).asPromise()];
|
|
6261
6312
|
case 3:
|
|
6262
6313
|
keywordsResult = _c.sent();
|
|
6263
6314
|
_b = keywordsResult.outputParameters.keywords, keywordsRaw = _b === void 0 ? '' : _b;
|