@promptbook/node 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
|
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
30
30
|
* @generated
|
|
31
31
|
* @see https://github.com/webgptorg/promptbook
|
|
32
32
|
*/
|
|
33
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-33';
|
|
34
34
|
/**
|
|
35
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
36
36
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -2086,6 +2086,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2086
2086
|
*/
|
|
2087
2087
|
function createTask(options) {
|
|
2088
2088
|
const { taskType, taskProcessCallback } = options;
|
|
2089
|
+
let { title } = options;
|
|
2089
2090
|
// TODO: [π] DRY
|
|
2090
2091
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2091
2092
|
let status = 'RUNNING';
|
|
@@ -2097,6 +2098,10 @@ function createTask(options) {
|
|
|
2097
2098
|
const partialResultSubject = new Subject();
|
|
2098
2099
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2099
2100
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2101
|
+
if (newOngoingResult.title) {
|
|
2102
|
+
title = newOngoingResult.title;
|
|
2103
|
+
}
|
|
2104
|
+
updatedAt = new Date();
|
|
2100
2105
|
Object.assign(currentValue, newOngoingResult);
|
|
2101
2106
|
// <- TODO: assign deep
|
|
2102
2107
|
partialResultSubject.next(newOngoingResult);
|
|
@@ -2142,17 +2147,24 @@ function createTask(options) {
|
|
|
2142
2147
|
return {
|
|
2143
2148
|
taskType,
|
|
2144
2149
|
taskId,
|
|
2150
|
+
get promptbookVersion() {
|
|
2151
|
+
return PROMPTBOOK_ENGINE_VERSION;
|
|
2152
|
+
},
|
|
2153
|
+
get title() {
|
|
2154
|
+
return title;
|
|
2155
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2156
|
+
},
|
|
2145
2157
|
get status() {
|
|
2146
2158
|
return status;
|
|
2147
|
-
// <- Note: [1]
|
|
2159
|
+
// <- Note: [1] --||--
|
|
2148
2160
|
},
|
|
2149
2161
|
get createdAt() {
|
|
2150
2162
|
return createdAt;
|
|
2151
|
-
// <- Note: [1]
|
|
2163
|
+
// <- Note: [1] --||--
|
|
2152
2164
|
},
|
|
2153
2165
|
get updatedAt() {
|
|
2154
2166
|
return updatedAt;
|
|
2155
|
-
// <- Note: [1]
|
|
2167
|
+
// <- Note: [1] --||--
|
|
2156
2168
|
},
|
|
2157
2169
|
asPromise,
|
|
2158
2170
|
asObservable() {
|
|
@@ -2160,15 +2172,15 @@ function createTask(options) {
|
|
|
2160
2172
|
},
|
|
2161
2173
|
get errors() {
|
|
2162
2174
|
return errors;
|
|
2163
|
-
// <- Note: [1]
|
|
2175
|
+
// <- Note: [1] --||--
|
|
2164
2176
|
},
|
|
2165
2177
|
get warnings() {
|
|
2166
2178
|
return warnings;
|
|
2167
|
-
// <- Note: [1]
|
|
2179
|
+
// <- Note: [1] --||--
|
|
2168
2180
|
},
|
|
2169
2181
|
get currentValue() {
|
|
2170
2182
|
return currentValue;
|
|
2171
|
-
// <- Note: [1]
|
|
2183
|
+
// <- Note: [1] --||--
|
|
2172
2184
|
},
|
|
2173
2185
|
};
|
|
2174
2186
|
}
|
|
@@ -2916,23 +2928,17 @@ class MultipleLlmExecutionTools {
|
|
|
2916
2928
|
* Check the configuration of all execution tools
|
|
2917
2929
|
*/
|
|
2918
2930
|
async checkConfiguration() {
|
|
2919
|
-
//
|
|
2920
|
-
|
|
2921
|
-
await llmExecutionTools.checkConfiguration();
|
|
2922
|
-
}
|
|
2931
|
+
// Note: Run checks in parallel
|
|
2932
|
+
await Promise.all(this.llmExecutionTools.map((tools) => tools.checkConfiguration()));
|
|
2923
2933
|
}
|
|
2924
2934
|
/**
|
|
2925
2935
|
* List all available models that can be used
|
|
2926
2936
|
* This lists is a combination of all available models from all execution tools
|
|
2927
2937
|
*/
|
|
2928
2938
|
async listModels() {
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
const models = await llmExecutionTools.listModels();
|
|
2933
|
-
availableModels.push(...models);
|
|
2934
|
-
}
|
|
2935
|
-
return availableModels;
|
|
2939
|
+
// Obtain all models in parallel and flatten
|
|
2940
|
+
const modelArrays = await Promise.all(this.llmExecutionTools.map((tools) => tools.listModels()));
|
|
2941
|
+
return modelArrays.flat();
|
|
2936
2942
|
}
|
|
2937
2943
|
/**
|
|
2938
2944
|
* Calls the best available chat model
|
|
@@ -4286,7 +4292,7 @@ async function getKnowledgeForTask(options) {
|
|
|
4286
4292
|
});
|
|
4287
4293
|
const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
|
|
4288
4294
|
const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
|
|
4289
|
-
console.log('!!! Embedding', {
|
|
4295
|
+
console.log('!!! `getKnowledgeForTask` Embedding', {
|
|
4290
4296
|
task,
|
|
4291
4297
|
taskEmbeddingPrompt,
|
|
4292
4298
|
taskEmbeddingResult,
|
|
@@ -4322,6 +4328,7 @@ async function getKnowledgeForTask(options) {
|
|
|
4322
4328
|
*/
|
|
4323
4329
|
async function getReservedParametersForTask(options) {
|
|
4324
4330
|
const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
|
|
4331
|
+
console.log('!!! getReservedParametersForTask', options);
|
|
4325
4332
|
const context = await getContextForTask(); // <- [π]
|
|
4326
4333
|
const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
|
|
4327
4334
|
const examples = await getExamplesForTask();
|
|
@@ -4358,6 +4365,7 @@ async function getReservedParametersForTask(options) {
|
|
|
4358
4365
|
*/
|
|
4359
4366
|
async function executeTask(options) {
|
|
4360
4367
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
4368
|
+
console.log('!!! executeTask', options);
|
|
4361
4369
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
4362
4370
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
4363
4371
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
@@ -4381,14 +4389,15 @@ async function executeTask(options) {
|
|
|
4381
4389
|
|
|
4382
4390
|
`));
|
|
4383
4391
|
}
|
|
4392
|
+
const reservedParameters = await getReservedParametersForTask({
|
|
4393
|
+
tools,
|
|
4394
|
+
preparedPipeline,
|
|
4395
|
+
task: currentTask,
|
|
4396
|
+
pipelineIdentification,
|
|
4397
|
+
parameters: parametersToPass,
|
|
4398
|
+
});
|
|
4384
4399
|
const definedParameters = Object.freeze({
|
|
4385
|
-
...
|
|
4386
|
-
tools,
|
|
4387
|
-
preparedPipeline,
|
|
4388
|
-
task: currentTask,
|
|
4389
|
-
pipelineIdentification,
|
|
4390
|
-
parameters: parametersToPass,
|
|
4391
|
-
})),
|
|
4400
|
+
...reservedParameters,
|
|
4392
4401
|
...parametersToPass,
|
|
4393
4402
|
});
|
|
4394
4403
|
const definedParameterNames = new Set(Object.keys(definedParameters));
|
|
@@ -4835,6 +4844,7 @@ function createPipelineExecutor(options) {
|
|
|
4835
4844
|
};
|
|
4836
4845
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
4837
4846
|
taskType: 'EXECUTION',
|
|
4847
|
+
title: pipeline.title,
|
|
4838
4848
|
taskProcessCallback(updateOngoingResult) {
|
|
4839
4849
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
4840
4850
|
updateOngoingResult(newOngoingResult);
|