@promptbook/cli 0.59.0-25 → 0.59.0-27
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 +151 -97
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/{umd/typings/src/conversion/validation/validatePromptbookJson.d.ts → esm/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
- package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +151 -97
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/core.index.d.ts +2 -2
- package/{esm/typings/src/conversion/validation/validatePromptbookJson.d.ts → umd/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
- package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +1 -1
- /package/esm/typings/src/conversion/validation/{validatePromptbookJson-logicErrors.test.d.ts → validatePromptbook-logicErrors.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/validation/{validatePromptbookJson.test.d.ts → validatePromptbook.test.d.ts} +0 -0
- /package/umd/typings/src/conversion/validation/{validatePromptbookJson-logicErrors.test.d.ts → validatePromptbook-logicErrors.test.d.ts} +0 -0
- /package/umd/typings/src/conversion/validation/{validatePromptbookJson.test.d.ts → validatePromptbook.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -143,7 +143,7 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
|
|
|
143
143
|
/**
|
|
144
144
|
* The version of the Promptbook library
|
|
145
145
|
*/
|
|
146
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
146
|
+
var PROMPTBOOK_VERSION = '0.59.0-26';
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
* Initializes testing `hello` command for Promptbook CLI utilities
|
|
@@ -184,61 +184,6 @@ var LOOP_LIMIT = 1000;
|
|
|
184
184
|
*/
|
|
185
185
|
var PROMPTBOOK_MAKED_BASE_FILENAME = "promptbook-library";
|
|
186
186
|
|
|
187
|
-
/**
|
|
188
|
-
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
189
|
-
*/
|
|
190
|
-
var PromptbookSyntaxError = /** @class */ (function (_super) {
|
|
191
|
-
__extends(PromptbookSyntaxError, _super);
|
|
192
|
-
function PromptbookSyntaxError(message) {
|
|
193
|
-
var _this = _super.call(this, message) || this;
|
|
194
|
-
_this.name = 'PromptbookSyntaxError';
|
|
195
|
-
Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
|
|
196
|
-
return _this;
|
|
197
|
-
}
|
|
198
|
-
return PromptbookSyntaxError;
|
|
199
|
-
}(Error));
|
|
200
|
-
|
|
201
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-24",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* This error indicates errors during the execution of the promptbook
|
|
205
|
-
*/
|
|
206
|
-
var PromptbookExecutionError = /** @class */ (function (_super) {
|
|
207
|
-
__extends(PromptbookExecutionError, _super);
|
|
208
|
-
function PromptbookExecutionError(message) {
|
|
209
|
-
var _this = _super.call(this, message) || this;
|
|
210
|
-
_this.name = 'PromptbookExecutionError';
|
|
211
|
-
Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
|
|
212
|
-
return _this;
|
|
213
|
-
}
|
|
214
|
-
return PromptbookExecutionError;
|
|
215
|
-
}(Error));
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Asserts that the execution of a promptnook is successful
|
|
219
|
-
*
|
|
220
|
-
* @param executionResult - The partial result of the promptnook execution
|
|
221
|
-
* @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
|
|
222
|
-
*/
|
|
223
|
-
function assertsExecutionSuccessful(executionResult) {
|
|
224
|
-
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
|
|
225
|
-
if (isSuccessful === true) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
if (errors.length === 0) {
|
|
229
|
-
throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
|
|
230
|
-
}
|
|
231
|
-
else if (errors.length === 1) {
|
|
232
|
-
throw errors[0];
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
throw new PromptbookExecutionError(spaceTrim$1(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* TODO: [🧠] Can this return type be better typed than void
|
|
240
|
-
*/
|
|
241
|
-
|
|
242
187
|
/**
|
|
243
188
|
* This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
|
|
244
189
|
*/
|
|
@@ -253,6 +198,20 @@ var PromptbookLogicError = /** @class */ (function (_super) {
|
|
|
253
198
|
return PromptbookLogicError;
|
|
254
199
|
}(Error));
|
|
255
200
|
|
|
201
|
+
/**
|
|
202
|
+
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
203
|
+
*/
|
|
204
|
+
var PromptbookSyntaxError = /** @class */ (function (_super) {
|
|
205
|
+
__extends(PromptbookSyntaxError, _super);
|
|
206
|
+
function PromptbookSyntaxError(message) {
|
|
207
|
+
var _this = _super.call(this, message) || this;
|
|
208
|
+
_this.name = 'PromptbookSyntaxError';
|
|
209
|
+
Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
|
|
210
|
+
return _this;
|
|
211
|
+
}
|
|
212
|
+
return PromptbookSyntaxError;
|
|
213
|
+
}(Error));
|
|
214
|
+
|
|
256
215
|
/**
|
|
257
216
|
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
258
217
|
*/
|
|
@@ -306,7 +265,7 @@ function isValidUrl(url) {
|
|
|
306
265
|
* @returns the same promptbook if it is logically valid
|
|
307
266
|
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
308
267
|
*/
|
|
309
|
-
function
|
|
268
|
+
function validatePromptbook(promptbook) {
|
|
310
269
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
311
270
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
312
271
|
if (promptbook.promptbookUrl !== undefined) {
|
|
@@ -370,8 +329,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
370
329
|
throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
|
|
371
330
|
}
|
|
372
331
|
definedParameters.add(template.resultingParameterName);
|
|
373
|
-
if (template.executionType === 'PROMPT_TEMPLATE' &&
|
|
374
|
-
(template.modelRequirements.modelVariant === undefined)) {
|
|
332
|
+
if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
|
|
375
333
|
throw new PromptbookLogicError(spaceTrim$1("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
|
|
376
334
|
}
|
|
377
335
|
if (template.jokers && template.jokers.length > 0) {
|
|
@@ -441,7 +399,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
441
399
|
var loopLimit = LOOP_LIMIT;
|
|
442
400
|
var _loop_2 = function () {
|
|
443
401
|
if (loopLimit-- < 0) {
|
|
444
|
-
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `
|
|
402
|
+
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
|
|
445
403
|
}
|
|
446
404
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
447
405
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -476,7 +434,48 @@ function validatePromptbookJson(promptbook) {
|
|
|
476
434
|
* > * It checks:
|
|
477
435
|
* > * - it has a valid structure
|
|
478
436
|
* > * - ...
|
|
479
|
-
* > ex port function
|
|
437
|
+
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
438
|
+
*/
|
|
439
|
+
|
|
440
|
+
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-26",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* This error indicates errors during the execution of the promptbook
|
|
444
|
+
*/
|
|
445
|
+
var PromptbookExecutionError = /** @class */ (function (_super) {
|
|
446
|
+
__extends(PromptbookExecutionError, _super);
|
|
447
|
+
function PromptbookExecutionError(message) {
|
|
448
|
+
var _this = _super.call(this, message) || this;
|
|
449
|
+
_this.name = 'PromptbookExecutionError';
|
|
450
|
+
Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
|
|
451
|
+
return _this;
|
|
452
|
+
}
|
|
453
|
+
return PromptbookExecutionError;
|
|
454
|
+
}(Error));
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Asserts that the execution of a promptnook is successful
|
|
458
|
+
*
|
|
459
|
+
* @param executionResult - The partial result of the promptnook execution
|
|
460
|
+
* @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
|
|
461
|
+
*/
|
|
462
|
+
function assertsExecutionSuccessful(executionResult) {
|
|
463
|
+
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
|
|
464
|
+
if (isSuccessful === true) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (errors.length === 0) {
|
|
468
|
+
throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
|
|
469
|
+
}
|
|
470
|
+
else if (errors.length === 1) {
|
|
471
|
+
throw errors[0];
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
throw new PromptbookExecutionError(spaceTrim$1(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* TODO: [🧠] Can this return type be better typed than void
|
|
480
479
|
*/
|
|
481
480
|
|
|
482
481
|
/**
|
|
@@ -1054,7 +1053,7 @@ function createPromptbookExecutor(options) {
|
|
|
1054
1053
|
var _this = this;
|
|
1055
1054
|
var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
1056
1055
|
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
|
|
1057
|
-
|
|
1056
|
+
validatePromptbook(promptbook);
|
|
1058
1057
|
var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
1059
1058
|
function executeSingleTemplate(currentTemplate) {
|
|
1060
1059
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1485,7 +1484,7 @@ function createPromptbookExecutor(options) {
|
|
|
1485
1484
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
1486
1485
|
});
|
|
1487
1486
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
1488
|
-
throw new UnexpectedError(spaceTrim$1("\n Can not resolve some parameters\n\n Note: This should be catched during
|
|
1487
|
+
throw new UnexpectedError(spaceTrim$1("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
|
|
1489
1488
|
case 1:
|
|
1490
1489
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
1491
1490
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -1872,7 +1871,7 @@ var SimplePromptbookLibrary = /** @class */ (function () {
|
|
|
1872
1871
|
if (promptbook.promptbookUrl === undefined) {
|
|
1873
1872
|
throw new PromptbookReferenceError(spaceTrim$1("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
|
|
1874
1873
|
}
|
|
1875
|
-
|
|
1874
|
+
validatePromptbook(promptbook);
|
|
1876
1875
|
// Note: [🦄]
|
|
1877
1876
|
if (this.library.has(promptbook.promptbookUrl) &&
|
|
1878
1877
|
promptbookJsonToString(promptbook) !==
|
|
@@ -1937,11 +1936,7 @@ function createLibraryFromJson() {
|
|
|
1937
1936
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1938
1937
|
promptbooks[_i] = arguments[_i];
|
|
1939
1938
|
}
|
|
1940
|
-
return
|
|
1941
|
-
return __generator(this, function (_a) {
|
|
1942
|
-
return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
1943
|
-
});
|
|
1944
|
-
});
|
|
1939
|
+
return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
1945
1940
|
}
|
|
1946
1941
|
|
|
1947
1942
|
/* tslint:disable */
|
|
@@ -2007,9 +2002,7 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2007
2002
|
switch (_b.label) {
|
|
2008
2003
|
case 0:
|
|
2009
2004
|
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2010
|
-
|
|
2011
|
-
case 1:
|
|
2012
|
-
library = _b.sent();
|
|
2005
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
2013
2006
|
promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
|
|
2014
2007
|
executor = createPromptbookExecutor({
|
|
2015
2008
|
promptbook: promptbook,
|
|
@@ -2021,7 +2014,7 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2021
2014
|
},
|
|
2022
2015
|
});
|
|
2023
2016
|
return [4 /*yield*/, executor({ content: content })];
|
|
2024
|
-
case
|
|
2017
|
+
case 1:
|
|
2025
2018
|
result = _b.sent();
|
|
2026
2019
|
assertsExecutionSuccessful(result);
|
|
2027
2020
|
outputParameters = result.outputParameters;
|
|
@@ -2060,7 +2053,7 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2060
2053
|
}];
|
|
2061
2054
|
});
|
|
2062
2055
|
}); }))];
|
|
2063
|
-
case
|
|
2056
|
+
case 2:
|
|
2064
2057
|
knowledge = _b.sent();
|
|
2065
2058
|
return [2 /*return*/, knowledge];
|
|
2066
2059
|
}
|
|
@@ -3230,9 +3223,7 @@ function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
|
3230
3223
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
3231
3224
|
case 1:
|
|
3232
3225
|
promptbookSources = _a.sent();
|
|
3233
|
-
|
|
3234
|
-
case 2:
|
|
3235
|
-
library = _a.sent();
|
|
3226
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
|
|
3236
3227
|
return [2 /*return*/];
|
|
3237
3228
|
}
|
|
3238
3229
|
});
|
|
@@ -3376,7 +3367,7 @@ function createLibraryFromDirectory(path, options) {
|
|
|
3376
3367
|
if (!isCrashOnError) {
|
|
3377
3368
|
// Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
|
|
3378
3369
|
// But be handled in current try-catch block
|
|
3379
|
-
|
|
3370
|
+
validatePromptbook(promptbook);
|
|
3380
3371
|
}
|
|
3381
3372
|
// Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePromptbookLibrary
|
|
3382
3373
|
promptbooks.push(promptbook);
|
|
@@ -3541,21 +3532,84 @@ function initializeMake(program) {
|
|
|
3541
3532
|
helloCommand.action(function (path, _a) {
|
|
3542
3533
|
var projectName = _a.projectName, format = _a.format, validation = _a.validation;
|
|
3543
3534
|
return __awaiter(_this, void 0, void 0, function () {
|
|
3544
|
-
var library, libraryJson, libraryJsonString, saveFile;
|
|
3535
|
+
var formats, validations, library, validations_1, validations_1_1, validation_1, _b, _c, promptbookUrl, promptbook, e_1_1, e_2_1, libraryJson, libraryJsonString, saveFile;
|
|
3536
|
+
var e_2, _d, e_1, _e;
|
|
3545
3537
|
var _this = this;
|
|
3546
|
-
return __generator(this, function (
|
|
3547
|
-
switch (
|
|
3538
|
+
return __generator(this, function (_f) {
|
|
3539
|
+
switch (_f.label) {
|
|
3548
3540
|
case 0:
|
|
3549
3541
|
console.info('!!!', { projectName: projectName, path: path, format: format, validation: validation });
|
|
3542
|
+
formats = (format || '')
|
|
3543
|
+
.split(',')
|
|
3544
|
+
.map(function (_) { return _.trim(); })
|
|
3545
|
+
.filter(function (_) { return _ !== ''; });
|
|
3546
|
+
validations = (validation || '')
|
|
3547
|
+
.split(',')
|
|
3548
|
+
.map(function (_) { return _.trim(); })
|
|
3549
|
+
.filter(function (_) { return _ !== ''; });
|
|
3550
3550
|
return [4 /*yield*/, createLibraryFromDirectory(path, {
|
|
3551
3551
|
isVerbose: true,
|
|
3552
3552
|
isRecursive: true,
|
|
3553
3553
|
})];
|
|
3554
3554
|
case 1:
|
|
3555
|
-
library =
|
|
3556
|
-
|
|
3555
|
+
library = _f.sent();
|
|
3556
|
+
_f.label = 2;
|
|
3557
3557
|
case 2:
|
|
3558
|
-
|
|
3558
|
+
_f.trys.push([2, 14, 15, 16]);
|
|
3559
|
+
validations_1 = __values(validations), validations_1_1 = validations_1.next();
|
|
3560
|
+
_f.label = 3;
|
|
3561
|
+
case 3:
|
|
3562
|
+
if (!!validations_1_1.done) return [3 /*break*/, 13];
|
|
3563
|
+
validation_1 = validations_1_1.value;
|
|
3564
|
+
_f.label = 4;
|
|
3565
|
+
case 4:
|
|
3566
|
+
_f.trys.push([4, 10, 11, 12]);
|
|
3567
|
+
e_1 = void 0;
|
|
3568
|
+
return [4 /*yield*/, library.listPromptbooks()];
|
|
3569
|
+
case 5:
|
|
3570
|
+
_b = (__values.apply(void 0, [_f.sent()])), _c = _b.next();
|
|
3571
|
+
_f.label = 6;
|
|
3572
|
+
case 6:
|
|
3573
|
+
if (!!_c.done) return [3 /*break*/, 9];
|
|
3574
|
+
promptbookUrl = _c.value;
|
|
3575
|
+
return [4 /*yield*/, library.getPromptbookByUrl(promptbookUrl)];
|
|
3576
|
+
case 7:
|
|
3577
|
+
promptbook = _f.sent();
|
|
3578
|
+
if (validation_1 === 'logic') {
|
|
3579
|
+
validatePromptbook(promptbook);
|
|
3580
|
+
}
|
|
3581
|
+
_f.label = 8;
|
|
3582
|
+
case 8:
|
|
3583
|
+
_c = _b.next();
|
|
3584
|
+
return [3 /*break*/, 6];
|
|
3585
|
+
case 9: return [3 /*break*/, 12];
|
|
3586
|
+
case 10:
|
|
3587
|
+
e_1_1 = _f.sent();
|
|
3588
|
+
e_1 = { error: e_1_1 };
|
|
3589
|
+
return [3 /*break*/, 12];
|
|
3590
|
+
case 11:
|
|
3591
|
+
try {
|
|
3592
|
+
if (_c && !_c.done && (_e = _b.return)) _e.call(_b);
|
|
3593
|
+
}
|
|
3594
|
+
finally { if (e_1) throw e_1.error; }
|
|
3595
|
+
return [7 /*endfinally*/];
|
|
3596
|
+
case 12:
|
|
3597
|
+
validations_1_1 = validations_1.next();
|
|
3598
|
+
return [3 /*break*/, 3];
|
|
3599
|
+
case 13: return [3 /*break*/, 16];
|
|
3600
|
+
case 14:
|
|
3601
|
+
e_2_1 = _f.sent();
|
|
3602
|
+
e_2 = { error: e_2_1 };
|
|
3603
|
+
return [3 /*break*/, 16];
|
|
3604
|
+
case 15:
|
|
3605
|
+
try {
|
|
3606
|
+
if (validations_1_1 && !validations_1_1.done && (_d = validations_1.return)) _d.call(validations_1);
|
|
3607
|
+
}
|
|
3608
|
+
finally { if (e_2) throw e_2.error; }
|
|
3609
|
+
return [7 /*endfinally*/];
|
|
3610
|
+
case 16: return [4 /*yield*/, libraryToJson(library)];
|
|
3611
|
+
case 17:
|
|
3612
|
+
libraryJson = _f.sent();
|
|
3559
3613
|
libraryJsonString = JSON.stringify(libraryJson);
|
|
3560
3614
|
saveFile = function (extension, content) { return __awaiter(_this, void 0, void 0, function () {
|
|
3561
3615
|
var filePath;
|
|
@@ -3571,25 +3625,25 @@ function initializeMake(program) {
|
|
|
3571
3625
|
}
|
|
3572
3626
|
});
|
|
3573
3627
|
}); };
|
|
3574
|
-
if (!
|
|
3628
|
+
if (!formats.includes('json')) return [3 /*break*/, 19];
|
|
3575
3629
|
return [4 /*yield*/, saveFile('json', libraryJsonString + '\n')];
|
|
3576
|
-
case
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
case
|
|
3580
|
-
if (
|
|
3630
|
+
case 18:
|
|
3631
|
+
_f.sent();
|
|
3632
|
+
_f.label = 19;
|
|
3633
|
+
case 19:
|
|
3634
|
+
if (formats.includes('javascript')) {
|
|
3581
3635
|
// TODO: !!!!;
|
|
3582
3636
|
// TODO: !!! DRY javascript and typescript
|
|
3583
|
-
|
|
3637
|
+
formats.push('javascript');
|
|
3584
3638
|
}
|
|
3585
|
-
if (!
|
|
3639
|
+
if (!formats.includes('typescript')) return [3 /*break*/, 21];
|
|
3586
3640
|
// TODO: !!!!!!!! Javascript json
|
|
3587
|
-
return [4 /*yield*/, saveFile('ts', spaceTrim("\n import
|
|
3588
|
-
case
|
|
3641
|
+
return [4 /*yield*/, saveFile('ts', spaceTrim("\n import { createLibraryFromJson } from '@promptbook/core';\n import type { PromptbookLibrary, SimplePromptbookLibrary } from '@promptbook/types';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPromptbookLibrary`\n */\n let promptbookLibrary: null | SimplePromptbookLibrary = null;\n\n\n /**\n * Get promptbook library for ").concat(projectName, "\n *\n * @returns {PromptbookLibrary} Library of promptbooks for ").concat(projectName, "\n * @generated by `@promptbook/cli`\n */\n export function getPromptbookLibrary(): PromptbookLibrary{\n if(promptbookLibrary===null){\n promptbookLibrary = createLibraryFromJson(").concat(libraryJsonString.substring(1, libraryJsonString.length - 1), ");\n }\n\n return promptbookLibrary;\n }\n ") + '\n'))];
|
|
3642
|
+
case 20:
|
|
3589
3643
|
// TODO: !!!!!!!! Javascript json
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
case
|
|
3644
|
+
_f.sent();
|
|
3645
|
+
_f.label = 21;
|
|
3646
|
+
case 21:
|
|
3593
3647
|
process.exit(0);
|
|
3594
3648
|
return [2 /*return*/];
|
|
3595
3649
|
}
|