@promptbook/markdown-utils 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 CHANGED
@@ -25,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-31';
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 @@ function assertsTaskSuccessful(executionResult) {
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 @@ function createTask(options) {
2211
2212
  const partialResultSubject = new 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 @@ function createTask(options) {
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 @@ function createTask(options) {
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
  }
@@ -2529,23 +2541,17 @@ class MultipleLlmExecutionTools {
2529
2541
  * Check the configuration of all execution tools
2530
2542
  */
2531
2543
  async checkConfiguration() {
2532
- // TODO: Maybe do it in parallel
2533
- for (const llmExecutionTools of this.llmExecutionTools) {
2534
- await llmExecutionTools.checkConfiguration();
2535
- }
2544
+ // Note: Run checks in parallel
2545
+ await Promise.all(this.llmExecutionTools.map((tools) => tools.checkConfiguration()));
2536
2546
  }
2537
2547
  /**
2538
2548
  * List all available models that can be used
2539
2549
  * This lists is a combination of all available models from all execution tools
2540
2550
  */
2541
2551
  async listModels() {
2542
- const availableModels = [];
2543
- for (const llmExecutionTools of this.llmExecutionTools) {
2544
- // TODO: [πŸͺ‚] Obtain models in parallel
2545
- const models = await llmExecutionTools.listModels();
2546
- availableModels.push(...models);
2547
- }
2548
- return availableModels;
2552
+ // Obtain all models in parallel and flatten
2553
+ const modelArrays = await Promise.all(this.llmExecutionTools.map((tools) => tools.listModels()));
2554
+ return modelArrays.flat();
2549
2555
  }
2550
2556
  /**
2551
2557
  * Calls the best available chat model
@@ -5341,7 +5347,7 @@ async function getKnowledgeForTask(options) {
5341
5347
  });
5342
5348
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5343
5349
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5344
- console.log('!!! Embedding', {
5350
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5345
5351
  task,
5346
5352
  taskEmbeddingPrompt,
5347
5353
  taskEmbeddingResult,
@@ -5377,6 +5383,7 @@ async function getKnowledgeForTask(options) {
5377
5383
  */
5378
5384
  async function getReservedParametersForTask(options) {
5379
5385
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5386
+ console.log('!!! getReservedParametersForTask', options);
5380
5387
  const context = await getContextForTask(); // <- [🏍]
5381
5388
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5382
5389
  const examples = await getExamplesForTask();
@@ -5413,6 +5420,7 @@ async function getReservedParametersForTask(options) {
5413
5420
  */
5414
5421
  async function executeTask(options) {
5415
5422
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5423
+ console.log('!!! executeTask', options);
5416
5424
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5417
5425
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5418
5426
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5436,14 +5444,15 @@ async function executeTask(options) {
5436
5444
 
5437
5445
  `));
5438
5446
  }
5447
+ const reservedParameters = await getReservedParametersForTask({
5448
+ tools,
5449
+ preparedPipeline,
5450
+ task: currentTask,
5451
+ pipelineIdentification,
5452
+ parameters: parametersToPass,
5453
+ });
5439
5454
  const definedParameters = Object.freeze({
5440
- ...(await getReservedParametersForTask({
5441
- tools,
5442
- preparedPipeline,
5443
- task: currentTask,
5444
- pipelineIdentification,
5445
- parameters: parametersToPass,
5446
- })),
5455
+ ...reservedParameters,
5447
5456
  ...parametersToPass,
5448
5457
  });
5449
5458
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -5890,6 +5899,7 @@ function createPipelineExecutor(options) {
5890
5899
  };
5891
5900
  const pipelineExecutor = (inputParameters) => createTask({
5892
5901
  taskType: 'EXECUTION',
5902
+ title: pipeline.title,
5893
5903
  taskProcessCallback(updateOngoingResult) {
5894
5904
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
5895
5905
  updateOngoingResult(newOngoingResult);