@promptbook/markdown-utils 0.92.0-32 β†’ 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.
@@ -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
  */
@@ -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-32`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/markdown-utils",
3
- "version": "0.92.0-32",
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,
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-32';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-33';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -2200,6 +2200,7 @@
2200
2200
  */
2201
2201
  function createTask(options) {
2202
2202
  const { taskType, taskProcessCallback } = options;
2203
+ let { title } = options;
2203
2204
  // TODO: [πŸ™] DRY
2204
2205
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
2205
2206
  let status = 'RUNNING';
@@ -2211,6 +2212,10 @@
2211
2212
  const partialResultSubject = new rxjs.Subject();
2212
2213
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2213
2214
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
2215
+ if (newOngoingResult.title) {
2216
+ title = newOngoingResult.title;
2217
+ }
2218
+ updatedAt = new Date();
2214
2219
  Object.assign(currentValue, newOngoingResult);
2215
2220
  // <- TODO: assign deep
2216
2221
  partialResultSubject.next(newOngoingResult);
@@ -2256,17 +2261,24 @@
2256
2261
  return {
2257
2262
  taskType,
2258
2263
  taskId,
2264
+ get promptbookVersion() {
2265
+ return PROMPTBOOK_ENGINE_VERSION;
2266
+ },
2267
+ get title() {
2268
+ return title;
2269
+ // <- Note: [1] Theese must be getters to allow changing the value in the future
2270
+ },
2259
2271
  get status() {
2260
2272
  return status;
2261
- // <- Note: [1] Theese must be getters to allow changing the value in the future
2273
+ // <- Note: [1] --||--
2262
2274
  },
2263
2275
  get createdAt() {
2264
2276
  return createdAt;
2265
- // <- Note: [1]
2277
+ // <- Note: [1] --||--
2266
2278
  },
2267
2279
  get updatedAt() {
2268
2280
  return updatedAt;
2269
- // <- Note: [1]
2281
+ // <- Note: [1] --||--
2270
2282
  },
2271
2283
  asPromise,
2272
2284
  asObservable() {
@@ -2274,15 +2286,15 @@
2274
2286
  },
2275
2287
  get errors() {
2276
2288
  return errors;
2277
- // <- Note: [1]
2289
+ // <- Note: [1] --||--
2278
2290
  },
2279
2291
  get warnings() {
2280
2292
  return warnings;
2281
- // <- Note: [1]
2293
+ // <- Note: [1] --||--
2282
2294
  },
2283
2295
  get currentValue() {
2284
2296
  return currentValue;
2285
- // <- Note: [1]
2297
+ // <- Note: [1] --||--
2286
2298
  },
2287
2299
  };
2288
2300
  }
@@ -5335,7 +5347,7 @@
5335
5347
  });
5336
5348
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5337
5349
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5338
- console.log('!!! Embedding', {
5350
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5339
5351
  task,
5340
5352
  taskEmbeddingPrompt,
5341
5353
  taskEmbeddingResult,
@@ -5371,6 +5383,7 @@
5371
5383
  */
5372
5384
  async function getReservedParametersForTask(options) {
5373
5385
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5386
+ console.log('!!! getReservedParametersForTask', options);
5374
5387
  const context = await getContextForTask(); // <- [🏍]
5375
5388
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5376
5389
  const examples = await getExamplesForTask();
@@ -5407,6 +5420,7 @@
5407
5420
  */
5408
5421
  async function executeTask(options) {
5409
5422
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5423
+ console.log('!!! executeTask', options);
5410
5424
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5411
5425
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5412
5426
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5430,14 +5444,15 @@
5430
5444
 
5431
5445
  `));
5432
5446
  }
5447
+ const reservedParameters = await getReservedParametersForTask({
5448
+ tools,
5449
+ preparedPipeline,
5450
+ task: currentTask,
5451
+ pipelineIdentification,
5452
+ parameters: parametersToPass,
5453
+ });
5433
5454
  const definedParameters = Object.freeze({
5434
- ...(await getReservedParametersForTask({
5435
- tools,
5436
- preparedPipeline,
5437
- task: currentTask,
5438
- pipelineIdentification,
5439
- parameters: parametersToPass,
5440
- })),
5455
+ ...reservedParameters,
5441
5456
  ...parametersToPass,
5442
5457
  });
5443
5458
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -5884,6 +5899,7 @@
5884
5899
  };
5885
5900
  const pipelineExecutor = (inputParameters) => createTask({
5886
5901
  taskType: 'EXECUTION',
5902
+ title: pipeline.title,
5887
5903
  taskProcessCallback(updateOngoingResult) {
5888
5904
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
5889
5905
  updateOngoingResult(newOngoingResult);