@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.
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-32';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-34';
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
  }
@@ -2699,12 +2711,14 @@ function countUsage(llmTools) {
2699
2711
  const spending = new Subject();
2700
2712
  const proxyTools = {
2701
2713
  get title() {
2702
- // TODO: [🧠] Maybe put here some suffix
2703
- return llmTools.title;
2714
+ return `${llmTools.title} (+usage)`;
2715
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
2716
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
2704
2717
  },
2705
2718
  get description() {
2706
- // TODO: [🧠] Maybe put here some suffix
2707
- return llmTools.description;
2719
+ return `${llmTools.description} (+usage)`;
2720
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
2721
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
2708
2722
  },
2709
2723
  checkConfiguration() {
2710
2724
  return /* not await */ llmTools.checkConfiguration();
@@ -2775,7 +2789,14 @@ class MultipleLlmExecutionTools {
2775
2789
  return 'Multiple LLM Providers';
2776
2790
  }
2777
2791
  get description() {
2778
- return this.llmExecutionTools.map(({ title }, index) => `${index + 1}) \`${title}\``).join('\n');
2792
+ const innerModelsTitlesAndDescriptions = this.llmExecutionTools
2793
+ .map(({ title, description }, index) => `${index + 1}) \`${title}\`\n${description}`)
2794
+ .join('\n\n');
2795
+ return spaceTrim((block) => `
2796
+ Multiple LLM Providers:
2797
+
2798
+ ${block(innerModelsTitlesAndDescriptions)}
2799
+ `);
2779
2800
  }
2780
2801
  /**
2781
2802
  * Check the configuration of all execution tools
@@ -5668,6 +5689,7 @@ function knowledgePiecesToString(knowledgePieces) {
5668
5689
  */
5669
5690
  async function getKnowledgeForTask(options) {
5670
5691
  const { tools, preparedPipeline, task, parameters } = options;
5692
+ console.log('!!! getKnowledgeForTask', options);
5671
5693
  const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
5672
5694
  const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
5673
5695
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
@@ -5706,7 +5728,7 @@ async function getKnowledgeForTask(options) {
5706
5728
  });
5707
5729
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
5708
5730
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
5709
- console.log('!!! Embedding', {
5731
+ console.log('!!! `getKnowledgeForTask` Embedding', {
5710
5732
  task,
5711
5733
  taskEmbeddingPrompt,
5712
5734
  taskEmbeddingResult,
@@ -5742,6 +5764,7 @@ async function getKnowledgeForTask(options) {
5742
5764
  */
5743
5765
  async function getReservedParametersForTask(options) {
5744
5766
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
5767
+ console.log('!!! getReservedParametersForTask', options);
5745
5768
  const context = await getContextForTask(); // <- [🏍]
5746
5769
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
5747
5770
  const examples = await getExamplesForTask();
@@ -5778,6 +5801,7 @@ async function getReservedParametersForTask(options) {
5778
5801
  */
5779
5802
  async function executeTask(options) {
5780
5803
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
5804
+ console.log('!!! executeTask', options);
5781
5805
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5782
5806
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
5783
5807
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -5801,14 +5825,15 @@ async function executeTask(options) {
5801
5825
 
5802
5826
  `));
5803
5827
  }
5828
+ const reservedParameters = await getReservedParametersForTask({
5829
+ tools,
5830
+ preparedPipeline,
5831
+ task: currentTask,
5832
+ pipelineIdentification,
5833
+ parameters: parametersToPass,
5834
+ });
5804
5835
  const definedParameters = Object.freeze({
5805
- ...(await getReservedParametersForTask({
5806
- tools,
5807
- preparedPipeline,
5808
- task: currentTask,
5809
- pipelineIdentification,
5810
- parameters: parametersToPass,
5811
- })),
5836
+ ...reservedParameters,
5812
5837
  ...parametersToPass,
5813
5838
  });
5814
5839
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -6255,6 +6280,7 @@ function createPipelineExecutor(options) {
6255
6280
  };
6256
6281
  const pipelineExecutor = (inputParameters) => createTask({
6257
6282
  taskType: 'EXECUTION',
6283
+ title: pipeline.title,
6258
6284
  taskProcessCallback(updateOngoingResult) {
6259
6285
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
6260
6286
  updateOngoingResult(newOngoingResult);
@@ -7935,12 +7961,13 @@ function startRemoteServer(options) {
7935
7961
  });
7936
7962
  function exportExecutionTask(executionTask, isFull) {
7937
7963
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
7938
- const { taskType, taskId, status, errors, warnings, createdAt, updatedAt, currentValue } = executionTask;
7964
+ const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
7939
7965
  if (isFull) {
7940
7966
  return {
7941
- nonce: '✨',
7942
7967
  taskId,
7968
+ title,
7943
7969
  taskType,
7970
+ promptbookVersion,
7944
7971
  status,
7945
7972
  errors: errors.map(serializeError),
7946
7973
  warnings: warnings.map(serializeError),
@@ -7951,9 +7978,10 @@ function startRemoteServer(options) {
7951
7978
  }
7952
7979
  else {
7953
7980
  return {
7954
- nonce: '✨',
7955
7981
  taskId,
7982
+ title,
7956
7983
  taskType,
7984
+ promptbookVersion,
7957
7985
  status,
7958
7986
  createdAt,
7959
7987
  updatedAt,