@promptbook/cli 0.92.0-29 → 0.92.0-30

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
@@ -21,9 +21,9 @@ import { lookup, extension } from 'mime-types';
21
21
  import glob from 'glob-promise';
22
22
  import moment from 'moment';
23
23
  import express from 'express';
24
+ import * as OpenApiValidator from 'express-openapi-validator';
24
25
  import http from 'http';
25
26
  import { Server } from 'socket.io';
26
- import * as OpenApiValidator from 'express-openapi-validator';
27
27
  import swaggerUi from 'swagger-ui-express';
28
28
  import Anthropic from '@anthropic-ai/sdk';
29
29
  import { OpenAIClient, AzureKeyCredential } from '@azure/openai';
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-29';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-30';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -178,7 +178,6 @@ const BIG_DATASET_TRESHOLD = 50;
178
178
  * @public exported from `@promptbook/core`
179
179
  */
180
180
  const FAILED_VALUE_PLACEHOLDER = '!?';
181
- // <- TODO: !!!! Use
182
181
  /**
183
182
  * Warning message for the generated sections and files files
184
183
  *
@@ -370,7 +369,7 @@ const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = `getPipelineCollection`;
370
369
  *
371
370
  * @public exported from `@promptbook/core`
372
371
  */
373
- const DEFAULT_RPM$1 = 60;
372
+ const DEFAULT_MAX_REQUESTS_PER_MINUTE = 60;
374
373
  /**
375
374
  * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
376
375
  *
@@ -5612,13 +5611,10 @@ const CsvFormatParser = {
5612
5611
  if (onProgress) {
5613
5612
  // Note: Report the CSV with all rows mapped so far
5614
5613
  /*
5615
- !!!!
5616
- // Report progress with updated value
5617
- const progressData = mappedData.map((row, i) =>
5618
- i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
5619
- );
5620
-
5621
-
5614
+ // TODO: [🛕] Report progress with all the rows including the pending ones
5615
+ const progressData = mappedData.map((row, i) =>
5616
+ i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
5617
+ );
5622
5618
  */
5623
5619
  await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
5624
5620
  }
@@ -11463,24 +11459,25 @@ async function compilePipeline(pipelineString, tools, options) {
11463
11459
  */
11464
11460
  function renderPromptbookMermaid(pipelineJson, options) {
11465
11461
  const { linkTask = () => null } = options || {};
11466
- const MERMAID_PREFIX = 'mermaid_';
11467
- const KNOWLEDGE_NAME = MERMAID_PREFIX + 'knowledge';
11468
- const RESERVED_NAME = MERMAID_PREFIX + 'reserved';
11462
+ const MERMAID_PREFIX = 'pipeline_';
11463
+ const MERMAID_KNOWLEDGE_NAME = MERMAID_PREFIX + 'knowledge';
11464
+ const MERMAID_RESERVED_NAME = MERMAID_PREFIX + 'reserved';
11465
+ const MERMAID_INPUT_NAME = MERMAID_PREFIX + 'input';
11466
+ const MERMAID_OUTPUT_NAME = MERMAID_PREFIX + 'output';
11469
11467
  const parameterNameToTaskName = (parameterName) => {
11470
11468
  if (parameterName === 'knowledge') {
11471
- return KNOWLEDGE_NAME;
11472
- // <- TODO: !!!! Check that this works
11469
+ return MERMAID_KNOWLEDGE_NAME;
11473
11470
  }
11474
11471
  else if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
11475
- return RESERVED_NAME;
11472
+ return MERMAID_RESERVED_NAME;
11476
11473
  }
11477
11474
  const parameter = pipelineJson.parameters.find((parameter) => parameter.name === parameterName);
11478
11475
  if (!parameter) {
11479
11476
  throw new UnexpectedError(`Could not find {${parameterName}}`);
11480
- // <- TODO: !!6 This causes problems when {knowledge} and other reserved parameters are used
11477
+ // <- TODO: This causes problems when {knowledge} and other reserved parameters are used
11481
11478
  }
11482
11479
  if (parameter.isInput) {
11483
- return MERMAID_PREFIX + 'input';
11480
+ return MERMAID_INPUT_NAME;
11484
11481
  }
11485
11482
  const task = pipelineJson.tasks.find((task) => task.resultingParameterName === parameterName);
11486
11483
  if (!task) {
@@ -11488,32 +11485,17 @@ function renderPromptbookMermaid(pipelineJson, options) {
11488
11485
  }
11489
11486
  return MERMAID_PREFIX + (task.name || normalizeTo_camelCase('task-' + titleToName(task.title)));
11490
11487
  };
11491
- const promptbookMermaid = spaceTrim$1((block) => `
11492
-
11493
- %% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
11494
-
11495
- flowchart LR
11496
- subgraph "${pipelineJson.title}"
11497
-
11498
- direction TB
11499
-
11500
- input((Input)):::input
11501
- ${RESERVED_NAME}((Other)):::${RESERVED_NAME}
11502
- ${KNOWLEDGE_NAME}((Knowledgebase)):::${KNOWLEDGE_NAME}
11503
- ${block(pipelineJson.tasks
11488
+ const inputAndIntermediateParametersMermaid = pipelineJson.tasks
11504
11489
  .flatMap(({ title, dependentParameterNames, resultingParameterName }) => [
11505
11490
  `${parameterNameToTaskName(resultingParameterName)}("${title}")`,
11506
11491
  ...dependentParameterNames.map((dependentParameterName) => `${parameterNameToTaskName(dependentParameterName)}--"{${dependentParameterName}}"-->${parameterNameToTaskName(resultingParameterName)}`),
11507
11492
  ])
11508
- .join('\n'))}
11509
-
11510
- ${block(pipelineJson.parameters
11493
+ .join('\n');
11494
+ const outputParametersMermaid = pipelineJson.parameters
11511
11495
  .filter(({ isOutput }) => isOutput)
11512
- .map(({ name }) => `${parameterNameToTaskName(name)}--"{${name}}"-->output`)
11513
- .join('\n'))}
11514
- output((Output)):::output
11515
-
11516
- ${block(pipelineJson.tasks
11496
+ .map(({ name }) => `${parameterNameToTaskName(name)}--"{${name}}"-->${MERMAID_OUTPUT_NAME}`)
11497
+ .join('\n');
11498
+ const linksMermaid = pipelineJson.tasks
11517
11499
  .map((task) => {
11518
11500
  const link = linkTask(task);
11519
11501
  if (link === null) {
@@ -11524,10 +11506,44 @@ function renderPromptbookMermaid(pipelineJson, options) {
11524
11506
  return `click ${taskName} href "${href}" "${title}";`;
11525
11507
  })
11526
11508
  .filter((line) => line !== '')
11527
- .join('\n'))}
11509
+ .join('\n');
11510
+ const interactionPointsMermaid = Object.entries({
11511
+ [MERMAID_INPUT_NAME]: 'Input',
11512
+ [MERMAID_OUTPUT_NAME]: 'Output',
11513
+ [MERMAID_RESERVED_NAME]: 'Other',
11514
+ [MERMAID_KNOWLEDGE_NAME]: 'Knowledge',
11515
+ })
11516
+ .filter(([MERMAID_NAME]) => (inputAndIntermediateParametersMermaid + outputParametersMermaid).includes(MERMAID_NAME))
11517
+ .map(([MERMAID_NAME, title]) => `${MERMAID_NAME}((${title})):::${MERMAID_NAME}`)
11518
+ .join('\n');
11519
+ const promptbookMermaid = spaceTrim$1((block) => `
11520
+
11521
+ %% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
11522
+
11523
+ flowchart LR
11524
+ subgraph "${pipelineJson.title}"
11525
+
11526
+ %% Basic configuration
11527
+ direction TB
11528
+
11529
+ %% Interaction points from pipeline to outside
11530
+ ${block(interactionPointsMermaid)}
11531
+
11532
+ %% Input and intermediate parameters
11533
+ ${block(inputAndIntermediateParametersMermaid)}
11534
+
11535
+
11536
+ %% Output parameters
11537
+ ${block(outputParametersMermaid)}
11538
+
11539
+ %% Links
11540
+ ${block(linksMermaid)}
11528
11541
 
11529
- classDef input color: grey;
11530
- classDef output color: grey;
11542
+ %% Styles
11543
+ classDef ${MERMAID_INPUT_NAME} color: grey;
11544
+ classDef ${MERMAID_OUTPUT_NAME} color: grey;
11545
+ classDef ${MERMAID_RESERVED_NAME} color: grey;
11546
+ classDef ${MERMAID_KNOWLEDGE_NAME} color: grey;
11531
11547
 
11532
11548
  end;
11533
11549
 
@@ -13611,15 +13627,15 @@ function $initializeRunCommand(program) {
13611
13627
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
13612
13628
  */
13613
13629
 
13614
- // TODO: !!!! List running services from REMOTE_SERVER_URLS
13615
- // TODO: !!!! Import directly from YML
13630
+ // TODO: [🥺] List running services from REMOTE_SERVER_URLS
13631
+ // TODO: [🥺] Import directly from YML
13616
13632
  /**
13617
- * @private !!!! Decide how to expose this
13633
+ * @private [🥺] Decide how to expose this
13618
13634
  */
13619
13635
  const openapiJson = {
13620
13636
  openapi: '3.0.0',
13621
13637
  info: {
13622
- title: 'Promptbook Remote Server API (!!!! From YML)',
13638
+ title: 'Promptbook Remote Server API ([🥺] From YML)',
13623
13639
  version: '1.0.0',
13624
13640
  description: 'API documentation for the Promptbook Remote Server',
13625
13641
  },
@@ -14277,7 +14293,7 @@ function startRemoteServer(options) {
14277
14293
  response.setHeader('X-Powered-By', 'Promptbook engine');
14278
14294
  next();
14279
14295
  });
14280
- // TODO: !!!! Expose openapiJson to consumer and also allow to add new routes
14296
+ // TODO: [🥺] Expose openapiJson to consumer and also allow to add new routes
14281
14297
  app.use(OpenApiValidator.middleware({
14282
14298
  apiSpec: openapiJson,
14283
14299
  ignorePaths(path) {
@@ -14574,7 +14590,7 @@ function startRemoteServer(options) {
14574
14590
  promptResult = await llm.callCompletionModel(prompt);
14575
14591
  break;
14576
14592
  case 'EMBEDDING':
14577
- console.log('!!! llm');
14593
+ console.log('!!! llm (EMBEDDING)', llm);
14578
14594
  if (llm.callEmbeddingModel === undefined) {
14579
14595
  // Note: [0] This check should not be a thing
14580
14596
  throw new PipelineExecutionError(`Embedding model is not available`);
@@ -16038,9 +16054,6 @@ const OPENAI_MODELS = exportJson({
16038
16054
  * Note: [💞] Ignore a discrepancy between file name and entity name
16039
16055
  */
16040
16056
 
16041
- // Default rate limits (requests per minute) - adjust as needed based on Azure OpenAI tier
16042
- const DEFAULT_RPM = 60;
16043
- // <- TODO: !!! Put in some better place
16044
16057
  /**
16045
16058
  * Execution Tools for calling Azure OpenAI API.
16046
16059
  *
@@ -16060,7 +16073,7 @@ class AzureOpenAiExecutionTools {
16060
16073
  this.client = null;
16061
16074
  // TODO: Allow configuring rate limits via options
16062
16075
  this.limiter = new Bottleneck({
16063
- minTime: 60000 / (this.options.maxRequestsPerMinute || DEFAULT_RPM),
16076
+ minTime: 60000 / (this.options.maxRequestsPerMinute || DEFAULT_MAX_REQUESTS_PER_MINUTE),
16064
16077
  });
16065
16078
  }
16066
16079
  get title() {
@@ -16976,7 +16989,7 @@ const _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
16976
16989
  className: 'OpenAiExecutionTools',
16977
16990
  options: {
16978
16991
  apiKey: 'sk-',
16979
- maxRequestsPerMinute: DEFAULT_RPM$1,
16992
+ maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
16980
16993
  },
16981
16994
  };
16982
16995
  },
@@ -17128,7 +17141,7 @@ class OpenAiExecutionTools {
17128
17141
  this.client = null;
17129
17142
  // TODO: Allow configuring rate limits via options
17130
17143
  this.limiter = new Bottleneck({
17131
- minTime: 60000 / (this.options.maxRequestsPerMinute || DEFAULT_RPM$1),
17144
+ minTime: 60000 / (this.options.maxRequestsPerMinute || DEFAULT_MAX_REQUESTS_PER_MINUTE),
17132
17145
  });
17133
17146
  }
17134
17147
  get title() {
@@ -17478,7 +17491,7 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
17478
17491
  constructor(options) {
17479
17492
  super(options);
17480
17493
  this.assistantId = options.assistantId;
17481
- // TODO: !!!! Make limiter same as in OpenAiExecutionTools
17494
+ // TODO: [👱] Make limiter same as in `OpenAiExecutionTools`
17482
17495
  }
17483
17496
  get title() {
17484
17497
  return 'OpenAI Assistant';