@promptbook/core 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 +1 -1
- package/umd/index.umd.js +49 -8
- package/umd/index.umd.js.map +1 -1
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 {
|
|
4
|
+
import { Subject } from 'rxjs';
|
|
5
5
|
import { randomBytes } from 'crypto';
|
|
6
6
|
import { forTime } from 'waitasecond';
|
|
7
7
|
import { parse, unparse } from 'papaparse';
|
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-8';
|
|
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
|
|
@@ -2079,21 +2079,41 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2079
2079
|
function createTask(options) {
|
|
2080
2080
|
const { taskType, taskProcessCallback } = options;
|
|
2081
2081
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2082
|
-
|
|
2082
|
+
let status = 'RUNNING';
|
|
2083
|
+
const createdAt = new Date();
|
|
2084
|
+
let updatedAt = createdAt;
|
|
2085
|
+
const errors = [];
|
|
2086
|
+
const warnings = [];
|
|
2087
|
+
const currentValue = {};
|
|
2088
|
+
const partialResultSubject = new Subject();
|
|
2089
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2083
2090
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2091
|
+
Object.assign(currentValue, newOngoingResult);
|
|
2084
2092
|
partialResultSubject.next(newOngoingResult);
|
|
2085
2093
|
});
|
|
2086
2094
|
finalResultPromise
|
|
2087
2095
|
.catch((error) => {
|
|
2096
|
+
errors.push(error);
|
|
2088
2097
|
partialResultSubject.error(error);
|
|
2089
2098
|
})
|
|
2090
|
-
.then((
|
|
2091
|
-
if (
|
|
2099
|
+
.then((executionResult) => {
|
|
2100
|
+
if (executionResult) {
|
|
2092
2101
|
try {
|
|
2093
|
-
|
|
2094
|
-
|
|
2102
|
+
updatedAt = new Date();
|
|
2103
|
+
errors.push(...executionResult.errors);
|
|
2104
|
+
warnings.push(...executionResult.warnings);
|
|
2105
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
2106
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2107
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2108
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2109
|
+
assertsTaskSuccessful(executionResult);
|
|
2110
|
+
status = 'FINISHED';
|
|
2111
|
+
Object.assign(currentValue, executionResult);
|
|
2112
|
+
partialResultSubject.next(executionResult);
|
|
2095
2113
|
}
|
|
2096
2114
|
catch (error) {
|
|
2115
|
+
status = 'ERROR';
|
|
2116
|
+
errors.push(error);
|
|
2097
2117
|
partialResultSubject.error(error);
|
|
2098
2118
|
}
|
|
2099
2119
|
}
|
|
@@ -2110,12 +2130,33 @@ function createTask(options) {
|
|
|
2110
2130
|
return {
|
|
2111
2131
|
taskType,
|
|
2112
2132
|
taskId,
|
|
2133
|
+
get status() {
|
|
2134
|
+
return status;
|
|
2135
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2136
|
+
},
|
|
2137
|
+
get createdAt() {
|
|
2138
|
+
return createdAt;
|
|
2139
|
+
// <- Note: [1]
|
|
2140
|
+
},
|
|
2141
|
+
get updatedAt() {
|
|
2142
|
+
return updatedAt;
|
|
2143
|
+
// <- Note: [1]
|
|
2144
|
+
},
|
|
2113
2145
|
asPromise,
|
|
2114
2146
|
asObservable() {
|
|
2115
2147
|
return partialResultSubject.asObservable();
|
|
2116
2148
|
},
|
|
2149
|
+
get errors() {
|
|
2150
|
+
return errors;
|
|
2151
|
+
// <- Note: [1]
|
|
2152
|
+
},
|
|
2153
|
+
get warnings() {
|
|
2154
|
+
return warnings;
|
|
2155
|
+
// <- Note: [1]
|
|
2156
|
+
},
|
|
2117
2157
|
get currentValue() {
|
|
2118
|
-
return
|
|
2158
|
+
return currentValue;
|
|
2159
|
+
// <- Note: [1]
|
|
2119
2160
|
},
|
|
2120
2161
|
};
|
|
2121
2162
|
}
|
|
@@ -3904,7 +3945,7 @@ async function executeAttempts(options) {
|
|
|
3904
3945
|
Last result:
|
|
3905
3946
|
${block($ongoingTaskResult.$resultString === null
|
|
3906
3947
|
? 'null'
|
|
3907
|
-
: $ongoingTaskResult.$resultString
|
|
3948
|
+
: spaceTrim$1($ongoingTaskResult.$resultString)
|
|
3908
3949
|
.split('\n')
|
|
3909
3950
|
.map((line) => `> ${line}`)
|
|
3910
3951
|
.join('\n'))}
|