@promptbook/cli 0.92.0-4 → 0.92.0-6

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
@@ -46,7 +46,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
46
46
  * @generated
47
47
  * @see https://github.com/webgptorg/promptbook
48
48
  */
49
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-4';
49
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-6';
50
50
  /**
51
51
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
52
52
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1004,6 +1004,45 @@ function $sideEffect(...sideEffectSubjects) {
1004
1004
  keepUnused(...sideEffectSubjects);
1005
1005
  }
1006
1006
 
1007
+ /**
1008
+ * Converts a JavaScript Object Notation (JSON) string into an object.
1009
+ *
1010
+ * Note: This is wrapper around `JSON.parse()` with better error and type handling
1011
+ *
1012
+ * @public exported from `@promptbook/utils`
1013
+ */
1014
+ function jsonParse(value) {
1015
+ if (value === undefined) {
1016
+ throw new Error(`Can not parse JSON from undefined value.`);
1017
+ }
1018
+ else if (typeof value !== 'string') {
1019
+ console.error('Can not parse JSON from non-string value.', { text: value });
1020
+ throw new Error(spaceTrim(`
1021
+ Can not parse JSON from non-string value.
1022
+
1023
+ The value type: ${typeof value}
1024
+ See more in console.
1025
+ `));
1026
+ }
1027
+ try {
1028
+ return JSON.parse(value);
1029
+ }
1030
+ catch (error) {
1031
+ if (!(error instanceof Error)) {
1032
+ throw error;
1033
+ }
1034
+ throw new Error(spaceTrim((block) => `
1035
+ ${block(error.message)}
1036
+
1037
+ The JSON text:
1038
+ ${block(value)}
1039
+ `));
1040
+ }
1041
+ }
1042
+ /**
1043
+ * TODO: !!!! Use in Promptbook.studio
1044
+ */
1045
+
1007
1046
  /**
1008
1047
  * Convert identification to Promptbook token
1009
1048
  *
@@ -2085,7 +2124,7 @@ class FileCacheStorage {
2085
2124
  return null;
2086
2125
  }
2087
2126
  const fileContent = await readFile(filename, 'utf-8');
2088
- const value = JSON.parse(fileContent);
2127
+ const value = jsonParse(fileContent);
2089
2128
  // TODO: [🌗]
2090
2129
  return value;
2091
2130
  }
@@ -3420,7 +3459,7 @@ async function $provideLlmToolsForCli(options) {
3420
3459
  password,
3421
3460
  }),
3422
3461
  });
3423
- const { isSuccess, message, error, identification } = (await response.json());
3462
+ const { isSuccess, message, error, identification } = jsonParse(await response.text());
3424
3463
  if (message) {
3425
3464
  if (isSuccess) {
3426
3465
  console.log(colors.green(message));
@@ -4451,7 +4490,7 @@ async function loadArchive(filePath, fs) {
4451
4490
  if (!indexFile) {
4452
4491
  throw new UnexpectedError(`Archive does not contain 'index.book.json' file`);
4453
4492
  }
4454
- const collectionJson = JSON.parse(await indexFile.async('text'));
4493
+ const collectionJson = jsonParse(await indexFile.async('text'));
4455
4494
  for (const pipeline of collectionJson) {
4456
4495
  validatePipeline(pipeline);
4457
4496
  }
@@ -4922,7 +4961,7 @@ function jsonStringsToJsons(object) {
4922
4961
  const newObject = { ...object };
4923
4962
  for (const [key, value] of Object.entries(object)) {
4924
4963
  if (typeof value === 'string' && isValidJsonString(value)) {
4925
- newObject[key] = JSON.parse(value);
4964
+ newObject[key] = jsonParse(value);
4926
4965
  }
4927
4966
  else {
4928
4967
  newObject[key] = jsonStringsToJsons(value);
@@ -6477,13 +6516,79 @@ async function getExamplesForTask(task) {
6477
6516
  /**
6478
6517
  * @@@
6479
6518
  *
6519
+ * Here is the place where RAG (retrieval-augmented generation) happens
6520
+ *
6480
6521
  * @private internal utility of `createPipelineExecutor`
6481
6522
  */
6482
6523
  async function getKnowledgeForTask(options) {
6483
- const { preparedPipeline, task } = options;
6484
- return preparedPipeline.knowledgePieces.map(({ content }) => `- ${content}`).join('\n');
6524
+ const { tools, preparedPipeline, task } = options;
6525
+ const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
6526
+ const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
6527
+ // <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
6528
+ if (firstKnowlegePiece === undefined || firstKnowlegeIndex === undefined) {
6529
+ return 'No knowledge pieces found';
6530
+ }
6531
+ // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
6532
+ const _llms = arrayableToArray(tools.llm);
6533
+ const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
6534
+ const taskEmbeddingPrompt = {
6535
+ title: 'Knowledge Search',
6536
+ modelRequirements: {
6537
+ modelVariant: 'EMBEDDING',
6538
+ modelName: firstKnowlegeIndex.modelName,
6539
+ },
6540
+ content: task.content,
6541
+ parameters: {
6542
+ /* !!!!!!!! */
6543
+ },
6544
+ };
6545
+ const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6546
+ const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6547
+ const { index } = knowledgePiece;
6548
+ const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowlegeIndex.modelName);
6549
+ // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
6550
+ if (knowledgePieceIndex === undefined) {
6551
+ return {
6552
+ content: knowledgePiece.content,
6553
+ relevance: 0,
6554
+ };
6555
+ }
6556
+ const relevance = computeCosineSimilarity(knowledgePieceIndex.position, taskEmbeddingResult.content);
6557
+ return {
6558
+ content: knowledgePiece.content,
6559
+ relevance,
6560
+ };
6561
+ });
6562
+ const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
6563
+ const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
6564
+ console.log('!!! Embedding', {
6565
+ task,
6566
+ taskEmbeddingPrompt,
6567
+ taskEmbeddingResult,
6568
+ firstKnowlegePiece,
6569
+ firstKnowlegeIndex,
6570
+ knowledgePiecesWithRelevance,
6571
+ knowledgePiecesSorted,
6572
+ knowledgePiecesLimited,
6573
+ });
6574
+ return knowledgePiecesLimited.map(({ content }) => `- ${content}`).join('\n');
6485
6575
  // <- TODO: [🧠] Some smart aggregation of knowledge pieces, single-line vs multi-line vs mixed
6486
6576
  }
6577
+ // TODO: !!!!!! Annotate + to new file
6578
+ function computeCosineSimilarity(embeddingVector1, embeddingVector2) {
6579
+ if (embeddingVector1.length !== embeddingVector2.length) {
6580
+ throw new TypeError('Embedding vectors must have the same length');
6581
+ }
6582
+ const dotProduct = embeddingVector1.reduce((sum, value, index) => sum + value * embeddingVector2[index], 0);
6583
+ const magnitude1 = Math.sqrt(embeddingVector1.reduce((sum, value) => sum + value * value, 0));
6584
+ const magnitude2 = Math.sqrt(embeddingVector2.reduce((sum, value) => sum + value * value, 0));
6585
+ return 1 - dotProduct / (magnitude1 * magnitude2);
6586
+ }
6587
+ /**
6588
+ * TODO: !!!! Verify if this is working
6589
+ * TODO: [♨] Implement Better - use keyword search
6590
+ * TODO: [♨] Examples of values
6591
+ */
6487
6592
 
6488
6593
  /**
6489
6594
  * @@@
@@ -6491,9 +6596,9 @@ async function getKnowledgeForTask(options) {
6491
6596
  * @private internal utility of `createPipelineExecutor`
6492
6597
  */
6493
6598
  async function getReservedParametersForTask(options) {
6494
- const { preparedPipeline, task, pipelineIdentification } = options;
6599
+ const { tools, preparedPipeline, task, pipelineIdentification } = options;
6495
6600
  const context = await getContextForTask(); // <- [🏍]
6496
- const knowledge = await getKnowledgeForTask({ preparedPipeline, task });
6601
+ const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task });
6497
6602
  const examples = await getExamplesForTask();
6498
6603
  const currentDate = new Date().toISOString(); // <- TODO: [🧠][💩] Better
6499
6604
  const modelName = RESERVED_PARAMETER_MISSING_VALUE;
@@ -6555,6 +6660,7 @@ async function executeTask(options) {
6555
6660
  }
6556
6661
  const definedParameters = Object.freeze({
6557
6662
  ...(await getReservedParametersForTask({
6663
+ tools,
6558
6664
  preparedPipeline,
6559
6665
  task: currentTask,
6560
6666
  pipelineIdentification,
@@ -7055,7 +7161,7 @@ async function preparePersona(personaDescription, tools, options) {
7055
7161
  }).asPromise();
7056
7162
  const { outputParameters } = result;
7057
7163
  const { modelsRequirements: modelsRequirementsJson } = outputParameters;
7058
- const modelsRequirementsUnchecked = JSON.parse(modelsRequirementsJson);
7164
+ const modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
7059
7165
  if (isVerbose) {
7060
7166
  console.info(`PERSONA ${personaDescription}`, modelsRequirementsUnchecked);
7061
7167
  }
@@ -7242,7 +7348,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
7242
7348
  > },
7243
7349
  */
7244
7350
  async asJson() {
7245
- return JSON.parse(await tools.fs.readFile(filename, 'utf-8'));
7351
+ return jsonParse(await tools.fs.readFile(filename, 'utf-8'));
7246
7352
  },
7247
7353
  async asText() {
7248
7354
  return await tools.fs.readFile(filename, 'utf-8');
@@ -12947,7 +13053,7 @@ function $initializeRunCommand(program) {
12947
13053
  }
12948
13054
  let inputParameters = {};
12949
13055
  if (json) {
12950
- inputParameters = JSON.parse(json);
13056
+ inputParameters = jsonParse(json);
12951
13057
  // <- TODO: Maybe check shape of passed JSON and if its valid parameters Record
12952
13058
  }
12953
13059
  // TODO: DRY [◽]
@@ -13178,7 +13284,7 @@ function $initializeRunCommand(program) {
13178
13284
  const openapiJson = {
13179
13285
  openapi: '3.0.0',
13180
13286
  info: {
13181
- title: 'Promptbook Remote Server API (!!!! From TS)',
13287
+ title: 'Promptbook Remote Server API (!!!! From YML)',
13182
13288
  version: '1.0.0',
13183
13289
  description: 'API documentation for the Promptbook Remote Server',
13184
13290
  },
@@ -13190,6 +13296,13 @@ const openapiJson = {
13190
13296
  responses: {
13191
13297
  '200': {
13192
13298
  description: 'Server details in markdown format.',
13299
+ content: {
13300
+ 'text/markdown': {
13301
+ schema: {
13302
+ type: 'string',
13303
+ },
13304
+ },
13305
+ },
13193
13306
  },
13194
13307
  },
13195
13308
  },
@@ -13220,13 +13333,22 @@ const openapiJson = {
13220
13333
  },
13221
13334
  },
13222
13335
  responses: {
13223
- '200': {
13336
+ '201': {
13224
13337
  description: 'Successful login',
13225
13338
  content: {
13226
13339
  'application/json': {
13227
13340
  schema: {
13228
13341
  type: 'object',
13229
13342
  properties: {
13343
+ isSuccess: {
13344
+ type: 'boolean',
13345
+ },
13346
+ message: {
13347
+ type: 'string',
13348
+ },
13349
+ error: {
13350
+ type: 'object',
13351
+ },
13230
13352
  identification: {
13231
13353
  type: 'object',
13232
13354
  },
@@ -13235,6 +13357,43 @@ const openapiJson = {
13235
13357
  },
13236
13358
  },
13237
13359
  },
13360
+ '400': {
13361
+ description: 'Bad request or login failed',
13362
+ content: {
13363
+ 'application/json': {
13364
+ schema: {
13365
+ type: 'object',
13366
+ properties: {
13367
+ error: {
13368
+ type: 'object',
13369
+ },
13370
+ },
13371
+ },
13372
+ },
13373
+ },
13374
+ },
13375
+ '401': {
13376
+ description: 'Authentication error',
13377
+ content: {
13378
+ 'application/json': {
13379
+ schema: {
13380
+ type: 'object',
13381
+ properties: {
13382
+ isSuccess: {
13383
+ type: 'boolean',
13384
+ enum: [false],
13385
+ },
13386
+ message: {
13387
+ type: 'string',
13388
+ },
13389
+ error: {
13390
+ type: 'object',
13391
+ },
13392
+ },
13393
+ },
13394
+ },
13395
+ },
13396
+ },
13238
13397
  },
13239
13398
  },
13240
13399
  },
@@ -13256,6 +13415,16 @@ const openapiJson = {
13256
13415
  },
13257
13416
  },
13258
13417
  },
13418
+ '500': {
13419
+ description: 'No collection available',
13420
+ content: {
13421
+ 'text/plain': {
13422
+ schema: {
13423
+ type: 'string',
13424
+ },
13425
+ },
13426
+ },
13427
+ },
13259
13428
  },
13260
13429
  },
13261
13430
  },
@@ -13287,6 +13456,28 @@ const openapiJson = {
13287
13456
  },
13288
13457
  '404': {
13289
13458
  description: 'Book not found.',
13459
+ content: {
13460
+ 'application/json': {
13461
+ schema: {
13462
+ type: 'object',
13463
+ properties: {
13464
+ error: {
13465
+ type: 'object',
13466
+ },
13467
+ },
13468
+ },
13469
+ },
13470
+ },
13471
+ },
13472
+ '500': {
13473
+ description: 'No collection available',
13474
+ content: {
13475
+ 'text/plain': {
13476
+ schema: {
13477
+ type: 'string',
13478
+ },
13479
+ },
13480
+ },
13290
13481
  },
13291
13482
  },
13292
13483
  },
@@ -13304,11 +13495,174 @@ const openapiJson = {
13304
13495
  type: 'array',
13305
13496
  items: {
13306
13497
  type: 'object',
13498
+ properties: {
13499
+ nonce: {
13500
+ type: 'string',
13501
+ },
13502
+ taskId: {
13503
+ type: 'string',
13504
+ },
13505
+ taskType: {
13506
+ type: 'string',
13507
+ },
13508
+ status: {
13509
+ type: 'string',
13510
+ },
13511
+ createdAt: {
13512
+ type: 'string',
13513
+ format: 'date-time',
13514
+ },
13515
+ updatedAt: {
13516
+ type: 'string',
13517
+ format: 'date-time',
13518
+ },
13519
+ },
13520
+ },
13521
+ },
13522
+ },
13523
+ },
13524
+ },
13525
+ },
13526
+ },
13527
+ },
13528
+ '/executions/last': {
13529
+ get: {
13530
+ summary: 'Get the last execution',
13531
+ description: 'Returns details of the last execution task.',
13532
+ responses: {
13533
+ '200': {
13534
+ description: 'The last execution task with full details.',
13535
+ content: {
13536
+ 'application/json': {
13537
+ schema: {
13538
+ type: 'object',
13539
+ properties: {
13540
+ nonce: {
13541
+ type: 'string',
13542
+ },
13543
+ taskId: {
13544
+ type: 'string',
13545
+ },
13546
+ taskType: {
13547
+ type: 'string',
13548
+ },
13549
+ status: {
13550
+ type: 'string',
13551
+ },
13552
+ errors: {
13553
+ type: 'array',
13554
+ items: {
13555
+ type: 'object',
13556
+ },
13557
+ },
13558
+ warnings: {
13559
+ type: 'array',
13560
+ items: {
13561
+ type: 'object',
13562
+ },
13563
+ },
13564
+ createdAt: {
13565
+ type: 'string',
13566
+ format: 'date-time',
13567
+ },
13568
+ updatedAt: {
13569
+ type: 'string',
13570
+ format: 'date-time',
13571
+ },
13572
+ currentValue: {
13573
+ type: 'object',
13574
+ },
13575
+ },
13576
+ },
13577
+ },
13578
+ },
13579
+ },
13580
+ '404': {
13581
+ description: 'No execution tasks found.',
13582
+ content: {
13583
+ 'text/plain': {
13584
+ schema: {
13585
+ type: 'string',
13586
+ },
13587
+ },
13588
+ },
13589
+ },
13590
+ },
13591
+ },
13592
+ },
13593
+ '/executions/{taskId}': {
13594
+ get: {
13595
+ summary: 'Get specific execution',
13596
+ description: 'Returns details of a specific execution task.',
13597
+ parameters: [
13598
+ {
13599
+ in: 'path',
13600
+ name: 'taskId',
13601
+ required: true,
13602
+ schema: {
13603
+ type: 'string',
13604
+ },
13605
+ description: 'The ID of the execution task to retrieve.',
13606
+ },
13607
+ ],
13608
+ responses: {
13609
+ '200': {
13610
+ description: 'The execution task with full details.',
13611
+ content: {
13612
+ 'application/json': {
13613
+ schema: {
13614
+ type: 'object',
13615
+ properties: {
13616
+ nonce: {
13617
+ type: 'string',
13618
+ },
13619
+ taskId: {
13620
+ type: 'string',
13621
+ },
13622
+ taskType: {
13623
+ type: 'string',
13624
+ },
13625
+ status: {
13626
+ type: 'string',
13627
+ },
13628
+ errors: {
13629
+ type: 'array',
13630
+ items: {
13631
+ type: 'object',
13632
+ },
13633
+ },
13634
+ warnings: {
13635
+ type: 'array',
13636
+ items: {
13637
+ type: 'object',
13638
+ },
13639
+ },
13640
+ createdAt: {
13641
+ type: 'string',
13642
+ format: 'date-time',
13643
+ },
13644
+ updatedAt: {
13645
+ type: 'string',
13646
+ format: 'date-time',
13647
+ },
13648
+ currentValue: {
13649
+ type: 'object',
13650
+ },
13307
13651
  },
13308
13652
  },
13309
13653
  },
13310
13654
  },
13311
13655
  },
13656
+ '404': {
13657
+ description: 'Execution task not found.',
13658
+ content: {
13659
+ 'text/plain': {
13660
+ schema: {
13661
+ type: 'string',
13662
+ },
13663
+ },
13664
+ },
13665
+ },
13312
13666
  },
13313
13667
  },
13314
13668
  },
@@ -13325,12 +13679,19 @@ const openapiJson = {
13325
13679
  properties: {
13326
13680
  pipelineUrl: {
13327
13681
  type: 'string',
13682
+ description: 'URL of the pipeline to execute',
13683
+ },
13684
+ book: {
13685
+ type: 'string',
13686
+ description: 'Alternative field for pipelineUrl',
13328
13687
  },
13329
13688
  inputParameters: {
13330
13689
  type: 'object',
13690
+ description: 'Parameters for pipeline execution',
13331
13691
  },
13332
13692
  identification: {
13333
13693
  type: 'object',
13694
+ description: 'User identification data',
13334
13695
  },
13335
13696
  },
13336
13697
  },
@@ -13350,13 +13711,164 @@ const openapiJson = {
13350
13711
  },
13351
13712
  '400': {
13352
13713
  description: 'Invalid input.',
13714
+ content: {
13715
+ 'application/json': {
13716
+ schema: {
13717
+ type: 'object',
13718
+ properties: {
13719
+ error: {
13720
+ type: 'object',
13721
+ },
13722
+ },
13723
+ },
13724
+ },
13725
+ },
13726
+ },
13727
+ '404': {
13728
+ description: 'Pipeline not found.',
13729
+ content: {
13730
+ 'text/plain': {
13731
+ schema: {
13732
+ type: 'string',
13733
+ },
13734
+ },
13735
+ },
13736
+ },
13737
+ },
13738
+ },
13739
+ },
13740
+ '/api-docs': {
13741
+ get: {
13742
+ summary: 'API documentation UI',
13743
+ description: 'Swagger UI for API documentation',
13744
+ responses: {
13745
+ '200': {
13746
+ description: 'HTML Swagger UI',
13747
+ },
13748
+ },
13749
+ },
13750
+ },
13751
+ '/swagger': {
13752
+ get: {
13753
+ summary: 'API documentation UI (alternative path)',
13754
+ description: 'Swagger UI for API documentation',
13755
+ responses: {
13756
+ '200': {
13757
+ description: 'HTML Swagger UI',
13758
+ },
13759
+ },
13760
+ },
13761
+ },
13762
+ '/openapi': {
13763
+ get: {
13764
+ summary: 'OpenAPI specification',
13765
+ description: 'Returns the OpenAPI JSON specification',
13766
+ responses: {
13767
+ '200': {
13768
+ description: 'OpenAPI specification',
13769
+ content: {
13770
+ 'application/json': {
13771
+ schema: {
13772
+ type: 'object',
13773
+ },
13774
+ },
13775
+ },
13353
13776
  },
13354
13777
  },
13355
13778
  },
13356
13779
  },
13357
13780
  },
13358
- components: {},
13359
- tags: [],
13781
+ components: {
13782
+ schemas: {
13783
+ Error: {
13784
+ type: 'object',
13785
+ properties: {
13786
+ error: {
13787
+ type: 'object',
13788
+ },
13789
+ },
13790
+ },
13791
+ ExecutionTaskSummary: {
13792
+ type: 'object',
13793
+ properties: {
13794
+ nonce: {
13795
+ type: 'string',
13796
+ },
13797
+ taskId: {
13798
+ type: 'string',
13799
+ },
13800
+ taskType: {
13801
+ type: 'string',
13802
+ },
13803
+ status: {
13804
+ type: 'string',
13805
+ },
13806
+ createdAt: {
13807
+ type: 'string',
13808
+ format: 'date-time',
13809
+ },
13810
+ updatedAt: {
13811
+ type: 'string',
13812
+ format: 'date-time',
13813
+ },
13814
+ },
13815
+ },
13816
+ ExecutionTaskFull: {
13817
+ type: 'object',
13818
+ properties: {
13819
+ nonce: {
13820
+ type: 'string',
13821
+ },
13822
+ taskId: {
13823
+ type: 'string',
13824
+ },
13825
+ taskType: {
13826
+ type: 'string',
13827
+ },
13828
+ status: {
13829
+ type: 'string',
13830
+ },
13831
+ errors: {
13832
+ type: 'array',
13833
+ items: {
13834
+ type: 'object',
13835
+ },
13836
+ },
13837
+ warnings: {
13838
+ type: 'array',
13839
+ items: {
13840
+ type: 'object',
13841
+ },
13842
+ },
13843
+ createdAt: {
13844
+ type: 'string',
13845
+ format: 'date-time',
13846
+ },
13847
+ updatedAt: {
13848
+ type: 'string',
13849
+ format: 'date-time',
13850
+ },
13851
+ currentValue: {
13852
+ type: 'object',
13853
+ },
13854
+ },
13855
+ },
13856
+ },
13857
+ },
13858
+ tags: [
13859
+ {
13860
+ name: 'Books',
13861
+ description: 'Operations related to books and pipelines',
13862
+ },
13863
+ {
13864
+ name: 'Executions',
13865
+ description: 'Operations related to execution tasks',
13866
+ },
13867
+ {
13868
+ name: 'Authentication',
13869
+ description: 'Authentication operations',
13870
+ },
13871
+ ],
13360
13872
  };
13361
13873
  /**
13362
13874
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -14001,7 +14513,7 @@ function $initializeTestCommand(program) {
14001
14513
  }
14002
14514
  }
14003
14515
  if (filename.endsWith('.bookc')) {
14004
- pipeline = JSON.parse(await readFile(filename, 'utf-8'));
14516
+ pipeline = jsonParse(await readFile(filename, 'utf-8'));
14005
14517
  }
14006
14518
  else {
14007
14519
  if (isVerbose) {
@@ -14110,6 +14622,37 @@ const _CLI = {
14110
14622
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
14111
14623
  */
14112
14624
 
14625
+ /**
14626
+ * How is the model provider trusted?
14627
+ *
14628
+ * @public exported from `@promptbook/core`
14629
+ */
14630
+ // <- TODO: Maybe do better levels of trust
14631
+ /**
14632
+ * How is the model provider important?
14633
+ *
14634
+ * @public exported from `@promptbook/core`
14635
+ */
14636
+ const MODEL_ORDER = {
14637
+ /**
14638
+ * Top-tier models, e.g. OpenAI, Anthropic,...
14639
+ */
14640
+ TOP_TIER: 333,
14641
+ /**
14642
+ * Mid-tier models, e.g. Llama, Mistral, etc.
14643
+ */
14644
+ NORMAL: 100,
14645
+ /**
14646
+ * Low-tier models, e.g. Phi, Tiny, etc.
14647
+ */
14648
+ LOW_TIER: 0,
14649
+ };
14650
+ /**
14651
+ * TODO: Add configuration schema and maybe some documentation link
14652
+ * TODO: Maybe constrain LlmToolsConfiguration[number] by generic to ensure that `createConfigurationFromEnv` and `getBoilerplateConfiguration` always create same `packageName` and `className`
14653
+ * TODO: [®] DRY Register logic
14654
+ */
14655
+
14113
14656
  /**
14114
14657
  * Registration of LLM provider metadata
14115
14658
  *
@@ -14124,9 +14667,11 @@ const _AnthropicClaudeMetadataRegistration = $llmToolsMetadataRegister.register(
14124
14667
  packageName: '@promptbook/anthropic-claude',
14125
14668
  className: 'AnthropicClaudeExecutionTools',
14126
14669
  envVariables: ['ANTHROPIC_CLAUDE_API_KEY'],
14670
+ trustLevel: 'CLOSED',
14671
+ order: MODEL_ORDER.TOP_TIER,
14127
14672
  getBoilerplateConfiguration() {
14128
14673
  return {
14129
- title: 'Anthropic Claude (boilerplate)',
14674
+ title: 'Anthropic Claude',
14130
14675
  packageName: '@promptbook/anthropic-claude',
14131
14676
  className: 'AnthropicClaudeExecutionTools',
14132
14677
  options: {
@@ -14662,9 +15207,11 @@ const _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
14662
15207
  packageName: '@promptbook/azure-openai',
14663
15208
  className: 'AzureOpenAiExecutionTools',
14664
15209
  envVariables: ['AZUREOPENAI_RESOURCE_NAME', 'AZUREOPENAI_DEPLOYMENT_NAME', 'AZUREOPENAI_API_KEY'],
15210
+ trustLevel: 'CLOSED_BUSINESS',
15211
+ order: MODEL_ORDER.NORMAL,
14665
15212
  getBoilerplateConfiguration() {
14666
15213
  return {
14667
- title: 'Azure Open AI (boilerplate)',
15214
+ title: 'Azure Open AI',
14668
15215
  packageName: '@promptbook/azure-openai',
14669
15216
  className: 'AzureOpenAiExecutionTools',
14670
15217
  options: {
@@ -15512,9 +16059,11 @@ const _DeepseekMetadataRegistration = $llmToolsMetadataRegister.register({
15512
16059
  packageName: '@promptbook/deepseek',
15513
16060
  className: 'DeepseekExecutionTools',
15514
16061
  envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
16062
+ trustLevel: 'UNTRUSTED',
16063
+ order: MODEL_ORDER.NORMAL,
15515
16064
  getBoilerplateConfiguration() {
15516
16065
  return {
15517
- title: 'Deepseek (boilerplate)',
16066
+ title: 'Deepseek',
15518
16067
  packageName: '@promptbook/deepseek',
15519
16068
  className: 'DeepseekExecutionTools',
15520
16069
  options: {
@@ -15833,9 +16382,11 @@ const _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
15833
16382
  packageName: '@promptbook/google',
15834
16383
  className: 'GoogleExecutionTools',
15835
16384
  envVariables: ['GOOGLE_GENERATIVE_AI_API_KEY'],
16385
+ trustLevel: 'CLOSED',
16386
+ order: MODEL_ORDER.NORMAL,
15836
16387
  getBoilerplateConfiguration() {
15837
16388
  return {
15838
- title: 'Google Gemini (boilerplate)',
16389
+ title: 'Google Gemini',
15839
16390
  packageName: '@promptbook/google',
15840
16391
  className: 'GoogleExecutionTools',
15841
16392
  options: {
@@ -16096,9 +16647,11 @@ const _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
16096
16647
  packageName: '@promptbook/openai',
16097
16648
  className: 'OpenAiExecutionTools',
16098
16649
  envVariables: ['OPENAI_API_KEY'],
16650
+ trustLevel: 'CLOSED',
16651
+ order: MODEL_ORDER.TOP_TIER,
16099
16652
  getBoilerplateConfiguration() {
16100
16653
  return {
16101
- title: 'Open AI (boilerplate)',
16654
+ title: 'Open AI',
16102
16655
  packageName: '@promptbook/openai',
16103
16656
  className: 'OpenAiExecutionTools',
16104
16657
  options: {
@@ -16136,9 +16689,11 @@ const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register(
16136
16689
  className: 'OpenAiAssistantExecutionTools',
16137
16690
  envVariables: null,
16138
16691
  // <- TODO: ['OPENAI_API_KEY', 'OPENAI_ASSISTANT_ID']
16692
+ trustLevel: 'CLOSED',
16693
+ order: MODEL_ORDER.NORMAL,
16139
16694
  getBoilerplateConfiguration() {
16140
16695
  return {
16141
- title: 'Open AI Assistant (boilerplate)',
16696
+ title: 'Open AI Assistant',
16142
16697
  packageName: '@promptbook/openai',
16143
16698
  className: 'OpenAiAssistantExecutionTools',
16144
16699
  options: {