@promptbook/cli 0.92.0-5 → 0.92.0-7

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/umd/index.umd.js CHANGED
@@ -56,7 +56,7 @@
56
56
  * @generated
57
57
  * @see https://github.com/webgptorg/promptbook
58
58
  */
59
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-5';
59
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-7';
60
60
  /**
61
61
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
62
62
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1014,6 +1014,45 @@
1014
1014
  keepUnused(...sideEffectSubjects);
1015
1015
  }
1016
1016
 
1017
+ /**
1018
+ * Converts a JavaScript Object Notation (JSON) string into an object.
1019
+ *
1020
+ * Note: This is wrapper around `JSON.parse()` with better error and type handling
1021
+ *
1022
+ * @public exported from `@promptbook/utils`
1023
+ */
1024
+ function jsonParse(value) {
1025
+ if (value === undefined) {
1026
+ throw new Error(`Can not parse JSON from undefined value.`);
1027
+ }
1028
+ else if (typeof value !== 'string') {
1029
+ console.error('Can not parse JSON from non-string value.', { text: value });
1030
+ throw new Error(spaceTrim__default["default"](`
1031
+ Can not parse JSON from non-string value.
1032
+
1033
+ The value type: ${typeof value}
1034
+ See more in console.
1035
+ `));
1036
+ }
1037
+ try {
1038
+ return JSON.parse(value);
1039
+ }
1040
+ catch (error) {
1041
+ if (!(error instanceof Error)) {
1042
+ throw error;
1043
+ }
1044
+ throw new Error(spaceTrim__default["default"]((block) => `
1045
+ ${block(error.message)}
1046
+
1047
+ The JSON text:
1048
+ ${block(value)}
1049
+ `));
1050
+ }
1051
+ }
1052
+ /**
1053
+ * TODO: !!!! Use in Promptbook.studio
1054
+ */
1055
+
1017
1056
  /**
1018
1057
  * Convert identification to Promptbook token
1019
1058
  *
@@ -2095,7 +2134,7 @@
2095
2134
  return null;
2096
2135
  }
2097
2136
  const fileContent = await promises.readFile(filename, 'utf-8');
2098
- const value = JSON.parse(fileContent);
2137
+ const value = jsonParse(fileContent);
2099
2138
  // TODO: [🌗]
2100
2139
  return value;
2101
2140
  }
@@ -3430,7 +3469,7 @@
3430
3469
  password,
3431
3470
  }),
3432
3471
  });
3433
- const { isSuccess, message, error, identification } = (await response.json());
3472
+ const { isSuccess, message, error, identification } = jsonParse(await response.text());
3434
3473
  if (message) {
3435
3474
  if (isSuccess) {
3436
3475
  console.log(colors__default["default"].green(message));
@@ -4461,7 +4500,7 @@
4461
4500
  if (!indexFile) {
4462
4501
  throw new UnexpectedError(`Archive does not contain 'index.book.json' file`);
4463
4502
  }
4464
- const collectionJson = JSON.parse(await indexFile.async('text'));
4503
+ const collectionJson = jsonParse(await indexFile.async('text'));
4465
4504
  for (const pipeline of collectionJson) {
4466
4505
  validatePipeline(pipeline);
4467
4506
  }
@@ -4932,7 +4971,7 @@
4932
4971
  const newObject = { ...object };
4933
4972
  for (const [key, value] of Object.entries(object)) {
4934
4973
  if (typeof value === 'string' && isValidJsonString(value)) {
4935
- newObject[key] = JSON.parse(value);
4974
+ newObject[key] = jsonParse(value);
4936
4975
  }
4937
4976
  else {
4938
4977
  newObject[key] = jsonStringsToJsons(value);
@@ -6487,13 +6526,79 @@
6487
6526
  /**
6488
6527
  * @@@
6489
6528
  *
6529
+ * Here is the place where RAG (retrieval-augmented generation) happens
6530
+ *
6490
6531
  * @private internal utility of `createPipelineExecutor`
6491
6532
  */
6492
6533
  async function getKnowledgeForTask(options) {
6493
- const { preparedPipeline, task } = options;
6494
- return preparedPipeline.knowledgePieces.map(({ content }) => `- ${content}`).join('\n');
6534
+ const { tools, preparedPipeline, task } = options;
6535
+ const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
6536
+ const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
6537
+ // <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
6538
+ if (firstKnowlegePiece === undefined || firstKnowlegeIndex === undefined) {
6539
+ return 'No knowledge pieces found';
6540
+ }
6541
+ // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
6542
+ const _llms = arrayableToArray(tools.llm);
6543
+ const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
6544
+ const taskEmbeddingPrompt = {
6545
+ title: 'Knowledge Search',
6546
+ modelRequirements: {
6547
+ modelVariant: 'EMBEDDING',
6548
+ modelName: firstKnowlegeIndex.modelName,
6549
+ },
6550
+ content: task.content,
6551
+ parameters: {
6552
+ /* !!!!!!!! */
6553
+ },
6554
+ };
6555
+ const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6556
+ const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6557
+ const { index } = knowledgePiece;
6558
+ const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowlegeIndex.modelName);
6559
+ // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
6560
+ if (knowledgePieceIndex === undefined) {
6561
+ return {
6562
+ content: knowledgePiece.content,
6563
+ relevance: 0,
6564
+ };
6565
+ }
6566
+ const relevance = computeCosineSimilarity(knowledgePieceIndex.position, taskEmbeddingResult.content);
6567
+ return {
6568
+ content: knowledgePiece.content,
6569
+ relevance,
6570
+ };
6571
+ });
6572
+ const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
6573
+ const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
6574
+ console.log('!!! Embedding', {
6575
+ task,
6576
+ taskEmbeddingPrompt,
6577
+ taskEmbeddingResult,
6578
+ firstKnowlegePiece,
6579
+ firstKnowlegeIndex,
6580
+ knowledgePiecesWithRelevance,
6581
+ knowledgePiecesSorted,
6582
+ knowledgePiecesLimited,
6583
+ });
6584
+ return knowledgePiecesLimited.map(({ content }) => `- ${content}`).join('\n');
6495
6585
  // <- TODO: [🧠] Some smart aggregation of knowledge pieces, single-line vs multi-line vs mixed
6496
6586
  }
6587
+ // TODO: !!!!!! Annotate + to new file
6588
+ function computeCosineSimilarity(embeddingVector1, embeddingVector2) {
6589
+ if (embeddingVector1.length !== embeddingVector2.length) {
6590
+ throw new TypeError('Embedding vectors must have the same length');
6591
+ }
6592
+ const dotProduct = embeddingVector1.reduce((sum, value, index) => sum + value * embeddingVector2[index], 0);
6593
+ const magnitude1 = Math.sqrt(embeddingVector1.reduce((sum, value) => sum + value * value, 0));
6594
+ const magnitude2 = Math.sqrt(embeddingVector2.reduce((sum, value) => sum + value * value, 0));
6595
+ return 1 - dotProduct / (magnitude1 * magnitude2);
6596
+ }
6597
+ /**
6598
+ * TODO: !!!! Verify if this is working
6599
+ * TODO: [♨] Implement Better - use keyword search
6600
+ * TODO: [♨] Examples of values
6601
+ */
6497
6602
 
6498
6603
  /**
6499
6604
  * @@@
@@ -6501,9 +6606,9 @@
6501
6606
  * @private internal utility of `createPipelineExecutor`
6502
6607
  */
6503
6608
  async function getReservedParametersForTask(options) {
6504
- const { preparedPipeline, task, pipelineIdentification } = options;
6609
+ const { tools, preparedPipeline, task, pipelineIdentification } = options;
6505
6610
  const context = await getContextForTask(); // <- [🏍]
6506
- const knowledge = await getKnowledgeForTask({ preparedPipeline, task });
6611
+ const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task });
6507
6612
  const examples = await getExamplesForTask();
6508
6613
  const currentDate = new Date().toISOString(); // <- TODO: [🧠][💩] Better
6509
6614
  const modelName = RESERVED_PARAMETER_MISSING_VALUE;
@@ -6565,6 +6670,7 @@
6565
6670
  }
6566
6671
  const definedParameters = Object.freeze({
6567
6672
  ...(await getReservedParametersForTask({
6673
+ tools,
6568
6674
  preparedPipeline,
6569
6675
  task: currentTask,
6570
6676
  pipelineIdentification,
@@ -7065,18 +7171,26 @@
7065
7171
  }).asPromise();
7066
7172
  const { outputParameters } = result;
7067
7173
  const { modelsRequirements: modelsRequirementsJson } = outputParameters;
7068
- const modelsRequirementsUnchecked = JSON.parse(modelsRequirementsJson);
7174
+ let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
7069
7175
  if (isVerbose) {
7070
7176
  console.info(`PERSONA ${personaDescription}`, modelsRequirementsUnchecked);
7071
7177
  }
7072
7178
  if (!Array.isArray(modelsRequirementsUnchecked)) {
7073
- throw new UnexpectedError(spaceTrim__default["default"]((block) => `
7074
- Invalid \`modelsRequirements\`:
7179
+ // <- TODO: Book should have syntax and system to enforce shape of JSON
7180
+ modelsRequirementsUnchecked = [modelsRequirementsUnchecked];
7181
+ /*
7182
+ throw new UnexpectedError(
7183
+ spaceTrim(
7184
+ (block) => `
7185
+ Invalid \`modelsRequirements\`:
7075
7186
 
7076
- \`\`\`json
7077
- ${block(JSON.stringify(modelsRequirementsUnchecked, null, 4))}
7078
- \`\`\`
7079
- `));
7187
+ \`\`\`json
7188
+ ${block(JSON.stringify(modelsRequirementsUnchecked, null, 4))}
7189
+ \`\`\`
7190
+ `,
7191
+ ),
7192
+ );
7193
+ */
7080
7194
  }
7081
7195
  const modelsRequirements = modelsRequirementsUnchecked.map((modelRequirements) => ({
7082
7196
  modelVariant: 'CHAT',
@@ -7252,7 +7366,7 @@
7252
7366
  > },
7253
7367
  */
7254
7368
  async asJson() {
7255
- return JSON.parse(await tools.fs.readFile(filename, 'utf-8'));
7369
+ return jsonParse(await tools.fs.readFile(filename, 'utf-8'));
7256
7370
  },
7257
7371
  async asText() {
7258
7372
  return await tools.fs.readFile(filename, 'utf-8');
@@ -12957,7 +13071,7 @@
12957
13071
  }
12958
13072
  let inputParameters = {};
12959
13073
  if (json) {
12960
- inputParameters = JSON.parse(json);
13074
+ inputParameters = jsonParse(json);
12961
13075
  // <- TODO: Maybe check shape of passed JSON and if its valid parameters Record
12962
13076
  }
12963
13077
  // TODO: DRY [◽]
@@ -13188,7 +13302,7 @@
13188
13302
  const openapiJson = {
13189
13303
  openapi: '3.0.0',
13190
13304
  info: {
13191
- title: 'Promptbook Remote Server API (!!!! From TS)',
13305
+ title: 'Promptbook Remote Server API (!!!! From YML)',
13192
13306
  version: '1.0.0',
13193
13307
  description: 'API documentation for the Promptbook Remote Server',
13194
13308
  },
@@ -13200,6 +13314,13 @@
13200
13314
  responses: {
13201
13315
  '200': {
13202
13316
  description: 'Server details in markdown format.',
13317
+ content: {
13318
+ 'text/markdown': {
13319
+ schema: {
13320
+ type: 'string',
13321
+ },
13322
+ },
13323
+ },
13203
13324
  },
13204
13325
  },
13205
13326
  },
@@ -13230,13 +13351,22 @@
13230
13351
  },
13231
13352
  },
13232
13353
  responses: {
13233
- '200': {
13354
+ '201': {
13234
13355
  description: 'Successful login',
13235
13356
  content: {
13236
13357
  'application/json': {
13237
13358
  schema: {
13238
13359
  type: 'object',
13239
13360
  properties: {
13361
+ isSuccess: {
13362
+ type: 'boolean',
13363
+ },
13364
+ message: {
13365
+ type: 'string',
13366
+ },
13367
+ error: {
13368
+ type: 'object',
13369
+ },
13240
13370
  identification: {
13241
13371
  type: 'object',
13242
13372
  },
@@ -13245,6 +13375,43 @@
13245
13375
  },
13246
13376
  },
13247
13377
  },
13378
+ '400': {
13379
+ description: 'Bad request or login failed',
13380
+ content: {
13381
+ 'application/json': {
13382
+ schema: {
13383
+ type: 'object',
13384
+ properties: {
13385
+ error: {
13386
+ type: 'object',
13387
+ },
13388
+ },
13389
+ },
13390
+ },
13391
+ },
13392
+ },
13393
+ '401': {
13394
+ description: 'Authentication error',
13395
+ content: {
13396
+ 'application/json': {
13397
+ schema: {
13398
+ type: 'object',
13399
+ properties: {
13400
+ isSuccess: {
13401
+ type: 'boolean',
13402
+ enum: [false],
13403
+ },
13404
+ message: {
13405
+ type: 'string',
13406
+ },
13407
+ error: {
13408
+ type: 'object',
13409
+ },
13410
+ },
13411
+ },
13412
+ },
13413
+ },
13414
+ },
13248
13415
  },
13249
13416
  },
13250
13417
  },
@@ -13266,6 +13433,16 @@
13266
13433
  },
13267
13434
  },
13268
13435
  },
13436
+ '500': {
13437
+ description: 'No collection available',
13438
+ content: {
13439
+ 'text/plain': {
13440
+ schema: {
13441
+ type: 'string',
13442
+ },
13443
+ },
13444
+ },
13445
+ },
13269
13446
  },
13270
13447
  },
13271
13448
  },
@@ -13297,6 +13474,28 @@
13297
13474
  },
13298
13475
  '404': {
13299
13476
  description: 'Book not found.',
13477
+ content: {
13478
+ 'application/json': {
13479
+ schema: {
13480
+ type: 'object',
13481
+ properties: {
13482
+ error: {
13483
+ type: 'object',
13484
+ },
13485
+ },
13486
+ },
13487
+ },
13488
+ },
13489
+ },
13490
+ '500': {
13491
+ description: 'No collection available',
13492
+ content: {
13493
+ 'text/plain': {
13494
+ schema: {
13495
+ type: 'string',
13496
+ },
13497
+ },
13498
+ },
13300
13499
  },
13301
13500
  },
13302
13501
  },
@@ -13314,6 +13513,28 @@
13314
13513
  type: 'array',
13315
13514
  items: {
13316
13515
  type: 'object',
13516
+ properties: {
13517
+ nonce: {
13518
+ type: 'string',
13519
+ },
13520
+ taskId: {
13521
+ type: 'string',
13522
+ },
13523
+ taskType: {
13524
+ type: 'string',
13525
+ },
13526
+ status: {
13527
+ type: 'string',
13528
+ },
13529
+ createdAt: {
13530
+ type: 'string',
13531
+ format: 'date-time',
13532
+ },
13533
+ updatedAt: {
13534
+ type: 'string',
13535
+ format: 'date-time',
13536
+ },
13537
+ },
13317
13538
  },
13318
13539
  },
13319
13540
  },
@@ -13322,6 +13543,147 @@
13322
13543
  },
13323
13544
  },
13324
13545
  },
13546
+ '/executions/last': {
13547
+ get: {
13548
+ summary: 'Get the last execution',
13549
+ description: 'Returns details of the last execution task.',
13550
+ responses: {
13551
+ '200': {
13552
+ description: 'The last execution task with full details.',
13553
+ content: {
13554
+ 'application/json': {
13555
+ schema: {
13556
+ type: 'object',
13557
+ properties: {
13558
+ nonce: {
13559
+ type: 'string',
13560
+ },
13561
+ taskId: {
13562
+ type: 'string',
13563
+ },
13564
+ taskType: {
13565
+ type: 'string',
13566
+ },
13567
+ status: {
13568
+ type: 'string',
13569
+ },
13570
+ errors: {
13571
+ type: 'array',
13572
+ items: {
13573
+ type: 'object',
13574
+ },
13575
+ },
13576
+ warnings: {
13577
+ type: 'array',
13578
+ items: {
13579
+ type: 'object',
13580
+ },
13581
+ },
13582
+ createdAt: {
13583
+ type: 'string',
13584
+ format: 'date-time',
13585
+ },
13586
+ updatedAt: {
13587
+ type: 'string',
13588
+ format: 'date-time',
13589
+ },
13590
+ currentValue: {
13591
+ type: 'object',
13592
+ },
13593
+ },
13594
+ },
13595
+ },
13596
+ },
13597
+ },
13598
+ '404': {
13599
+ description: 'No execution tasks found.',
13600
+ content: {
13601
+ 'text/plain': {
13602
+ schema: {
13603
+ type: 'string',
13604
+ },
13605
+ },
13606
+ },
13607
+ },
13608
+ },
13609
+ },
13610
+ },
13611
+ '/executions/{taskId}': {
13612
+ get: {
13613
+ summary: 'Get specific execution',
13614
+ description: 'Returns details of a specific execution task.',
13615
+ parameters: [
13616
+ {
13617
+ in: 'path',
13618
+ name: 'taskId',
13619
+ required: true,
13620
+ schema: {
13621
+ type: 'string',
13622
+ },
13623
+ description: 'The ID of the execution task to retrieve.',
13624
+ },
13625
+ ],
13626
+ responses: {
13627
+ '200': {
13628
+ description: 'The execution task with full details.',
13629
+ content: {
13630
+ 'application/json': {
13631
+ schema: {
13632
+ type: 'object',
13633
+ properties: {
13634
+ nonce: {
13635
+ type: 'string',
13636
+ },
13637
+ taskId: {
13638
+ type: 'string',
13639
+ },
13640
+ taskType: {
13641
+ type: 'string',
13642
+ },
13643
+ status: {
13644
+ type: 'string',
13645
+ },
13646
+ errors: {
13647
+ type: 'array',
13648
+ items: {
13649
+ type: 'object',
13650
+ },
13651
+ },
13652
+ warnings: {
13653
+ type: 'array',
13654
+ items: {
13655
+ type: 'object',
13656
+ },
13657
+ },
13658
+ createdAt: {
13659
+ type: 'string',
13660
+ format: 'date-time',
13661
+ },
13662
+ updatedAt: {
13663
+ type: 'string',
13664
+ format: 'date-time',
13665
+ },
13666
+ currentValue: {
13667
+ type: 'object',
13668
+ },
13669
+ },
13670
+ },
13671
+ },
13672
+ },
13673
+ },
13674
+ '404': {
13675
+ description: 'Execution task not found.',
13676
+ content: {
13677
+ 'text/plain': {
13678
+ schema: {
13679
+ type: 'string',
13680
+ },
13681
+ },
13682
+ },
13683
+ },
13684
+ },
13685
+ },
13686
+ },
13325
13687
  '/executions/new': {
13326
13688
  post: {
13327
13689
  summary: 'Start a new execution',
@@ -13335,12 +13697,19 @@
13335
13697
  properties: {
13336
13698
  pipelineUrl: {
13337
13699
  type: 'string',
13700
+ description: 'URL of the pipeline to execute',
13701
+ },
13702
+ book: {
13703
+ type: 'string',
13704
+ description: 'Alternative field for pipelineUrl',
13338
13705
  },
13339
13706
  inputParameters: {
13340
13707
  type: 'object',
13708
+ description: 'Parameters for pipeline execution',
13341
13709
  },
13342
13710
  identification: {
13343
13711
  type: 'object',
13712
+ description: 'User identification data',
13344
13713
  },
13345
13714
  },
13346
13715
  },
@@ -13360,13 +13729,164 @@
13360
13729
  },
13361
13730
  '400': {
13362
13731
  description: 'Invalid input.',
13732
+ content: {
13733
+ 'application/json': {
13734
+ schema: {
13735
+ type: 'object',
13736
+ properties: {
13737
+ error: {
13738
+ type: 'object',
13739
+ },
13740
+ },
13741
+ },
13742
+ },
13743
+ },
13744
+ },
13745
+ '404': {
13746
+ description: 'Pipeline not found.',
13747
+ content: {
13748
+ 'text/plain': {
13749
+ schema: {
13750
+ type: 'string',
13751
+ },
13752
+ },
13753
+ },
13754
+ },
13755
+ },
13756
+ },
13757
+ },
13758
+ '/api-docs': {
13759
+ get: {
13760
+ summary: 'API documentation UI',
13761
+ description: 'Swagger UI for API documentation',
13762
+ responses: {
13763
+ '200': {
13764
+ description: 'HTML Swagger UI',
13765
+ },
13766
+ },
13767
+ },
13768
+ },
13769
+ '/swagger': {
13770
+ get: {
13771
+ summary: 'API documentation UI (alternative path)',
13772
+ description: 'Swagger UI for API documentation',
13773
+ responses: {
13774
+ '200': {
13775
+ description: 'HTML Swagger UI',
13776
+ },
13777
+ },
13778
+ },
13779
+ },
13780
+ '/openapi': {
13781
+ get: {
13782
+ summary: 'OpenAPI specification',
13783
+ description: 'Returns the OpenAPI JSON specification',
13784
+ responses: {
13785
+ '200': {
13786
+ description: 'OpenAPI specification',
13787
+ content: {
13788
+ 'application/json': {
13789
+ schema: {
13790
+ type: 'object',
13791
+ },
13792
+ },
13793
+ },
13794
+ },
13795
+ },
13796
+ },
13797
+ },
13798
+ },
13799
+ components: {
13800
+ schemas: {
13801
+ Error: {
13802
+ type: 'object',
13803
+ properties: {
13804
+ error: {
13805
+ type: 'object',
13806
+ },
13807
+ },
13808
+ },
13809
+ ExecutionTaskSummary: {
13810
+ type: 'object',
13811
+ properties: {
13812
+ nonce: {
13813
+ type: 'string',
13814
+ },
13815
+ taskId: {
13816
+ type: 'string',
13817
+ },
13818
+ taskType: {
13819
+ type: 'string',
13820
+ },
13821
+ status: {
13822
+ type: 'string',
13823
+ },
13824
+ createdAt: {
13825
+ type: 'string',
13826
+ format: 'date-time',
13827
+ },
13828
+ updatedAt: {
13829
+ type: 'string',
13830
+ format: 'date-time',
13831
+ },
13832
+ },
13833
+ },
13834
+ ExecutionTaskFull: {
13835
+ type: 'object',
13836
+ properties: {
13837
+ nonce: {
13838
+ type: 'string',
13839
+ },
13840
+ taskId: {
13841
+ type: 'string',
13842
+ },
13843
+ taskType: {
13844
+ type: 'string',
13845
+ },
13846
+ status: {
13847
+ type: 'string',
13848
+ },
13849
+ errors: {
13850
+ type: 'array',
13851
+ items: {
13852
+ type: 'object',
13853
+ },
13854
+ },
13855
+ warnings: {
13856
+ type: 'array',
13857
+ items: {
13858
+ type: 'object',
13859
+ },
13860
+ },
13861
+ createdAt: {
13862
+ type: 'string',
13863
+ format: 'date-time',
13864
+ },
13865
+ updatedAt: {
13866
+ type: 'string',
13867
+ format: 'date-time',
13868
+ },
13869
+ currentValue: {
13870
+ type: 'object',
13363
13871
  },
13364
13872
  },
13365
13873
  },
13366
13874
  },
13367
13875
  },
13368
- components: {},
13369
- tags: [],
13876
+ tags: [
13877
+ {
13878
+ name: 'Books',
13879
+ description: 'Operations related to books and pipelines',
13880
+ },
13881
+ {
13882
+ name: 'Executions',
13883
+ description: 'Operations related to execution tasks',
13884
+ },
13885
+ {
13886
+ name: 'Authentication',
13887
+ description: 'Authentication operations',
13888
+ },
13889
+ ],
13370
13890
  };
13371
13891
  /**
13372
13892
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -14011,7 +14531,7 @@
14011
14531
  }
14012
14532
  }
14013
14533
  if (filename.endsWith('.bookc')) {
14014
- pipeline = JSON.parse(await promises.readFile(filename, 'utf-8'));
14534
+ pipeline = jsonParse(await promises.readFile(filename, 'utf-8'));
14015
14535
  }
14016
14536
  else {
14017
14537
  if (isVerbose) {
@@ -14120,6 +14640,37 @@
14120
14640
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
14121
14641
  */
14122
14642
 
14643
+ /**
14644
+ * How is the model provider trusted?
14645
+ *
14646
+ * @public exported from `@promptbook/core`
14647
+ */
14648
+ // <- TODO: Maybe do better levels of trust
14649
+ /**
14650
+ * How is the model provider important?
14651
+ *
14652
+ * @public exported from `@promptbook/core`
14653
+ */
14654
+ const MODEL_ORDER = {
14655
+ /**
14656
+ * Top-tier models, e.g. OpenAI, Anthropic,...
14657
+ */
14658
+ TOP_TIER: 333,
14659
+ /**
14660
+ * Mid-tier models, e.g. Llama, Mistral, etc.
14661
+ */
14662
+ NORMAL: 100,
14663
+ /**
14664
+ * Low-tier models, e.g. Phi, Tiny, etc.
14665
+ */
14666
+ LOW_TIER: 0,
14667
+ };
14668
+ /**
14669
+ * TODO: Add configuration schema and maybe some documentation link
14670
+ * TODO: Maybe constrain LlmToolsConfiguration[number] by generic to ensure that `createConfigurationFromEnv` and `getBoilerplateConfiguration` always create same `packageName` and `className`
14671
+ * TODO: [®] DRY Register logic
14672
+ */
14673
+
14123
14674
  /**
14124
14675
  * Registration of LLM provider metadata
14125
14676
  *
@@ -14134,9 +14685,11 @@
14134
14685
  packageName: '@promptbook/anthropic-claude',
14135
14686
  className: 'AnthropicClaudeExecutionTools',
14136
14687
  envVariables: ['ANTHROPIC_CLAUDE_API_KEY'],
14688
+ trustLevel: 'CLOSED',
14689
+ order: MODEL_ORDER.TOP_TIER,
14137
14690
  getBoilerplateConfiguration() {
14138
14691
  return {
14139
- title: 'Anthropic Claude (boilerplate)',
14692
+ title: 'Anthropic Claude',
14140
14693
  packageName: '@promptbook/anthropic-claude',
14141
14694
  className: 'AnthropicClaudeExecutionTools',
14142
14695
  options: {
@@ -14672,9 +15225,11 @@
14672
15225
  packageName: '@promptbook/azure-openai',
14673
15226
  className: 'AzureOpenAiExecutionTools',
14674
15227
  envVariables: ['AZUREOPENAI_RESOURCE_NAME', 'AZUREOPENAI_DEPLOYMENT_NAME', 'AZUREOPENAI_API_KEY'],
15228
+ trustLevel: 'CLOSED_BUSINESS',
15229
+ order: MODEL_ORDER.NORMAL,
14675
15230
  getBoilerplateConfiguration() {
14676
15231
  return {
14677
- title: 'Azure Open AI (boilerplate)',
15232
+ title: 'Azure Open AI',
14678
15233
  packageName: '@promptbook/azure-openai',
14679
15234
  className: 'AzureOpenAiExecutionTools',
14680
15235
  options: {
@@ -15522,9 +16077,11 @@
15522
16077
  packageName: '@promptbook/deepseek',
15523
16078
  className: 'DeepseekExecutionTools',
15524
16079
  envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
16080
+ trustLevel: 'UNTRUSTED',
16081
+ order: MODEL_ORDER.NORMAL,
15525
16082
  getBoilerplateConfiguration() {
15526
16083
  return {
15527
- title: 'Deepseek (boilerplate)',
16084
+ title: 'Deepseek',
15528
16085
  packageName: '@promptbook/deepseek',
15529
16086
  className: 'DeepseekExecutionTools',
15530
16087
  options: {
@@ -15843,9 +16400,11 @@
15843
16400
  packageName: '@promptbook/google',
15844
16401
  className: 'GoogleExecutionTools',
15845
16402
  envVariables: ['GOOGLE_GENERATIVE_AI_API_KEY'],
16403
+ trustLevel: 'CLOSED',
16404
+ order: MODEL_ORDER.NORMAL,
15846
16405
  getBoilerplateConfiguration() {
15847
16406
  return {
15848
- title: 'Google Gemini (boilerplate)',
16407
+ title: 'Google Gemini',
15849
16408
  packageName: '@promptbook/google',
15850
16409
  className: 'GoogleExecutionTools',
15851
16410
  options: {
@@ -16106,9 +16665,11 @@
16106
16665
  packageName: '@promptbook/openai',
16107
16666
  className: 'OpenAiExecutionTools',
16108
16667
  envVariables: ['OPENAI_API_KEY'],
16668
+ trustLevel: 'CLOSED',
16669
+ order: MODEL_ORDER.TOP_TIER,
16109
16670
  getBoilerplateConfiguration() {
16110
16671
  return {
16111
- title: 'Open AI (boilerplate)',
16672
+ title: 'Open AI',
16112
16673
  packageName: '@promptbook/openai',
16113
16674
  className: 'OpenAiExecutionTools',
16114
16675
  options: {
@@ -16146,9 +16707,11 @@
16146
16707
  className: 'OpenAiAssistantExecutionTools',
16147
16708
  envVariables: null,
16148
16709
  // <- TODO: ['OPENAI_API_KEY', 'OPENAI_ASSISTANT_ID']
16710
+ trustLevel: 'CLOSED',
16711
+ order: MODEL_ORDER.NORMAL,
16149
16712
  getBoilerplateConfiguration() {
16150
16713
  return {
16151
- title: 'Open AI Assistant (boilerplate)',
16714
+ title: 'Open AI Assistant',
16152
16715
  packageName: '@promptbook/openai',
16153
16716
  className: 'OpenAiAssistantExecutionTools',
16154
16717
  options: {