@promptbook/cli 0.59.0-27 → 0.59.0-28
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 +29 -25
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +1 -2
- package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +2 -2
- package/package.json +2 -2
- package/umd/index.umd.js +29 -25
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/types.index.d.ts +1 -2
- package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +2 -2
package/umd/index.umd.js
CHANGED
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
/**
|
|
148
148
|
* The version of the Promptbook library
|
|
149
149
|
*/
|
|
150
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
150
|
+
var PROMPTBOOK_VERSION = '0.59.0-27';
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
153
|
* Initializes testing `hello` command for Promptbook CLI utilities
|
|
@@ -441,7 +441,7 @@
|
|
|
441
441
|
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
442
442
|
*/
|
|
443
443
|
|
|
444
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-
|
|
444
|
+
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-27",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:[]}];
|
|
445
445
|
|
|
446
446
|
/**
|
|
447
447
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -2007,7 +2007,9 @@
|
|
|
2007
2007
|
case 0:
|
|
2008
2008
|
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2009
2009
|
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
2010
|
-
|
|
2010
|
+
return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
|
|
2011
|
+
case 1:
|
|
2012
|
+
promptbook = _b.sent();
|
|
2011
2013
|
executor = createPromptbookExecutor({
|
|
2012
2014
|
promptbook: promptbook,
|
|
2013
2015
|
tools: {
|
|
@@ -2018,7 +2020,7 @@
|
|
|
2018
2020
|
},
|
|
2019
2021
|
});
|
|
2020
2022
|
return [4 /*yield*/, executor({ content: content })];
|
|
2021
|
-
case
|
|
2023
|
+
case 2:
|
|
2022
2024
|
result = _b.sent();
|
|
2023
2025
|
assertsExecutionSuccessful(result);
|
|
2024
2026
|
outputParameters = result.outputParameters;
|
|
@@ -2057,7 +2059,7 @@
|
|
|
2057
2059
|
}];
|
|
2058
2060
|
});
|
|
2059
2061
|
}); }))];
|
|
2060
|
-
case
|
|
2062
|
+
case 3:
|
|
2061
2063
|
knowledge = _b.sent();
|
|
2062
2064
|
return [2 /*return*/, knowledge];
|
|
2063
2065
|
}
|
|
@@ -3316,14 +3318,11 @@
|
|
|
3316
3318
|
switch (_b.label) {
|
|
3317
3319
|
case 0:
|
|
3318
3320
|
if (isVerbose) {
|
|
3319
|
-
console.info("Creating promptbook library from path ".concat(path$1));
|
|
3321
|
+
console.info("Creating promptbook library from path ".concat(path$1.split('\\').join('/')));
|
|
3320
3322
|
}
|
|
3321
3323
|
return [4 /*yield*/, listAllFiles(path$1, isRecursive)];
|
|
3322
3324
|
case 1:
|
|
3323
3325
|
fileNames = _b.sent();
|
|
3324
|
-
if (isVerbose) {
|
|
3325
|
-
console.info('createLibraryFromDirectory', { path: path$1, isRecursive: isRecursive, fileNames: fileNames });
|
|
3326
|
-
}
|
|
3327
3326
|
promptbooks = [];
|
|
3328
3327
|
_loop_1 = function (fileName) {
|
|
3329
3328
|
var promptbook, promptbookString, _c, _d, error_1, wrappedErrorMessage;
|
|
@@ -3343,7 +3342,7 @@
|
|
|
3343
3342
|
case 3:
|
|
3344
3343
|
if (!fileName.endsWith('.ptbk.json')) return [3 /*break*/, 5];
|
|
3345
3344
|
if (isVerbose) {
|
|
3346
|
-
console.info("Loading ".concat(fileName));
|
|
3345
|
+
console.info("Loading ".concat(fileName.split('\\').join('/')));
|
|
3347
3346
|
}
|
|
3348
3347
|
_d = (_c = JSON).parse;
|
|
3349
3348
|
return [4 /*yield*/, promises.readFile(fileName, 'utf8')];
|
|
@@ -3353,7 +3352,7 @@
|
|
|
3353
3352
|
return [3 /*break*/, 6];
|
|
3354
3353
|
case 5:
|
|
3355
3354
|
if (isVerbose) {
|
|
3356
|
-
console.info("Skipping file ".concat(fileName));
|
|
3355
|
+
console.info("Skipping file ".concat(fileName.split('\\').join('/')));
|
|
3357
3356
|
}
|
|
3358
3357
|
_e.label = 6;
|
|
3359
3358
|
case 6:
|
|
@@ -3361,12 +3360,12 @@
|
|
|
3361
3360
|
if (promptbook !== null) {
|
|
3362
3361
|
if (!promptbook.promptbookUrl) {
|
|
3363
3362
|
if (isVerbose) {
|
|
3364
|
-
console.info("Not loading ".concat(fileName, " - missing URL"));
|
|
3363
|
+
console.info("Not loading ".concat(fileName.split('\\').join('/'), " - missing URL"));
|
|
3365
3364
|
}
|
|
3366
3365
|
}
|
|
3367
3366
|
else {
|
|
3368
3367
|
if (isVerbose) {
|
|
3369
|
-
console.info("Loading ".concat(fileName));
|
|
3368
|
+
console.info("Loading ".concat(fileName.split('\\').join('/')));
|
|
3370
3369
|
}
|
|
3371
3370
|
if (!isCrashOnError) {
|
|
3372
3371
|
// Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
|
|
@@ -3532,9 +3531,10 @@
|
|
|
3532
3531
|
helloCommand.option('-f, --format <format>', spaceTrim__default["default"]("\n Output format of builded library \"javascript\", \"typescript\" or \"json\"\n\n Note: You can use multiple formats separated by comma\n "), 'javascript' /* <- Note: [🏳🌈] */);
|
|
3533
3532
|
helloCommand.option('--no-validation', "Do not validate logic of promptbooks in library", true);
|
|
3534
3533
|
helloCommand.option('--validation', "Types of validations separated by comma (options \"logic\",\"imports\")", 'logic,imports');
|
|
3534
|
+
helloCommand.option('--verbose', "Is verbose", false);
|
|
3535
3535
|
// TODO: !!! Auto-detect AI api keys + explicit api keys as argv
|
|
3536
3536
|
helloCommand.action(function (path$1, _a) {
|
|
3537
|
-
var projectName = _a.projectName, format = _a.format, validation = _a.validation;
|
|
3537
|
+
var projectName = _a.projectName, format = _a.format, validation = _a.validation, verbose = _a.verbose;
|
|
3538
3538
|
return __awaiter(_this, void 0, void 0, function () {
|
|
3539
3539
|
var formats, validations, library, validations_1, validations_1_1, validation_1, _b, _c, promptbookUrl, promptbook, e_1_1, e_2_1, libraryJson, libraryJsonString, saveFile;
|
|
3540
3540
|
var e_2, _d, e_1, _e;
|
|
@@ -3552,7 +3552,7 @@
|
|
|
3552
3552
|
.map(function (_) { return _.trim(); })
|
|
3553
3553
|
.filter(function (_) { return _ !== ''; });
|
|
3554
3554
|
return [4 /*yield*/, createLibraryFromDirectory(path$1, {
|
|
3555
|
-
isVerbose:
|
|
3555
|
+
isVerbose: verbose,
|
|
3556
3556
|
isRecursive: true,
|
|
3557
3557
|
})];
|
|
3558
3558
|
case 1:
|
|
@@ -3581,6 +3581,9 @@
|
|
|
3581
3581
|
promptbook = _f.sent();
|
|
3582
3582
|
if (validation_1 === 'logic') {
|
|
3583
3583
|
validatePromptbook(promptbook);
|
|
3584
|
+
if (verbose) {
|
|
3585
|
+
console.info(colors__default["default"].green("Validated logic of ".concat(promptbook.promptbookUrl)));
|
|
3586
|
+
}
|
|
3584
3587
|
}
|
|
3585
3588
|
_f.label = 8;
|
|
3586
3589
|
case 8:
|
|
@@ -3624,7 +3627,9 @@
|
|
|
3624
3627
|
return [4 /*yield*/, promises.writeFile(filePath, content, 'utf-8')];
|
|
3625
3628
|
case 1:
|
|
3626
3629
|
_a.sent();
|
|
3627
|
-
|
|
3630
|
+
if (verbose) {
|
|
3631
|
+
console.info(colors__default["default"].green("Maked ".concat(filePath.split('\\').join('/'))));
|
|
3632
|
+
}
|
|
3628
3633
|
return [2 /*return*/];
|
|
3629
3634
|
}
|
|
3630
3635
|
});
|
|
@@ -3635,19 +3640,18 @@
|
|
|
3635
3640
|
_f.sent();
|
|
3636
3641
|
_f.label = 19;
|
|
3637
3642
|
case 19:
|
|
3638
|
-
if (formats.includes('javascript'))
|
|
3639
|
-
|
|
3640
|
-
// TODO: !!! DRY javascript and typescript
|
|
3641
|
-
formats.push('javascript');
|
|
3642
|
-
}
|
|
3643
|
-
if (!formats.includes('typescript')) return [3 /*break*/, 21];
|
|
3644
|
-
// TODO: !!!!!!!! Javascript json
|
|
3645
|
-
return [4 /*yield*/, saveFile('ts', spaceTrim__default["default"]("\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'))];
|
|
3643
|
+
if (!formats.includes('javascript')) return [3 /*break*/, 21];
|
|
3644
|
+
return [4 /*yield*/, saveFile('ts', spaceTrim__default["default"]("\n import { createLibraryFromJson } from '@promptbook/core';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPromptbookLibrary`\n */\n let promptbookLibrary = 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(){\n if(promptbookLibrary===null){\n promptbookLibrary = createLibraryFromJson(").concat(libraryJsonString.substring(1, libraryJsonString.length - 1), ");\n }\n\n return promptbookLibrary;\n }\n ") + '\n'))];
|
|
3646
3645
|
case 20:
|
|
3647
|
-
// TODO: !!!!!!!! Javascript json
|
|
3648
3646
|
_f.sent();
|
|
3649
3647
|
_f.label = 21;
|
|
3650
3648
|
case 21:
|
|
3649
|
+
if (!formats.includes('typescript')) return [3 /*break*/, 23];
|
|
3650
|
+
return [4 /*yield*/, saveFile('ts', spaceTrim__default["default"]("\n import { createLibraryFromJson } from '@promptbook/core';\n import type { PromptbookLibrary, PromptbookLibrary } from '@promptbook/types';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPromptbookLibrary`\n */\n let promptbookLibrary: null | PromptbookLibrary = 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'))];
|
|
3651
|
+
case 22:
|
|
3652
|
+
_f.sent();
|
|
3653
|
+
_f.label = 23;
|
|
3654
|
+
case 23:
|
|
3651
3655
|
process.exit(0);
|
|
3652
3656
|
return [2 /*return*/];
|
|
3653
3657
|
}
|