@promptbook/remote-server 0.100.0-44 → 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
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2021,7 +2021,7 @@
|
|
|
2021
2021
|
* @private internal helper function
|
|
2022
2022
|
*/
|
|
2023
2023
|
function createTask(options) {
|
|
2024
|
-
const { taskType, taskProcessCallback
|
|
2024
|
+
const { taskType, taskProcessCallback } = options;
|
|
2025
2025
|
let { title } = options;
|
|
2026
2026
|
// TODO: [🐙] DRY
|
|
2027
2027
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -2031,6 +2031,7 @@
|
|
|
2031
2031
|
const errors = [];
|
|
2032
2032
|
const warnings = [];
|
|
2033
2033
|
let currentValue = {};
|
|
2034
|
+
let customTldr = null;
|
|
2034
2035
|
const partialResultSubject = new rxjs.Subject();
|
|
2035
2036
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2036
2037
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2041,6 +2042,9 @@
|
|
|
2041
2042
|
Object.assign(currentValue, newOngoingResult);
|
|
2042
2043
|
// <- TODO: assign deep
|
|
2043
2044
|
partialResultSubject.next(newOngoingResult);
|
|
2045
|
+
}, (tldrInfo) => {
|
|
2046
|
+
customTldr = tldrInfo;
|
|
2047
|
+
updatedAt = new Date();
|
|
2044
2048
|
});
|
|
2045
2049
|
finalResultPromise
|
|
2046
2050
|
.catch((error) => {
|
|
@@ -2096,9 +2100,9 @@
|
|
|
2096
2100
|
},
|
|
2097
2101
|
get tldr() {
|
|
2098
2102
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2099
|
-
// Use custom tldr
|
|
2100
|
-
if (
|
|
2101
|
-
return
|
|
2103
|
+
// Use custom tldr if available
|
|
2104
|
+
if (customTldr) {
|
|
2105
|
+
return customTldr;
|
|
2102
2106
|
}
|
|
2103
2107
|
// Fallback to default implementation
|
|
2104
2108
|
const cv = currentValue;
|
|
@@ -6499,75 +6503,59 @@
|
|
|
6499
6503
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
6500
6504
|
taskType: 'EXECUTION',
|
|
6501
6505
|
title: pipeline.title,
|
|
6502
|
-
taskProcessCallback(updateOngoingResult) {
|
|
6506
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6503
6507
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6508
|
+
var _a;
|
|
6504
6509
|
updateOngoingResult(newOngoingResult);
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
message: errorMessage,
|
|
6523
|
-
};
|
|
6524
|
-
}
|
|
6525
|
-
// Calculate progress based on pipeline tasks
|
|
6526
|
-
const totalTasks = pipeline.tasks.length;
|
|
6527
|
-
let completedTasks = 0;
|
|
6528
|
-
let currentTaskName = '';
|
|
6529
|
-
// Check execution report for completed tasks
|
|
6530
|
-
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6531
|
-
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6532
|
-
// Count completed tasks by matching titles
|
|
6533
|
-
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
|
6534
|
-
completedTasks = completedTasksByTitle.length;
|
|
6535
|
-
// Find current task being executed (first task not yet completed)
|
|
6536
|
-
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
|
6537
|
-
if (remainingTasks.length > 0) {
|
|
6538
|
-
currentTaskName = remainingTasks[0].name;
|
|
6510
|
+
// Calculate and update tldr based on pipeline progress
|
|
6511
|
+
const cv = newOngoingResult;
|
|
6512
|
+
// Calculate progress based on pipeline tasks
|
|
6513
|
+
const totalTasks = pipeline.tasks.length;
|
|
6514
|
+
let completedTasks = 0;
|
|
6515
|
+
let currentTaskName = '';
|
|
6516
|
+
// Check execution report for completed tasks
|
|
6517
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6518
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6519
|
+
// Count completed tasks by matching titles
|
|
6520
|
+
const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
|
|
6521
|
+
completedTasks = completedTasksByTitle.length;
|
|
6522
|
+
// Find current task being executed (first task not yet completed)
|
|
6523
|
+
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
6524
|
+
if (remainingTasks.length > 0) {
|
|
6525
|
+
currentTaskName = remainingTasks[0].name;
|
|
6526
|
+
}
|
|
6539
6527
|
}
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
};
|
|
6528
|
+
// Calculate progress percentage
|
|
6529
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
|
6530
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
|
6531
|
+
if (completedTasks < totalTasks) {
|
|
6532
|
+
const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
|
|
6533
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
|
6534
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
6535
|
+
// Add partial progress for current task
|
|
6536
|
+
percent += (1 / totalTasks) * timeProgress;
|
|
6537
|
+
}
|
|
6538
|
+
// Clamp to [0,1]
|
|
6539
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6540
|
+
// Generate message
|
|
6541
|
+
let message = '';
|
|
6542
|
+
if (currentTaskName) {
|
|
6543
|
+
// Find the task to get its title
|
|
6544
|
+
const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
|
|
6545
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
|
6546
|
+
message = `Working on task ${taskTitle}`;
|
|
6547
|
+
}
|
|
6548
|
+
else if (completedTasks === 0) {
|
|
6549
|
+
message = 'Starting pipeline execution';
|
|
6550
|
+
}
|
|
6551
|
+
else {
|
|
6552
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
|
6553
|
+
}
|
|
6554
|
+
updateTldr({
|
|
6555
|
+
percent: percent,
|
|
6556
|
+
message,
|
|
6557
|
+
});
|
|
6558
|
+
});
|
|
6571
6559
|
},
|
|
6572
6560
|
});
|
|
6573
6561
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|