@promptbook/markitdown 0.100.0-45 → 0.100.0-46
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 +88 -64
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -6
- package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +4 -10
- package/esm/typings/src/book-components/Chat/interfaces/ChatMessage.d.ts +12 -26
- package/esm/typings/src/book-components/Chat/interfaces/ChatParticipant.d.ts +12 -0
- package/esm/typings/src/config.d.ts +7 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +8 -0
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -0
- package/esm/typings/src/playground/permanent/error-handling-playground.d.ts +5 -0
- package/esm/typings/src/utils/organization/preserve.d.ts +21 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -3
- package/umd/index.umd.js +92 -68
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/esm/index.es.js
CHANGED
|
@@ -3,8 +3,9 @@ import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
|
3
3
|
import { SHA256 } from 'crypto-js';
|
|
4
4
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
5
5
|
import { basename, join, dirname } from 'path';
|
|
6
|
-
import { format } from 'prettier';
|
|
7
6
|
import parserHtml from 'prettier/parser-html';
|
|
7
|
+
import parserMarkdown from 'prettier/parser-markdown';
|
|
8
|
+
import { format } from 'prettier/standalone';
|
|
8
9
|
import { randomBytes } from 'crypto';
|
|
9
10
|
import { Subject } from 'rxjs';
|
|
10
11
|
import { forTime } from 'waitasecond';
|
|
@@ -26,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
27
|
* @generated
|
|
27
28
|
* @see https://github.com/webgptorg/promptbook
|
|
28
29
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-46';
|
|
30
31
|
/**
|
|
31
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -224,6 +225,13 @@ const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
|
224
225
|
* @public exported from `@promptbook/core`
|
|
225
226
|
*/
|
|
226
227
|
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
228
|
+
/**
|
|
229
|
+
* API request timeout in milliseconds
|
|
230
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
231
|
+
*
|
|
232
|
+
* @public exported from `@promptbook/core`
|
|
233
|
+
*/
|
|
234
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
227
235
|
/**
|
|
228
236
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
229
237
|
*
|
|
@@ -1027,7 +1035,7 @@ function prettifyMarkdown(content) {
|
|
|
1027
1035
|
try {
|
|
1028
1036
|
return format(content, {
|
|
1029
1037
|
parser: 'markdown',
|
|
1030
|
-
plugins: [parserHtml],
|
|
1038
|
+
plugins: [parserMarkdown, parserHtml],
|
|
1031
1039
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1032
1040
|
endOfLine: 'lf',
|
|
1033
1041
|
tabWidth: 4,
|
|
@@ -3167,7 +3175,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3167
3175
|
const result = await preparePersonaExecutor({
|
|
3168
3176
|
availableModels /* <- Note: Passing as JSON */,
|
|
3169
3177
|
personaDescription,
|
|
3170
|
-
}).asPromise();
|
|
3178
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3171
3179
|
const { outputParameters } = result;
|
|
3172
3180
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3173
3181
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -3931,7 +3939,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
3931
3939
|
});
|
|
3932
3940
|
const result = await prepareTitleExecutor({
|
|
3933
3941
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
3934
|
-
}).asPromise();
|
|
3942
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3935
3943
|
const { outputParameters } = result;
|
|
3936
3944
|
const { title: titleRaw } = outputParameters;
|
|
3937
3945
|
if (isVerbose) {
|
|
@@ -6146,64 +6154,74 @@ function createPipelineExecutor(options) {
|
|
|
6146
6154
|
});
|
|
6147
6155
|
});
|
|
6148
6156
|
};
|
|
6149
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
// Find current task being executed (first task not yet completed)
|
|
6169
|
-
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
6170
|
-
if (remainingTasks.length > 0) {
|
|
6171
|
-
currentTaskName = remainingTasks[0].name;
|
|
6157
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6158
|
+
const startTime = new Date().getTime();
|
|
6159
|
+
return createTask({
|
|
6160
|
+
taskType: 'EXECUTION',
|
|
6161
|
+
title: pipeline.title,
|
|
6162
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6163
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6164
|
+
var _a, _b;
|
|
6165
|
+
updateOngoingResult(newOngoingResult);
|
|
6166
|
+
// Calculate and update tldr based on pipeline progress
|
|
6167
|
+
const cv = newOngoingResult;
|
|
6168
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6169
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6170
|
+
let resolvedParameters = 0;
|
|
6171
|
+
let currentTaskTitle = '';
|
|
6172
|
+
// Get the resolved parameters from output parameters
|
|
6173
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6174
|
+
// Count how many output parameters have non-empty values
|
|
6175
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6172
6176
|
}
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6177
|
+
// Try to determine current task from execution report
|
|
6178
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6179
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6180
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6181
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6184
|
+
// Calculate base progress percentage
|
|
6185
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6186
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6187
|
+
if (resolvedParameters < totalParameters) {
|
|
6188
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6189
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6190
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6191
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6192
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6193
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6194
|
+
}
|
|
6195
|
+
else if (percent < 1) {
|
|
6196
|
+
// Add partial progress for current task
|
|
6197
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6198
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6199
|
+
}
|
|
6200
|
+
}
|
|
6201
|
+
// Clamp to [0,1]
|
|
6202
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6203
|
+
// Generate message
|
|
6204
|
+
let message = '';
|
|
6205
|
+
if (currentTaskTitle) {
|
|
6206
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6207
|
+
}
|
|
6208
|
+
else if (resolvedParameters === 0) {
|
|
6209
|
+
message = 'Starting pipeline execution';
|
|
6210
|
+
}
|
|
6211
|
+
else if (resolvedParameters < totalParameters) {
|
|
6212
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6213
|
+
}
|
|
6214
|
+
else {
|
|
6215
|
+
message = 'Completing pipeline execution';
|
|
6216
|
+
}
|
|
6217
|
+
updateTldr({
|
|
6218
|
+
percent: percent,
|
|
6219
|
+
message,
|
|
6220
|
+
});
|
|
6203
6221
|
});
|
|
6204
|
-
}
|
|
6205
|
-
}
|
|
6206
|
-
}
|
|
6222
|
+
},
|
|
6223
|
+
});
|
|
6224
|
+
};
|
|
6207
6225
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6208
6226
|
return pipelineExecutor;
|
|
6209
6227
|
}
|
|
@@ -6288,7 +6306,9 @@ class MarkdownScraper {
|
|
|
6288
6306
|
},
|
|
6289
6307
|
});
|
|
6290
6308
|
const knowledgeContent = await source.asText();
|
|
6291
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6309
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6310
|
+
isCrashedOnError: true,
|
|
6311
|
+
});
|
|
6292
6312
|
const { outputParameters } = result;
|
|
6293
6313
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6294
6314
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6312,12 +6332,16 @@ class MarkdownScraper {
|
|
|
6312
6332
|
];
|
|
6313
6333
|
*/
|
|
6314
6334
|
try {
|
|
6315
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6335
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6336
|
+
isCrashedOnError: true,
|
|
6337
|
+
});
|
|
6316
6338
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6317
6339
|
title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6318
6340
|
name = titleToName(title);
|
|
6319
6341
|
// --- Keywords
|
|
6320
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6342
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6343
|
+
isCrashedOnError: true,
|
|
6344
|
+
});
|
|
6321
6345
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6322
6346
|
keywords = (keywordsRaw || '')
|
|
6323
6347
|
.split(',')
|