@promptbook/legacy-documents 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 +2 -2
- 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
|
@@ -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.92.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-34';
|
|
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
|
|
@@ -2675,6 +2675,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2675
2675
|
*/
|
|
2676
2676
|
function createTask(options) {
|
|
2677
2677
|
const { taskType, taskProcessCallback } = options;
|
|
2678
|
+
let { title } = options;
|
|
2678
2679
|
// TODO: [🐙] DRY
|
|
2679
2680
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2680
2681
|
let status = 'RUNNING';
|
|
@@ -2686,6 +2687,10 @@ function createTask(options) {
|
|
|
2686
2687
|
const partialResultSubject = new Subject();
|
|
2687
2688
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2688
2689
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2690
|
+
if (newOngoingResult.title) {
|
|
2691
|
+
title = newOngoingResult.title;
|
|
2692
|
+
}
|
|
2693
|
+
updatedAt = new Date();
|
|
2689
2694
|
Object.assign(currentValue, newOngoingResult);
|
|
2690
2695
|
// <- TODO: assign deep
|
|
2691
2696
|
partialResultSubject.next(newOngoingResult);
|
|
@@ -2731,17 +2736,24 @@ function createTask(options) {
|
|
|
2731
2736
|
return {
|
|
2732
2737
|
taskType,
|
|
2733
2738
|
taskId,
|
|
2739
|
+
get promptbookVersion() {
|
|
2740
|
+
return PROMPTBOOK_ENGINE_VERSION;
|
|
2741
|
+
},
|
|
2742
|
+
get title() {
|
|
2743
|
+
return title;
|
|
2744
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2745
|
+
},
|
|
2734
2746
|
get status() {
|
|
2735
2747
|
return status;
|
|
2736
|
-
// <- Note: [1]
|
|
2748
|
+
// <- Note: [1] --||--
|
|
2737
2749
|
},
|
|
2738
2750
|
get createdAt() {
|
|
2739
2751
|
return createdAt;
|
|
2740
|
-
// <- Note: [1]
|
|
2752
|
+
// <- Note: [1] --||--
|
|
2741
2753
|
},
|
|
2742
2754
|
get updatedAt() {
|
|
2743
2755
|
return updatedAt;
|
|
2744
|
-
// <- Note: [1]
|
|
2756
|
+
// <- Note: [1] --||--
|
|
2745
2757
|
},
|
|
2746
2758
|
asPromise,
|
|
2747
2759
|
asObservable() {
|
|
@@ -2749,15 +2761,15 @@ function createTask(options) {
|
|
|
2749
2761
|
},
|
|
2750
2762
|
get errors() {
|
|
2751
2763
|
return errors;
|
|
2752
|
-
// <- Note: [1]
|
|
2764
|
+
// <- Note: [1] --||--
|
|
2753
2765
|
},
|
|
2754
2766
|
get warnings() {
|
|
2755
2767
|
return warnings;
|
|
2756
|
-
// <- Note: [1]
|
|
2768
|
+
// <- Note: [1] --||--
|
|
2757
2769
|
},
|
|
2758
2770
|
get currentValue() {
|
|
2759
2771
|
return currentValue;
|
|
2760
|
-
// <- Note: [1]
|
|
2772
|
+
// <- Note: [1] --||--
|
|
2761
2773
|
},
|
|
2762
2774
|
};
|
|
2763
2775
|
}
|
|
@@ -2922,12 +2934,14 @@ function countUsage(llmTools) {
|
|
|
2922
2934
|
const spending = new Subject();
|
|
2923
2935
|
const proxyTools = {
|
|
2924
2936
|
get title() {
|
|
2925
|
-
|
|
2926
|
-
|
|
2937
|
+
return `${llmTools.title} (+usage)`;
|
|
2938
|
+
// <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
|
|
2939
|
+
// <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
|
|
2927
2940
|
},
|
|
2928
2941
|
get description() {
|
|
2929
|
-
|
|
2930
|
-
|
|
2942
|
+
return `${llmTools.description} (+usage)`;
|
|
2943
|
+
// <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
|
|
2944
|
+
// <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
|
|
2931
2945
|
},
|
|
2932
2946
|
checkConfiguration() {
|
|
2933
2947
|
return /* not await */ llmTools.checkConfiguration();
|
|
@@ -2998,7 +3012,14 @@ class MultipleLlmExecutionTools {
|
|
|
2998
3012
|
return 'Multiple LLM Providers';
|
|
2999
3013
|
}
|
|
3000
3014
|
get description() {
|
|
3001
|
-
|
|
3015
|
+
const innerModelsTitlesAndDescriptions = this.llmExecutionTools
|
|
3016
|
+
.map(({ title, description }, index) => `${index + 1}) \`${title}\`\n${description}`)
|
|
3017
|
+
.join('\n\n');
|
|
3018
|
+
return spaceTrim$1((block) => `
|
|
3019
|
+
Multiple LLM Providers:
|
|
3020
|
+
|
|
3021
|
+
${block(innerModelsTitlesAndDescriptions)}
|
|
3022
|
+
`);
|
|
3002
3023
|
}
|
|
3003
3024
|
/**
|
|
3004
3025
|
* Check the configuration of all execution tools
|
|
@@ -5477,6 +5498,7 @@ function knowledgePiecesToString(knowledgePieces) {
|
|
|
5477
5498
|
*/
|
|
5478
5499
|
async function getKnowledgeForTask(options) {
|
|
5479
5500
|
const { tools, preparedPipeline, task, parameters } = options;
|
|
5501
|
+
console.log('!!! getKnowledgeForTask', options);
|
|
5480
5502
|
const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
|
|
5481
5503
|
const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
|
|
5482
5504
|
// <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
|
|
@@ -5515,7 +5537,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5515
5537
|
});
|
|
5516
5538
|
const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
|
|
5517
5539
|
const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
|
|
5518
|
-
console.log('!!! Embedding', {
|
|
5540
|
+
console.log('!!! `getKnowledgeForTask` Embedding', {
|
|
5519
5541
|
task,
|
|
5520
5542
|
taskEmbeddingPrompt,
|
|
5521
5543
|
taskEmbeddingResult,
|
|
@@ -5551,6 +5573,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5551
5573
|
*/
|
|
5552
5574
|
async function getReservedParametersForTask(options) {
|
|
5553
5575
|
const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
|
|
5576
|
+
console.log('!!! getReservedParametersForTask', options);
|
|
5554
5577
|
const context = await getContextForTask(); // <- [🏍]
|
|
5555
5578
|
const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
|
|
5556
5579
|
const examples = await getExamplesForTask();
|
|
@@ -5587,6 +5610,7 @@ async function getReservedParametersForTask(options) {
|
|
|
5587
5610
|
*/
|
|
5588
5611
|
async function executeTask(options) {
|
|
5589
5612
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5613
|
+
console.log('!!! executeTask', options);
|
|
5590
5614
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5591
5615
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
|
|
5592
5616
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
@@ -5610,14 +5634,15 @@ async function executeTask(options) {
|
|
|
5610
5634
|
|
|
5611
5635
|
`));
|
|
5612
5636
|
}
|
|
5637
|
+
const reservedParameters = await getReservedParametersForTask({
|
|
5638
|
+
tools,
|
|
5639
|
+
preparedPipeline,
|
|
5640
|
+
task: currentTask,
|
|
5641
|
+
pipelineIdentification,
|
|
5642
|
+
parameters: parametersToPass,
|
|
5643
|
+
});
|
|
5613
5644
|
const definedParameters = Object.freeze({
|
|
5614
|
-
...
|
|
5615
|
-
tools,
|
|
5616
|
-
preparedPipeline,
|
|
5617
|
-
task: currentTask,
|
|
5618
|
-
pipelineIdentification,
|
|
5619
|
-
parameters: parametersToPass,
|
|
5620
|
-
})),
|
|
5645
|
+
...reservedParameters,
|
|
5621
5646
|
...parametersToPass,
|
|
5622
5647
|
});
|
|
5623
5648
|
const definedParameterNames = new Set(Object.keys(definedParameters));
|
|
@@ -6064,6 +6089,7 @@ function createPipelineExecutor(options) {
|
|
|
6064
6089
|
};
|
|
6065
6090
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
6066
6091
|
taskType: 'EXECUTION',
|
|
6092
|
+
title: pipeline.title,
|
|
6067
6093
|
taskProcessCallback(updateOngoingResult) {
|
|
6068
6094
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6069
6095
|
updateOngoingResult(newOngoingResult);
|
|
@@ -6194,6 +6220,12 @@ class MarkdownScraper {
|
|
|
6194
6220
|
}
|
|
6195
6221
|
// ---
|
|
6196
6222
|
if (!llmTools.callEmbeddingModel) {
|
|
6223
|
+
console.log('!!! No callEmbeddingModel function provided', {
|
|
6224
|
+
'llmTools.title': llmTools.title,
|
|
6225
|
+
'llmTools.description': llmTools.description,
|
|
6226
|
+
'llmTools.callEmbeddingModel': llmTools.callEmbeddingModel,
|
|
6227
|
+
llmTools,
|
|
6228
|
+
});
|
|
6197
6229
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
6198
6230
|
console.error('No callEmbeddingModel function provided');
|
|
6199
6231
|
}
|