@promptbook/node 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
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
|
|
50
50
|
/**
|
|
51
51
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
52
52
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2104,7 +2104,7 @@
|
|
|
2104
2104
|
* @private internal helper function
|
|
2105
2105
|
*/
|
|
2106
2106
|
function createTask(options) {
|
|
2107
|
-
const { taskType, taskProcessCallback
|
|
2107
|
+
const { taskType, taskProcessCallback } = options;
|
|
2108
2108
|
let { title } = options;
|
|
2109
2109
|
// TODO: [🐙] DRY
|
|
2110
2110
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -2114,6 +2114,7 @@
|
|
|
2114
2114
|
const errors = [];
|
|
2115
2115
|
const warnings = [];
|
|
2116
2116
|
let currentValue = {};
|
|
2117
|
+
let customTldr = null;
|
|
2117
2118
|
const partialResultSubject = new rxjs.Subject();
|
|
2118
2119
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2119
2120
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2124,6 +2125,9 @@
|
|
|
2124
2125
|
Object.assign(currentValue, newOngoingResult);
|
|
2125
2126
|
// <- TODO: assign deep
|
|
2126
2127
|
partialResultSubject.next(newOngoingResult);
|
|
2128
|
+
}, (tldrInfo) => {
|
|
2129
|
+
customTldr = tldrInfo;
|
|
2130
|
+
updatedAt = new Date();
|
|
2127
2131
|
});
|
|
2128
2132
|
finalResultPromise
|
|
2129
2133
|
.catch((error) => {
|
|
@@ -2179,9 +2183,9 @@
|
|
|
2179
2183
|
},
|
|
2180
2184
|
get tldr() {
|
|
2181
2185
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2182
|
-
// Use custom tldr
|
|
2183
|
-
if (
|
|
2184
|
-
return
|
|
2186
|
+
// Use custom tldr if available
|
|
2187
|
+
if (customTldr) {
|
|
2188
|
+
return customTldr;
|
|
2185
2189
|
}
|
|
2186
2190
|
// Fallback to default implementation
|
|
2187
2191
|
const cv = currentValue;
|
|
@@ -5026,75 +5030,59 @@
|
|
|
5026
5030
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
5027
5031
|
taskType: 'EXECUTION',
|
|
5028
5032
|
title: pipeline.title,
|
|
5029
|
-
taskProcessCallback(updateOngoingResult) {
|
|
5033
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
5030
5034
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
5035
|
+
var _a;
|
|
5031
5036
|
updateOngoingResult(newOngoingResult);
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
message: errorMessage,
|
|
5050
|
-
};
|
|
5051
|
-
}
|
|
5052
|
-
// Calculate progress based on pipeline tasks
|
|
5053
|
-
const totalTasks = pipeline.tasks.length;
|
|
5054
|
-
let completedTasks = 0;
|
|
5055
|
-
let currentTaskName = '';
|
|
5056
|
-
// Check execution report for completed tasks
|
|
5057
|
-
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
5058
|
-
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
5059
|
-
// Count completed tasks by matching titles
|
|
5060
|
-
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
|
5061
|
-
completedTasks = completedTasksByTitle.length;
|
|
5062
|
-
// Find current task being executed (first task not yet completed)
|
|
5063
|
-
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
|
5064
|
-
if (remainingTasks.length > 0) {
|
|
5065
|
-
currentTaskName = remainingTasks[0].name;
|
|
5037
|
+
// Calculate and update tldr based on pipeline progress
|
|
5038
|
+
const cv = newOngoingResult;
|
|
5039
|
+
// Calculate progress based on pipeline tasks
|
|
5040
|
+
const totalTasks = pipeline.tasks.length;
|
|
5041
|
+
let completedTasks = 0;
|
|
5042
|
+
let currentTaskName = '';
|
|
5043
|
+
// Check execution report for completed tasks
|
|
5044
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
5045
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
5046
|
+
// Count completed tasks by matching titles
|
|
5047
|
+
const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
|
|
5048
|
+
completedTasks = completedTasksByTitle.length;
|
|
5049
|
+
// Find current task being executed (first task not yet completed)
|
|
5050
|
+
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
5051
|
+
if (remainingTasks.length > 0) {
|
|
5052
|
+
currentTaskName = remainingTasks[0].name;
|
|
5053
|
+
}
|
|
5066
5054
|
}
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
};
|
|
5055
|
+
// Calculate progress percentage
|
|
5056
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
|
5057
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
|
5058
|
+
if (completedTasks < totalTasks) {
|
|
5059
|
+
const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
|
|
5060
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
|
5061
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
5062
|
+
// Add partial progress for current task
|
|
5063
|
+
percent += (1 / totalTasks) * timeProgress;
|
|
5064
|
+
}
|
|
5065
|
+
// Clamp to [0,1]
|
|
5066
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
5067
|
+
// Generate message
|
|
5068
|
+
let message = '';
|
|
5069
|
+
if (currentTaskName) {
|
|
5070
|
+
// Find the task to get its title
|
|
5071
|
+
const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
|
|
5072
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
|
5073
|
+
message = `Working on task ${taskTitle}`;
|
|
5074
|
+
}
|
|
5075
|
+
else if (completedTasks === 0) {
|
|
5076
|
+
message = 'Starting pipeline execution';
|
|
5077
|
+
}
|
|
5078
|
+
else {
|
|
5079
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
|
5080
|
+
}
|
|
5081
|
+
updateTldr({
|
|
5082
|
+
percent: percent,
|
|
5083
|
+
message,
|
|
5084
|
+
});
|
|
5085
|
+
});
|
|
5098
5086
|
},
|
|
5099
5087
|
});
|
|
5100
5088
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|