@promptbook/remote-server 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
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-31';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-33';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -2004,6 +2004,7 @@ function assertsTaskSuccessful(executionResult) {
2004
2004
  */
2005
2005
  function createTask(options) {
2006
2006
  const { taskType, taskProcessCallback } = options;
2007
+ let { title } = options;
2007
2008
  // TODO: [πŸ™] DRY
2008
2009
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
2009
2010
  let status = 'RUNNING';
@@ -2015,6 +2016,10 @@ function createTask(options) {
2015
2016
  const partialResultSubject = new Subject();
2016
2017
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2017
2018
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
2019
+ if (newOngoingResult.title) {
2020
+ title = newOngoingResult.title;
2021
+ }
2022
+ updatedAt = new Date();
2018
2023
  Object.assign(currentValue, newOngoingResult);
2019
2024
  // <- TODO: assign deep
2020
2025
  partialResultSubject.next(newOngoingResult);
@@ -2060,17 +2065,24 @@ function createTask(options) {
2060
2065
  return {
2061
2066
  taskType,
2062
2067
  taskId,
2068
+ get promptbookVersion() {
2069
+ return PROMPTBOOK_ENGINE_VERSION;
2070
+ },
2071
+ get title() {
2072
+ return title;
2073
+ // <- Note: [1] Theese must be getters to allow changing the value in the future
2074
+ },
2063
2075
  get status() {
2064
2076
  return status;
2065
- // <- Note: [1] Theese must be getters to allow changing the value in the future
2077
+ // <- Note: [1] --||--
2066
2078
  },
2067
2079
  get createdAt() {
2068
2080
  return createdAt;
2069
- // <- Note: [1]
2081
+ // <- Note: [1] --||--
2070
2082
  },
2071
2083
  get updatedAt() {
2072
2084
  return updatedAt;
2073
- // <- Note: [1]
2085
+ // <- Note: [1] --||--
2074
2086
  },
2075
2087
  asPromise,
2076
2088
  asObservable() {
@@ -2078,15 +2090,15 @@ function createTask(options) {
2078
2090
  },
2079
2091
  get errors() {
2080
2092
  return errors;
2081
- // <- Note: [1]
2093
+ // <- Note: [1] --||--
2082
2094
  },
2083
2095
  get warnings() {
2084
2096
  return warnings;
2085
- // <- Note: [1]
2097
+ // <- Note: [1] --||--
2086
2098
  },
2087
2099
  get currentValue() {
2088
2100
  return currentValue;
2089
- // <- Note: [1]
2101
+ // <- Note: [1] --||--
2090
2102
  },
2091
2103
  };
2092
2104
  }
@@ -2781,23 +2793,17 @@ class MultipleLlmExecutionTools {
2781
2793
  * Check the configuration of all execution tools
2782
2794
  */
2783
2795
  async checkConfiguration() {
2784
- // TODO: Maybe do it in parallel
2785
- for (const llmExecutionTools of this.llmExecutionTools) {
2786
- await llmExecutionTools.checkConfiguration();
2787
- }
2796
+ // Note: Run checks in parallel
2797
+ await Promise.all(this.llmExecutionTools.map((tools) => tools.checkConfiguration()));
2788
2798
  }
2789
2799
  /**
2790
2800
  * List all available models that can be used
2791
2801
  * This lists is a combination of all available models from all execution tools
2792
2802
  */
2793
2803
  async listModels() {
2794
- const availableModels = [];
2795
- for (const llmExecutionTools of this.llmExecutionTools) {
2796
- // TODO: [πŸͺ‚] Obtain models in parallel
2797
- const models = await llmExecutionTools.listModels();
2798
- availableModels.push(...models);
2799
- }
2800
- return availableModels;
2804
+ // Obtain all models in parallel and flatten
2805
+ const modelArrays = await Promise.all(this.llmExecutionTools.map((tools) => tools.listModels()));
2806
+ return modelArrays.flat();
2801
2807
  }
2802
2808
  /**
2803
2809
  * Calls the best available chat model
@@ -5712,7 +5718,7 @@ async function getKnowledgeForTask(options) {
5712
5718
  });
5713
5719
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5714
5720
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5715
- console.log('!!! Embedding', {
5721
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5716
5722
  task,
5717
5723
  taskEmbeddingPrompt,
5718
5724
  taskEmbeddingResult,
@@ -5748,6 +5754,7 @@ async function getKnowledgeForTask(options) {
5748
5754
  */
5749
5755
  async function getReservedParametersForTask(options) {
5750
5756
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5757
+ console.log('!!! getReservedParametersForTask', options);
5751
5758
  const context = await getContextForTask(); // <- [🏍]
5752
5759
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5753
5760
  const examples = await getExamplesForTask();
@@ -5784,6 +5791,7 @@ async function getReservedParametersForTask(options) {
5784
5791
  */
5785
5792
  async function executeTask(options) {
5786
5793
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5794
+ console.log('!!! executeTask', options);
5787
5795
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5788
5796
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5789
5797
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5807,14 +5815,15 @@ async function executeTask(options) {
5807
5815
 
5808
5816
  `));
5809
5817
  }
5818
+ const reservedParameters = await getReservedParametersForTask({
5819
+ tools,
5820
+ preparedPipeline,
5821
+ task: currentTask,
5822
+ pipelineIdentification,
5823
+ parameters: parametersToPass,
5824
+ });
5810
5825
  const definedParameters = Object.freeze({
5811
- ...(await getReservedParametersForTask({
5812
- tools,
5813
- preparedPipeline,
5814
- task: currentTask,
5815
- pipelineIdentification,
5816
- parameters: parametersToPass,
5817
- })),
5826
+ ...reservedParameters,
5818
5827
  ...parametersToPass,
5819
5828
  });
5820
5829
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -6261,6 +6270,7 @@ function createPipelineExecutor(options) {
6261
6270
  };
6262
6271
  const pipelineExecutor = (inputParameters) => createTask({
6263
6272
  taskType: 'EXECUTION',
6273
+ title: pipeline.title,
6264
6274
  taskProcessCallback(updateOngoingResult) {
6265
6275
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
6266
6276
  updateOngoingResult(newOngoingResult);
@@ -7941,12 +7951,13 @@ function startRemoteServer(options) {
7941
7951
  });
7942
7952
  function exportExecutionTask(executionTask, isFull) {
7943
7953
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
7944
- const { taskType, taskId, status, errors, warnings, createdAt, updatedAt, currentValue } = executionTask;
7954
+ const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
7945
7955
  if (isFull) {
7946
7956
  return {
7947
- nonce: '✨',
7948
7957
  taskId,
7958
+ title,
7949
7959
  taskType,
7960
+ promptbookVersion,
7950
7961
  status,
7951
7962
  errors: errors.map(serializeError),
7952
7963
  warnings: warnings.map(serializeError),
@@ -7957,9 +7968,10 @@ function startRemoteServer(options) {
7957
7968
  }
7958
7969
  else {
7959
7970
  return {
7960
- nonce: '✨',
7961
7971
  taskId,
7972
+ title,
7962
7973
  taskType,
7974
+ promptbookVersion,
7963
7975
  status,
7964
7976
  createdAt,
7965
7977
  updatedAt,