@promptbook/documents 0.88.0-1 → 0.88.0-8
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 +50 -9
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/cli/cli-commands/common/handleActionErrors.d.ts +11 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +24 -0
- package/package.json +2 -2
- package/umd/index.umd.js +49 -8
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -8,7 +8,7 @@ import hexEncoder from 'crypto-js/enc-hex';
|
|
|
8
8
|
import { basename, join, dirname } from 'path';
|
|
9
9
|
import { format } from 'prettier';
|
|
10
10
|
import parserHtml from 'prettier/parser-html';
|
|
11
|
-
import {
|
|
11
|
+
import { Subject } from 'rxjs';
|
|
12
12
|
import { randomBytes } from 'crypto';
|
|
13
13
|
import sha256 from 'crypto-js/sha256';
|
|
14
14
|
import { lookup, extension } from 'mime-types';
|
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-8';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2464,21 +2464,41 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2464
2464
|
function createTask(options) {
|
|
2465
2465
|
const { taskType, taskProcessCallback } = options;
|
|
2466
2466
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2467
|
-
|
|
2467
|
+
let status = 'RUNNING';
|
|
2468
|
+
const createdAt = new Date();
|
|
2469
|
+
let updatedAt = createdAt;
|
|
2470
|
+
const errors = [];
|
|
2471
|
+
const warnings = [];
|
|
2472
|
+
const currentValue = {};
|
|
2473
|
+
const partialResultSubject = new Subject();
|
|
2474
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2468
2475
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2476
|
+
Object.assign(currentValue, newOngoingResult);
|
|
2469
2477
|
partialResultSubject.next(newOngoingResult);
|
|
2470
2478
|
});
|
|
2471
2479
|
finalResultPromise
|
|
2472
2480
|
.catch((error) => {
|
|
2481
|
+
errors.push(error);
|
|
2473
2482
|
partialResultSubject.error(error);
|
|
2474
2483
|
})
|
|
2475
|
-
.then((
|
|
2476
|
-
if (
|
|
2484
|
+
.then((executionResult) => {
|
|
2485
|
+
if (executionResult) {
|
|
2477
2486
|
try {
|
|
2478
|
-
|
|
2479
|
-
|
|
2487
|
+
updatedAt = new Date();
|
|
2488
|
+
errors.push(...executionResult.errors);
|
|
2489
|
+
warnings.push(...executionResult.warnings);
|
|
2490
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
2491
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2492
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2493
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2494
|
+
assertsTaskSuccessful(executionResult);
|
|
2495
|
+
status = 'FINISHED';
|
|
2496
|
+
Object.assign(currentValue, executionResult);
|
|
2497
|
+
partialResultSubject.next(executionResult);
|
|
2480
2498
|
}
|
|
2481
2499
|
catch (error) {
|
|
2500
|
+
status = 'ERROR';
|
|
2501
|
+
errors.push(error);
|
|
2482
2502
|
partialResultSubject.error(error);
|
|
2483
2503
|
}
|
|
2484
2504
|
}
|
|
@@ -2495,12 +2515,33 @@ function createTask(options) {
|
|
|
2495
2515
|
return {
|
|
2496
2516
|
taskType,
|
|
2497
2517
|
taskId,
|
|
2518
|
+
get status() {
|
|
2519
|
+
return status;
|
|
2520
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2521
|
+
},
|
|
2522
|
+
get createdAt() {
|
|
2523
|
+
return createdAt;
|
|
2524
|
+
// <- Note: [1]
|
|
2525
|
+
},
|
|
2526
|
+
get updatedAt() {
|
|
2527
|
+
return updatedAt;
|
|
2528
|
+
// <- Note: [1]
|
|
2529
|
+
},
|
|
2498
2530
|
asPromise,
|
|
2499
2531
|
asObservable() {
|
|
2500
2532
|
return partialResultSubject.asObservable();
|
|
2501
2533
|
},
|
|
2534
|
+
get errors() {
|
|
2535
|
+
return errors;
|
|
2536
|
+
// <- Note: [1]
|
|
2537
|
+
},
|
|
2538
|
+
get warnings() {
|
|
2539
|
+
return warnings;
|
|
2540
|
+
// <- Note: [1]
|
|
2541
|
+
},
|
|
2502
2542
|
get currentValue() {
|
|
2503
|
-
return
|
|
2543
|
+
return currentValue;
|
|
2544
|
+
// <- Note: [1]
|
|
2504
2545
|
},
|
|
2505
2546
|
};
|
|
2506
2547
|
}
|
|
@@ -4865,7 +4906,7 @@ async function executeAttempts(options) {
|
|
|
4865
4906
|
Last result:
|
|
4866
4907
|
${block($ongoingTaskResult.$resultString === null
|
|
4867
4908
|
? 'null'
|
|
4868
|
-
: $ongoingTaskResult.$resultString
|
|
4909
|
+
: spaceTrim($ongoingTaskResult.$resultString)
|
|
4869
4910
|
.split('\n')
|
|
4870
4911
|
.map((line) => `> ${line}`)
|
|
4871
4912
|
.join('\n'))}
|