@promptbook/markdown-utils 0.92.0-32 → 0.92.0-34
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 +52 -20
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -4
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +19 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +1 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +4 -4
- package/esm/typings/src/storage/local-storage/getIndexedDbStorage.d.ts +2 -1
- package/esm/typings/src/storage/local-storage/utils/IndexedDbStorageOptions.d.ts +14 -0
- package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.d.ts +2 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +52 -20
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/llm-providers/{multiple → _multiple}/MultipleLlmExecutionTools.d.ts +0 -0
- /package/esm/typings/src/llm-providers/{multiple → _multiple}/joinLlmExecutionTools.d.ts +0 -0
- /package/esm/typings/src/llm-providers/{multiple → _multiple}/playground/playground.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -25,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-34';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2200,6 +2200,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2200
2200
|
*/
|
|
2201
2201
|
function createTask(options) {
|
|
2202
2202
|
const { taskType, taskProcessCallback } = options;
|
|
2203
|
+
let { title } = options;
|
|
2203
2204
|
// TODO: [🐙] DRY
|
|
2204
2205
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2205
2206
|
let status = 'RUNNING';
|
|
@@ -2211,6 +2212,10 @@ function createTask(options) {
|
|
|
2211
2212
|
const partialResultSubject = new Subject();
|
|
2212
2213
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2213
2214
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2215
|
+
if (newOngoingResult.title) {
|
|
2216
|
+
title = newOngoingResult.title;
|
|
2217
|
+
}
|
|
2218
|
+
updatedAt = new Date();
|
|
2214
2219
|
Object.assign(currentValue, newOngoingResult);
|
|
2215
2220
|
// <- TODO: assign deep
|
|
2216
2221
|
partialResultSubject.next(newOngoingResult);
|
|
@@ -2256,17 +2261,24 @@ function createTask(options) {
|
|
|
2256
2261
|
return {
|
|
2257
2262
|
taskType,
|
|
2258
2263
|
taskId,
|
|
2264
|
+
get promptbookVersion() {
|
|
2265
|
+
return PROMPTBOOK_ENGINE_VERSION;
|
|
2266
|
+
},
|
|
2267
|
+
get title() {
|
|
2268
|
+
return title;
|
|
2269
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2270
|
+
},
|
|
2259
2271
|
get status() {
|
|
2260
2272
|
return status;
|
|
2261
|
-
// <- Note: [1]
|
|
2273
|
+
// <- Note: [1] --||--
|
|
2262
2274
|
},
|
|
2263
2275
|
get createdAt() {
|
|
2264
2276
|
return createdAt;
|
|
2265
|
-
// <- Note: [1]
|
|
2277
|
+
// <- Note: [1] --||--
|
|
2266
2278
|
},
|
|
2267
2279
|
get updatedAt() {
|
|
2268
2280
|
return updatedAt;
|
|
2269
|
-
// <- Note: [1]
|
|
2281
|
+
// <- Note: [1] --||--
|
|
2270
2282
|
},
|
|
2271
2283
|
asPromise,
|
|
2272
2284
|
asObservable() {
|
|
@@ -2274,15 +2286,15 @@ function createTask(options) {
|
|
|
2274
2286
|
},
|
|
2275
2287
|
get errors() {
|
|
2276
2288
|
return errors;
|
|
2277
|
-
// <- Note: [1]
|
|
2289
|
+
// <- Note: [1] --||--
|
|
2278
2290
|
},
|
|
2279
2291
|
get warnings() {
|
|
2280
2292
|
return warnings;
|
|
2281
|
-
// <- Note: [1]
|
|
2293
|
+
// <- Note: [1] --||--
|
|
2282
2294
|
},
|
|
2283
2295
|
get currentValue() {
|
|
2284
2296
|
return currentValue;
|
|
2285
|
-
// <- Note: [1]
|
|
2297
|
+
// <- Note: [1] --||--
|
|
2286
2298
|
},
|
|
2287
2299
|
};
|
|
2288
2300
|
}
|
|
@@ -2447,12 +2459,14 @@ function countUsage(llmTools) {
|
|
|
2447
2459
|
const spending = new Subject();
|
|
2448
2460
|
const proxyTools = {
|
|
2449
2461
|
get title() {
|
|
2450
|
-
|
|
2451
|
-
|
|
2462
|
+
return `${llmTools.title} (+usage)`;
|
|
2463
|
+
// <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
|
|
2464
|
+
// <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
|
|
2452
2465
|
},
|
|
2453
2466
|
get description() {
|
|
2454
|
-
|
|
2455
|
-
|
|
2467
|
+
return `${llmTools.description} (+usage)`;
|
|
2468
|
+
// <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
|
|
2469
|
+
// <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
|
|
2456
2470
|
},
|
|
2457
2471
|
checkConfiguration() {
|
|
2458
2472
|
return /* not await */ llmTools.checkConfiguration();
|
|
@@ -2523,7 +2537,14 @@ class MultipleLlmExecutionTools {
|
|
|
2523
2537
|
return 'Multiple LLM Providers';
|
|
2524
2538
|
}
|
|
2525
2539
|
get description() {
|
|
2526
|
-
|
|
2540
|
+
const innerModelsTitlesAndDescriptions = this.llmExecutionTools
|
|
2541
|
+
.map(({ title, description }, index) => `${index + 1}) \`${title}\`\n${description}`)
|
|
2542
|
+
.join('\n\n');
|
|
2543
|
+
return spaceTrim((block) => `
|
|
2544
|
+
Multiple LLM Providers:
|
|
2545
|
+
|
|
2546
|
+
${block(innerModelsTitlesAndDescriptions)}
|
|
2547
|
+
`);
|
|
2527
2548
|
}
|
|
2528
2549
|
/**
|
|
2529
2550
|
* Check the configuration of all execution tools
|
|
@@ -5297,6 +5318,7 @@ function knowledgePiecesToString(knowledgePieces) {
|
|
|
5297
5318
|
*/
|
|
5298
5319
|
async function getKnowledgeForTask(options) {
|
|
5299
5320
|
const { tools, preparedPipeline, task, parameters } = options;
|
|
5321
|
+
console.log('!!! getKnowledgeForTask', options);
|
|
5300
5322
|
const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
|
|
5301
5323
|
const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
|
|
5302
5324
|
// <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
|
|
@@ -5335,7 +5357,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5335
5357
|
});
|
|
5336
5358
|
const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
|
|
5337
5359
|
const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
|
|
5338
|
-
console.log('!!! Embedding', {
|
|
5360
|
+
console.log('!!! `getKnowledgeForTask` Embedding', {
|
|
5339
5361
|
task,
|
|
5340
5362
|
taskEmbeddingPrompt,
|
|
5341
5363
|
taskEmbeddingResult,
|
|
@@ -5371,6 +5393,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5371
5393
|
*/
|
|
5372
5394
|
async function getReservedParametersForTask(options) {
|
|
5373
5395
|
const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
|
|
5396
|
+
console.log('!!! getReservedParametersForTask', options);
|
|
5374
5397
|
const context = await getContextForTask(); // <- [🏍]
|
|
5375
5398
|
const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
|
|
5376
5399
|
const examples = await getExamplesForTask();
|
|
@@ -5407,6 +5430,7 @@ async function getReservedParametersForTask(options) {
|
|
|
5407
5430
|
*/
|
|
5408
5431
|
async function executeTask(options) {
|
|
5409
5432
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5433
|
+
console.log('!!! executeTask', options);
|
|
5410
5434
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5411
5435
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
|
|
5412
5436
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
@@ -5430,14 +5454,15 @@ async function executeTask(options) {
|
|
|
5430
5454
|
|
|
5431
5455
|
`));
|
|
5432
5456
|
}
|
|
5457
|
+
const reservedParameters = await getReservedParametersForTask({
|
|
5458
|
+
tools,
|
|
5459
|
+
preparedPipeline,
|
|
5460
|
+
task: currentTask,
|
|
5461
|
+
pipelineIdentification,
|
|
5462
|
+
parameters: parametersToPass,
|
|
5463
|
+
});
|
|
5433
5464
|
const definedParameters = Object.freeze({
|
|
5434
|
-
...
|
|
5435
|
-
tools,
|
|
5436
|
-
preparedPipeline,
|
|
5437
|
-
task: currentTask,
|
|
5438
|
-
pipelineIdentification,
|
|
5439
|
-
parameters: parametersToPass,
|
|
5440
|
-
})),
|
|
5465
|
+
...reservedParameters,
|
|
5441
5466
|
...parametersToPass,
|
|
5442
5467
|
});
|
|
5443
5468
|
const definedParameterNames = new Set(Object.keys(definedParameters));
|
|
@@ -5884,6 +5909,7 @@ function createPipelineExecutor(options) {
|
|
|
5884
5909
|
};
|
|
5885
5910
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
5886
5911
|
taskType: 'EXECUTION',
|
|
5912
|
+
title: pipeline.title,
|
|
5887
5913
|
taskProcessCallback(updateOngoingResult) {
|
|
5888
5914
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
5889
5915
|
updateOngoingResult(newOngoingResult);
|
|
@@ -6014,6 +6040,12 @@ class MarkdownScraper {
|
|
|
6014
6040
|
}
|
|
6015
6041
|
// ---
|
|
6016
6042
|
if (!llmTools.callEmbeddingModel) {
|
|
6043
|
+
console.log('!!! No callEmbeddingModel function provided', {
|
|
6044
|
+
'llmTools.title': llmTools.title,
|
|
6045
|
+
'llmTools.description': llmTools.description,
|
|
6046
|
+
'llmTools.callEmbeddingModel': llmTools.callEmbeddingModel,
|
|
6047
|
+
llmTools,
|
|
6048
|
+
});
|
|
6017
6049
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
6018
6050
|
console.error('No callEmbeddingModel function provided');
|
|
6019
6051
|
}
|