@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/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-4';
59
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-6';
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,7 +7171,7 @@
7065
7171
  }).asPromise();
7066
7172
  const { outputParameters } = result;
7067
7173
  const { modelsRequirements: modelsRequirementsJson } = outputParameters;
7068
- const modelsRequirementsUnchecked = JSON.parse(modelsRequirementsJson);
7174
+ const modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
7069
7175
  if (isVerbose) {
7070
7176
  console.info(`PERSONA ${personaDescription}`, modelsRequirementsUnchecked);
7071
7177
  }
@@ -7252,7 +7358,7 @@
7252
7358
  > },
7253
7359
  */
7254
7360
  async asJson() {
7255
- return JSON.parse(await tools.fs.readFile(filename, 'utf-8'));
7361
+ return jsonParse(await tools.fs.readFile(filename, 'utf-8'));
7256
7362
  },
7257
7363
  async asText() {
7258
7364
  return await tools.fs.readFile(filename, 'utf-8');
@@ -12957,7 +13063,7 @@
12957
13063
  }
12958
13064
  let inputParameters = {};
12959
13065
  if (json) {
12960
- inputParameters = JSON.parse(json);
13066
+ inputParameters = jsonParse(json);
12961
13067
  // <- TODO: Maybe check shape of passed JSON and if its valid parameters Record
12962
13068
  }
12963
13069
  // TODO: DRY [◽]
@@ -13188,7 +13294,7 @@
13188
13294
  const openapiJson = {
13189
13295
  openapi: '3.0.0',
13190
13296
  info: {
13191
- title: 'Promptbook Remote Server API (!!!! From TS)',
13297
+ title: 'Promptbook Remote Server API (!!!! From YML)',
13192
13298
  version: '1.0.0',
13193
13299
  description: 'API documentation for the Promptbook Remote Server',
13194
13300
  },
@@ -13200,6 +13306,13 @@
13200
13306
  responses: {
13201
13307
  '200': {
13202
13308
  description: 'Server details in markdown format.',
13309
+ content: {
13310
+ 'text/markdown': {
13311
+ schema: {
13312
+ type: 'string',
13313
+ },
13314
+ },
13315
+ },
13203
13316
  },
13204
13317
  },
13205
13318
  },
@@ -13230,13 +13343,22 @@
13230
13343
  },
13231
13344
  },
13232
13345
  responses: {
13233
- '200': {
13346
+ '201': {
13234
13347
  description: 'Successful login',
13235
13348
  content: {
13236
13349
  'application/json': {
13237
13350
  schema: {
13238
13351
  type: 'object',
13239
13352
  properties: {
13353
+ isSuccess: {
13354
+ type: 'boolean',
13355
+ },
13356
+ message: {
13357
+ type: 'string',
13358
+ },
13359
+ error: {
13360
+ type: 'object',
13361
+ },
13240
13362
  identification: {
13241
13363
  type: 'object',
13242
13364
  },
@@ -13245,6 +13367,43 @@
13245
13367
  },
13246
13368
  },
13247
13369
  },
13370
+ '400': {
13371
+ description: 'Bad request or login failed',
13372
+ content: {
13373
+ 'application/json': {
13374
+ schema: {
13375
+ type: 'object',
13376
+ properties: {
13377
+ error: {
13378
+ type: 'object',
13379
+ },
13380
+ },
13381
+ },
13382
+ },
13383
+ },
13384
+ },
13385
+ '401': {
13386
+ description: 'Authentication error',
13387
+ content: {
13388
+ 'application/json': {
13389
+ schema: {
13390
+ type: 'object',
13391
+ properties: {
13392
+ isSuccess: {
13393
+ type: 'boolean',
13394
+ enum: [false],
13395
+ },
13396
+ message: {
13397
+ type: 'string',
13398
+ },
13399
+ error: {
13400
+ type: 'object',
13401
+ },
13402
+ },
13403
+ },
13404
+ },
13405
+ },
13406
+ },
13248
13407
  },
13249
13408
  },
13250
13409
  },
@@ -13266,6 +13425,16 @@
13266
13425
  },
13267
13426
  },
13268
13427
  },
13428
+ '500': {
13429
+ description: 'No collection available',
13430
+ content: {
13431
+ 'text/plain': {
13432
+ schema: {
13433
+ type: 'string',
13434
+ },
13435
+ },
13436
+ },
13437
+ },
13269
13438
  },
13270
13439
  },
13271
13440
  },
@@ -13297,6 +13466,28 @@
13297
13466
  },
13298
13467
  '404': {
13299
13468
  description: 'Book not found.',
13469
+ content: {
13470
+ 'application/json': {
13471
+ schema: {
13472
+ type: 'object',
13473
+ properties: {
13474
+ error: {
13475
+ type: 'object',
13476
+ },
13477
+ },
13478
+ },
13479
+ },
13480
+ },
13481
+ },
13482
+ '500': {
13483
+ description: 'No collection available',
13484
+ content: {
13485
+ 'text/plain': {
13486
+ schema: {
13487
+ type: 'string',
13488
+ },
13489
+ },
13490
+ },
13300
13491
  },
13301
13492
  },
13302
13493
  },
@@ -13314,11 +13505,174 @@
13314
13505
  type: 'array',
13315
13506
  items: {
13316
13507
  type: 'object',
13508
+ properties: {
13509
+ nonce: {
13510
+ type: 'string',
13511
+ },
13512
+ taskId: {
13513
+ type: 'string',
13514
+ },
13515
+ taskType: {
13516
+ type: 'string',
13517
+ },
13518
+ status: {
13519
+ type: 'string',
13520
+ },
13521
+ createdAt: {
13522
+ type: 'string',
13523
+ format: 'date-time',
13524
+ },
13525
+ updatedAt: {
13526
+ type: 'string',
13527
+ format: 'date-time',
13528
+ },
13529
+ },
13530
+ },
13531
+ },
13532
+ },
13533
+ },
13534
+ },
13535
+ },
13536
+ },
13537
+ },
13538
+ '/executions/last': {
13539
+ get: {
13540
+ summary: 'Get the last execution',
13541
+ description: 'Returns details of the last execution task.',
13542
+ responses: {
13543
+ '200': {
13544
+ description: 'The last execution task with full details.',
13545
+ content: {
13546
+ 'application/json': {
13547
+ schema: {
13548
+ type: 'object',
13549
+ properties: {
13550
+ nonce: {
13551
+ type: 'string',
13552
+ },
13553
+ taskId: {
13554
+ type: 'string',
13555
+ },
13556
+ taskType: {
13557
+ type: 'string',
13558
+ },
13559
+ status: {
13560
+ type: 'string',
13561
+ },
13562
+ errors: {
13563
+ type: 'array',
13564
+ items: {
13565
+ type: 'object',
13566
+ },
13567
+ },
13568
+ warnings: {
13569
+ type: 'array',
13570
+ items: {
13571
+ type: 'object',
13572
+ },
13573
+ },
13574
+ createdAt: {
13575
+ type: 'string',
13576
+ format: 'date-time',
13577
+ },
13578
+ updatedAt: {
13579
+ type: 'string',
13580
+ format: 'date-time',
13581
+ },
13582
+ currentValue: {
13583
+ type: 'object',
13584
+ },
13585
+ },
13586
+ },
13587
+ },
13588
+ },
13589
+ },
13590
+ '404': {
13591
+ description: 'No execution tasks found.',
13592
+ content: {
13593
+ 'text/plain': {
13594
+ schema: {
13595
+ type: 'string',
13596
+ },
13597
+ },
13598
+ },
13599
+ },
13600
+ },
13601
+ },
13602
+ },
13603
+ '/executions/{taskId}': {
13604
+ get: {
13605
+ summary: 'Get specific execution',
13606
+ description: 'Returns details of a specific execution task.',
13607
+ parameters: [
13608
+ {
13609
+ in: 'path',
13610
+ name: 'taskId',
13611
+ required: true,
13612
+ schema: {
13613
+ type: 'string',
13614
+ },
13615
+ description: 'The ID of the execution task to retrieve.',
13616
+ },
13617
+ ],
13618
+ responses: {
13619
+ '200': {
13620
+ description: 'The execution task with full details.',
13621
+ content: {
13622
+ 'application/json': {
13623
+ schema: {
13624
+ type: 'object',
13625
+ properties: {
13626
+ nonce: {
13627
+ type: 'string',
13628
+ },
13629
+ taskId: {
13630
+ type: 'string',
13631
+ },
13632
+ taskType: {
13633
+ type: 'string',
13634
+ },
13635
+ status: {
13636
+ type: 'string',
13637
+ },
13638
+ errors: {
13639
+ type: 'array',
13640
+ items: {
13641
+ type: 'object',
13642
+ },
13643
+ },
13644
+ warnings: {
13645
+ type: 'array',
13646
+ items: {
13647
+ type: 'object',
13648
+ },
13649
+ },
13650
+ createdAt: {
13651
+ type: 'string',
13652
+ format: 'date-time',
13653
+ },
13654
+ updatedAt: {
13655
+ type: 'string',
13656
+ format: 'date-time',
13657
+ },
13658
+ currentValue: {
13659
+ type: 'object',
13660
+ },
13317
13661
  },
13318
13662
  },
13319
13663
  },
13320
13664
  },
13321
13665
  },
13666
+ '404': {
13667
+ description: 'Execution task not found.',
13668
+ content: {
13669
+ 'text/plain': {
13670
+ schema: {
13671
+ type: 'string',
13672
+ },
13673
+ },
13674
+ },
13675
+ },
13322
13676
  },
13323
13677
  },
13324
13678
  },
@@ -13335,12 +13689,19 @@
13335
13689
  properties: {
13336
13690
  pipelineUrl: {
13337
13691
  type: 'string',
13692
+ description: 'URL of the pipeline to execute',
13693
+ },
13694
+ book: {
13695
+ type: 'string',
13696
+ description: 'Alternative field for pipelineUrl',
13338
13697
  },
13339
13698
  inputParameters: {
13340
13699
  type: 'object',
13700
+ description: 'Parameters for pipeline execution',
13341
13701
  },
13342
13702
  identification: {
13343
13703
  type: 'object',
13704
+ description: 'User identification data',
13344
13705
  },
13345
13706
  },
13346
13707
  },
@@ -13360,13 +13721,164 @@
13360
13721
  },
13361
13722
  '400': {
13362
13723
  description: 'Invalid input.',
13724
+ content: {
13725
+ 'application/json': {
13726
+ schema: {
13727
+ type: 'object',
13728
+ properties: {
13729
+ error: {
13730
+ type: 'object',
13731
+ },
13732
+ },
13733
+ },
13734
+ },
13735
+ },
13736
+ },
13737
+ '404': {
13738
+ description: 'Pipeline not found.',
13739
+ content: {
13740
+ 'text/plain': {
13741
+ schema: {
13742
+ type: 'string',
13743
+ },
13744
+ },
13745
+ },
13746
+ },
13747
+ },
13748
+ },
13749
+ },
13750
+ '/api-docs': {
13751
+ get: {
13752
+ summary: 'API documentation UI',
13753
+ description: 'Swagger UI for API documentation',
13754
+ responses: {
13755
+ '200': {
13756
+ description: 'HTML Swagger UI',
13757
+ },
13758
+ },
13759
+ },
13760
+ },
13761
+ '/swagger': {
13762
+ get: {
13763
+ summary: 'API documentation UI (alternative path)',
13764
+ description: 'Swagger UI for API documentation',
13765
+ responses: {
13766
+ '200': {
13767
+ description: 'HTML Swagger UI',
13768
+ },
13769
+ },
13770
+ },
13771
+ },
13772
+ '/openapi': {
13773
+ get: {
13774
+ summary: 'OpenAPI specification',
13775
+ description: 'Returns the OpenAPI JSON specification',
13776
+ responses: {
13777
+ '200': {
13778
+ description: 'OpenAPI specification',
13779
+ content: {
13780
+ 'application/json': {
13781
+ schema: {
13782
+ type: 'object',
13783
+ },
13784
+ },
13785
+ },
13363
13786
  },
13364
13787
  },
13365
13788
  },
13366
13789
  },
13367
13790
  },
13368
- components: {},
13369
- tags: [],
13791
+ components: {
13792
+ schemas: {
13793
+ Error: {
13794
+ type: 'object',
13795
+ properties: {
13796
+ error: {
13797
+ type: 'object',
13798
+ },
13799
+ },
13800
+ },
13801
+ ExecutionTaskSummary: {
13802
+ type: 'object',
13803
+ properties: {
13804
+ nonce: {
13805
+ type: 'string',
13806
+ },
13807
+ taskId: {
13808
+ type: 'string',
13809
+ },
13810
+ taskType: {
13811
+ type: 'string',
13812
+ },
13813
+ status: {
13814
+ type: 'string',
13815
+ },
13816
+ createdAt: {
13817
+ type: 'string',
13818
+ format: 'date-time',
13819
+ },
13820
+ updatedAt: {
13821
+ type: 'string',
13822
+ format: 'date-time',
13823
+ },
13824
+ },
13825
+ },
13826
+ ExecutionTaskFull: {
13827
+ type: 'object',
13828
+ properties: {
13829
+ nonce: {
13830
+ type: 'string',
13831
+ },
13832
+ taskId: {
13833
+ type: 'string',
13834
+ },
13835
+ taskType: {
13836
+ type: 'string',
13837
+ },
13838
+ status: {
13839
+ type: 'string',
13840
+ },
13841
+ errors: {
13842
+ type: 'array',
13843
+ items: {
13844
+ type: 'object',
13845
+ },
13846
+ },
13847
+ warnings: {
13848
+ type: 'array',
13849
+ items: {
13850
+ type: 'object',
13851
+ },
13852
+ },
13853
+ createdAt: {
13854
+ type: 'string',
13855
+ format: 'date-time',
13856
+ },
13857
+ updatedAt: {
13858
+ type: 'string',
13859
+ format: 'date-time',
13860
+ },
13861
+ currentValue: {
13862
+ type: 'object',
13863
+ },
13864
+ },
13865
+ },
13866
+ },
13867
+ },
13868
+ tags: [
13869
+ {
13870
+ name: 'Books',
13871
+ description: 'Operations related to books and pipelines',
13872
+ },
13873
+ {
13874
+ name: 'Executions',
13875
+ description: 'Operations related to execution tasks',
13876
+ },
13877
+ {
13878
+ name: 'Authentication',
13879
+ description: 'Authentication operations',
13880
+ },
13881
+ ],
13370
13882
  };
13371
13883
  /**
13372
13884
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -14011,7 +14523,7 @@
14011
14523
  }
14012
14524
  }
14013
14525
  if (filename.endsWith('.bookc')) {
14014
- pipeline = JSON.parse(await promises.readFile(filename, 'utf-8'));
14526
+ pipeline = jsonParse(await promises.readFile(filename, 'utf-8'));
14015
14527
  }
14016
14528
  else {
14017
14529
  if (isVerbose) {
@@ -14120,6 +14632,37 @@
14120
14632
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
14121
14633
  */
14122
14634
 
14635
+ /**
14636
+ * How is the model provider trusted?
14637
+ *
14638
+ * @public exported from `@promptbook/core`
14639
+ */
14640
+ // <- TODO: Maybe do better levels of trust
14641
+ /**
14642
+ * How is the model provider important?
14643
+ *
14644
+ * @public exported from `@promptbook/core`
14645
+ */
14646
+ const MODEL_ORDER = {
14647
+ /**
14648
+ * Top-tier models, e.g. OpenAI, Anthropic,...
14649
+ */
14650
+ TOP_TIER: 333,
14651
+ /**
14652
+ * Mid-tier models, e.g. Llama, Mistral, etc.
14653
+ */
14654
+ NORMAL: 100,
14655
+ /**
14656
+ * Low-tier models, e.g. Phi, Tiny, etc.
14657
+ */
14658
+ LOW_TIER: 0,
14659
+ };
14660
+ /**
14661
+ * TODO: Add configuration schema and maybe some documentation link
14662
+ * TODO: Maybe constrain LlmToolsConfiguration[number] by generic to ensure that `createConfigurationFromEnv` and `getBoilerplateConfiguration` always create same `packageName` and `className`
14663
+ * TODO: [®] DRY Register logic
14664
+ */
14665
+
14123
14666
  /**
14124
14667
  * Registration of LLM provider metadata
14125
14668
  *
@@ -14134,9 +14677,11 @@
14134
14677
  packageName: '@promptbook/anthropic-claude',
14135
14678
  className: 'AnthropicClaudeExecutionTools',
14136
14679
  envVariables: ['ANTHROPIC_CLAUDE_API_KEY'],
14680
+ trustLevel: 'CLOSED',
14681
+ order: MODEL_ORDER.TOP_TIER,
14137
14682
  getBoilerplateConfiguration() {
14138
14683
  return {
14139
- title: 'Anthropic Claude (boilerplate)',
14684
+ title: 'Anthropic Claude',
14140
14685
  packageName: '@promptbook/anthropic-claude',
14141
14686
  className: 'AnthropicClaudeExecutionTools',
14142
14687
  options: {
@@ -14672,9 +15217,11 @@
14672
15217
  packageName: '@promptbook/azure-openai',
14673
15218
  className: 'AzureOpenAiExecutionTools',
14674
15219
  envVariables: ['AZUREOPENAI_RESOURCE_NAME', 'AZUREOPENAI_DEPLOYMENT_NAME', 'AZUREOPENAI_API_KEY'],
15220
+ trustLevel: 'CLOSED_BUSINESS',
15221
+ order: MODEL_ORDER.NORMAL,
14675
15222
  getBoilerplateConfiguration() {
14676
15223
  return {
14677
- title: 'Azure Open AI (boilerplate)',
15224
+ title: 'Azure Open AI',
14678
15225
  packageName: '@promptbook/azure-openai',
14679
15226
  className: 'AzureOpenAiExecutionTools',
14680
15227
  options: {
@@ -15522,9 +16069,11 @@
15522
16069
  packageName: '@promptbook/deepseek',
15523
16070
  className: 'DeepseekExecutionTools',
15524
16071
  envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
16072
+ trustLevel: 'UNTRUSTED',
16073
+ order: MODEL_ORDER.NORMAL,
15525
16074
  getBoilerplateConfiguration() {
15526
16075
  return {
15527
- title: 'Deepseek (boilerplate)',
16076
+ title: 'Deepseek',
15528
16077
  packageName: '@promptbook/deepseek',
15529
16078
  className: 'DeepseekExecutionTools',
15530
16079
  options: {
@@ -15843,9 +16392,11 @@
15843
16392
  packageName: '@promptbook/google',
15844
16393
  className: 'GoogleExecutionTools',
15845
16394
  envVariables: ['GOOGLE_GENERATIVE_AI_API_KEY'],
16395
+ trustLevel: 'CLOSED',
16396
+ order: MODEL_ORDER.NORMAL,
15846
16397
  getBoilerplateConfiguration() {
15847
16398
  return {
15848
- title: 'Google Gemini (boilerplate)',
16399
+ title: 'Google Gemini',
15849
16400
  packageName: '@promptbook/google',
15850
16401
  className: 'GoogleExecutionTools',
15851
16402
  options: {
@@ -16106,9 +16657,11 @@
16106
16657
  packageName: '@promptbook/openai',
16107
16658
  className: 'OpenAiExecutionTools',
16108
16659
  envVariables: ['OPENAI_API_KEY'],
16660
+ trustLevel: 'CLOSED',
16661
+ order: MODEL_ORDER.TOP_TIER,
16109
16662
  getBoilerplateConfiguration() {
16110
16663
  return {
16111
- title: 'Open AI (boilerplate)',
16664
+ title: 'Open AI',
16112
16665
  packageName: '@promptbook/openai',
16113
16666
  className: 'OpenAiExecutionTools',
16114
16667
  options: {
@@ -16146,9 +16699,11 @@
16146
16699
  className: 'OpenAiAssistantExecutionTools',
16147
16700
  envVariables: null,
16148
16701
  // <- TODO: ['OPENAI_API_KEY', 'OPENAI_ASSISTANT_ID']
16702
+ trustLevel: 'CLOSED',
16703
+ order: MODEL_ORDER.NORMAL,
16149
16704
  getBoilerplateConfiguration() {
16150
16705
  return {
16151
- title: 'Open AI Assistant (boilerplate)',
16706
+ title: 'Open AI Assistant',
16152
16707
  packageName: '@promptbook/openai',
16153
16708
  className: 'OpenAiAssistantExecutionTools',
16154
16709
  options: {