@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/umd/index.umd.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2691,7 +2691,7 @@
|
|
|
2691
2691
|
* @private internal helper function
|
|
2692
2692
|
*/
|
|
2693
2693
|
function createTask(options) {
|
|
2694
|
-
const { taskType, taskProcessCallback
|
|
2694
|
+
const { taskType, taskProcessCallback } = options;
|
|
2695
2695
|
let { title } = options;
|
|
2696
2696
|
// TODO: [🐙] DRY
|
|
2697
2697
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -2701,6 +2701,7 @@
|
|
|
2701
2701
|
const errors = [];
|
|
2702
2702
|
const warnings = [];
|
|
2703
2703
|
let currentValue = {};
|
|
2704
|
+
let customTldr = null;
|
|
2704
2705
|
const partialResultSubject = new rxjs.Subject();
|
|
2705
2706
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2706
2707
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2711,6 +2712,9 @@
|
|
|
2711
2712
|
Object.assign(currentValue, newOngoingResult);
|
|
2712
2713
|
// <- TODO: assign deep
|
|
2713
2714
|
partialResultSubject.next(newOngoingResult);
|
|
2715
|
+
}, (tldrInfo) => {
|
|
2716
|
+
customTldr = tldrInfo;
|
|
2717
|
+
updatedAt = new Date();
|
|
2714
2718
|
});
|
|
2715
2719
|
finalResultPromise
|
|
2716
2720
|
.catch((error) => {
|
|
@@ -2766,9 +2770,9 @@
|
|
|
2766
2770
|
},
|
|
2767
2771
|
get tldr() {
|
|
2768
2772
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2769
|
-
// Use custom tldr
|
|
2770
|
-
if (
|
|
2771
|
-
return
|
|
2773
|
+
// Use custom tldr if available
|
|
2774
|
+
if (customTldr) {
|
|
2775
|
+
return customTldr;
|
|
2772
2776
|
}
|
|
2773
2777
|
// Fallback to default implementation
|
|
2774
2778
|
const cv = currentValue;
|
|
@@ -6307,75 +6311,59 @@
|
|
|
6307
6311
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
6308
6312
|
taskType: 'EXECUTION',
|
|
6309
6313
|
title: pipeline.title,
|
|
6310
|
-
taskProcessCallback(updateOngoingResult) {
|
|
6314
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6311
6315
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6316
|
+
var _a;
|
|
6312
6317
|
updateOngoingResult(newOngoingResult);
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
message: errorMessage,
|
|
6331
|
-
};
|
|
6332
|
-
}
|
|
6333
|
-
// Calculate progress based on pipeline tasks
|
|
6334
|
-
const totalTasks = pipeline.tasks.length;
|
|
6335
|
-
let completedTasks = 0;
|
|
6336
|
-
let currentTaskName = '';
|
|
6337
|
-
// Check execution report for completed tasks
|
|
6338
|
-
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6339
|
-
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6340
|
-
// Count completed tasks by matching titles
|
|
6341
|
-
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
|
6342
|
-
completedTasks = completedTasksByTitle.length;
|
|
6343
|
-
// Find current task being executed (first task not yet completed)
|
|
6344
|
-
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
|
6345
|
-
if (remainingTasks.length > 0) {
|
|
6346
|
-
currentTaskName = remainingTasks[0].name;
|
|
6318
|
+
// Calculate and update tldr based on pipeline progress
|
|
6319
|
+
const cv = newOngoingResult;
|
|
6320
|
+
// Calculate progress based on pipeline tasks
|
|
6321
|
+
const totalTasks = pipeline.tasks.length;
|
|
6322
|
+
let completedTasks = 0;
|
|
6323
|
+
let currentTaskName = '';
|
|
6324
|
+
// Check execution report for completed tasks
|
|
6325
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6326
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6327
|
+
// Count completed tasks by matching titles
|
|
6328
|
+
const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
|
|
6329
|
+
completedTasks = completedTasksByTitle.length;
|
|
6330
|
+
// Find current task being executed (first task not yet completed)
|
|
6331
|
+
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
6332
|
+
if (remainingTasks.length > 0) {
|
|
6333
|
+
currentTaskName = remainingTasks[0].name;
|
|
6334
|
+
}
|
|
6347
6335
|
}
|
|
6348
|
-
|
|
6349
|
-
|
|
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
|
-
};
|
|
6336
|
+
// Calculate progress percentage
|
|
6337
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
|
6338
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
|
6339
|
+
if (completedTasks < totalTasks) {
|
|
6340
|
+
const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
|
|
6341
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
|
6342
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
6343
|
+
// Add partial progress for current task
|
|
6344
|
+
percent += (1 / totalTasks) * timeProgress;
|
|
6345
|
+
}
|
|
6346
|
+
// Clamp to [0,1]
|
|
6347
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6348
|
+
// Generate message
|
|
6349
|
+
let message = '';
|
|
6350
|
+
if (currentTaskName) {
|
|
6351
|
+
// Find the task to get its title
|
|
6352
|
+
const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
|
|
6353
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
|
6354
|
+
message = `Working on task ${taskTitle}`;
|
|
6355
|
+
}
|
|
6356
|
+
else if (completedTasks === 0) {
|
|
6357
|
+
message = 'Starting pipeline execution';
|
|
6358
|
+
}
|
|
6359
|
+
else {
|
|
6360
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
|
6361
|
+
}
|
|
6362
|
+
updateTldr({
|
|
6363
|
+
percent: percent,
|
|
6364
|
+
message,
|
|
6365
|
+
});
|
|
6366
|
+
});
|
|
6379
6367
|
},
|
|
6380
6368
|
});
|
|
6381
6369
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|