@promptbook/pdf 0.101.0-18 → 0.101.0-19
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 +44 -39
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/MockedChat.d.ts +7 -1
- 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/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/_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/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/scrapers/markdown/MarkdownScraper.d.ts +1 -2
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +44 -39
- package/umd/index.umd.js.map +1 -1
- 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-19';
|
|
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
|
|
@@ -2960,6 +2960,25 @@ function countUsage(llmTools) {
|
|
|
2960
2960
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2961
2961
|
*/
|
|
2962
2962
|
|
|
2963
|
+
/**
|
|
2964
|
+
* Takes an item or an array of items and returns an array of items
|
|
2965
|
+
*
|
|
2966
|
+
* 1) Any item except array and undefined returns array with that one item (also null)
|
|
2967
|
+
* 2) Undefined returns empty array
|
|
2968
|
+
* 3) Array returns itself
|
|
2969
|
+
*
|
|
2970
|
+
* @private internal utility
|
|
2971
|
+
*/
|
|
2972
|
+
function arrayableToArray(input) {
|
|
2973
|
+
if (input === undefined) {
|
|
2974
|
+
return [];
|
|
2975
|
+
}
|
|
2976
|
+
if (input instanceof Array) {
|
|
2977
|
+
return input;
|
|
2978
|
+
}
|
|
2979
|
+
return [input];
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2963
2982
|
/**
|
|
2964
2983
|
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
2965
2984
|
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
@@ -3040,12 +3059,10 @@ class MultipleLlmExecutionTools {
|
|
|
3040
3059
|
/**
|
|
3041
3060
|
* Gets array of execution tools in order of priority
|
|
3042
3061
|
*/
|
|
3043
|
-
constructor(...llmExecutionTools) {
|
|
3062
|
+
constructor(title, ...llmExecutionTools) {
|
|
3063
|
+
this.title = title;
|
|
3044
3064
|
this.llmExecutionTools = llmExecutionTools;
|
|
3045
3065
|
}
|
|
3046
|
-
get title() {
|
|
3047
|
-
return 'Multiple LLM Providers';
|
|
3048
|
-
}
|
|
3049
3066
|
get description() {
|
|
3050
3067
|
const innerModelsTitlesAndDescriptions = this.llmExecutionTools
|
|
3051
3068
|
.map(({ title, description }, index) => {
|
|
@@ -3131,7 +3148,7 @@ class MultipleLlmExecutionTools {
|
|
|
3131
3148
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
3132
3149
|
// <- case [🤖]:
|
|
3133
3150
|
default:
|
|
3134
|
-
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
3151
|
+
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
|
|
3135
3152
|
}
|
|
3136
3153
|
}
|
|
3137
3154
|
catch (error) {
|
|
@@ -3152,7 +3169,7 @@ class MultipleLlmExecutionTools {
|
|
|
3152
3169
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3153
3170
|
// 3) ...
|
|
3154
3171
|
spaceTrim((block) => `
|
|
3155
|
-
All execution tools failed:
|
|
3172
|
+
All execution tools of ${this.title} failed:
|
|
3156
3173
|
|
|
3157
3174
|
${block(errors
|
|
3158
3175
|
.map(({ error, llmExecutionTools }, i) => `${i + 1}) **${llmExecutionTools.title}** thrown **${error.name || 'Error'}:** ${error.message}`)
|
|
@@ -3161,11 +3178,11 @@ class MultipleLlmExecutionTools {
|
|
|
3161
3178
|
`));
|
|
3162
3179
|
}
|
|
3163
3180
|
else if (this.llmExecutionTools.length === 0) {
|
|
3164
|
-
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools
|
|
3181
|
+
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
3165
3182
|
}
|
|
3166
3183
|
else {
|
|
3167
3184
|
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3168
|
-
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}"
|
|
3185
|
+
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
3169
3186
|
|
|
3170
3187
|
Available \`LlmExecutionTools\`:
|
|
3171
3188
|
${block(this.description)}
|
|
@@ -3195,7 +3212,7 @@ class MultipleLlmExecutionTools {
|
|
|
3195
3212
|
*
|
|
3196
3213
|
* @public exported from `@promptbook/core`
|
|
3197
3214
|
*/
|
|
3198
|
-
function joinLlmExecutionTools(...llmExecutionTools) {
|
|
3215
|
+
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
3199
3216
|
if (llmExecutionTools.length === 0) {
|
|
3200
3217
|
const warningMessage = spaceTrim(`
|
|
3201
3218
|
You have not provided any \`LlmExecutionTools\`
|
|
@@ -3227,30 +3244,27 @@ function joinLlmExecutionTools(...llmExecutionTools) {
|
|
|
3227
3244
|
};
|
|
3228
3245
|
*/
|
|
3229
3246
|
}
|
|
3230
|
-
return new MultipleLlmExecutionTools(...llmExecutionTools);
|
|
3247
|
+
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
3231
3248
|
}
|
|
3232
3249
|
/**
|
|
3233
3250
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3234
3251
|
*/
|
|
3235
3252
|
|
|
3236
3253
|
/**
|
|
3237
|
-
*
|
|
3238
|
-
*
|
|
3239
|
-
* 1) Any item except array and undefined returns array with that one item (also null)
|
|
3240
|
-
* 2) Undefined returns empty array
|
|
3241
|
-
* 3) Array returns itself
|
|
3254
|
+
* Just returns the given `LlmExecutionTools` or joins multiple into one
|
|
3242
3255
|
*
|
|
3243
|
-
* @
|
|
3256
|
+
* @public exported from `@promptbook/core`
|
|
3244
3257
|
*/
|
|
3245
|
-
function
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
}
|
|
3252
|
-
return [input];
|
|
3258
|
+
function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
3259
|
+
const _llms = arrayableToArray(oneOrMoreLlmExecutionTools);
|
|
3260
|
+
const llmTools = _llms.length === 1
|
|
3261
|
+
? _llms[0]
|
|
3262
|
+
: joinLlmExecutionTools('Multiple LLM Providers joined by `getSingleLlmExecutionTools`', ..._llms);
|
|
3263
|
+
return llmTools;
|
|
3253
3264
|
}
|
|
3265
|
+
/**
|
|
3266
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3267
|
+
*/
|
|
3254
3268
|
|
|
3255
3269
|
/**
|
|
3256
3270
|
* Prepares the persona for the pipeline
|
|
@@ -3269,8 +3283,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3269
3283
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
|
3270
3284
|
tools,
|
|
3271
3285
|
});
|
|
3272
|
-
const
|
|
3273
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
3286
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
3274
3287
|
const availableModels = (await llmTools.listModels())
|
|
3275
3288
|
.filter(({ modelVariant }) => modelVariant === 'CHAT')
|
|
3276
3289
|
.map(({ modelName, modelDescription }) => ({
|
|
@@ -4042,9 +4055,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
4042
4055
|
if (tools === undefined || tools.llm === undefined) {
|
|
4043
4056
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
4044
4057
|
}
|
|
4045
|
-
|
|
4046
|
-
const _llms = arrayableToArray(tools.llm);
|
|
4047
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
4058
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
4048
4059
|
const llmToolsWithUsage = countUsage(llmTools);
|
|
4049
4060
|
// <- TODO: [🌯]
|
|
4050
4061
|
/*
|
|
@@ -5187,9 +5198,7 @@ async function executeAttempts(options) {
|
|
|
5187
5198
|
$scriptPipelineExecutionErrors: [],
|
|
5188
5199
|
$failedResults: [], // Track all failed attempts
|
|
5189
5200
|
};
|
|
5190
|
-
|
|
5191
|
-
const _llms = arrayableToArray(tools.llm);
|
|
5192
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
5201
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
5193
5202
|
attempts: for (let attemptIndex = -jokerParameterNames.length; attemptIndex < maxAttempts; attemptIndex++) {
|
|
5194
5203
|
const isJokerAttempt = attemptIndex < 0;
|
|
5195
5204
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
@@ -5709,9 +5718,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5709
5718
|
return ''; // <- Note: Np knowledge present, return empty string
|
|
5710
5719
|
}
|
|
5711
5720
|
try {
|
|
5712
|
-
|
|
5713
|
-
const _llms = arrayableToArray(tools.llm);
|
|
5714
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
5721
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
|
5715
5722
|
const taskEmbeddingPrompt = {
|
|
5716
5723
|
title: 'Knowledge Search',
|
|
5717
5724
|
modelRequirements: {
|
|
@@ -6428,9 +6435,7 @@ class MarkdownScraper {
|
|
|
6428
6435
|
throw new MissingToolsError('LLM tools are required for scraping external files');
|
|
6429
6436
|
// <- Note: This scraper is used in all other scrapers, so saying "external files" not "markdown files"
|
|
6430
6437
|
}
|
|
6431
|
-
|
|
6432
|
-
const _llms = arrayableToArray(llm);
|
|
6433
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
6438
|
+
const llmTools = getSingleLlmExecutionTools(llm);
|
|
6434
6439
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
6435
6440
|
const collection = createCollectionFromJson(...PipelineCollection);
|
|
6436
6441
|
const prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
|