@promptbook/core 0.85.0-3 → 0.85.0-5
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
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { format } from 'prettier';
|
|
3
3
|
import parserHtml from 'prettier/parser-html';
|
|
4
|
-
import { BehaviorSubject
|
|
4
|
+
import { BehaviorSubject } from 'rxjs';
|
|
5
5
|
import { randomBytes } from 'crypto';
|
|
6
6
|
import { forTime } from 'waitasecond';
|
|
7
7
|
import { unparse, parse } from 'papaparse';
|
|
8
8
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
9
9
|
import sha256 from 'crypto-js/sha256';
|
|
10
|
-
import { basename, join, dirname } from '
|
|
10
|
+
import { basename, join, dirname } from 'path';
|
|
11
11
|
import { SHA256 } from 'crypto-js';
|
|
12
12
|
import { lookup, extension } from 'mime-types';
|
|
13
13
|
import moment from 'moment';
|
|
@@ -27,7 +27,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-
|
|
30
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-4';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2374,11 +2374,29 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2374
2374
|
*/
|
|
2375
2375
|
function createTask(options) {
|
|
2376
2376
|
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2377
|
-
var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(
|
|
2377
|
+
var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: !!! To global config + Use Base58 to avoid simmilar char conflicts */));
|
|
2378
2378
|
var partialResultSubject = new BehaviorSubject({});
|
|
2379
2379
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2380
2380
|
partialResultSubject.next(newOngoingResult);
|
|
2381
2381
|
});
|
|
2382
|
+
finalResultPromise
|
|
2383
|
+
.catch(function (error) {
|
|
2384
|
+
// console.error('!!!!! Task failed:', error);
|
|
2385
|
+
partialResultSubject.error(error);
|
|
2386
|
+
})
|
|
2387
|
+
.then(function (value) {
|
|
2388
|
+
// console.error('!!!!! Task finished:', value);
|
|
2389
|
+
if (value) {
|
|
2390
|
+
try {
|
|
2391
|
+
assertsTaskSuccessful(value);
|
|
2392
|
+
partialResultSubject.next(value);
|
|
2393
|
+
}
|
|
2394
|
+
catch (error) {
|
|
2395
|
+
partialResultSubject.error(error);
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
partialResultSubject.complete();
|
|
2399
|
+
});
|
|
2382
2400
|
function asPromise(options) {
|
|
2383
2401
|
return __awaiter(this, void 0, void 0, function () {
|
|
2384
2402
|
var _a, isCrashedOnError, finalResult;
|
|
@@ -2389,7 +2407,9 @@ function createTask(options) {
|
|
|
2389
2407
|
return [4 /*yield*/, finalResultPromise];
|
|
2390
2408
|
case 1:
|
|
2391
2409
|
finalResult = _b.sent();
|
|
2410
|
+
console.error('!!!!! finalResult:', finalResult);
|
|
2392
2411
|
if (isCrashedOnError) {
|
|
2412
|
+
console.error('!!!!! isCrashedOnError:', finalResult);
|
|
2393
2413
|
assertsTaskSuccessful(finalResult);
|
|
2394
2414
|
}
|
|
2395
2415
|
return [2 /*return*/, finalResult];
|
|
@@ -2402,9 +2422,10 @@ function createTask(options) {
|
|
|
2402
2422
|
taskId: taskId,
|
|
2403
2423
|
asPromise: asPromise,
|
|
2404
2424
|
asObservable: function () {
|
|
2405
|
-
return
|
|
2406
|
-
|
|
2407
|
-
|
|
2425
|
+
return partialResultSubject.asObservable();
|
|
2426
|
+
},
|
|
2427
|
+
get currentValue() {
|
|
2428
|
+
return partialResultSubject.value;
|
|
2408
2429
|
},
|
|
2409
2430
|
};
|
|
2410
2431
|
}
|