@promptbook/documents 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 +53 -46
- 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 +53 -46
- 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
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-20';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1056,11 +1056,12 @@ async function getScraperIntermediateSource(source, options) {
|
|
|
1056
1056
|
catch (error) {
|
|
1057
1057
|
// Note: If we can't create cache directory, continue without it
|
|
1058
1058
|
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
1059
|
-
if (error instanceof Error &&
|
|
1060
|
-
error.message.includes('
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1059
|
+
if (error instanceof Error &&
|
|
1060
|
+
(error.message.includes('EROFS') ||
|
|
1061
|
+
error.message.includes('read-only') ||
|
|
1062
|
+
error.message.includes('EACCES') ||
|
|
1063
|
+
error.message.includes('EPERM') ||
|
|
1064
|
+
error.message.includes('ENOENT'))) ;
|
|
1064
1065
|
else {
|
|
1065
1066
|
// Re-throw other unexpected errors
|
|
1066
1067
|
throw error;
|
|
@@ -3120,6 +3121,25 @@ function countUsage(llmTools) {
|
|
|
3120
3121
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3121
3122
|
*/
|
|
3122
3123
|
|
|
3124
|
+
/**
|
|
3125
|
+
* Takes an item or an array of items and returns an array of items
|
|
3126
|
+
*
|
|
3127
|
+
* 1) Any item except array and undefined returns array with that one item (also null)
|
|
3128
|
+
* 2) Undefined returns empty array
|
|
3129
|
+
* 3) Array returns itself
|
|
3130
|
+
*
|
|
3131
|
+
* @private internal utility
|
|
3132
|
+
*/
|
|
3133
|
+
function arrayableToArray(input) {
|
|
3134
|
+
if (input === undefined) {
|
|
3135
|
+
return [];
|
|
3136
|
+
}
|
|
3137
|
+
if (input instanceof Array) {
|
|
3138
|
+
return input;
|
|
3139
|
+
}
|
|
3140
|
+
return [input];
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3123
3143
|
/**
|
|
3124
3144
|
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
3125
3145
|
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
@@ -3200,12 +3220,10 @@ class MultipleLlmExecutionTools {
|
|
|
3200
3220
|
/**
|
|
3201
3221
|
* Gets array of execution tools in order of priority
|
|
3202
3222
|
*/
|
|
3203
|
-
constructor(...llmExecutionTools) {
|
|
3223
|
+
constructor(title, ...llmExecutionTools) {
|
|
3224
|
+
this.title = title;
|
|
3204
3225
|
this.llmExecutionTools = llmExecutionTools;
|
|
3205
3226
|
}
|
|
3206
|
-
get title() {
|
|
3207
|
-
return 'Multiple LLM Providers';
|
|
3208
|
-
}
|
|
3209
3227
|
get description() {
|
|
3210
3228
|
const innerModelsTitlesAndDescriptions = this.llmExecutionTools
|
|
3211
3229
|
.map(({ title, description }, index) => {
|
|
@@ -3291,7 +3309,7 @@ class MultipleLlmExecutionTools {
|
|
|
3291
3309
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
3292
3310
|
// <- case [🤖]:
|
|
3293
3311
|
default:
|
|
3294
|
-
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
3312
|
+
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
|
|
3295
3313
|
}
|
|
3296
3314
|
}
|
|
3297
3315
|
catch (error) {
|
|
@@ -3312,7 +3330,7 @@ class MultipleLlmExecutionTools {
|
|
|
3312
3330
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3313
3331
|
// 3) ...
|
|
3314
3332
|
spaceTrim$1((block) => `
|
|
3315
|
-
All execution tools failed:
|
|
3333
|
+
All execution tools of ${this.title} failed:
|
|
3316
3334
|
|
|
3317
3335
|
${block(errors
|
|
3318
3336
|
.map(({ error, llmExecutionTools }, i) => `${i + 1}) **${llmExecutionTools.title}** thrown **${error.name || 'Error'}:** ${error.message}`)
|
|
@@ -3321,11 +3339,11 @@ class MultipleLlmExecutionTools {
|
|
|
3321
3339
|
`));
|
|
3322
3340
|
}
|
|
3323
3341
|
else if (this.llmExecutionTools.length === 0) {
|
|
3324
|
-
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools
|
|
3342
|
+
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
3325
3343
|
}
|
|
3326
3344
|
else {
|
|
3327
3345
|
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
3328
|
-
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}"
|
|
3346
|
+
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
3329
3347
|
|
|
3330
3348
|
Available \`LlmExecutionTools\`:
|
|
3331
3349
|
${block(this.description)}
|
|
@@ -3355,7 +3373,7 @@ class MultipleLlmExecutionTools {
|
|
|
3355
3373
|
*
|
|
3356
3374
|
* @public exported from `@promptbook/core`
|
|
3357
3375
|
*/
|
|
3358
|
-
function joinLlmExecutionTools(...llmExecutionTools) {
|
|
3376
|
+
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
3359
3377
|
if (llmExecutionTools.length === 0) {
|
|
3360
3378
|
const warningMessage = spaceTrim$1(`
|
|
3361
3379
|
You have not provided any \`LlmExecutionTools\`
|
|
@@ -3387,30 +3405,27 @@ function joinLlmExecutionTools(...llmExecutionTools) {
|
|
|
3387
3405
|
};
|
|
3388
3406
|
*/
|
|
3389
3407
|
}
|
|
3390
|
-
return new MultipleLlmExecutionTools(...llmExecutionTools);
|
|
3408
|
+
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
3391
3409
|
}
|
|
3392
3410
|
/**
|
|
3393
3411
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3394
3412
|
*/
|
|
3395
3413
|
|
|
3396
3414
|
/**
|
|
3397
|
-
*
|
|
3398
|
-
*
|
|
3399
|
-
* 1) Any item except array and undefined returns array with that one item (also null)
|
|
3400
|
-
* 2) Undefined returns empty array
|
|
3401
|
-
* 3) Array returns itself
|
|
3415
|
+
* Just returns the given `LlmExecutionTools` or joins multiple into one
|
|
3402
3416
|
*
|
|
3403
|
-
* @
|
|
3417
|
+
* @public exported from `@promptbook/core`
|
|
3404
3418
|
*/
|
|
3405
|
-
function
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
}
|
|
3412
|
-
return [input];
|
|
3419
|
+
function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
3420
|
+
const _llms = arrayableToArray(oneOrMoreLlmExecutionTools);
|
|
3421
|
+
const llmTools = _llms.length === 1
|
|
3422
|
+
? _llms[0]
|
|
3423
|
+
: joinLlmExecutionTools('Multiple LLM Providers joined by `getSingleLlmExecutionTools`', ..._llms);
|
|
3424
|
+
return llmTools;
|
|
3413
3425
|
}
|
|
3426
|
+
/**
|
|
3427
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3428
|
+
*/
|
|
3414
3429
|
|
|
3415
3430
|
/**
|
|
3416
3431
|
* Prepares the persona for the pipeline
|
|
@@ -3429,8 +3444,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3429
3444
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
|
3430
3445
|
tools,
|
|
3431
3446
|
});
|
|
3432
|
-
const
|
|
3433
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
3447
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
3434
3448
|
const availableModels = (await llmTools.listModels())
|
|
3435
3449
|
.filter(({ modelVariant }) => modelVariant === 'CHAT')
|
|
3436
3450
|
.map(({ modelName, modelDescription }) => ({
|
|
@@ -3474,6 +3488,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3474
3488
|
};
|
|
3475
3489
|
}
|
|
3476
3490
|
/**
|
|
3491
|
+
* TODO: [😩] DRY `preparePersona` and `selectBestModelFromAvailable`
|
|
3477
3492
|
* TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
|
|
3478
3493
|
* TODO: [🏢] Check validity of `modelName` in pipeline
|
|
3479
3494
|
* TODO: [🏢] Check validity of `systemMessage` in pipeline
|
|
@@ -4191,9 +4206,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
4191
4206
|
if (tools === undefined || tools.llm === undefined) {
|
|
4192
4207
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
4193
4208
|
}
|
|
4194
|
-
|
|
4195
|
-
const _llms = arrayableToArray(tools.llm);
|
|
4196
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
4209
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
4197
4210
|
const llmToolsWithUsage = countUsage(llmTools);
|
|
4198
4211
|
// <- TODO: [🌯]
|
|
4199
4212
|
/*
|
|
@@ -5336,9 +5349,7 @@ async function executeAttempts(options) {
|
|
|
5336
5349
|
$scriptPipelineExecutionErrors: [],
|
|
5337
5350
|
$failedResults: [], // Track all failed attempts
|
|
5338
5351
|
};
|
|
5339
|
-
|
|
5340
|
-
const _llms = arrayableToArray(tools.llm);
|
|
5341
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
5352
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
5342
5353
|
attempts: for (let attemptIndex = -jokerParameterNames.length; attemptIndex < maxAttempts; attemptIndex++) {
|
|
5343
5354
|
const isJokerAttempt = attemptIndex < 0;
|
|
5344
5355
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
@@ -5858,9 +5869,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5858
5869
|
return ''; // <- Note: Np knowledge present, return empty string
|
|
5859
5870
|
}
|
|
5860
5871
|
try {
|
|
5861
|
-
|
|
5862
|
-
const _llms = arrayableToArray(tools.llm);
|
|
5863
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
5872
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
5864
5873
|
const taskEmbeddingPrompt = {
|
|
5865
5874
|
title: 'Knowledge Search',
|
|
5866
5875
|
modelRequirements: {
|
|
@@ -6461,13 +6470,13 @@ function createPipelineExecutor(options) {
|
|
|
6461
6470
|
// Calculate and update tldr based on pipeline progress
|
|
6462
6471
|
const cv = newOngoingResult;
|
|
6463
6472
|
// Calculate progress based on parameters resolved vs total parameters
|
|
6464
|
-
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6473
|
+
const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
|
|
6465
6474
|
let resolvedParameters = 0;
|
|
6466
6475
|
let currentTaskTitle = '';
|
|
6467
6476
|
// Get the resolved parameters from output parameters
|
|
6468
6477
|
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6469
6478
|
// Count how many output parameters have non-empty values
|
|
6470
|
-
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6479
|
+
resolvedParameters = Object.values(cv.outputParameters).filter((value) => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6471
6480
|
}
|
|
6472
6481
|
// Try to determine current task from execution report
|
|
6473
6482
|
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
@@ -6577,9 +6586,7 @@ class MarkdownScraper {
|
|
|
6577
6586
|
throw new MissingToolsError('LLM tools are required for scraping external files');
|
|
6578
6587
|
// <- Note: This scraper is used in all other scrapers, so saying "external files" not "markdown files"
|
|
6579
6588
|
}
|
|
6580
|
-
|
|
6581
|
-
const _llms = arrayableToArray(llm);
|
|
6582
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
6589
|
+
const llmTools = getSingleLlmExecutionTools(llm);
|
|
6583
6590
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
6584
6591
|
const collection = createCollectionFromJson(...PipelineCollection);
|
|
6585
6592
|
const prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
|