@promptbook/markitdown 0.101.0-2 → 0.101.0-20
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 -51
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +20 -0
- package/esm/typings/src/_packages/core.index.d.ts +14 -0
- package/esm/typings/src/_packages/types.index.d.ts +14 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +41 -3
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +3 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +4 -22
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +1 -26
- package/esm/typings/src/book-2.0/agent-source/parseParameters.d.ts +13 -0
- package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +8 -2
- package/esm/typings/src/book-2.0/commitments/DELETE/DELETE.d.ts +59 -0
- package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +8 -2
- package/esm/typings/src/book-2.0/commitments/GOAL/GOAL.d.ts +45 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/MEMORY/MEMORY.d.ts +46 -0
- package/esm/typings/src/book-2.0/commitments/MESSAGE/MESSAGE.d.ts +47 -0
- package/esm/typings/src/book-2.0/commitments/META/META.d.ts +62 -0
- package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +31 -4
- package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +20 -2
- package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +8 -2
- package/esm/typings/src/book-2.0/commitments/SCENARIO/SCENARIO.d.ts +46 -0
- package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +8 -2
- package/esm/typings/src/book-2.0/commitments/index.d.ts +7 -3
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +2 -2
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/MockedChat.d.ts +63 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/index.d.ts +3 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +15 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +26 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/hooks/index.d.ts +2 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatAutoScroll.d.ts +41 -0
- package/esm/typings/src/book-components/Chat/hooks/useSendMessageToLlmChat.d.ts +44 -0
- package/esm/typings/src/book-components/Chat/utils/parseMessageButtons.d.ts +22 -0
- package/esm/typings/src/book-components/icons/PauseIcon.d.ts +8 -0
- package/esm/typings/src/book-components/icons/PlayIcon.d.ts +8 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -2
- package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +1 -3
- package/esm/typings/src/formats/csv/CsvFormatError.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -2
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +8 -2
- package/esm/typings/src/llm-providers/_common/utils/removeUnsupportedModelRequirements.d.ts +25 -0
- package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +5 -13
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +11 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +2 -1
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +54 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +29 -0
- package/esm/typings/src/llm-providers/agent/playground/playground.d.ts +8 -0
- package/esm/typings/src/llm-providers/agent/register-configuration.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/register-constructor.d.ts +13 -0
- package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -0
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -5
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +2 -6
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +15 -8
- package/esm/typings/src/personas/preparePersona.d.ts +1 -0
- package/esm/typings/src/remote-server/openapi-types.d.ts +31 -31
- package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -2
- package/esm/typings/src/types/ModelRequirements.d.ts +2 -4
- package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +1 -1
- package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +1 -1
- package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +59 -51
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/utils/extractAgentMetadata.d.ts +0 -17
- package/esm/typings/src/book-2.0/utils/extractProfileImageFromSystemMessage.d.ts +0 -12
- package/esm/typings/src/llm-providers/mocked/test/joker.test.d.ts +0 -4
- package/esm/typings/src/llm-providers/mocked/test/mocked-chat.test.d.ts +0 -5
- package/esm/typings/src/llm-providers/mocked/test/mocked-completion.test.d.ts +0 -4
- package/esm/typings/src/scripting/_test/postprocessing.test.d.ts +0 -1
- /package/esm/typings/src/{cli/test/ptbk.test.d.ts → llm-providers/_common/utils/removeUnsupportedModelRequirements.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -24,7 +24,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
24
24
|
* @generated
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
|
27
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-20';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -864,11 +864,12 @@ async function getScraperIntermediateSource(source, options) {
|
|
|
864
864
|
catch (error) {
|
|
865
865
|
// Note: If we can't create cache directory, continue without it
|
|
866
866
|
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
867
|
-
if (error instanceof Error &&
|
|
868
|
-
error.message.includes('
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
867
|
+
if (error instanceof Error &&
|
|
868
|
+
(error.message.includes('EROFS') ||
|
|
869
|
+
error.message.includes('read-only') ||
|
|
870
|
+
error.message.includes('EACCES') ||
|
|
871
|
+
error.message.includes('EPERM') ||
|
|
872
|
+
error.message.includes('ENOENT'))) ;
|
|
872
873
|
else {
|
|
873
874
|
// Re-throw other unexpected errors
|
|
874
875
|
throw error;
|
|
@@ -2946,6 +2947,25 @@ function countUsage(llmTools) {
|
|
|
2946
2947
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2947
2948
|
*/
|
|
2948
2949
|
|
|
2950
|
+
/**
|
|
2951
|
+
* Takes an item or an array of items and returns an array of items
|
|
2952
|
+
*
|
|
2953
|
+
* 1) Any item except array and undefined returns array with that one item (also null)
|
|
2954
|
+
* 2) Undefined returns empty array
|
|
2955
|
+
* 3) Array returns itself
|
|
2956
|
+
*
|
|
2957
|
+
* @private internal utility
|
|
2958
|
+
*/
|
|
2959
|
+
function arrayableToArray(input) {
|
|
2960
|
+
if (input === undefined) {
|
|
2961
|
+
return [];
|
|
2962
|
+
}
|
|
2963
|
+
if (input instanceof Array) {
|
|
2964
|
+
return input;
|
|
2965
|
+
}
|
|
2966
|
+
return [input];
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2949
2969
|
/**
|
|
2950
2970
|
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
2951
2971
|
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
@@ -3026,12 +3046,10 @@ class MultipleLlmExecutionTools {
|
|
|
3026
3046
|
/**
|
|
3027
3047
|
* Gets array of execution tools in order of priority
|
|
3028
3048
|
*/
|
|
3029
|
-
constructor(...llmExecutionTools) {
|
|
3049
|
+
constructor(title, ...llmExecutionTools) {
|
|
3050
|
+
this.title = title;
|
|
3030
3051
|
this.llmExecutionTools = llmExecutionTools;
|
|
3031
3052
|
}
|
|
3032
|
-
get title() {
|
|
3033
|
-
return 'Multiple LLM Providers';
|
|
3034
|
-
}
|
|
3035
3053
|
get description() {
|
|
3036
3054
|
const innerModelsTitlesAndDescriptions = this.llmExecutionTools
|
|
3037
3055
|
.map(({ title, description }, index) => {
|
|
@@ -3117,7 +3135,7 @@ class MultipleLlmExecutionTools {
|
|
|
3117
3135
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
3118
3136
|
// <- case [🤖]:
|
|
3119
3137
|
default:
|
|
3120
|
-
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
3138
|
+
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
|
|
3121
3139
|
}
|
|
3122
3140
|
}
|
|
3123
3141
|
catch (error) {
|
|
@@ -3138,7 +3156,7 @@ class MultipleLlmExecutionTools {
|
|
|
3138
3156
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3139
3157
|
// 3) ...
|
|
3140
3158
|
spaceTrim((block) => `
|
|
3141
|
-
All execution tools failed:
|
|
3159
|
+
All execution tools of ${this.title} failed:
|
|
3142
3160
|
|
|
3143
3161
|
${block(errors
|
|
3144
3162
|
.map(({ error, llmExecutionTools }, i) => `${i + 1}) **${llmExecutionTools.title}** thrown **${error.name || 'Error'}:** ${error.message}`)
|
|
@@ -3147,11 +3165,11 @@ class MultipleLlmExecutionTools {
|
|
|
3147
3165
|
`));
|
|
3148
3166
|
}
|
|
3149
3167
|
else if (this.llmExecutionTools.length === 0) {
|
|
3150
|
-
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools
|
|
3168
|
+
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
3151
3169
|
}
|
|
3152
3170
|
else {
|
|
3153
3171
|
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3154
|
-
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}"
|
|
3172
|
+
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
3155
3173
|
|
|
3156
3174
|
Available \`LlmExecutionTools\`:
|
|
3157
3175
|
${block(this.description)}
|
|
@@ -3181,7 +3199,7 @@ class MultipleLlmExecutionTools {
|
|
|
3181
3199
|
*
|
|
3182
3200
|
* @public exported from `@promptbook/core`
|
|
3183
3201
|
*/
|
|
3184
|
-
function joinLlmExecutionTools(...llmExecutionTools) {
|
|
3202
|
+
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
3185
3203
|
if (llmExecutionTools.length === 0) {
|
|
3186
3204
|
const warningMessage = spaceTrim(`
|
|
3187
3205
|
You have not provided any \`LlmExecutionTools\`
|
|
@@ -3213,30 +3231,27 @@ function joinLlmExecutionTools(...llmExecutionTools) {
|
|
|
3213
3231
|
};
|
|
3214
3232
|
*/
|
|
3215
3233
|
}
|
|
3216
|
-
return new MultipleLlmExecutionTools(...llmExecutionTools);
|
|
3234
|
+
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
3217
3235
|
}
|
|
3218
3236
|
/**
|
|
3219
3237
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3220
3238
|
*/
|
|
3221
3239
|
|
|
3222
3240
|
/**
|
|
3223
|
-
*
|
|
3241
|
+
* Just returns the given `LlmExecutionTools` or joins multiple into one
|
|
3224
3242
|
*
|
|
3225
|
-
*
|
|
3226
|
-
* 2) Undefined returns empty array
|
|
3227
|
-
* 3) Array returns itself
|
|
3228
|
-
*
|
|
3229
|
-
* @private internal utility
|
|
3243
|
+
* @public exported from `@promptbook/core`
|
|
3230
3244
|
*/
|
|
3231
|
-
function
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
}
|
|
3238
|
-
return [input];
|
|
3245
|
+
function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
3246
|
+
const _llms = arrayableToArray(oneOrMoreLlmExecutionTools);
|
|
3247
|
+
const llmTools = _llms.length === 1
|
|
3248
|
+
? _llms[0]
|
|
3249
|
+
: joinLlmExecutionTools('Multiple LLM Providers joined by `getSingleLlmExecutionTools`', ..._llms);
|
|
3250
|
+
return llmTools;
|
|
3239
3251
|
}
|
|
3252
|
+
/**
|
|
3253
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3254
|
+
*/
|
|
3240
3255
|
|
|
3241
3256
|
/**
|
|
3242
3257
|
* Prepares the persona for the pipeline
|
|
@@ -3255,8 +3270,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3255
3270
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
|
3256
3271
|
tools,
|
|
3257
3272
|
});
|
|
3258
|
-
const
|
|
3259
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
3273
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
3260
3274
|
const availableModels = (await llmTools.listModels())
|
|
3261
3275
|
.filter(({ modelVariant }) => modelVariant === 'CHAT')
|
|
3262
3276
|
.map(({ modelName, modelDescription }) => ({
|
|
@@ -3300,6 +3314,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3300
3314
|
};
|
|
3301
3315
|
}
|
|
3302
3316
|
/**
|
|
3317
|
+
* TODO: [😩] DRY `preparePersona` and `selectBestModelFromAvailable`
|
|
3303
3318
|
* TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
|
|
3304
3319
|
* TODO: [🏢] Check validity of `modelName` in pipeline
|
|
3305
3320
|
* TODO: [🏢] Check validity of `systemMessage` in pipeline
|
|
@@ -4027,9 +4042,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
4027
4042
|
if (tools === undefined || tools.llm === undefined) {
|
|
4028
4043
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
4029
4044
|
}
|
|
4030
|
-
|
|
4031
|
-
const _llms = arrayableToArray(tools.llm);
|
|
4032
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
4045
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
4033
4046
|
const llmToolsWithUsage = countUsage(llmTools);
|
|
4034
4047
|
// <- TODO: [🌯]
|
|
4035
4048
|
/*
|
|
@@ -5172,9 +5185,7 @@ async function executeAttempts(options) {
|
|
|
5172
5185
|
$scriptPipelineExecutionErrors: [],
|
|
5173
5186
|
$failedResults: [], // Track all failed attempts
|
|
5174
5187
|
};
|
|
5175
|
-
|
|
5176
|
-
const _llms = arrayableToArray(tools.llm);
|
|
5177
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
5188
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
5178
5189
|
attempts: for (let attemptIndex = -jokerParameterNames.length; attemptIndex < maxAttempts; attemptIndex++) {
|
|
5179
5190
|
const isJokerAttempt = attemptIndex < 0;
|
|
5180
5191
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
@@ -5694,9 +5705,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5694
5705
|
return ''; // <- Note: Np knowledge present, return empty string
|
|
5695
5706
|
}
|
|
5696
5707
|
try {
|
|
5697
|
-
|
|
5698
|
-
const _llms = arrayableToArray(tools.llm);
|
|
5699
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
5708
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
5700
5709
|
const taskEmbeddingPrompt = {
|
|
5701
5710
|
title: 'Knowledge Search',
|
|
5702
5711
|
modelRequirements: {
|
|
@@ -6297,13 +6306,13 @@ function createPipelineExecutor(options) {
|
|
|
6297
6306
|
// Calculate and update tldr based on pipeline progress
|
|
6298
6307
|
const cv = newOngoingResult;
|
|
6299
6308
|
// Calculate progress based on parameters resolved vs total parameters
|
|
6300
|
-
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6309
|
+
const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
|
|
6301
6310
|
let resolvedParameters = 0;
|
|
6302
6311
|
let currentTaskTitle = '';
|
|
6303
6312
|
// Get the resolved parameters from output parameters
|
|
6304
6313
|
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6305
6314
|
// Count how many output parameters have non-empty values
|
|
6306
|
-
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6315
|
+
resolvedParameters = Object.values(cv.outputParameters).filter((value) => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6307
6316
|
}
|
|
6308
6317
|
// Try to determine current task from execution report
|
|
6309
6318
|
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
@@ -6413,9 +6422,7 @@ class MarkdownScraper {
|
|
|
6413
6422
|
throw new MissingToolsError('LLM tools are required for scraping external files');
|
|
6414
6423
|
// <- Note: This scraper is used in all other scrapers, so saying "external files" not "markdown files"
|
|
6415
6424
|
}
|
|
6416
|
-
|
|
6417
|
-
const _llms = arrayableToArray(llm);
|
|
6418
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
6425
|
+
const llmTools = getSingleLlmExecutionTools(llm);
|
|
6419
6426
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
6420
6427
|
const collection = createCollectionFromJson(...PipelineCollection);
|
|
6421
6428
|
const prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
|
|
@@ -6634,11 +6641,12 @@ class MarkitdownScraper {
|
|
|
6634
6641
|
catch (error) {
|
|
6635
6642
|
// Note: If we can't write to cache, we'll continue without caching
|
|
6636
6643
|
// This handles read-only filesystems like Vercel
|
|
6637
|
-
if (error instanceof Error &&
|
|
6638
|
-
error.message.includes('
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6644
|
+
if (error instanceof Error &&
|
|
6645
|
+
(error.message.includes('EROFS') ||
|
|
6646
|
+
error.message.includes('read-only') ||
|
|
6647
|
+
error.message.includes('EACCES') ||
|
|
6648
|
+
error.message.includes('EPERM') ||
|
|
6649
|
+
error.message.includes('ENOENT'))) ;
|
|
6642
6650
|
else {
|
|
6643
6651
|
// Re-throw other unexpected errors
|
|
6644
6652
|
throw error;
|