@promptbook/remote-server 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.
@@ -102,12 +102,12 @@ import { createLlmToolsFromConfiguration } from '../llm-providers/_common/regist
102
102
  import { cacheLlmTools } from '../llm-providers/_common/utils/cache/cacheLlmTools';
103
103
  import { countUsage } from '../llm-providers/_common/utils/count-total-usage/countUsage';
104
104
  import { limitTotalUsage } from '../llm-providers/_common/utils/count-total-usage/limitTotalUsage';
105
+ import { joinLlmExecutionTools } from '../llm-providers/_multiple/joinLlmExecutionTools';
106
+ import { MultipleLlmExecutionTools } from '../llm-providers/_multiple/MultipleLlmExecutionTools';
105
107
  import { _AnthropicClaudeMetadataRegistration } from '../llm-providers/anthropic-claude/register-configuration';
106
108
  import { _AzureOpenAiMetadataRegistration } from '../llm-providers/azure-openai/register-configuration';
107
109
  import { _DeepseekMetadataRegistration } from '../llm-providers/deepseek/register-configuration';
108
110
  import { _GoogleMetadataRegistration } from '../llm-providers/google/register-configuration';
109
- import { joinLlmExecutionTools } from '../llm-providers/multiple/joinLlmExecutionTools';
110
- import { MultipleLlmExecutionTools } from '../llm-providers/multiple/MultipleLlmExecutionTools';
111
111
  import { _OpenAiMetadataRegistration } from '../llm-providers/openai/register-configuration';
112
112
  import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/register-configuration';
113
113
  import { migratePipeline } from '../migrations/migratePipeline';
@@ -249,12 +249,12 @@ export { createLlmToolsFromConfiguration };
249
249
  export { cacheLlmTools };
250
250
  export { countUsage };
251
251
  export { limitTotalUsage };
252
+ export { joinLlmExecutionTools };
253
+ export { MultipleLlmExecutionTools };
252
254
  export { _AnthropicClaudeMetadataRegistration };
253
255
  export { _AzureOpenAiMetadataRegistration };
254
256
  export { _DeepseekMetadataRegistration };
255
257
  export { _GoogleMetadataRegistration };
256
- export { joinLlmExecutionTools };
257
- export { MultipleLlmExecutionTools };
258
258
  export { _OpenAiMetadataRegistration };
259
259
  export { _OpenAiAssistantMetadataRegistration };
260
260
  export { migratePipeline };
@@ -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>) => void): Promise<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
  */
@@ -1,4 +1,4 @@
1
- import { MultipleLlmExecutionTools } from '../../multiple/MultipleLlmExecutionTools';
1
+ import { MultipleLlmExecutionTools } from '../../_multiple/MultipleLlmExecutionTools';
2
2
  import type { CreateLlmToolsFromConfigurationOptions } from './createLlmToolsFromConfiguration';
3
3
  /**
4
4
  * Automatically configures LLM tools from environment variables in Node.js
@@ -1,5 +1,5 @@
1
1
  import type { string_user_id } from '../../../types/typeAliases';
2
- import { MultipleLlmExecutionTools } from '../../multiple/MultipleLlmExecutionTools';
2
+ import { MultipleLlmExecutionTools } from '../../_multiple/MultipleLlmExecutionTools';
3
3
  import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
4
4
  /**
5
5
  * Options for `$provideLlmToolsFromEnv`
@@ -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>(dbName?: string, storeName?: string): PromptbookStorage<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-31`).
18
+ * It follows semantic versioning (e.g., `0.92.0-33`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.92.0-32",
3
+ "version": "0.92.0-34",
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/remote-server.index.d.ts",
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.92.0-32"
54
+ "@promptbook/core": "0.92.0-34"
55
55
  },
56
56
  "dependencies": {
57
57
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-32';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-34';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2019,6 +2019,7 @@
2019
2019
  */
2020
2020
  function createTask(options) {
2021
2021
  const { taskType, taskProcessCallback } = options;
2022
+ let { title } = options;
2022
2023
  // TODO: [🐙] DRY
2023
2024
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
2024
2025
  let status = 'RUNNING';
@@ -2030,6 +2031,10 @@
2030
2031
  const partialResultSubject = new rxjs.Subject();
2031
2032
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2032
2033
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
2034
+ if (newOngoingResult.title) {
2035
+ title = newOngoingResult.title;
2036
+ }
2037
+ updatedAt = new Date();
2033
2038
  Object.assign(currentValue, newOngoingResult);
2034
2039
  // <- TODO: assign deep
2035
2040
  partialResultSubject.next(newOngoingResult);
@@ -2075,17 +2080,24 @@
2075
2080
  return {
2076
2081
  taskType,
2077
2082
  taskId,
2083
+ get promptbookVersion() {
2084
+ return PROMPTBOOK_ENGINE_VERSION;
2085
+ },
2086
+ get title() {
2087
+ return title;
2088
+ // <- Note: [1] Theese must be getters to allow changing the value in the future
2089
+ },
2078
2090
  get status() {
2079
2091
  return status;
2080
- // <- Note: [1] Theese must be getters to allow changing the value in the future
2092
+ // <- Note: [1] --||--
2081
2093
  },
2082
2094
  get createdAt() {
2083
2095
  return createdAt;
2084
- // <- Note: [1]
2096
+ // <- Note: [1] --||--
2085
2097
  },
2086
2098
  get updatedAt() {
2087
2099
  return updatedAt;
2088
- // <- Note: [1]
2100
+ // <- Note: [1] --||--
2089
2101
  },
2090
2102
  asPromise,
2091
2103
  asObservable() {
@@ -2093,15 +2105,15 @@
2093
2105
  },
2094
2106
  get errors() {
2095
2107
  return errors;
2096
- // <- Note: [1]
2108
+ // <- Note: [1] --||--
2097
2109
  },
2098
2110
  get warnings() {
2099
2111
  return warnings;
2100
- // <- Note: [1]
2112
+ // <- Note: [1] --||--
2101
2113
  },
2102
2114
  get currentValue() {
2103
2115
  return currentValue;
2104
- // <- Note: [1]
2116
+ // <- Note: [1] --||--
2105
2117
  },
2106
2118
  };
2107
2119
  }
@@ -2714,12 +2726,14 @@
2714
2726
  const spending = new rxjs.Subject();
2715
2727
  const proxyTools = {
2716
2728
  get title() {
2717
- // TODO: [🧠] Maybe put here some suffix
2718
- return llmTools.title;
2729
+ return `${llmTools.title} (+usage)`;
2730
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
2731
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
2719
2732
  },
2720
2733
  get description() {
2721
- // TODO: [🧠] Maybe put here some suffix
2722
- return llmTools.description;
2734
+ return `${llmTools.description} (+usage)`;
2735
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
2736
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
2723
2737
  },
2724
2738
  checkConfiguration() {
2725
2739
  return /* not await */ llmTools.checkConfiguration();
@@ -2790,7 +2804,14 @@
2790
2804
  return 'Multiple LLM Providers';
2791
2805
  }
2792
2806
  get description() {
2793
- return this.llmExecutionTools.map(({ title }, index) => `${index + 1}) \`${title}\``).join('\n');
2807
+ const innerModelsTitlesAndDescriptions = this.llmExecutionTools
2808
+ .map(({ title, description }, index) => `${index + 1}) \`${title}\`\n${description}`)
2809
+ .join('\n\n');
2810
+ return spaceTrim__default["default"]((block) => `
2811
+ Multiple LLM Providers:
2812
+
2813
+ ${block(innerModelsTitlesAndDescriptions)}
2814
+ `);
2794
2815
  }
2795
2816
  /**
2796
2817
  * Check the configuration of all execution tools
@@ -5683,6 +5704,7 @@
5683
5704
  */
5684
5705
  async function getKnowledgeForTask(options) {
5685
5706
  const { tools, preparedPipeline, task, parameters } = options;
5707
+ console.log('!!! getKnowledgeForTask', options);
5686
5708
  const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
5687
5709
  const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
5688
5710
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
@@ -5721,7 +5743,7 @@
5721
5743
  });
5722
5744
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5723
5745
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5724
- console.log('!!! Embedding', {
5746
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5725
5747
  task,
5726
5748
  taskEmbeddingPrompt,
5727
5749
  taskEmbeddingResult,
@@ -5757,6 +5779,7 @@
5757
5779
  */
5758
5780
  async function getReservedParametersForTask(options) {
5759
5781
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5782
+ console.log('!!! getReservedParametersForTask', options);
5760
5783
  const context = await getContextForTask(); // <- [🏍]
5761
5784
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5762
5785
  const examples = await getExamplesForTask();
@@ -5793,6 +5816,7 @@
5793
5816
  */
5794
5817
  async function executeTask(options) {
5795
5818
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5819
+ console.log('!!! executeTask', options);
5796
5820
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5797
5821
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5798
5822
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5816,14 +5840,15 @@
5816
5840
 
5817
5841
  `));
5818
5842
  }
5843
+ const reservedParameters = await getReservedParametersForTask({
5844
+ tools,
5845
+ preparedPipeline,
5846
+ task: currentTask,
5847
+ pipelineIdentification,
5848
+ parameters: parametersToPass,
5849
+ });
5819
5850
  const definedParameters = Object.freeze({
5820
- ...(await getReservedParametersForTask({
5821
- tools,
5822
- preparedPipeline,
5823
- task: currentTask,
5824
- pipelineIdentification,
5825
- parameters: parametersToPass,
5826
- })),
5851
+ ...reservedParameters,
5827
5852
  ...parametersToPass,
5828
5853
  });
5829
5854
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -6270,6 +6295,7 @@
6270
6295
  };
6271
6296
  const pipelineExecutor = (inputParameters) => createTask({
6272
6297
  taskType: 'EXECUTION',
6298
+ title: pipeline.title,
6273
6299
  taskProcessCallback(updateOngoingResult) {
6274
6300
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
6275
6301
  updateOngoingResult(newOngoingResult);
@@ -7950,12 +7976,13 @@
7950
7976
  });
7951
7977
  function exportExecutionTask(executionTask, isFull) {
7952
7978
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
7953
- const { taskType, taskId, status, errors, warnings, createdAt, updatedAt, currentValue } = executionTask;
7979
+ const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
7954
7980
  if (isFull) {
7955
7981
  return {
7956
- nonce: '✨',
7957
7982
  taskId,
7983
+ title,
7958
7984
  taskType,
7985
+ promptbookVersion,
7959
7986
  status,
7960
7987
  errors: errors.map(serializeError),
7961
7988
  warnings: warnings.map(serializeError),
@@ -7966,9 +7993,10 @@
7966
7993
  }
7967
7994
  else {
7968
7995
  return {
7969
- nonce: '✨',
7970
7996
  taskId,
7997
+ title,
7971
7998
  taskType,
7999
+ promptbookVersion,
7972
8000
  status,
7973
8001
  createdAt,
7974
8002
  updatedAt,