@promptbook/legacy-documents 0.100.0-43 → 0.100.0-45
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 +59 -71
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +10 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +12 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +26 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource.d.ts +19 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +134 -0
- package/esm/typings/src/book-components/Chat/interfaces/ChatMessage.d.ts +30 -0
- package/esm/typings/src/book-components/Chat/utils/ExportFormat.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/utils/addUtmParamsToUrl.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/createShortLinkForChat.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/downloadFile.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/utils/exportChatHistory.d.ts +11 -0
- package/esm/typings/src/book-components/Chat/utils/generatePdfContent.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/utils/generateQrDataUrl.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/getPromptbookBranding.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToHtml.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToJson.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToMarkdown.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToText.d.ts +10 -0
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +4 -13
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +59 -71
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -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.100.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
|
|
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
|
|
@@ -2693,7 +2693,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2693
2693
|
* @private internal helper function
|
|
2694
2694
|
*/
|
|
2695
2695
|
function createTask(options) {
|
|
2696
|
-
const { taskType, taskProcessCallback
|
|
2696
|
+
const { taskType, taskProcessCallback } = options;
|
|
2697
2697
|
let { title } = options;
|
|
2698
2698
|
// TODO: [🐙] DRY
|
|
2699
2699
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -2703,6 +2703,7 @@ function createTask(options) {
|
|
|
2703
2703
|
const errors = [];
|
|
2704
2704
|
const warnings = [];
|
|
2705
2705
|
let currentValue = {};
|
|
2706
|
+
let customTldr = null;
|
|
2706
2707
|
const partialResultSubject = new Subject();
|
|
2707
2708
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2708
2709
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2713,6 +2714,9 @@ function createTask(options) {
|
|
|
2713
2714
|
Object.assign(currentValue, newOngoingResult);
|
|
2714
2715
|
// <- TODO: assign deep
|
|
2715
2716
|
partialResultSubject.next(newOngoingResult);
|
|
2717
|
+
}, (tldrInfo) => {
|
|
2718
|
+
customTldr = tldrInfo;
|
|
2719
|
+
updatedAt = new Date();
|
|
2716
2720
|
});
|
|
2717
2721
|
finalResultPromise
|
|
2718
2722
|
.catch((error) => {
|
|
@@ -2768,9 +2772,9 @@ function createTask(options) {
|
|
|
2768
2772
|
},
|
|
2769
2773
|
get tldr() {
|
|
2770
2774
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2771
|
-
// Use custom tldr
|
|
2772
|
-
if (
|
|
2773
|
-
return
|
|
2775
|
+
// Use custom tldr if available
|
|
2776
|
+
if (customTldr) {
|
|
2777
|
+
return customTldr;
|
|
2774
2778
|
}
|
|
2775
2779
|
// Fallback to default implementation
|
|
2776
2780
|
const cv = currentValue;
|
|
@@ -6309,75 +6313,59 @@ function createPipelineExecutor(options) {
|
|
|
6309
6313
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
6310
6314
|
taskType: 'EXECUTION',
|
|
6311
6315
|
title: pipeline.title,
|
|
6312
|
-
taskProcessCallback(updateOngoingResult) {
|
|
6316
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6313
6317
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6318
|
+
var _a;
|
|
6314
6319
|
updateOngoingResult(newOngoingResult);
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
message: errorMessage,
|
|
6333
|
-
};
|
|
6334
|
-
}
|
|
6335
|
-
// Calculate progress based on pipeline tasks
|
|
6336
|
-
const totalTasks = pipeline.tasks.length;
|
|
6337
|
-
let completedTasks = 0;
|
|
6338
|
-
let currentTaskName = '';
|
|
6339
|
-
// Check execution report for completed tasks
|
|
6340
|
-
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6341
|
-
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6342
|
-
// Count completed tasks by matching titles
|
|
6343
|
-
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
|
6344
|
-
completedTasks = completedTasksByTitle.length;
|
|
6345
|
-
// Find current task being executed (first task not yet completed)
|
|
6346
|
-
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
|
6347
|
-
if (remainingTasks.length > 0) {
|
|
6348
|
-
currentTaskName = remainingTasks[0].name;
|
|
6320
|
+
// Calculate and update tldr based on pipeline progress
|
|
6321
|
+
const cv = newOngoingResult;
|
|
6322
|
+
// Calculate progress based on pipeline tasks
|
|
6323
|
+
const totalTasks = pipeline.tasks.length;
|
|
6324
|
+
let completedTasks = 0;
|
|
6325
|
+
let currentTaskName = '';
|
|
6326
|
+
// Check execution report for completed tasks
|
|
6327
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6328
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6329
|
+
// Count completed tasks by matching titles
|
|
6330
|
+
const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
|
|
6331
|
+
completedTasks = completedTasksByTitle.length;
|
|
6332
|
+
// Find current task being executed (first task not yet completed)
|
|
6333
|
+
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
6334
|
+
if (remainingTasks.length > 0) {
|
|
6335
|
+
currentTaskName = remainingTasks[0].name;
|
|
6336
|
+
}
|
|
6349
6337
|
}
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
};
|
|
6338
|
+
// Calculate progress percentage
|
|
6339
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
|
6340
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
|
6341
|
+
if (completedTasks < totalTasks) {
|
|
6342
|
+
const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
|
|
6343
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
|
6344
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
6345
|
+
// Add partial progress for current task
|
|
6346
|
+
percent += (1 / totalTasks) * timeProgress;
|
|
6347
|
+
}
|
|
6348
|
+
// Clamp to [0,1]
|
|
6349
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6350
|
+
// Generate message
|
|
6351
|
+
let message = '';
|
|
6352
|
+
if (currentTaskName) {
|
|
6353
|
+
// Find the task to get its title
|
|
6354
|
+
const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
|
|
6355
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
|
6356
|
+
message = `Working on task ${taskTitle}`;
|
|
6357
|
+
}
|
|
6358
|
+
else if (completedTasks === 0) {
|
|
6359
|
+
message = 'Starting pipeline execution';
|
|
6360
|
+
}
|
|
6361
|
+
else {
|
|
6362
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
|
6363
|
+
}
|
|
6364
|
+
updateTldr({
|
|
6365
|
+
percent: percent,
|
|
6366
|
+
message,
|
|
6367
|
+
});
|
|
6368
|
+
});
|
|
6381
6369
|
},
|
|
6382
6370
|
});
|
|
6383
6371
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|