@promptbook/node 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
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-32';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-34';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2086,6 +2086,7 @@ function assertsTaskSuccessful(executionResult) {
2086
2086
  */
2087
2087
  function createTask(options) {
2088
2088
  const { taskType, taskProcessCallback } = options;
2089
+ let { title } = options;
2089
2090
  // TODO: [🐙] DRY
2090
2091
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
2091
2092
  let status = 'RUNNING';
@@ -2097,6 +2098,10 @@ function createTask(options) {
2097
2098
  const partialResultSubject = new Subject();
2098
2099
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2099
2100
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
2101
+ if (newOngoingResult.title) {
2102
+ title = newOngoingResult.title;
2103
+ }
2104
+ updatedAt = new Date();
2100
2105
  Object.assign(currentValue, newOngoingResult);
2101
2106
  // <- TODO: assign deep
2102
2107
  partialResultSubject.next(newOngoingResult);
@@ -2142,17 +2147,24 @@ function createTask(options) {
2142
2147
  return {
2143
2148
  taskType,
2144
2149
  taskId,
2150
+ get promptbookVersion() {
2151
+ return PROMPTBOOK_ENGINE_VERSION;
2152
+ },
2153
+ get title() {
2154
+ return title;
2155
+ // <- Note: [1] Theese must be getters to allow changing the value in the future
2156
+ },
2145
2157
  get status() {
2146
2158
  return status;
2147
- // <- Note: [1] Theese must be getters to allow changing the value in the future
2159
+ // <- Note: [1] --||--
2148
2160
  },
2149
2161
  get createdAt() {
2150
2162
  return createdAt;
2151
- // <- Note: [1]
2163
+ // <- Note: [1] --||--
2152
2164
  },
2153
2165
  get updatedAt() {
2154
2166
  return updatedAt;
2155
- // <- Note: [1]
2167
+ // <- Note: [1] --||--
2156
2168
  },
2157
2169
  asPromise,
2158
2170
  asObservable() {
@@ -2160,15 +2172,15 @@ function createTask(options) {
2160
2172
  },
2161
2173
  get errors() {
2162
2174
  return errors;
2163
- // <- Note: [1]
2175
+ // <- Note: [1] --||--
2164
2176
  },
2165
2177
  get warnings() {
2166
2178
  return warnings;
2167
- // <- Note: [1]
2179
+ // <- Note: [1] --||--
2168
2180
  },
2169
2181
  get currentValue() {
2170
2182
  return currentValue;
2171
- // <- Note: [1]
2183
+ // <- Note: [1] --||--
2172
2184
  },
2173
2185
  };
2174
2186
  }
@@ -2910,7 +2922,14 @@ class MultipleLlmExecutionTools {
2910
2922
  return 'Multiple LLM Providers';
2911
2923
  }
2912
2924
  get description() {
2913
- return this.llmExecutionTools.map(({ title }, index) => `${index + 1}) \`${title}\``).join('\n');
2925
+ const innerModelsTitlesAndDescriptions = this.llmExecutionTools
2926
+ .map(({ title, description }, index) => `${index + 1}) \`${title}\`\n${description}`)
2927
+ .join('\n\n');
2928
+ return spaceTrim((block) => `
2929
+ Multiple LLM Providers:
2930
+
2931
+ ${block(innerModelsTitlesAndDescriptions)}
2932
+ `);
2914
2933
  }
2915
2934
  /**
2916
2935
  * Check the configuration of all execution tools
@@ -4242,6 +4261,7 @@ function knowledgePiecesToString(knowledgePieces) {
4242
4261
  */
4243
4262
  async function getKnowledgeForTask(options) {
4244
4263
  const { tools, preparedPipeline, task, parameters } = options;
4264
+ console.log('!!! getKnowledgeForTask', options);
4245
4265
  const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
4246
4266
  const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
4247
4267
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
@@ -4280,7 +4300,7 @@ async function getKnowledgeForTask(options) {
4280
4300
  });
4281
4301
  const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
4282
4302
  const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
4283
- console.log('!!! Embedding', {
4303
+ console.log('!!! `getKnowledgeForTask` Embedding', {
4284
4304
  task,
4285
4305
  taskEmbeddingPrompt,
4286
4306
  taskEmbeddingResult,
@@ -4316,6 +4336,7 @@ async function getKnowledgeForTask(options) {
4316
4336
  */
4317
4337
  async function getReservedParametersForTask(options) {
4318
4338
  const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
4339
+ console.log('!!! getReservedParametersForTask', options);
4319
4340
  const context = await getContextForTask(); // <- [🏍]
4320
4341
  const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
4321
4342
  const examples = await getExamplesForTask();
@@ -4352,6 +4373,7 @@ async function getReservedParametersForTask(options) {
4352
4373
  */
4353
4374
  async function executeTask(options) {
4354
4375
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
4376
+ console.log('!!! executeTask', options);
4355
4377
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
4356
4378
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
4357
4379
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -4375,14 +4397,15 @@ async function executeTask(options) {
4375
4397
 
4376
4398
  `));
4377
4399
  }
4400
+ const reservedParameters = await getReservedParametersForTask({
4401
+ tools,
4402
+ preparedPipeline,
4403
+ task: currentTask,
4404
+ pipelineIdentification,
4405
+ parameters: parametersToPass,
4406
+ });
4378
4407
  const definedParameters = Object.freeze({
4379
- ...(await getReservedParametersForTask({
4380
- tools,
4381
- preparedPipeline,
4382
- task: currentTask,
4383
- pipelineIdentification,
4384
- parameters: parametersToPass,
4385
- })),
4408
+ ...reservedParameters,
4386
4409
  ...parametersToPass,
4387
4410
  });
4388
4411
  const definedParameterNames = new Set(Object.keys(definedParameters));
@@ -4829,6 +4852,7 @@ function createPipelineExecutor(options) {
4829
4852
  };
4830
4853
  const pipelineExecutor = (inputParameters) => createTask({
4831
4854
  taskType: 'EXECUTION',
4855
+ title: pipeline.title,
4832
4856
  taskProcessCallback(updateOngoingResult) {
4833
4857
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
4834
4858
  updateOngoingResult(newOngoingResult);
@@ -4880,12 +4904,14 @@ function countUsage(llmTools) {
4880
4904
  const spending = new Subject();
4881
4905
  const proxyTools = {
4882
4906
  get title() {
4883
- // TODO: [🧠] Maybe put here some suffix
4884
- return llmTools.title;
4907
+ return `${llmTools.title} (+usage)`;
4908
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
4909
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
4885
4910
  },
4886
4911
  get description() {
4887
- // TODO: [🧠] Maybe put here some suffix
4888
- return llmTools.description;
4912
+ return `${llmTools.description} (+usage)`;
4913
+ // <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
4914
+ // <- TODO: [🧈][🧠] Does it make sence to suffix "(+usage)"?
4889
4915
  },
4890
4916
  checkConfiguration() {
4891
4917
  return /* not await */ llmTools.checkConfiguration();