@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
|
@@ -134,6 +134,7 @@ import type { JavascriptExecutionToolsOptions } from '../scripting/javascript/Ja
|
|
|
134
134
|
import type { PostprocessingFunction } from '../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
135
135
|
import type { PromptbookStorage } from '../storage/_common/PromptbookStorage';
|
|
136
136
|
import type { FileCacheStorageOptions } from '../storage/file-cache-storage/FileCacheStorageOptions';
|
|
137
|
+
import type { IndexedDbStorageOptions } from '../storage/local-storage/utils/IndexedDbStorageOptions';
|
|
137
138
|
import type { IntermediateFilesStrategy } from '../types/IntermediateFilesStrategy';
|
|
138
139
|
import type { ModelRequirements } from '../types/ModelRequirements';
|
|
139
140
|
import type { CompletionModelRequirements } from '../types/ModelRequirements';
|
|
@@ -431,6 +432,7 @@ export type { JavascriptExecutionToolsOptions };
|
|
|
431
432
|
export type { PostprocessingFunction };
|
|
432
433
|
export type { PromptbookStorage };
|
|
433
434
|
export type { FileCacheStorageOptions };
|
|
435
|
+
export type { IndexedDbStorageOptions };
|
|
434
436
|
export type { IntermediateFilesStrategy };
|
|
435
437
|
export type { ModelRequirements };
|
|
436
438
|
export type { CompletionModelRequirements };
|
|
@@ -2,6 +2,7 @@ import type { Observable } from 'rxjs';
|
|
|
2
2
|
import { PartialDeep } from 'type-fest';
|
|
3
3
|
import type { task_id } from '../types/typeAliases';
|
|
4
4
|
import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
5
|
+
import type { string_promptbook_version } from '../version';
|
|
5
6
|
import type { AbstractTaskResult } from './AbstractTaskResult';
|
|
6
7
|
import type { PipelineExecutorResult } from './PipelineExecutorResult';
|
|
7
8
|
/**
|
|
@@ -12,12 +13,21 @@ type CreateTaskOptions<TTaskResult extends AbstractTaskResult> = {
|
|
|
12
13
|
* The type of task to create
|
|
13
14
|
*/
|
|
14
15
|
readonly taskType: AbstractTask<TTaskResult>['taskType'];
|
|
16
|
+
/**
|
|
17
|
+
* Human-readable title of the task - used for displaying in the UI
|
|
18
|
+
*/
|
|
19
|
+
readonly title: AbstractTask<TTaskResult>['title'];
|
|
15
20
|
/**
|
|
16
21
|
* Callback that processes the task and updates the ongoing result
|
|
17
22
|
* @param ongoingResult The partial result of the task processing
|
|
18
23
|
* @returns The final task result
|
|
19
24
|
*/
|
|
20
|
-
taskProcessCallback(updateOngoingResult: (newOngoingResult: PartialDeep<TTaskResult>
|
|
25
|
+
taskProcessCallback(updateOngoingResult: (newOngoingResult: PartialDeep<TTaskResult> & {
|
|
26
|
+
/**
|
|
27
|
+
* Optional update of the task title
|
|
28
|
+
*/
|
|
29
|
+
readonly title?: AbstractTask<TTaskResult>['title'];
|
|
30
|
+
}) => void): Promise<TTaskResult>;
|
|
21
31
|
};
|
|
22
32
|
/**
|
|
23
33
|
* Helper to create a new task
|
|
@@ -52,10 +62,18 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
|
|
|
52
62
|
* Type of the task
|
|
53
63
|
*/
|
|
54
64
|
readonly taskType: string_SCREAMING_CASE;
|
|
65
|
+
/**
|
|
66
|
+
* Version of the promptbook used to run the task
|
|
67
|
+
*/
|
|
68
|
+
readonly promptbookVersion: string_promptbook_version;
|
|
55
69
|
/**
|
|
56
70
|
* Unique identifier for the task
|
|
57
71
|
*/
|
|
58
72
|
readonly taskId: task_id;
|
|
73
|
+
/**
|
|
74
|
+
* Human-readable title of the task - used for displaying in the UI
|
|
75
|
+
*/
|
|
76
|
+
readonly title: string;
|
|
59
77
|
/**
|
|
60
78
|
* Status of the task
|
|
61
79
|
*/
|
|
@@ -2,6 +2,7 @@ import Anthropic from '@anthropic-ai/sdk';
|
|
|
2
2
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
3
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
4
4
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
5
|
+
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
5
6
|
import type { Prompt } from '../../types/Prompt';
|
|
6
7
|
import type { string_markdown } from '../../types/typeAliases';
|
|
7
8
|
import type { string_markdown_text } from '../../types/typeAliases';
|
|
@@ -19,6 +20,7 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
|
|
|
19
20
|
* Anthropic Claude API client.
|
|
20
21
|
*/
|
|
21
22
|
private client;
|
|
23
|
+
private limiter;
|
|
22
24
|
/**
|
|
23
25
|
* Creates Anthropic Claude Execution Tools.
|
|
24
26
|
*
|
|
@@ -40,6 +42,10 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
|
|
|
40
42
|
* Calls Anthropic Claude API to use a chat model.
|
|
41
43
|
*/
|
|
42
44
|
callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<ChatPromptResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Calls Anthropic Claude API to use a completion model.
|
|
47
|
+
*/
|
|
48
|
+
callCompletionModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<CompletionPromptResult>;
|
|
43
49
|
/**
|
|
44
50
|
* Get the model that should be used as default
|
|
45
51
|
*/
|
|
@@ -9,6 +9,10 @@ import type { string_user_id } from '../../types/typeAliases';
|
|
|
9
9
|
* @public exported from `@promptbook/azure-openai`
|
|
10
10
|
*/
|
|
11
11
|
export type AzureOpenAiExecutionToolsOptions = CommonToolsOptions & {
|
|
12
|
+
/**
|
|
13
|
+
* The API key of the Azure OpenAI resource
|
|
14
|
+
*/
|
|
15
|
+
readonly apiKey: string_token;
|
|
12
16
|
/**
|
|
13
17
|
* The resource name of the Azure OpenAI resource
|
|
14
18
|
*
|
|
@@ -23,10 +27,6 @@ export type AzureOpenAiExecutionToolsOptions = CommonToolsOptions & {
|
|
|
23
27
|
* Note: Typically you have one resource and multiple deployments.
|
|
24
28
|
*/
|
|
25
29
|
readonly deploymentName: string_name;
|
|
26
|
-
/**
|
|
27
|
-
* The API key of the Azure OpenAI resource
|
|
28
|
-
*/
|
|
29
|
-
readonly apiKey: string_token;
|
|
30
30
|
/**
|
|
31
31
|
* A unique identifier representing your end-user, which can help Azure OpenAI to monitor
|
|
32
32
|
* and detect abuse.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
2
|
+
import type { IndexedDbStorageOptions } from './utils/IndexedDbStorageOptions';
|
|
2
3
|
/**
|
|
3
4
|
* Gets wrapper around IndexedDB which can be used as PromptbookStorage
|
|
4
5
|
*
|
|
5
6
|
* @public exported from `@promptbook/browser`
|
|
6
7
|
*/
|
|
7
|
-
export declare function getIndexedDbStorage<TItem>(): PromptbookStorage<TItem>;
|
|
8
|
+
export declare function getIndexedDbStorage<TItem>(options: IndexedDbStorageOptions): PromptbookStorage<TItem>;
|
|
8
9
|
/**
|
|
9
10
|
* Note: [π΅] Code in this file should never be published outside of `@promptbook/browser`
|
|
10
11
|
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { string_name } from '../../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Options for IndexedDB storage
|
|
4
|
+
*/
|
|
5
|
+
export type IndexedDbStorageOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Name of the database
|
|
8
|
+
*/
|
|
9
|
+
databaseName: string_name;
|
|
10
|
+
/**
|
|
11
|
+
* Name of the object store (table) in the database
|
|
12
|
+
*/
|
|
13
|
+
storeName: string_name;
|
|
14
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PromptbookStorage } from '../../_common/PromptbookStorage';
|
|
2
|
+
import type { IndexedDbStorageOptions } from './IndexedDbStorageOptions';
|
|
2
3
|
/**
|
|
3
4
|
* Creates a PromptbookStorage backed by IndexedDB.
|
|
4
5
|
* Uses a single object store named 'promptbook'.
|
|
5
6
|
* @private for `getIndexedDbStorage`
|
|
6
7
|
*/
|
|
7
|
-
export declare function makePromptbookStorageFromIndexedDb<TValue>(
|
|
8
|
+
export declare function makePromptbookStorageFromIndexedDb<TValue>(options: IndexedDbStorageOptions): PromptbookStorage<TValue>;
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.92.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.92.0-32`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.92.0-
|
|
3
|
+
"version": "0.92.0-33",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"module": "./esm/index.es.js",
|
|
52
52
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.92.0-
|
|
54
|
+
"@promptbook/core": "0.92.0-33"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-33';
|
|
50
50
|
/**
|
|
51
51
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
52
52
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -2102,6 +2102,7 @@
|
|
|
2102
2102
|
*/
|
|
2103
2103
|
function createTask(options) {
|
|
2104
2104
|
const { taskType, taskProcessCallback } = options;
|
|
2105
|
+
let { title } = options;
|
|
2105
2106
|
// TODO: [π] DRY
|
|
2106
2107
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2107
2108
|
let status = 'RUNNING';
|
|
@@ -2113,6 +2114,10 @@
|
|
|
2113
2114
|
const partialResultSubject = new rxjs.Subject();
|
|
2114
2115
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2115
2116
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2117
|
+
if (newOngoingResult.title) {
|
|
2118
|
+
title = newOngoingResult.title;
|
|
2119
|
+
}
|
|
2120
|
+
updatedAt = new Date();
|
|
2116
2121
|
Object.assign(currentValue, newOngoingResult);
|
|
2117
2122
|
// <- TODO: assign deep
|
|
2118
2123
|
partialResultSubject.next(newOngoingResult);
|
|
@@ -2158,17 +2163,24 @@
|
|
|
2158
2163
|
return {
|
|
2159
2164
|
taskType,
|
|
2160
2165
|
taskId,
|
|
2166
|
+
get promptbookVersion() {
|
|
2167
|
+
return PROMPTBOOK_ENGINE_VERSION;
|
|
2168
|
+
},
|
|
2169
|
+
get title() {
|
|
2170
|
+
return title;
|
|
2171
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2172
|
+
},
|
|
2161
2173
|
get status() {
|
|
2162
2174
|
return status;
|
|
2163
|
-
// <- Note: [1]
|
|
2175
|
+
// <- Note: [1] --||--
|
|
2164
2176
|
},
|
|
2165
2177
|
get createdAt() {
|
|
2166
2178
|
return createdAt;
|
|
2167
|
-
// <- Note: [1]
|
|
2179
|
+
// <- Note: [1] --||--
|
|
2168
2180
|
},
|
|
2169
2181
|
get updatedAt() {
|
|
2170
2182
|
return updatedAt;
|
|
2171
|
-
// <- Note: [1]
|
|
2183
|
+
// <- Note: [1] --||--
|
|
2172
2184
|
},
|
|
2173
2185
|
asPromise,
|
|
2174
2186
|
asObservable() {
|
|
@@ -2176,15 +2188,15 @@
|
|
|
2176
2188
|
},
|
|
2177
2189
|
get errors() {
|
|
2178
2190
|
return errors;
|
|
2179
|
-
// <- Note: [1]
|
|
2191
|
+
// <- Note: [1] --||--
|
|
2180
2192
|
},
|
|
2181
2193
|
get warnings() {
|
|
2182
2194
|
return warnings;
|
|
2183
|
-
// <- Note: [1]
|
|
2195
|
+
// <- Note: [1] --||--
|
|
2184
2196
|
},
|
|
2185
2197
|
get currentValue() {
|
|
2186
2198
|
return currentValue;
|
|
2187
|
-
// <- Note: [1]
|
|
2199
|
+
// <- Note: [1] --||--
|
|
2188
2200
|
},
|
|
2189
2201
|
};
|
|
2190
2202
|
}
|
|
@@ -2932,23 +2944,17 @@
|
|
|
2932
2944
|
* Check the configuration of all execution tools
|
|
2933
2945
|
*/
|
|
2934
2946
|
async checkConfiguration() {
|
|
2935
|
-
//
|
|
2936
|
-
|
|
2937
|
-
await llmExecutionTools.checkConfiguration();
|
|
2938
|
-
}
|
|
2947
|
+
// Note: Run checks in parallel
|
|
2948
|
+
await Promise.all(this.llmExecutionTools.map((tools) => tools.checkConfiguration()));
|
|
2939
2949
|
}
|
|
2940
2950
|
/**
|
|
2941
2951
|
* List all available models that can be used
|
|
2942
2952
|
* This lists is a combination of all available models from all execution tools
|
|
2943
2953
|
*/
|
|
2944
2954
|
async listModels() {
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
const models = await llmExecutionTools.listModels();
|
|
2949
|
-
availableModels.push(...models);
|
|
2950
|
-
}
|
|
2951
|
-
return availableModels;
|
|
2955
|
+
// Obtain all models in parallel and flatten
|
|
2956
|
+
const modelArrays = await Promise.all(this.llmExecutionTools.map((tools) => tools.listModels()));
|
|
2957
|
+
return modelArrays.flat();
|
|
2952
2958
|
}
|
|
2953
2959
|
/**
|
|
2954
2960
|
* Calls the best available chat model
|
|
@@ -4302,7 +4308,7 @@
|
|
|
4302
4308
|
});
|
|
4303
4309
|
const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
|
|
4304
4310
|
const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
|
|
4305
|
-
console.log('!!! Embedding', {
|
|
4311
|
+
console.log('!!! `getKnowledgeForTask` Embedding', {
|
|
4306
4312
|
task,
|
|
4307
4313
|
taskEmbeddingPrompt,
|
|
4308
4314
|
taskEmbeddingResult,
|
|
@@ -4338,6 +4344,7 @@
|
|
|
4338
4344
|
*/
|
|
4339
4345
|
async function getReservedParametersForTask(options) {
|
|
4340
4346
|
const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
|
|
4347
|
+
console.log('!!! getReservedParametersForTask', options);
|
|
4341
4348
|
const context = await getContextForTask(); // <- [π]
|
|
4342
4349
|
const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
|
|
4343
4350
|
const examples = await getExamplesForTask();
|
|
@@ -4374,6 +4381,7 @@
|
|
|
4374
4381
|
*/
|
|
4375
4382
|
async function executeTask(options) {
|
|
4376
4383
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
4384
|
+
console.log('!!! executeTask', options);
|
|
4377
4385
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
4378
4386
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
4379
4387
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
@@ -4397,14 +4405,15 @@
|
|
|
4397
4405
|
|
|
4398
4406
|
`));
|
|
4399
4407
|
}
|
|
4408
|
+
const reservedParameters = await getReservedParametersForTask({
|
|
4409
|
+
tools,
|
|
4410
|
+
preparedPipeline,
|
|
4411
|
+
task: currentTask,
|
|
4412
|
+
pipelineIdentification,
|
|
4413
|
+
parameters: parametersToPass,
|
|
4414
|
+
});
|
|
4400
4415
|
const definedParameters = Object.freeze({
|
|
4401
|
-
...
|
|
4402
|
-
tools,
|
|
4403
|
-
preparedPipeline,
|
|
4404
|
-
task: currentTask,
|
|
4405
|
-
pipelineIdentification,
|
|
4406
|
-
parameters: parametersToPass,
|
|
4407
|
-
})),
|
|
4416
|
+
...reservedParameters,
|
|
4408
4417
|
...parametersToPass,
|
|
4409
4418
|
});
|
|
4410
4419
|
const definedParameterNames = new Set(Object.keys(definedParameters));
|
|
@@ -4851,6 +4860,7 @@
|
|
|
4851
4860
|
};
|
|
4852
4861
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
4853
4862
|
taskType: 'EXECUTION',
|
|
4863
|
+
title: pipeline.title,
|
|
4854
4864
|
taskProcessCallback(updateOngoingResult) {
|
|
4855
4865
|
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
4856
4866
|
updateOngoingResult(newOngoingResult);
|