@promptbook/legacy-documents 0.92.0-31 β 0.92.0-33
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 +36 -26
- package/esm/index.es.js.map +1 -1
- 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/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +6 -0
- 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 +36 -26
- package/umd/index.umd.js.map +1 -1
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-33';
|
|
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
|
}
|
|
@@ -3004,23 +3016,17 @@ class MultipleLlmExecutionTools {
|
|
|
3004
3016
|
* Check the configuration of all execution tools
|
|
3005
3017
|
*/
|
|
3006
3018
|
async checkConfiguration() {
|
|
3007
|
-
//
|
|
3008
|
-
|
|
3009
|
-
await llmExecutionTools.checkConfiguration();
|
|
3010
|
-
}
|
|
3019
|
+
// Note: Run checks in parallel
|
|
3020
|
+
await Promise.all(this.llmExecutionTools.map((tools) => tools.checkConfiguration()));
|
|
3011
3021
|
}
|
|
3012
3022
|
/**
|
|
3013
3023
|
* List all available models that can be used
|
|
3014
3024
|
* This lists is a combination of all available models from all execution tools
|
|
3015
3025
|
*/
|
|
3016
3026
|
async listModels() {
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
const models = await llmExecutionTools.listModels();
|
|
3021
|
-
availableModels.push(...models);
|
|
3022
|
-
}
|
|
3023
|
-
return availableModels;
|
|
3027
|
+
// Obtain all models in parallel and flatten
|
|
3028
|
+
const modelArrays = await Promise.all(this.llmExecutionTools.map((tools) => tools.listModels()));
|
|
3029
|
+
return modelArrays.flat();
|
|
3024
3030
|
}
|
|
3025
3031
|
/**
|
|
3026
3032
|
* Calls the best available chat model
|
|
@@ -5521,7 +5527,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5521
5527
|
});
|
|
5522
5528
|
const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
|
|
5523
5529
|
const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
|
|
5524
|
-
console.log('!!! Embedding', {
|
|
5530
|
+
console.log('!!! `getKnowledgeForTask` Embedding', {
|
|
5525
5531
|
task,
|
|
5526
5532
|
taskEmbeddingPrompt,
|
|
5527
5533
|
taskEmbeddingResult,
|
|
@@ -5557,6 +5563,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5557
5563
|
*/
|
|
5558
5564
|
async function getReservedParametersForTask(options) {
|
|
5559
5565
|
const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
|
|
5566
|
+
console.log('!!! getReservedParametersForTask', options);
|
|
5560
5567
|
const context = await getContextForTask(); // <- [π]
|
|
5561
5568
|
const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
|
|
5562
5569
|
const examples = await getExamplesForTask();
|
|
@@ -5593,6 +5600,7 @@ async function getReservedParametersForTask(options) {
|
|
|
5593
5600
|
*/
|
|
5594
5601
|
async function executeTask(options) {
|
|
5595
5602
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5603
|
+
console.log('!!! executeTask', options);
|
|
5596
5604
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5597
5605
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
5598
5606
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
@@ -5616,14 +5624,15 @@ async function executeTask(options) {
|
|
|
5616
5624
|
|
|
5617
5625
|
`));
|
|
5618
5626
|
}
|
|
5627
|
+
const reservedParameters = await getReservedParametersForTask({
|
|
5628
|
+
tools,
|
|
5629
|
+
preparedPipeline,
|
|
5630
|
+
task: currentTask,
|
|
5631
|
+
pipelineIdentification,
|
|
5632
|
+
parameters: parametersToPass,
|
|
5633
|
+
});
|
|
5619
5634
|
const definedParameters = Object.freeze({
|
|
5620
|
-
...
|
|
5621
|
-
tools,
|
|
5622
|
-
preparedPipeline,
|
|
5623
|
-
task: currentTask,
|
|
5624
|
-
pipelineIdentification,
|
|
5625
|
-
parameters: parametersToPass,
|
|
5626
|
-
})),
|
|
5635
|
+
...reservedParameters,
|
|
5627
5636
|
...parametersToPass,
|
|
5628
5637
|
});
|
|
5629
5638
|
const definedParameterNames = new Set(Object.keys(definedParameters));
|
|
@@ -6070,6 +6079,7 @@ function createPipelineExecutor(options) {
|
|
|
6070
6079
|
};
|
|
6071
6080
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
6072
6081
|
taskType: 'EXECUTION',
|
|
6082
|
+
title: pipeline.title,
|
|
6073
6083
|
taskProcessCallback(updateOngoingResult) {
|
|
6074
6084
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6075
6085
|
updateOngoingResult(newOngoingResult);
|