@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/esm/index.es.js +588 -25
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +1 -1
- package/esm/typings/src/conversion/archive/loadArchive.d.ts +2 -2
- package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +12 -0
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +5 -0
- package/esm/typings/src/formats/json/utils/jsonParse.d.ts +11 -0
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +43 -0
- package/esm/typings/src/remote-server/openapi-types.d.ts +348 -6
- package/esm/typings/src/remote-server/openapi.d.ts +397 -3
- package/package.json +1 -1
- package/umd/index.umd.js +592 -29
- package/umd/index.umd.js.map +1 -1
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-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-7';
|
|
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 =
|
|
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.
|
|
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 =
|
|
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] =
|
|
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
|
-
|
|
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,18 +7161,26 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
7055
7161
|
}).asPromise();
|
|
7056
7162
|
const { outputParameters } = result;
|
|
7057
7163
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
7058
|
-
|
|
7164
|
+
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
7059
7165
|
if (isVerbose) {
|
|
7060
7166
|
console.info(`PERSONA ${personaDescription}`, modelsRequirementsUnchecked);
|
|
7061
7167
|
}
|
|
7062
7168
|
if (!Array.isArray(modelsRequirementsUnchecked)) {
|
|
7063
|
-
|
|
7169
|
+
// <- TODO: Book should have syntax and system to enforce shape of JSON
|
|
7170
|
+
modelsRequirementsUnchecked = [modelsRequirementsUnchecked];
|
|
7171
|
+
/*
|
|
7172
|
+
throw new UnexpectedError(
|
|
7173
|
+
spaceTrim(
|
|
7174
|
+
(block) => `
|
|
7064
7175
|
Invalid \`modelsRequirements\`:
|
|
7065
7176
|
|
|
7066
7177
|
\`\`\`json
|
|
7067
7178
|
${block(JSON.stringify(modelsRequirementsUnchecked, null, 4))}
|
|
7068
7179
|
\`\`\`
|
|
7069
|
-
|
|
7180
|
+
`,
|
|
7181
|
+
),
|
|
7182
|
+
);
|
|
7183
|
+
*/
|
|
7070
7184
|
}
|
|
7071
7185
|
const modelsRequirements = modelsRequirementsUnchecked.map((modelRequirements) => ({
|
|
7072
7186
|
modelVariant: 'CHAT',
|
|
@@ -7242,7 +7356,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
7242
7356
|
> },
|
|
7243
7357
|
*/
|
|
7244
7358
|
async asJson() {
|
|
7245
|
-
return
|
|
7359
|
+
return jsonParse(await tools.fs.readFile(filename, 'utf-8'));
|
|
7246
7360
|
},
|
|
7247
7361
|
async asText() {
|
|
7248
7362
|
return await tools.fs.readFile(filename, 'utf-8');
|
|
@@ -12947,7 +13061,7 @@ function $initializeRunCommand(program) {
|
|
|
12947
13061
|
}
|
|
12948
13062
|
let inputParameters = {};
|
|
12949
13063
|
if (json) {
|
|
12950
|
-
inputParameters =
|
|
13064
|
+
inputParameters = jsonParse(json);
|
|
12951
13065
|
// <- TODO: Maybe check shape of passed JSON and if its valid parameters Record
|
|
12952
13066
|
}
|
|
12953
13067
|
// TODO: DRY [◽]
|
|
@@ -13178,7 +13292,7 @@ function $initializeRunCommand(program) {
|
|
|
13178
13292
|
const openapiJson = {
|
|
13179
13293
|
openapi: '3.0.0',
|
|
13180
13294
|
info: {
|
|
13181
|
-
title: 'Promptbook Remote Server API (!!!! From
|
|
13295
|
+
title: 'Promptbook Remote Server API (!!!! From YML)',
|
|
13182
13296
|
version: '1.0.0',
|
|
13183
13297
|
description: 'API documentation for the Promptbook Remote Server',
|
|
13184
13298
|
},
|
|
@@ -13190,6 +13304,13 @@ const openapiJson = {
|
|
|
13190
13304
|
responses: {
|
|
13191
13305
|
'200': {
|
|
13192
13306
|
description: 'Server details in markdown format.',
|
|
13307
|
+
content: {
|
|
13308
|
+
'text/markdown': {
|
|
13309
|
+
schema: {
|
|
13310
|
+
type: 'string',
|
|
13311
|
+
},
|
|
13312
|
+
},
|
|
13313
|
+
},
|
|
13193
13314
|
},
|
|
13194
13315
|
},
|
|
13195
13316
|
},
|
|
@@ -13220,13 +13341,22 @@ const openapiJson = {
|
|
|
13220
13341
|
},
|
|
13221
13342
|
},
|
|
13222
13343
|
responses: {
|
|
13223
|
-
'
|
|
13344
|
+
'201': {
|
|
13224
13345
|
description: 'Successful login',
|
|
13225
13346
|
content: {
|
|
13226
13347
|
'application/json': {
|
|
13227
13348
|
schema: {
|
|
13228
13349
|
type: 'object',
|
|
13229
13350
|
properties: {
|
|
13351
|
+
isSuccess: {
|
|
13352
|
+
type: 'boolean',
|
|
13353
|
+
},
|
|
13354
|
+
message: {
|
|
13355
|
+
type: 'string',
|
|
13356
|
+
},
|
|
13357
|
+
error: {
|
|
13358
|
+
type: 'object',
|
|
13359
|
+
},
|
|
13230
13360
|
identification: {
|
|
13231
13361
|
type: 'object',
|
|
13232
13362
|
},
|
|
@@ -13235,6 +13365,43 @@ const openapiJson = {
|
|
|
13235
13365
|
},
|
|
13236
13366
|
},
|
|
13237
13367
|
},
|
|
13368
|
+
'400': {
|
|
13369
|
+
description: 'Bad request or login failed',
|
|
13370
|
+
content: {
|
|
13371
|
+
'application/json': {
|
|
13372
|
+
schema: {
|
|
13373
|
+
type: 'object',
|
|
13374
|
+
properties: {
|
|
13375
|
+
error: {
|
|
13376
|
+
type: 'object',
|
|
13377
|
+
},
|
|
13378
|
+
},
|
|
13379
|
+
},
|
|
13380
|
+
},
|
|
13381
|
+
},
|
|
13382
|
+
},
|
|
13383
|
+
'401': {
|
|
13384
|
+
description: 'Authentication error',
|
|
13385
|
+
content: {
|
|
13386
|
+
'application/json': {
|
|
13387
|
+
schema: {
|
|
13388
|
+
type: 'object',
|
|
13389
|
+
properties: {
|
|
13390
|
+
isSuccess: {
|
|
13391
|
+
type: 'boolean',
|
|
13392
|
+
enum: [false],
|
|
13393
|
+
},
|
|
13394
|
+
message: {
|
|
13395
|
+
type: 'string',
|
|
13396
|
+
},
|
|
13397
|
+
error: {
|
|
13398
|
+
type: 'object',
|
|
13399
|
+
},
|
|
13400
|
+
},
|
|
13401
|
+
},
|
|
13402
|
+
},
|
|
13403
|
+
},
|
|
13404
|
+
},
|
|
13238
13405
|
},
|
|
13239
13406
|
},
|
|
13240
13407
|
},
|
|
@@ -13256,6 +13423,16 @@ const openapiJson = {
|
|
|
13256
13423
|
},
|
|
13257
13424
|
},
|
|
13258
13425
|
},
|
|
13426
|
+
'500': {
|
|
13427
|
+
description: 'No collection available',
|
|
13428
|
+
content: {
|
|
13429
|
+
'text/plain': {
|
|
13430
|
+
schema: {
|
|
13431
|
+
type: 'string',
|
|
13432
|
+
},
|
|
13433
|
+
},
|
|
13434
|
+
},
|
|
13435
|
+
},
|
|
13259
13436
|
},
|
|
13260
13437
|
},
|
|
13261
13438
|
},
|
|
@@ -13287,6 +13464,28 @@ const openapiJson = {
|
|
|
13287
13464
|
},
|
|
13288
13465
|
'404': {
|
|
13289
13466
|
description: 'Book not found.',
|
|
13467
|
+
content: {
|
|
13468
|
+
'application/json': {
|
|
13469
|
+
schema: {
|
|
13470
|
+
type: 'object',
|
|
13471
|
+
properties: {
|
|
13472
|
+
error: {
|
|
13473
|
+
type: 'object',
|
|
13474
|
+
},
|
|
13475
|
+
},
|
|
13476
|
+
},
|
|
13477
|
+
},
|
|
13478
|
+
},
|
|
13479
|
+
},
|
|
13480
|
+
'500': {
|
|
13481
|
+
description: 'No collection available',
|
|
13482
|
+
content: {
|
|
13483
|
+
'text/plain': {
|
|
13484
|
+
schema: {
|
|
13485
|
+
type: 'string',
|
|
13486
|
+
},
|
|
13487
|
+
},
|
|
13488
|
+
},
|
|
13290
13489
|
},
|
|
13291
13490
|
},
|
|
13292
13491
|
},
|
|
@@ -13304,6 +13503,28 @@ const openapiJson = {
|
|
|
13304
13503
|
type: 'array',
|
|
13305
13504
|
items: {
|
|
13306
13505
|
type: 'object',
|
|
13506
|
+
properties: {
|
|
13507
|
+
nonce: {
|
|
13508
|
+
type: 'string',
|
|
13509
|
+
},
|
|
13510
|
+
taskId: {
|
|
13511
|
+
type: 'string',
|
|
13512
|
+
},
|
|
13513
|
+
taskType: {
|
|
13514
|
+
type: 'string',
|
|
13515
|
+
},
|
|
13516
|
+
status: {
|
|
13517
|
+
type: 'string',
|
|
13518
|
+
},
|
|
13519
|
+
createdAt: {
|
|
13520
|
+
type: 'string',
|
|
13521
|
+
format: 'date-time',
|
|
13522
|
+
},
|
|
13523
|
+
updatedAt: {
|
|
13524
|
+
type: 'string',
|
|
13525
|
+
format: 'date-time',
|
|
13526
|
+
},
|
|
13527
|
+
},
|
|
13307
13528
|
},
|
|
13308
13529
|
},
|
|
13309
13530
|
},
|
|
@@ -13312,6 +13533,147 @@ const openapiJson = {
|
|
|
13312
13533
|
},
|
|
13313
13534
|
},
|
|
13314
13535
|
},
|
|
13536
|
+
'/executions/last': {
|
|
13537
|
+
get: {
|
|
13538
|
+
summary: 'Get the last execution',
|
|
13539
|
+
description: 'Returns details of the last execution task.',
|
|
13540
|
+
responses: {
|
|
13541
|
+
'200': {
|
|
13542
|
+
description: 'The last execution task with full details.',
|
|
13543
|
+
content: {
|
|
13544
|
+
'application/json': {
|
|
13545
|
+
schema: {
|
|
13546
|
+
type: 'object',
|
|
13547
|
+
properties: {
|
|
13548
|
+
nonce: {
|
|
13549
|
+
type: 'string',
|
|
13550
|
+
},
|
|
13551
|
+
taskId: {
|
|
13552
|
+
type: 'string',
|
|
13553
|
+
},
|
|
13554
|
+
taskType: {
|
|
13555
|
+
type: 'string',
|
|
13556
|
+
},
|
|
13557
|
+
status: {
|
|
13558
|
+
type: 'string',
|
|
13559
|
+
},
|
|
13560
|
+
errors: {
|
|
13561
|
+
type: 'array',
|
|
13562
|
+
items: {
|
|
13563
|
+
type: 'object',
|
|
13564
|
+
},
|
|
13565
|
+
},
|
|
13566
|
+
warnings: {
|
|
13567
|
+
type: 'array',
|
|
13568
|
+
items: {
|
|
13569
|
+
type: 'object',
|
|
13570
|
+
},
|
|
13571
|
+
},
|
|
13572
|
+
createdAt: {
|
|
13573
|
+
type: 'string',
|
|
13574
|
+
format: 'date-time',
|
|
13575
|
+
},
|
|
13576
|
+
updatedAt: {
|
|
13577
|
+
type: 'string',
|
|
13578
|
+
format: 'date-time',
|
|
13579
|
+
},
|
|
13580
|
+
currentValue: {
|
|
13581
|
+
type: 'object',
|
|
13582
|
+
},
|
|
13583
|
+
},
|
|
13584
|
+
},
|
|
13585
|
+
},
|
|
13586
|
+
},
|
|
13587
|
+
},
|
|
13588
|
+
'404': {
|
|
13589
|
+
description: 'No execution tasks found.',
|
|
13590
|
+
content: {
|
|
13591
|
+
'text/plain': {
|
|
13592
|
+
schema: {
|
|
13593
|
+
type: 'string',
|
|
13594
|
+
},
|
|
13595
|
+
},
|
|
13596
|
+
},
|
|
13597
|
+
},
|
|
13598
|
+
},
|
|
13599
|
+
},
|
|
13600
|
+
},
|
|
13601
|
+
'/executions/{taskId}': {
|
|
13602
|
+
get: {
|
|
13603
|
+
summary: 'Get specific execution',
|
|
13604
|
+
description: 'Returns details of a specific execution task.',
|
|
13605
|
+
parameters: [
|
|
13606
|
+
{
|
|
13607
|
+
in: 'path',
|
|
13608
|
+
name: 'taskId',
|
|
13609
|
+
required: true,
|
|
13610
|
+
schema: {
|
|
13611
|
+
type: 'string',
|
|
13612
|
+
},
|
|
13613
|
+
description: 'The ID of the execution task to retrieve.',
|
|
13614
|
+
},
|
|
13615
|
+
],
|
|
13616
|
+
responses: {
|
|
13617
|
+
'200': {
|
|
13618
|
+
description: 'The execution task with full details.',
|
|
13619
|
+
content: {
|
|
13620
|
+
'application/json': {
|
|
13621
|
+
schema: {
|
|
13622
|
+
type: 'object',
|
|
13623
|
+
properties: {
|
|
13624
|
+
nonce: {
|
|
13625
|
+
type: 'string',
|
|
13626
|
+
},
|
|
13627
|
+
taskId: {
|
|
13628
|
+
type: 'string',
|
|
13629
|
+
},
|
|
13630
|
+
taskType: {
|
|
13631
|
+
type: 'string',
|
|
13632
|
+
},
|
|
13633
|
+
status: {
|
|
13634
|
+
type: 'string',
|
|
13635
|
+
},
|
|
13636
|
+
errors: {
|
|
13637
|
+
type: 'array',
|
|
13638
|
+
items: {
|
|
13639
|
+
type: 'object',
|
|
13640
|
+
},
|
|
13641
|
+
},
|
|
13642
|
+
warnings: {
|
|
13643
|
+
type: 'array',
|
|
13644
|
+
items: {
|
|
13645
|
+
type: 'object',
|
|
13646
|
+
},
|
|
13647
|
+
},
|
|
13648
|
+
createdAt: {
|
|
13649
|
+
type: 'string',
|
|
13650
|
+
format: 'date-time',
|
|
13651
|
+
},
|
|
13652
|
+
updatedAt: {
|
|
13653
|
+
type: 'string',
|
|
13654
|
+
format: 'date-time',
|
|
13655
|
+
},
|
|
13656
|
+
currentValue: {
|
|
13657
|
+
type: 'object',
|
|
13658
|
+
},
|
|
13659
|
+
},
|
|
13660
|
+
},
|
|
13661
|
+
},
|
|
13662
|
+
},
|
|
13663
|
+
},
|
|
13664
|
+
'404': {
|
|
13665
|
+
description: 'Execution task not found.',
|
|
13666
|
+
content: {
|
|
13667
|
+
'text/plain': {
|
|
13668
|
+
schema: {
|
|
13669
|
+
type: 'string',
|
|
13670
|
+
},
|
|
13671
|
+
},
|
|
13672
|
+
},
|
|
13673
|
+
},
|
|
13674
|
+
},
|
|
13675
|
+
},
|
|
13676
|
+
},
|
|
13315
13677
|
'/executions/new': {
|
|
13316
13678
|
post: {
|
|
13317
13679
|
summary: 'Start a new execution',
|
|
@@ -13325,12 +13687,19 @@ const openapiJson = {
|
|
|
13325
13687
|
properties: {
|
|
13326
13688
|
pipelineUrl: {
|
|
13327
13689
|
type: 'string',
|
|
13690
|
+
description: 'URL of the pipeline to execute',
|
|
13691
|
+
},
|
|
13692
|
+
book: {
|
|
13693
|
+
type: 'string',
|
|
13694
|
+
description: 'Alternative field for pipelineUrl',
|
|
13328
13695
|
},
|
|
13329
13696
|
inputParameters: {
|
|
13330
13697
|
type: 'object',
|
|
13698
|
+
description: 'Parameters for pipeline execution',
|
|
13331
13699
|
},
|
|
13332
13700
|
identification: {
|
|
13333
13701
|
type: 'object',
|
|
13702
|
+
description: 'User identification data',
|
|
13334
13703
|
},
|
|
13335
13704
|
},
|
|
13336
13705
|
},
|
|
@@ -13350,13 +13719,164 @@ const openapiJson = {
|
|
|
13350
13719
|
},
|
|
13351
13720
|
'400': {
|
|
13352
13721
|
description: 'Invalid input.',
|
|
13722
|
+
content: {
|
|
13723
|
+
'application/json': {
|
|
13724
|
+
schema: {
|
|
13725
|
+
type: 'object',
|
|
13726
|
+
properties: {
|
|
13727
|
+
error: {
|
|
13728
|
+
type: 'object',
|
|
13729
|
+
},
|
|
13730
|
+
},
|
|
13731
|
+
},
|
|
13732
|
+
},
|
|
13733
|
+
},
|
|
13734
|
+
},
|
|
13735
|
+
'404': {
|
|
13736
|
+
description: 'Pipeline not found.',
|
|
13737
|
+
content: {
|
|
13738
|
+
'text/plain': {
|
|
13739
|
+
schema: {
|
|
13740
|
+
type: 'string',
|
|
13741
|
+
},
|
|
13742
|
+
},
|
|
13743
|
+
},
|
|
13744
|
+
},
|
|
13745
|
+
},
|
|
13746
|
+
},
|
|
13747
|
+
},
|
|
13748
|
+
'/api-docs': {
|
|
13749
|
+
get: {
|
|
13750
|
+
summary: 'API documentation UI',
|
|
13751
|
+
description: 'Swagger UI for API documentation',
|
|
13752
|
+
responses: {
|
|
13753
|
+
'200': {
|
|
13754
|
+
description: 'HTML Swagger UI',
|
|
13755
|
+
},
|
|
13756
|
+
},
|
|
13757
|
+
},
|
|
13758
|
+
},
|
|
13759
|
+
'/swagger': {
|
|
13760
|
+
get: {
|
|
13761
|
+
summary: 'API documentation UI (alternative path)',
|
|
13762
|
+
description: 'Swagger UI for API documentation',
|
|
13763
|
+
responses: {
|
|
13764
|
+
'200': {
|
|
13765
|
+
description: 'HTML Swagger UI',
|
|
13766
|
+
},
|
|
13767
|
+
},
|
|
13768
|
+
},
|
|
13769
|
+
},
|
|
13770
|
+
'/openapi': {
|
|
13771
|
+
get: {
|
|
13772
|
+
summary: 'OpenAPI specification',
|
|
13773
|
+
description: 'Returns the OpenAPI JSON specification',
|
|
13774
|
+
responses: {
|
|
13775
|
+
'200': {
|
|
13776
|
+
description: 'OpenAPI specification',
|
|
13777
|
+
content: {
|
|
13778
|
+
'application/json': {
|
|
13779
|
+
schema: {
|
|
13780
|
+
type: 'object',
|
|
13781
|
+
},
|
|
13782
|
+
},
|
|
13783
|
+
},
|
|
13353
13784
|
},
|
|
13354
13785
|
},
|
|
13355
13786
|
},
|
|
13356
13787
|
},
|
|
13357
13788
|
},
|
|
13358
|
-
components: {
|
|
13359
|
-
|
|
13789
|
+
components: {
|
|
13790
|
+
schemas: {
|
|
13791
|
+
Error: {
|
|
13792
|
+
type: 'object',
|
|
13793
|
+
properties: {
|
|
13794
|
+
error: {
|
|
13795
|
+
type: 'object',
|
|
13796
|
+
},
|
|
13797
|
+
},
|
|
13798
|
+
},
|
|
13799
|
+
ExecutionTaskSummary: {
|
|
13800
|
+
type: 'object',
|
|
13801
|
+
properties: {
|
|
13802
|
+
nonce: {
|
|
13803
|
+
type: 'string',
|
|
13804
|
+
},
|
|
13805
|
+
taskId: {
|
|
13806
|
+
type: 'string',
|
|
13807
|
+
},
|
|
13808
|
+
taskType: {
|
|
13809
|
+
type: 'string',
|
|
13810
|
+
},
|
|
13811
|
+
status: {
|
|
13812
|
+
type: 'string',
|
|
13813
|
+
},
|
|
13814
|
+
createdAt: {
|
|
13815
|
+
type: 'string',
|
|
13816
|
+
format: 'date-time',
|
|
13817
|
+
},
|
|
13818
|
+
updatedAt: {
|
|
13819
|
+
type: 'string',
|
|
13820
|
+
format: 'date-time',
|
|
13821
|
+
},
|
|
13822
|
+
},
|
|
13823
|
+
},
|
|
13824
|
+
ExecutionTaskFull: {
|
|
13825
|
+
type: 'object',
|
|
13826
|
+
properties: {
|
|
13827
|
+
nonce: {
|
|
13828
|
+
type: 'string',
|
|
13829
|
+
},
|
|
13830
|
+
taskId: {
|
|
13831
|
+
type: 'string',
|
|
13832
|
+
},
|
|
13833
|
+
taskType: {
|
|
13834
|
+
type: 'string',
|
|
13835
|
+
},
|
|
13836
|
+
status: {
|
|
13837
|
+
type: 'string',
|
|
13838
|
+
},
|
|
13839
|
+
errors: {
|
|
13840
|
+
type: 'array',
|
|
13841
|
+
items: {
|
|
13842
|
+
type: 'object',
|
|
13843
|
+
},
|
|
13844
|
+
},
|
|
13845
|
+
warnings: {
|
|
13846
|
+
type: 'array',
|
|
13847
|
+
items: {
|
|
13848
|
+
type: 'object',
|
|
13849
|
+
},
|
|
13850
|
+
},
|
|
13851
|
+
createdAt: {
|
|
13852
|
+
type: 'string',
|
|
13853
|
+
format: 'date-time',
|
|
13854
|
+
},
|
|
13855
|
+
updatedAt: {
|
|
13856
|
+
type: 'string',
|
|
13857
|
+
format: 'date-time',
|
|
13858
|
+
},
|
|
13859
|
+
currentValue: {
|
|
13860
|
+
type: 'object',
|
|
13861
|
+
},
|
|
13862
|
+
},
|
|
13863
|
+
},
|
|
13864
|
+
},
|
|
13865
|
+
},
|
|
13866
|
+
tags: [
|
|
13867
|
+
{
|
|
13868
|
+
name: 'Books',
|
|
13869
|
+
description: 'Operations related to books and pipelines',
|
|
13870
|
+
},
|
|
13871
|
+
{
|
|
13872
|
+
name: 'Executions',
|
|
13873
|
+
description: 'Operations related to execution tasks',
|
|
13874
|
+
},
|
|
13875
|
+
{
|
|
13876
|
+
name: 'Authentication',
|
|
13877
|
+
description: 'Authentication operations',
|
|
13878
|
+
},
|
|
13879
|
+
],
|
|
13360
13880
|
};
|
|
13361
13881
|
/**
|
|
13362
13882
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -14001,7 +14521,7 @@ function $initializeTestCommand(program) {
|
|
|
14001
14521
|
}
|
|
14002
14522
|
}
|
|
14003
14523
|
if (filename.endsWith('.bookc')) {
|
|
14004
|
-
pipeline =
|
|
14524
|
+
pipeline = jsonParse(await readFile(filename, 'utf-8'));
|
|
14005
14525
|
}
|
|
14006
14526
|
else {
|
|
14007
14527
|
if (isVerbose) {
|
|
@@ -14110,6 +14630,37 @@ const _CLI = {
|
|
|
14110
14630
|
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
14111
14631
|
*/
|
|
14112
14632
|
|
|
14633
|
+
/**
|
|
14634
|
+
* How is the model provider trusted?
|
|
14635
|
+
*
|
|
14636
|
+
* @public exported from `@promptbook/core`
|
|
14637
|
+
*/
|
|
14638
|
+
// <- TODO: Maybe do better levels of trust
|
|
14639
|
+
/**
|
|
14640
|
+
* How is the model provider important?
|
|
14641
|
+
*
|
|
14642
|
+
* @public exported from `@promptbook/core`
|
|
14643
|
+
*/
|
|
14644
|
+
const MODEL_ORDER = {
|
|
14645
|
+
/**
|
|
14646
|
+
* Top-tier models, e.g. OpenAI, Anthropic,...
|
|
14647
|
+
*/
|
|
14648
|
+
TOP_TIER: 333,
|
|
14649
|
+
/**
|
|
14650
|
+
* Mid-tier models, e.g. Llama, Mistral, etc.
|
|
14651
|
+
*/
|
|
14652
|
+
NORMAL: 100,
|
|
14653
|
+
/**
|
|
14654
|
+
* Low-tier models, e.g. Phi, Tiny, etc.
|
|
14655
|
+
*/
|
|
14656
|
+
LOW_TIER: 0,
|
|
14657
|
+
};
|
|
14658
|
+
/**
|
|
14659
|
+
* TODO: Add configuration schema and maybe some documentation link
|
|
14660
|
+
* TODO: Maybe constrain LlmToolsConfiguration[number] by generic to ensure that `createConfigurationFromEnv` and `getBoilerplateConfiguration` always create same `packageName` and `className`
|
|
14661
|
+
* TODO: [®] DRY Register logic
|
|
14662
|
+
*/
|
|
14663
|
+
|
|
14113
14664
|
/**
|
|
14114
14665
|
* Registration of LLM provider metadata
|
|
14115
14666
|
*
|
|
@@ -14124,9 +14675,11 @@ const _AnthropicClaudeMetadataRegistration = $llmToolsMetadataRegister.register(
|
|
|
14124
14675
|
packageName: '@promptbook/anthropic-claude',
|
|
14125
14676
|
className: 'AnthropicClaudeExecutionTools',
|
|
14126
14677
|
envVariables: ['ANTHROPIC_CLAUDE_API_KEY'],
|
|
14678
|
+
trustLevel: 'CLOSED',
|
|
14679
|
+
order: MODEL_ORDER.TOP_TIER,
|
|
14127
14680
|
getBoilerplateConfiguration() {
|
|
14128
14681
|
return {
|
|
14129
|
-
title: 'Anthropic Claude
|
|
14682
|
+
title: 'Anthropic Claude',
|
|
14130
14683
|
packageName: '@promptbook/anthropic-claude',
|
|
14131
14684
|
className: 'AnthropicClaudeExecutionTools',
|
|
14132
14685
|
options: {
|
|
@@ -14662,9 +15215,11 @@ const _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
14662
15215
|
packageName: '@promptbook/azure-openai',
|
|
14663
15216
|
className: 'AzureOpenAiExecutionTools',
|
|
14664
15217
|
envVariables: ['AZUREOPENAI_RESOURCE_NAME', 'AZUREOPENAI_DEPLOYMENT_NAME', 'AZUREOPENAI_API_KEY'],
|
|
15218
|
+
trustLevel: 'CLOSED_BUSINESS',
|
|
15219
|
+
order: MODEL_ORDER.NORMAL,
|
|
14665
15220
|
getBoilerplateConfiguration() {
|
|
14666
15221
|
return {
|
|
14667
|
-
title: 'Azure Open AI
|
|
15222
|
+
title: 'Azure Open AI',
|
|
14668
15223
|
packageName: '@promptbook/azure-openai',
|
|
14669
15224
|
className: 'AzureOpenAiExecutionTools',
|
|
14670
15225
|
options: {
|
|
@@ -15512,9 +16067,11 @@ const _DeepseekMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
15512
16067
|
packageName: '@promptbook/deepseek',
|
|
15513
16068
|
className: 'DeepseekExecutionTools',
|
|
15514
16069
|
envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
|
|
16070
|
+
trustLevel: 'UNTRUSTED',
|
|
16071
|
+
order: MODEL_ORDER.NORMAL,
|
|
15515
16072
|
getBoilerplateConfiguration() {
|
|
15516
16073
|
return {
|
|
15517
|
-
title: 'Deepseek
|
|
16074
|
+
title: 'Deepseek',
|
|
15518
16075
|
packageName: '@promptbook/deepseek',
|
|
15519
16076
|
className: 'DeepseekExecutionTools',
|
|
15520
16077
|
options: {
|
|
@@ -15833,9 +16390,11 @@ const _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
15833
16390
|
packageName: '@promptbook/google',
|
|
15834
16391
|
className: 'GoogleExecutionTools',
|
|
15835
16392
|
envVariables: ['GOOGLE_GENERATIVE_AI_API_KEY'],
|
|
16393
|
+
trustLevel: 'CLOSED',
|
|
16394
|
+
order: MODEL_ORDER.NORMAL,
|
|
15836
16395
|
getBoilerplateConfiguration() {
|
|
15837
16396
|
return {
|
|
15838
|
-
title: 'Google Gemini
|
|
16397
|
+
title: 'Google Gemini',
|
|
15839
16398
|
packageName: '@promptbook/google',
|
|
15840
16399
|
className: 'GoogleExecutionTools',
|
|
15841
16400
|
options: {
|
|
@@ -16096,9 +16655,11 @@ const _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
16096
16655
|
packageName: '@promptbook/openai',
|
|
16097
16656
|
className: 'OpenAiExecutionTools',
|
|
16098
16657
|
envVariables: ['OPENAI_API_KEY'],
|
|
16658
|
+
trustLevel: 'CLOSED',
|
|
16659
|
+
order: MODEL_ORDER.TOP_TIER,
|
|
16099
16660
|
getBoilerplateConfiguration() {
|
|
16100
16661
|
return {
|
|
16101
|
-
title: 'Open AI
|
|
16662
|
+
title: 'Open AI',
|
|
16102
16663
|
packageName: '@promptbook/openai',
|
|
16103
16664
|
className: 'OpenAiExecutionTools',
|
|
16104
16665
|
options: {
|
|
@@ -16136,9 +16697,11 @@ const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register(
|
|
|
16136
16697
|
className: 'OpenAiAssistantExecutionTools',
|
|
16137
16698
|
envVariables: null,
|
|
16138
16699
|
// <- TODO: ['OPENAI_API_KEY', 'OPENAI_ASSISTANT_ID']
|
|
16700
|
+
trustLevel: 'CLOSED',
|
|
16701
|
+
order: MODEL_ORDER.NORMAL,
|
|
16139
16702
|
getBoilerplateConfiguration() {
|
|
16140
16703
|
return {
|
|
16141
|
-
title: 'Open AI Assistant
|
|
16704
|
+
title: 'Open AI Assistant',
|
|
16142
16705
|
packageName: '@promptbook/openai',
|
|
16143
16706
|
className: 'OpenAiAssistantExecutionTools',
|
|
16144
16707
|
options: {
|