@promptbook/core 0.85.0-0 → 0.85.0-10

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,7 +1,7 @@
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, concat, from } from 'rxjs';
4
+ import { BehaviorSubject } from 'rxjs';
5
5
  import { randomBytes } from 'crypto';
6
6
  import { forTime } from 'waitasecond';
7
7
  import { unparse, parse } from 'papaparse';
@@ -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.84.0';
30
+ var PROMPTBOOK_ENGINE_VERSION = '0.85.0-9';
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,10 +2374,26 @@ 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(256 /* <- TODO: !!! To global config */));
2378
- var resultSubject = new BehaviorSubject({});
2377
+ var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */));
2378
+ var partialResultSubject = new BehaviorSubject({});
2379
2379
  var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
2380
- resultSubject.next(newOngoingResult);
2380
+ partialResultSubject.next(newOngoingResult);
2381
+ });
2382
+ finalResultPromise
2383
+ .catch(function (error) {
2384
+ partialResultSubject.error(error);
2385
+ })
2386
+ .then(function (value) {
2387
+ if (value) {
2388
+ try {
2389
+ assertsTaskSuccessful(value);
2390
+ partialResultSubject.next(value);
2391
+ }
2392
+ catch (error) {
2393
+ partialResultSubject.error(error);
2394
+ }
2395
+ }
2396
+ partialResultSubject.complete();
2381
2397
  });
2382
2398
  function asPromise(options) {
2383
2399
  return __awaiter(this, void 0, void 0, function () {
@@ -2402,9 +2418,10 @@ function createTask(options) {
2402
2418
  taskId: taskId,
2403
2419
  asPromise: asPromise,
2404
2420
  asObservable: function () {
2405
- return concat(resultSubject.asObservable(), from(asPromise({
2406
- isCrashedOnError: true,
2407
- })));
2421
+ return partialResultSubject.asObservable();
2422
+ },
2423
+ get currentValue() {
2424
+ return partialResultSubject.value;
2408
2425
  },
2409
2426
  };
2410
2427
  }