@promptbook/wizard 0.100.0-36 → 0.100.0-37
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.
@@ -29,6 +29,19 @@ type CreateTaskOptions<TTaskResult extends AbstractTaskResult> = {
|
|
29
29
|
*/
|
30
30
|
readonly title?: AbstractTask<TTaskResult>['title'];
|
31
31
|
}) => void): Promise<TTaskResult>;
|
32
|
+
/**
|
33
|
+
* Optional callback to provide custom tldr information
|
34
|
+
* @param createdAt When the task was created
|
35
|
+
* @param status Current task status
|
36
|
+
* @param currentValue Current partial result
|
37
|
+
* @param errors Current errors
|
38
|
+
* @param warnings Current warnings
|
39
|
+
* @returns Custom tldr information
|
40
|
+
*/
|
41
|
+
tldrProvider?(createdAt: Date, status: task_status, currentValue: PartialDeep<TTaskResult>, errors: Array<Error>, warnings: Array<Error>): {
|
42
|
+
readonly percent: number_percent;
|
43
|
+
readonly message: string;
|
44
|
+
};
|
32
45
|
};
|
33
46
|
/**
|
34
47
|
* Helper to create a new task
|
@@ -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-36`).
|
19
19
|
*
|
20
20
|
* @generated
|
21
21
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@promptbook/wizard",
|
3
|
-
"version": "0.100.0-
|
3
|
+
"version": "0.100.0-37",
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
5
5
|
"private": false,
|
6
6
|
"sideEffects": false,
|
@@ -95,7 +95,7 @@
|
|
95
95
|
"module": "./esm/index.es.js",
|
96
96
|
"typings": "./esm/typings/src/_packages/wizard.index.d.ts",
|
97
97
|
"peerDependencies": {
|
98
|
-
"@promptbook/core": "0.100.0-
|
98
|
+
"@promptbook/core": "0.100.0-37"
|
99
99
|
},
|
100
100
|
"dependencies": {
|
101
101
|
"@ai-sdk/deepseek": "0.1.6",
|
package/umd/index.umd.js
CHANGED
@@ -49,7 +49,7 @@
|
|
49
49
|
* @generated
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
51
51
|
*/
|
52
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
52
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-37';
|
53
53
|
/**
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
55
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
@@ -7182,7 +7182,7 @@
|
|
7182
7182
|
* @private internal helper function
|
7183
7183
|
*/
|
7184
7184
|
function createTask(options) {
|
7185
|
-
const { taskType, taskProcessCallback } = options;
|
7185
|
+
const { taskType, taskProcessCallback, tldrProvider } = options;
|
7186
7186
|
let { title } = options;
|
7187
7187
|
// TODO: [🐙] DRY
|
7188
7188
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
@@ -7257,7 +7257,11 @@
|
|
7257
7257
|
},
|
7258
7258
|
get tldr() {
|
7259
7259
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
7260
|
-
//
|
7260
|
+
// Use custom tldr provider if available
|
7261
|
+
if (tldrProvider) {
|
7262
|
+
return tldrProvider(createdAt, status, currentValue, errors, warnings);
|
7263
|
+
}
|
7264
|
+
// Fallback to default implementation
|
7261
7265
|
const cv = currentValue;
|
7262
7266
|
// If explicit percent is provided, use it
|
7263
7267
|
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;
|
@@ -10324,6 +10328,71 @@
|
|
10324
10328
|
updateOngoingResult(newOngoingResult);
|
10325
10329
|
});
|
10326
10330
|
},
|
10331
|
+
tldrProvider(createdAt, status, currentValue, errors) {
|
10332
|
+
var _a;
|
10333
|
+
// Better progress estimation based on pipeline structure
|
10334
|
+
const cv = currentValue;
|
10335
|
+
// Handle finished/error states
|
10336
|
+
if (status === 'FINISHED') {
|
10337
|
+
return {
|
10338
|
+
percent: 1,
|
10339
|
+
message: 'Finished',
|
10340
|
+
};
|
10341
|
+
}
|
10342
|
+
if (status === 'ERROR') {
|
10343
|
+
const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
|
10344
|
+
return {
|
10345
|
+
percent: 0,
|
10346
|
+
message: errorMessage,
|
10347
|
+
};
|
10348
|
+
}
|
10349
|
+
// Calculate progress based on pipeline tasks
|
10350
|
+
const totalTasks = pipeline.tasks.length;
|
10351
|
+
let completedTasks = 0;
|
10352
|
+
let currentTaskName = '';
|
10353
|
+
// Check execution report for completed tasks
|
10354
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
10355
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
10356
|
+
// Count completed tasks by matching titles
|
10357
|
+
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
10358
|
+
completedTasks = completedTasksByTitle.length;
|
10359
|
+
// Find current task being executed (first task not yet completed)
|
10360
|
+
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
10361
|
+
if (remainingTasks.length > 0) {
|
10362
|
+
currentTaskName = remainingTasks[0].name;
|
10363
|
+
}
|
10364
|
+
}
|
10365
|
+
// Calculate progress percentage
|
10366
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
10367
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
10368
|
+
if (completedTasks < totalTasks) {
|
10369
|
+
const elapsedMs = new Date().getTime() - createdAt.getTime();
|
10370
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
10371
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
10372
|
+
// Add partial progress for current task
|
10373
|
+
percent += (1 / totalTasks) * timeProgress;
|
10374
|
+
}
|
10375
|
+
// Clamp to [0,1]
|
10376
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
10377
|
+
// Generate message
|
10378
|
+
let message = '';
|
10379
|
+
if (currentTaskName) {
|
10380
|
+
// Find the task to get its title
|
10381
|
+
const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
|
10382
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
10383
|
+
message = `Working on task ${taskTitle}`;
|
10384
|
+
}
|
10385
|
+
else if (completedTasks === 0) {
|
10386
|
+
message = 'Starting pipeline execution';
|
10387
|
+
}
|
10388
|
+
else {
|
10389
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
10390
|
+
}
|
10391
|
+
return {
|
10392
|
+
percent,
|
10393
|
+
message,
|
10394
|
+
};
|
10395
|
+
},
|
10327
10396
|
});
|
10328
10397
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
10329
10398
|
return pipelineExecutor;
|