@promptbook/markdown-utils 0.100.0-33 → 0.100.0-34
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
2
|
import { PartialDeep } from 'type-fest';
|
|
3
|
+
import type { number_percent } from '../types/typeAliases';
|
|
3
4
|
import type { task_id } from '../types/typeAliases';
|
|
4
5
|
import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
5
6
|
import type { string_promptbook_version } from '../version';
|
|
@@ -80,6 +81,19 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
|
|
|
80
81
|
* Status of the task
|
|
81
82
|
*/
|
|
82
83
|
readonly status: task_status;
|
|
84
|
+
/**
|
|
85
|
+
* Short summary of the task status for quick overview in the UI
|
|
86
|
+
*/
|
|
87
|
+
readonly tldr: {
|
|
88
|
+
/**
|
|
89
|
+
* Progress in percentage from 0 to 1 (100%) that can be used to display a progress bar
|
|
90
|
+
*/
|
|
91
|
+
readonly percent: number_percent;
|
|
92
|
+
/**
|
|
93
|
+
* Short summary message of the task status that can be displayed in the UI
|
|
94
|
+
*/
|
|
95
|
+
readonly message: string;
|
|
96
|
+
};
|
|
83
97
|
/**
|
|
84
98
|
* Date when the task was created
|
|
85
99
|
*/
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.100.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.100.0-33`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-34';
|
|
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
|
|
@@ -2269,6 +2269,55 @@
|
|
|
2269
2269
|
return status;
|
|
2270
2270
|
// <- Note: [1] --||--
|
|
2271
2271
|
},
|
|
2272
|
+
get tldr() {
|
|
2273
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2274
|
+
// Derive a short progress summary from currentValue, status and any errors/warnings.
|
|
2275
|
+
const cv = currentValue;
|
|
2276
|
+
// Try several common places where a percent might be stored on the partial result
|
|
2277
|
+
let percentRaw = (_f = (_d = (_b = (_a = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : (_c = cv === null || cv === void 0 ? void 0 : cv.usage) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : (_e = cv === null || cv === void 0 ? void 0 : cv.progress) === null || _e === void 0 ? void 0 : _e.percent) !== null && _f !== void 0 ? _f : cv === null || cv === void 0 ? void 0 : cv.percent;
|
|
2278
|
+
// If we didn't find a numeric percent, infer from status
|
|
2279
|
+
if (typeof percentRaw !== 'number') {
|
|
2280
|
+
if (status === 'FINISHED') {
|
|
2281
|
+
percentRaw = 1;
|
|
2282
|
+
}
|
|
2283
|
+
else if (status === 'ERROR') {
|
|
2284
|
+
percentRaw = 0;
|
|
2285
|
+
}
|
|
2286
|
+
else {
|
|
2287
|
+
percentRaw = 0;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
// Clamp to [0,1]
|
|
2291
|
+
let percent = Number(percentRaw) || 0;
|
|
2292
|
+
if (percent < 0)
|
|
2293
|
+
percent = 0;
|
|
2294
|
+
if (percent > 1)
|
|
2295
|
+
percent = 1;
|
|
2296
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2297
|
+
const messageFromResult = (_k = (_j = (_h = (_g = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _g === void 0 ? void 0 : _g.message) !== null && _h !== void 0 ? _h : cv === null || cv === void 0 ? void 0 : cv.message) !== null && _j !== void 0 ? _j : cv === null || cv === void 0 ? void 0 : cv.summary) !== null && _k !== void 0 ? _k : cv === null || cv === void 0 ? void 0 : cv.statusMessage;
|
|
2298
|
+
let message = messageFromResult;
|
|
2299
|
+
if (!message) {
|
|
2300
|
+
if (errors.length) {
|
|
2301
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2302
|
+
}
|
|
2303
|
+
else if (warnings.length) {
|
|
2304
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2305
|
+
}
|
|
2306
|
+
else if (status === 'FINISHED') {
|
|
2307
|
+
message = 'Finished';
|
|
2308
|
+
}
|
|
2309
|
+
else if (status === 'ERROR') {
|
|
2310
|
+
message = 'Error';
|
|
2311
|
+
}
|
|
2312
|
+
else {
|
|
2313
|
+
message = 'Running';
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
return {
|
|
2317
|
+
percent: percent,
|
|
2318
|
+
message,
|
|
2319
|
+
};
|
|
2320
|
+
},
|
|
2272
2321
|
get createdAt() {
|
|
2273
2322
|
return createdAt;
|
|
2274
2323
|
// <- Note: [1] --||--
|