@promptbook/node 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
|
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
30
30
|
* @generated
|
|
31
31
|
* @see https://github.com/webgptorg/promptbook
|
|
32
32
|
*/
|
|
33
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
|
|
34
34
|
/**
|
|
35
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
36
36
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2088,7 +2088,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2088
2088
|
* @private internal helper function
|
|
2089
2089
|
*/
|
|
2090
2090
|
function createTask(options) {
|
|
2091
|
-
const { taskType, taskProcessCallback
|
|
2091
|
+
const { taskType, taskProcessCallback } = options;
|
|
2092
2092
|
let { title } = options;
|
|
2093
2093
|
// TODO: [🐙] DRY
|
|
2094
2094
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -2098,6 +2098,7 @@ function createTask(options) {
|
|
|
2098
2098
|
const errors = [];
|
|
2099
2099
|
const warnings = [];
|
|
2100
2100
|
let currentValue = {};
|
|
2101
|
+
let customTldr = null;
|
|
2101
2102
|
const partialResultSubject = new Subject();
|
|
2102
2103
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2103
2104
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2108,6 +2109,9 @@ function createTask(options) {
|
|
|
2108
2109
|
Object.assign(currentValue, newOngoingResult);
|
|
2109
2110
|
// <- TODO: assign deep
|
|
2110
2111
|
partialResultSubject.next(newOngoingResult);
|
|
2112
|
+
}, (tldrInfo) => {
|
|
2113
|
+
customTldr = tldrInfo;
|
|
2114
|
+
updatedAt = new Date();
|
|
2111
2115
|
});
|
|
2112
2116
|
finalResultPromise
|
|
2113
2117
|
.catch((error) => {
|
|
@@ -2163,9 +2167,9 @@ function createTask(options) {
|
|
|
2163
2167
|
},
|
|
2164
2168
|
get tldr() {
|
|
2165
2169
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2166
|
-
// Use custom tldr
|
|
2167
|
-
if (
|
|
2168
|
-
return
|
|
2170
|
+
// Use custom tldr if available
|
|
2171
|
+
if (customTldr) {
|
|
2172
|
+
return customTldr;
|
|
2169
2173
|
}
|
|
2170
2174
|
// Fallback to default implementation
|
|
2171
2175
|
const cv = currentValue;
|
|
@@ -5010,75 +5014,59 @@ function createPipelineExecutor(options) {
|
|
|
5010
5014
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
5011
5015
|
taskType: 'EXECUTION',
|
|
5012
5016
|
title: pipeline.title,
|
|
5013
|
-
taskProcessCallback(updateOngoingResult) {
|
|
5017
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
5014
5018
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
5019
|
+
var _a;
|
|
5015
5020
|
updateOngoingResult(newOngoingResult);
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
message: errorMessage,
|
|
5034
|
-
};
|
|
5035
|
-
}
|
|
5036
|
-
// Calculate progress based on pipeline tasks
|
|
5037
|
-
const totalTasks = pipeline.tasks.length;
|
|
5038
|
-
let completedTasks = 0;
|
|
5039
|
-
let currentTaskName = '';
|
|
5040
|
-
// Check execution report for completed tasks
|
|
5041
|
-
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
5042
|
-
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
5043
|
-
// Count completed tasks by matching titles
|
|
5044
|
-
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
|
5045
|
-
completedTasks = completedTasksByTitle.length;
|
|
5046
|
-
// Find current task being executed (first task not yet completed)
|
|
5047
|
-
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
|
5048
|
-
if (remainingTasks.length > 0) {
|
|
5049
|
-
currentTaskName = remainingTasks[0].name;
|
|
5021
|
+
// Calculate and update tldr based on pipeline progress
|
|
5022
|
+
const cv = newOngoingResult;
|
|
5023
|
+
// Calculate progress based on pipeline tasks
|
|
5024
|
+
const totalTasks = pipeline.tasks.length;
|
|
5025
|
+
let completedTasks = 0;
|
|
5026
|
+
let currentTaskName = '';
|
|
5027
|
+
// Check execution report for completed tasks
|
|
5028
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
5029
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
5030
|
+
// Count completed tasks by matching titles
|
|
5031
|
+
const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
|
|
5032
|
+
completedTasks = completedTasksByTitle.length;
|
|
5033
|
+
// Find current task being executed (first task not yet completed)
|
|
5034
|
+
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
5035
|
+
if (remainingTasks.length > 0) {
|
|
5036
|
+
currentTaskName = remainingTasks[0].name;
|
|
5037
|
+
}
|
|
5050
5038
|
}
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
};
|
|
5039
|
+
// Calculate progress percentage
|
|
5040
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
|
5041
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
|
5042
|
+
if (completedTasks < totalTasks) {
|
|
5043
|
+
const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
|
|
5044
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
|
5045
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
5046
|
+
// Add partial progress for current task
|
|
5047
|
+
percent += (1 / totalTasks) * timeProgress;
|
|
5048
|
+
}
|
|
5049
|
+
// Clamp to [0,1]
|
|
5050
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
5051
|
+
// Generate message
|
|
5052
|
+
let message = '';
|
|
5053
|
+
if (currentTaskName) {
|
|
5054
|
+
// Find the task to get its title
|
|
5055
|
+
const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
|
|
5056
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
|
5057
|
+
message = `Working on task ${taskTitle}`;
|
|
5058
|
+
}
|
|
5059
|
+
else if (completedTasks === 0) {
|
|
5060
|
+
message = 'Starting pipeline execution';
|
|
5061
|
+
}
|
|
5062
|
+
else {
|
|
5063
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
|
5064
|
+
}
|
|
5065
|
+
updateTldr({
|
|
5066
|
+
percent: percent,
|
|
5067
|
+
message,
|
|
5068
|
+
});
|
|
5069
|
+
});
|
|
5082
5070
|
},
|
|
5083
5071
|
});
|
|
5084
5072
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|