@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.
package/esm/index.es.js
CHANGED
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
38
38
|
* @generated
|
39
39
|
* @see https://github.com/webgptorg/promptbook
|
40
40
|
*/
|
41
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
41
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-37';
|
42
42
|
/**
|
43
43
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
44
44
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
@@ -7171,7 +7171,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
7171
7171
|
* @private internal helper function
|
7172
7172
|
*/
|
7173
7173
|
function createTask(options) {
|
7174
|
-
const { taskType, taskProcessCallback } = options;
|
7174
|
+
const { taskType, taskProcessCallback, tldrProvider } = options;
|
7175
7175
|
let { title } = options;
|
7176
7176
|
// TODO: [🐙] DRY
|
7177
7177
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
@@ -7246,7 +7246,11 @@ function createTask(options) {
|
|
7246
7246
|
},
|
7247
7247
|
get tldr() {
|
7248
7248
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
7249
|
-
//
|
7249
|
+
// Use custom tldr provider if available
|
7250
|
+
if (tldrProvider) {
|
7251
|
+
return tldrProvider(createdAt, status, currentValue, errors, warnings);
|
7252
|
+
}
|
7253
|
+
// Fallback to default implementation
|
7250
7254
|
const cv = currentValue;
|
7251
7255
|
// If explicit percent is provided, use it
|
7252
7256
|
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;
|
@@ -10313,6 +10317,71 @@ function createPipelineExecutor(options) {
|
|
10313
10317
|
updateOngoingResult(newOngoingResult);
|
10314
10318
|
});
|
10315
10319
|
},
|
10320
|
+
tldrProvider(createdAt, status, currentValue, errors) {
|
10321
|
+
var _a;
|
10322
|
+
// Better progress estimation based on pipeline structure
|
10323
|
+
const cv = currentValue;
|
10324
|
+
// Handle finished/error states
|
10325
|
+
if (status === 'FINISHED') {
|
10326
|
+
return {
|
10327
|
+
percent: 1,
|
10328
|
+
message: 'Finished',
|
10329
|
+
};
|
10330
|
+
}
|
10331
|
+
if (status === 'ERROR') {
|
10332
|
+
const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
|
10333
|
+
return {
|
10334
|
+
percent: 0,
|
10335
|
+
message: errorMessage,
|
10336
|
+
};
|
10337
|
+
}
|
10338
|
+
// Calculate progress based on pipeline tasks
|
10339
|
+
const totalTasks = pipeline.tasks.length;
|
10340
|
+
let completedTasks = 0;
|
10341
|
+
let currentTaskName = '';
|
10342
|
+
// Check execution report for completed tasks
|
10343
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
10344
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
10345
|
+
// Count completed tasks by matching titles
|
10346
|
+
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
10347
|
+
completedTasks = completedTasksByTitle.length;
|
10348
|
+
// Find current task being executed (first task not yet completed)
|
10349
|
+
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
10350
|
+
if (remainingTasks.length > 0) {
|
10351
|
+
currentTaskName = remainingTasks[0].name;
|
10352
|
+
}
|
10353
|
+
}
|
10354
|
+
// Calculate progress percentage
|
10355
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
10356
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
10357
|
+
if (completedTasks < totalTasks) {
|
10358
|
+
const elapsedMs = new Date().getTime() - createdAt.getTime();
|
10359
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
10360
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
10361
|
+
// Add partial progress for current task
|
10362
|
+
percent += (1 / totalTasks) * timeProgress;
|
10363
|
+
}
|
10364
|
+
// Clamp to [0,1]
|
10365
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
10366
|
+
// Generate message
|
10367
|
+
let message = '';
|
10368
|
+
if (currentTaskName) {
|
10369
|
+
// Find the task to get its title
|
10370
|
+
const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
|
10371
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
10372
|
+
message = `Working on task ${taskTitle}`;
|
10373
|
+
}
|
10374
|
+
else if (completedTasks === 0) {
|
10375
|
+
message = 'Starting pipeline execution';
|
10376
|
+
}
|
10377
|
+
else {
|
10378
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
10379
|
+
}
|
10380
|
+
return {
|
10381
|
+
percent,
|
10382
|
+
message,
|
10383
|
+
};
|
10384
|
+
},
|
10316
10385
|
});
|
10317
10386
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
10318
10387
|
return pipelineExecutor;
|