@promptbook/markdown-utils 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 +1 -1
- package/umd/index.umd.js +59 -71
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2202,7 +2202,7 @@
|
|
|
2202
2202
|
* @private internal helper function
|
|
2203
2203
|
*/
|
|
2204
2204
|
function createTask(options) {
|
|
2205
|
-
const { taskType, taskProcessCallback
|
|
2205
|
+
const { taskType, taskProcessCallback } = options;
|
|
2206
2206
|
let { title } = options;
|
|
2207
2207
|
// TODO: [🐙] DRY
|
|
2208
2208
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -2212,6 +2212,7 @@
|
|
|
2212
2212
|
const errors = [];
|
|
2213
2213
|
const warnings = [];
|
|
2214
2214
|
let currentValue = {};
|
|
2215
|
+
let customTldr = null;
|
|
2215
2216
|
const partialResultSubject = new rxjs.Subject();
|
|
2216
2217
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2217
2218
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2222,6 +2223,9 @@
|
|
|
2222
2223
|
Object.assign(currentValue, newOngoingResult);
|
|
2223
2224
|
// <- TODO: assign deep
|
|
2224
2225
|
partialResultSubject.next(newOngoingResult);
|
|
2226
|
+
}, (tldrInfo) => {
|
|
2227
|
+
customTldr = tldrInfo;
|
|
2228
|
+
updatedAt = new Date();
|
|
2225
2229
|
});
|
|
2226
2230
|
finalResultPromise
|
|
2227
2231
|
.catch((error) => {
|
|
@@ -2277,9 +2281,9 @@
|
|
|
2277
2281
|
},
|
|
2278
2282
|
get tldr() {
|
|
2279
2283
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2280
|
-
// Use custom tldr
|
|
2281
|
-
if (
|
|
2282
|
-
return
|
|
2284
|
+
// Use custom tldr if available
|
|
2285
|
+
if (customTldr) {
|
|
2286
|
+
return customTldr;
|
|
2283
2287
|
}
|
|
2284
2288
|
// Fallback to default implementation
|
|
2285
2289
|
const cv = currentValue;
|
|
@@ -6113,75 +6117,59 @@
|
|
|
6113
6117
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
6114
6118
|
taskType: 'EXECUTION',
|
|
6115
6119
|
title: pipeline.title,
|
|
6116
|
-
taskProcessCallback(updateOngoingResult) {
|
|
6120
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6117
6121
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6122
|
+
var _a;
|
|
6118
6123
|
updateOngoingResult(newOngoingResult);
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
message: errorMessage,
|
|
6137
|
-
};
|
|
6138
|
-
}
|
|
6139
|
-
// Calculate progress based on pipeline tasks
|
|
6140
|
-
const totalTasks = pipeline.tasks.length;
|
|
6141
|
-
let completedTasks = 0;
|
|
6142
|
-
let currentTaskName = '';
|
|
6143
|
-
// Check execution report for completed tasks
|
|
6144
|
-
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6145
|
-
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6146
|
-
// Count completed tasks by matching titles
|
|
6147
|
-
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
|
6148
|
-
completedTasks = completedTasksByTitle.length;
|
|
6149
|
-
// Find current task being executed (first task not yet completed)
|
|
6150
|
-
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
|
6151
|
-
if (remainingTasks.length > 0) {
|
|
6152
|
-
currentTaskName = remainingTasks[0].name;
|
|
6124
|
+
// Calculate and update tldr based on pipeline progress
|
|
6125
|
+
const cv = newOngoingResult;
|
|
6126
|
+
// Calculate progress based on pipeline tasks
|
|
6127
|
+
const totalTasks = pipeline.tasks.length;
|
|
6128
|
+
let completedTasks = 0;
|
|
6129
|
+
let currentTaskName = '';
|
|
6130
|
+
// Check execution report for completed tasks
|
|
6131
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6132
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6133
|
+
// Count completed tasks by matching titles
|
|
6134
|
+
const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
|
|
6135
|
+
completedTasks = completedTasksByTitle.length;
|
|
6136
|
+
// Find current task being executed (first task not yet completed)
|
|
6137
|
+
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
6138
|
+
if (remainingTasks.length > 0) {
|
|
6139
|
+
currentTaskName = remainingTasks[0].name;
|
|
6140
|
+
}
|
|
6153
6141
|
}
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
};
|
|
6142
|
+
// Calculate progress percentage
|
|
6143
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
|
6144
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
|
6145
|
+
if (completedTasks < totalTasks) {
|
|
6146
|
+
const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
|
|
6147
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
|
6148
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
6149
|
+
// Add partial progress for current task
|
|
6150
|
+
percent += (1 / totalTasks) * timeProgress;
|
|
6151
|
+
}
|
|
6152
|
+
// Clamp to [0,1]
|
|
6153
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6154
|
+
// Generate message
|
|
6155
|
+
let message = '';
|
|
6156
|
+
if (currentTaskName) {
|
|
6157
|
+
// Find the task to get its title
|
|
6158
|
+
const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
|
|
6159
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
|
6160
|
+
message = `Working on task ${taskTitle}`;
|
|
6161
|
+
}
|
|
6162
|
+
else if (completedTasks === 0) {
|
|
6163
|
+
message = 'Starting pipeline execution';
|
|
6164
|
+
}
|
|
6165
|
+
else {
|
|
6166
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
|
6167
|
+
}
|
|
6168
|
+
updateTldr({
|
|
6169
|
+
percent: percent,
|
|
6170
|
+
message,
|
|
6171
|
+
});
|
|
6172
|
+
});
|
|
6185
6173
|
},
|
|
6186
6174
|
});
|
|
6187
6175
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|