@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/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-27';
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
* Initializes testing `hello` command for Promptbook CLI utilities
|
|
@@ -437,7 +437,7 @@ function validatePromptbook(promptbook) {
|
|
|
437
437
|
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
438
438
|
*/
|
|
439
439
|
|
|
440
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-
|
|
440
|
+
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:[]}];
|
|
441
441
|
|
|
442
442
|
/**
|
|
443
443
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -2003,7 +2003,9 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2003
2003
|
case 0:
|
|
2004
2004
|
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2005
2005
|
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
2006
|
-
|
|
2006
|
+
return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
|
|
2007
|
+
case 1:
|
|
2008
|
+
promptbook = _b.sent();
|
|
2007
2009
|
executor = createPromptbookExecutor({
|
|
2008
2010
|
promptbook: promptbook,
|
|
2009
2011
|
tools: {
|
|
@@ -2014,7 +2016,7 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2014
2016
|
},
|
|
2015
2017
|
});
|
|
2016
2018
|
return [4 /*yield*/, executor({ content: content })];
|
|
2017
|
-
case
|
|
2019
|
+
case 2:
|
|
2018
2020
|
result = _b.sent();
|
|
2019
2021
|
assertsExecutionSuccessful(result);
|
|
2020
2022
|
outputParameters = result.outputParameters;
|
|
@@ -2053,7 +2055,7 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2053
2055
|
}];
|
|
2054
2056
|
});
|
|
2055
2057
|
}); }))];
|
|
2056
|
-
case
|
|
2058
|
+
case 3:
|
|
2057
2059
|
knowledge = _b.sent();
|
|
2058
2060
|
return [2 /*return*/, knowledge];
|
|
2059
2061
|
}
|
|
@@ -3312,14 +3314,11 @@ function createLibraryFromDirectory(path, options) {
|
|
|
3312
3314
|
switch (_b.label) {
|
|
3313
3315
|
case 0:
|
|
3314
3316
|
if (isVerbose) {
|
|
3315
|
-
console.info("Creating promptbook library from path ".concat(path));
|
|
3317
|
+
console.info("Creating promptbook library from path ".concat(path.split('\\').join('/')));
|
|
3316
3318
|
}
|
|
3317
3319
|
return [4 /*yield*/, listAllFiles(path, isRecursive)];
|
|
3318
3320
|
case 1:
|
|
3319
3321
|
fileNames = _b.sent();
|
|
3320
|
-
if (isVerbose) {
|
|
3321
|
-
console.info('createLibraryFromDirectory', { path: path, isRecursive: isRecursive, fileNames: fileNames });
|
|
3322
|
-
}
|
|
3323
3322
|
promptbooks = [];
|
|
3324
3323
|
_loop_1 = function (fileName) {
|
|
3325
3324
|
var promptbook, promptbookString, _c, _d, error_1, wrappedErrorMessage;
|
|
@@ -3339,7 +3338,7 @@ function createLibraryFromDirectory(path, options) {
|
|
|
3339
3338
|
case 3:
|
|
3340
3339
|
if (!fileName.endsWith('.ptbk.json')) return [3 /*break*/, 5];
|
|
3341
3340
|
if (isVerbose) {
|
|
3342
|
-
console.info("Loading ".concat(fileName));
|
|
3341
|
+
console.info("Loading ".concat(fileName.split('\\').join('/')));
|
|
3343
3342
|
}
|
|
3344
3343
|
_d = (_c = JSON).parse;
|
|
3345
3344
|
return [4 /*yield*/, readFile(fileName, 'utf8')];
|
|
@@ -3349,7 +3348,7 @@ function createLibraryFromDirectory(path, options) {
|
|
|
3349
3348
|
return [3 /*break*/, 6];
|
|
3350
3349
|
case 5:
|
|
3351
3350
|
if (isVerbose) {
|
|
3352
|
-
console.info("Skipping file ".concat(fileName));
|
|
3351
|
+
console.info("Skipping file ".concat(fileName.split('\\').join('/')));
|
|
3353
3352
|
}
|
|
3354
3353
|
_e.label = 6;
|
|
3355
3354
|
case 6:
|
|
@@ -3357,12 +3356,12 @@ function createLibraryFromDirectory(path, options) {
|
|
|
3357
3356
|
if (promptbook !== null) {
|
|
3358
3357
|
if (!promptbook.promptbookUrl) {
|
|
3359
3358
|
if (isVerbose) {
|
|
3360
|
-
console.info("Not loading ".concat(fileName, " - missing URL"));
|
|
3359
|
+
console.info("Not loading ".concat(fileName.split('\\').join('/'), " - missing URL"));
|
|
3361
3360
|
}
|
|
3362
3361
|
}
|
|
3363
3362
|
else {
|
|
3364
3363
|
if (isVerbose) {
|
|
3365
|
-
console.info("Loading ".concat(fileName));
|
|
3364
|
+
console.info("Loading ".concat(fileName.split('\\').join('/')));
|
|
3366
3365
|
}
|
|
3367
3366
|
if (!isCrashOnError) {
|
|
3368
3367
|
// Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
|
|
@@ -3528,9 +3527,10 @@ function initializeMake(program) {
|
|
|
3528
3527
|
helloCommand.option('-f, --format <format>', spaceTrim("\n Output format of builded library \"javascript\", \"typescript\" or \"json\"\n\n Note: You can use multiple formats separated by comma\n "), 'javascript' /* <- Note: [🏳🌈] */);
|
|
3529
3528
|
helloCommand.option('--no-validation', "Do not validate logic of promptbooks in library", true);
|
|
3530
3529
|
helloCommand.option('--validation', "Types of validations separated by comma (options \"logic\",\"imports\")", 'logic,imports');
|
|
3530
|
+
helloCommand.option('--verbose', "Is verbose", false);
|
|
3531
3531
|
// TODO: !!! Auto-detect AI api keys + explicit api keys as argv
|
|
3532
3532
|
helloCommand.action(function (path, _a) {
|
|
3533
|
-
var projectName = _a.projectName, format = _a.format, validation = _a.validation;
|
|
3533
|
+
var projectName = _a.projectName, format = _a.format, validation = _a.validation, verbose = _a.verbose;
|
|
3534
3534
|
return __awaiter(_this, void 0, void 0, function () {
|
|
3535
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
3536
|
var e_2, _d, e_1, _e;
|
|
@@ -3548,7 +3548,7 @@ function initializeMake(program) {
|
|
|
3548
3548
|
.map(function (_) { return _.trim(); })
|
|
3549
3549
|
.filter(function (_) { return _ !== ''; });
|
|
3550
3550
|
return [4 /*yield*/, createLibraryFromDirectory(path, {
|
|
3551
|
-
isVerbose:
|
|
3551
|
+
isVerbose: verbose,
|
|
3552
3552
|
isRecursive: true,
|
|
3553
3553
|
})];
|
|
3554
3554
|
case 1:
|
|
@@ -3577,6 +3577,9 @@ function initializeMake(program) {
|
|
|
3577
3577
|
promptbook = _f.sent();
|
|
3578
3578
|
if (validation_1 === 'logic') {
|
|
3579
3579
|
validatePromptbook(promptbook);
|
|
3580
|
+
if (verbose) {
|
|
3581
|
+
console.info(colors.green("Validated logic of ".concat(promptbook.promptbookUrl)));
|
|
3582
|
+
}
|
|
3580
3583
|
}
|
|
3581
3584
|
_f.label = 8;
|
|
3582
3585
|
case 8:
|
|
@@ -3620,7 +3623,9 @@ function initializeMake(program) {
|
|
|
3620
3623
|
return [4 /*yield*/, writeFile(filePath, content, 'utf-8')];
|
|
3621
3624
|
case 1:
|
|
3622
3625
|
_a.sent();
|
|
3623
|
-
|
|
3626
|
+
if (verbose) {
|
|
3627
|
+
console.info(colors.green("Maked ".concat(filePath.split('\\').join('/'))));
|
|
3628
|
+
}
|
|
3624
3629
|
return [2 /*return*/];
|
|
3625
3630
|
}
|
|
3626
3631
|
});
|
|
@@ -3631,19 +3636,18 @@ function initializeMake(program) {
|
|
|
3631
3636
|
_f.sent();
|
|
3632
3637
|
_f.label = 19;
|
|
3633
3638
|
case 19:
|
|
3634
|
-
if (formats.includes('javascript'))
|
|
3635
|
-
|
|
3636
|
-
// TODO: !!! DRY javascript and typescript
|
|
3637
|
-
formats.push('javascript');
|
|
3638
|
-
}
|
|
3639
|
-
if (!formats.includes('typescript')) return [3 /*break*/, 21];
|
|
3640
|
-
// TODO: !!!!!!!! Javascript json
|
|
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'))];
|
|
3639
|
+
if (!formats.includes('javascript')) return [3 /*break*/, 21];
|
|
3640
|
+
return [4 /*yield*/, saveFile('ts', spaceTrim("\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'))];
|
|
3642
3641
|
case 20:
|
|
3643
|
-
// TODO: !!!!!!!! Javascript json
|
|
3644
3642
|
_f.sent();
|
|
3645
3643
|
_f.label = 21;
|
|
3646
3644
|
case 21:
|
|
3645
|
+
if (!formats.includes('typescript')) return [3 /*break*/, 23];
|
|
3646
|
+
return [4 /*yield*/, saveFile('ts', spaceTrim("\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'))];
|
|
3647
|
+
case 22:
|
|
3648
|
+
_f.sent();
|
|
3649
|
+
_f.label = 23;
|
|
3650
|
+
case 23:
|
|
3647
3651
|
process.exit(0);
|
|
3648
3652
|
return [2 /*return*/];
|
|
3649
3653
|
}
|