@promptbook/node 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 +46 -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 +46 -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
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
28
28
|
* @generated
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
30
30
|
*/
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-19';
|
32
32
|
/**
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
@@ -3010,6 +3010,25 @@ function mapAvailableToExpectedParameters(options) {
|
|
3010
3010
|
return mappedParameters;
|
3011
3011
|
}
|
3012
3012
|
|
3013
|
+
/**
|
3014
|
+
* Takes an item or an array of items and returns an array of items
|
3015
|
+
*
|
3016
|
+
* 1) Any item except array and undefined returns array with that one item (also null)
|
3017
|
+
* 2) Undefined returns empty array
|
3018
|
+
* 3) Array returns itself
|
3019
|
+
*
|
3020
|
+
* @private internal utility
|
3021
|
+
*/
|
3022
|
+
function arrayableToArray(input) {
|
3023
|
+
if (input === undefined) {
|
3024
|
+
return [];
|
3025
|
+
}
|
3026
|
+
if (input instanceof Array) {
|
3027
|
+
return input;
|
3028
|
+
}
|
3029
|
+
return [input];
|
3030
|
+
}
|
3031
|
+
|
3013
3032
|
/**
|
3014
3033
|
* Predefined profiles for LLM providers to maintain consistency across the application
|
3015
3034
|
* These profiles represent each provider as a virtual persona in chat interfaces
|
@@ -3090,12 +3109,10 @@ class MultipleLlmExecutionTools {
|
|
3090
3109
|
/**
|
3091
3110
|
* Gets array of execution tools in order of priority
|
3092
3111
|
*/
|
3093
|
-
constructor(...llmExecutionTools) {
|
3112
|
+
constructor(title, ...llmExecutionTools) {
|
3113
|
+
this.title = title;
|
3094
3114
|
this.llmExecutionTools = llmExecutionTools;
|
3095
3115
|
}
|
3096
|
-
get title() {
|
3097
|
-
return 'Multiple LLM Providers';
|
3098
|
-
}
|
3099
3116
|
get description() {
|
3100
3117
|
const innerModelsTitlesAndDescriptions = this.llmExecutionTools
|
3101
3118
|
.map(({ title, description }, index) => {
|
@@ -3181,7 +3198,7 @@ class MultipleLlmExecutionTools {
|
|
3181
3198
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
3182
3199
|
// <- case [🤖]:
|
3183
3200
|
default:
|
3184
|
-
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
3201
|
+
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
|
3185
3202
|
}
|
3186
3203
|
}
|
3187
3204
|
catch (error) {
|
@@ -3202,7 +3219,7 @@ class MultipleLlmExecutionTools {
|
|
3202
3219
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
3203
3220
|
// 3) ...
|
3204
3221
|
spaceTrim((block) => `
|
3205
|
-
All execution tools failed:
|
3222
|
+
All execution tools of ${this.title} failed:
|
3206
3223
|
|
3207
3224
|
${block(errors
|
3208
3225
|
.map(({ error, llmExecutionTools }, i) => `${i + 1}) **${llmExecutionTools.title}** thrown **${error.name || 'Error'}:** ${error.message}`)
|
@@ -3211,11 +3228,11 @@ class MultipleLlmExecutionTools {
|
|
3211
3228
|
`));
|
3212
3229
|
}
|
3213
3230
|
else if (this.llmExecutionTools.length === 0) {
|
3214
|
-
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools
|
3231
|
+
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
3215
3232
|
}
|
3216
3233
|
else {
|
3217
3234
|
throw new PipelineExecutionError(spaceTrim((block) => `
|
3218
|
-
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}"
|
3235
|
+
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
3219
3236
|
|
3220
3237
|
Available \`LlmExecutionTools\`:
|
3221
3238
|
${block(this.description)}
|
@@ -3245,7 +3262,7 @@ class MultipleLlmExecutionTools {
|
|
3245
3262
|
*
|
3246
3263
|
* @public exported from `@promptbook/core`
|
3247
3264
|
*/
|
3248
|
-
function joinLlmExecutionTools(...llmExecutionTools) {
|
3265
|
+
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
3249
3266
|
if (llmExecutionTools.length === 0) {
|
3250
3267
|
const warningMessage = spaceTrim(`
|
3251
3268
|
You have not provided any \`LlmExecutionTools\`
|
@@ -3277,30 +3294,27 @@ function joinLlmExecutionTools(...llmExecutionTools) {
|
|
3277
3294
|
};
|
3278
3295
|
*/
|
3279
3296
|
}
|
3280
|
-
return new MultipleLlmExecutionTools(...llmExecutionTools);
|
3297
|
+
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
3281
3298
|
}
|
3282
3299
|
/**
|
3283
3300
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
3284
3301
|
*/
|
3285
3302
|
|
3286
3303
|
/**
|
3287
|
-
*
|
3288
|
-
*
|
3289
|
-
* 1) Any item except array and undefined returns array with that one item (also null)
|
3290
|
-
* 2) Undefined returns empty array
|
3291
|
-
* 3) Array returns itself
|
3304
|
+
* Just returns the given `LlmExecutionTools` or joins multiple into one
|
3292
3305
|
*
|
3293
|
-
* @
|
3306
|
+
* @public exported from `@promptbook/core`
|
3294
3307
|
*/
|
3295
|
-
function
|
3296
|
-
|
3297
|
-
|
3298
|
-
|
3299
|
-
|
3300
|
-
|
3301
|
-
}
|
3302
|
-
return [input];
|
3308
|
+
function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
3309
|
+
const _llms = arrayableToArray(oneOrMoreLlmExecutionTools);
|
3310
|
+
const llmTools = _llms.length === 1
|
3311
|
+
? _llms[0]
|
3312
|
+
: joinLlmExecutionTools('Multiple LLM Providers joined by `getSingleLlmExecutionTools`', ..._llms);
|
3313
|
+
return llmTools;
|
3303
3314
|
}
|
3315
|
+
/**
|
3316
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
3317
|
+
*/
|
3304
3318
|
|
3305
3319
|
/**
|
3306
3320
|
* Just says that the variable is not used but should be kept
|
@@ -4003,9 +4017,7 @@ async function executeAttempts(options) {
|
|
4003
4017
|
$scriptPipelineExecutionErrors: [],
|
4004
4018
|
$failedResults: [], // Track all failed attempts
|
4005
4019
|
};
|
4006
|
-
|
4007
|
-
const _llms = arrayableToArray(tools.llm);
|
4008
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
4020
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
4009
4021
|
attempts: for (let attemptIndex = -jokerParameterNames.length; attemptIndex < maxAttempts; attemptIndex++) {
|
4010
4022
|
const isJokerAttempt = attemptIndex < 0;
|
4011
4023
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
@@ -4525,9 +4537,7 @@ async function getKnowledgeForTask(options) {
|
|
4525
4537
|
return ''; // <- Note: Np knowledge present, return empty string
|
4526
4538
|
}
|
4527
4539
|
try {
|
4528
|
-
|
4529
|
-
const _llms = arrayableToArray(tools.llm);
|
4530
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
4540
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
4531
4541
|
const taskEmbeddingPrompt = {
|
4532
4542
|
title: 'Knowledge Search',
|
4533
4543
|
modelRequirements: {
|
@@ -5307,8 +5317,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
5307
5317
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
5308
5318
|
tools,
|
5309
5319
|
});
|
5310
|
-
const
|
5311
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
5320
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
5312
5321
|
const availableModels = (await llmTools.listModels())
|
5313
5322
|
.filter(({ modelVariant }) => modelVariant === 'CHAT')
|
5314
5323
|
.map(({ modelName, modelDescription }) => ({
|
@@ -6208,9 +6217,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
6208
6217
|
if (tools === undefined || tools.llm === undefined) {
|
6209
6218
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
6210
6219
|
}
|
6211
|
-
|
6212
|
-
const _llms = arrayableToArray(tools.llm);
|
6213
|
-
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
6220
|
+
const llmTools = getSingleLlmExecutionTools(tools.llm);
|
6214
6221
|
const llmToolsWithUsage = countUsage(llmTools);
|
6215
6222
|
// <- TODO: [🌯]
|
6216
6223
|
/*
|
@@ -10565,7 +10572,7 @@ const $isRunningInWebWorker = new Function(`
|
|
10565
10572
|
* @public exported from `@promptbook/core`
|
10566
10573
|
*/
|
10567
10574
|
function createLlmToolsFromConfiguration(configuration, options = {}) {
|
10568
|
-
const { isVerbose = DEFAULT_IS_VERBOSE, userId } = options;
|
10575
|
+
const { title = 'LLM Tools from Configuration', isVerbose = DEFAULT_IS_VERBOSE, userId } = options;
|
10569
10576
|
const llmTools = configuration.map((llmConfiguration) => {
|
10570
10577
|
const registeredItem = $llmToolsRegister
|
10571
10578
|
.list()
|
@@ -10597,7 +10604,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
|
|
10597
10604
|
...llmConfiguration.options,
|
10598
10605
|
});
|
10599
10606
|
});
|
10600
|
-
return joinLlmExecutionTools(...llmTools);
|
10607
|
+
return joinLlmExecutionTools(title, ...llmTools);
|
10601
10608
|
}
|
10602
10609
|
/**
|
10603
10610
|
* TODO: [🎌] Together with `createLlmToolsFromConfiguration` + 'EXECUTION_TOOLS_CLASSES' gets to `@promptbook/core` ALL model providers, make this more efficient
|
@@ -11197,7 +11204,7 @@ async function $provideExecutionToolsForNode(options) {
|
|
11197
11204
|
throw new EnvironmentMismatchError('Function `$getExecutionToolsForNode` works only in Node.js environment');
|
11198
11205
|
}
|
11199
11206
|
const fs = $provideFilesystemForNode();
|
11200
|
-
const llm = await $provideLlmToolsFromEnv(options);
|
11207
|
+
const llm = await $provideLlmToolsFromEnv({ title: 'LLM Tools for Node.js', ...options });
|
11201
11208
|
const executables = await $provideExecutablesForNode();
|
11202
11209
|
const tools = {
|
11203
11210
|
llm,
|