@promptbook/cli 0.81.0-16 → 0.81.0-18
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 +51 -51
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/markdown-utils.index.d.ts +2 -2
- package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +9 -4
- package/esm/typings/src/formfactors/image-generator/ImageGeneratorFormfactorDefinition.d.ts +1 -1
- package/esm/typings/src/formfactors/index.d.ts +10 -5
- package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +3 -0
- package/esm/typings/src/pipeline/book-notation.d.ts +15 -0
- package/esm/typings/src/pipeline/isValidPipelineString.d.ts +11 -0
- package/esm/typings/src/pipeline/isValidPipelineString.test.d.ts +4 -0
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -1
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
- package/esm/typings/src/utils/markdown/{removeContentComments.d.ts → removeMarkdownComments.d.ts} +2 -2
- package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +51 -51
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/utils/markdown/{removeContentComments.test.d.ts → removeMarkdownComments.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -39,7 +39,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
39
39
|
* @generated
|
|
40
40
|
* @see https://github.com/webgptorg/promptbook
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
42
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-17';
|
|
43
43
|
/**
|
|
44
44
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
45
45
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -733,7 +733,6 @@ function checkSerializableAsJson(options) {
|
|
|
733
733
|
function deepClone(objectValue) {
|
|
734
734
|
return JSON.parse(JSON.stringify(objectValue));
|
|
735
735
|
/*
|
|
736
|
-
!!!!!!!!
|
|
737
736
|
TODO: [🧠] Is there a better implementation?
|
|
738
737
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
739
738
|
> for (const propertyName of propertyNames) {
|
|
@@ -845,7 +844,7 @@ var RESERVED_PARAMETER_NAMES = exportJson({
|
|
|
845
844
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
846
845
|
*/
|
|
847
846
|
|
|
848
|
-
// <- TODO:
|
|
847
|
+
// <- TODO: Auto convert to type `import { ... } from 'type-fest';`
|
|
849
848
|
/**
|
|
850
849
|
* Tests if the value is [🚉] serializable as JSON
|
|
851
850
|
*
|
|
@@ -2117,10 +2116,9 @@ function $provideLlmToolsConfigurationFromEnv() {
|
|
|
2117
2116
|
case 1:
|
|
2118
2117
|
if (!(i < LOOP_LIMIT)) return [3 /*break*/, 4];
|
|
2119
2118
|
envFilename = join(rootDirname, '.env' /* <- TODO: [🕝] Make here more candidates */);
|
|
2120
|
-
console.log({ rootDirname: rootDirname, envFilename: envFilename });
|
|
2121
2119
|
return [4 /*yield*/, isFileExisting(envFilename, $provideFilesystemForNode())];
|
|
2122
2120
|
case 2:
|
|
2123
|
-
//
|
|
2121
|
+
// console.log({ rootDirname, envFilename });
|
|
2124
2122
|
if (_a.sent()) {
|
|
2125
2123
|
dotenv.config({ path: envFilename });
|
|
2126
2124
|
return [3 /*break*/, 4];
|
|
@@ -7992,20 +7990,24 @@ var ChatbotFormfactorDefinition = {
|
|
|
7992
7990
|
*/
|
|
7993
7991
|
var GeneratorFormfactorDefinition = {
|
|
7994
7992
|
name: 'GENERATOR',
|
|
7995
|
-
description: "
|
|
7993
|
+
description: "Generates any kind (in HTML with possible scripts and css format) of content from input message",
|
|
7996
7994
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
|
|
7997
7995
|
pipelineInterface: {
|
|
7998
7996
|
inputParameters: [
|
|
7999
|
-
/* @@@ */
|
|
8000
7997
|
{
|
|
8001
|
-
name: '
|
|
8002
|
-
description:
|
|
7998
|
+
name: 'inputMessage',
|
|
7999
|
+
description: "Input message to be image made from",
|
|
8003
8000
|
isInput: true,
|
|
8004
8001
|
isOutput: false,
|
|
8005
8002
|
},
|
|
8006
8003
|
],
|
|
8007
8004
|
outputParameters: [
|
|
8008
|
-
|
|
8005
|
+
{
|
|
8006
|
+
name: 'result',
|
|
8007
|
+
description: "Result in HTML to be shown to user",
|
|
8008
|
+
isInput: false,
|
|
8009
|
+
isOutput: true,
|
|
8010
|
+
},
|
|
8009
8011
|
],
|
|
8010
8012
|
},
|
|
8011
8013
|
};
|
|
@@ -8044,7 +8046,7 @@ var GenericFormfactorDefinition = {
|
|
|
8044
8046
|
*/
|
|
8045
8047
|
var ImageGeneratorFormfactorDefinition = {
|
|
8046
8048
|
name: 'IMAGE_GENERATOR',
|
|
8047
|
-
description: "
|
|
8049
|
+
description: "Generates prompt for image generation from input message",
|
|
8048
8050
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
|
|
8049
8051
|
pipelineInterface: {
|
|
8050
8052
|
inputParameters: [
|
|
@@ -9478,7 +9480,7 @@ var QuickChatbotHla = {
|
|
|
9478
9480
|
isOutput: true,
|
|
9479
9481
|
exampleValues: ['Hello, I am a Pavol`s virtual avatar. How can I help you?'],
|
|
9480
9482
|
});
|
|
9481
|
-
// TODO:
|
|
9483
|
+
// TODO: Use spaceTrim in multiline strings
|
|
9482
9484
|
$pipelineJson.tasks.push({
|
|
9483
9485
|
taskType: 'PROMPT_TASK',
|
|
9484
9486
|
name: 'create-an-answer',
|
|
@@ -9486,8 +9488,11 @@ var QuickChatbotHla = {
|
|
|
9486
9488
|
content: 'Write a response to the user message:\n\n**Question from user**\n\n> {userMessage}\n\n**Previous conversation**\n\n> {previousConversationSummary}',
|
|
9487
9489
|
resultingParameterName: 'chatbotResponse',
|
|
9488
9490
|
personaName: personaName,
|
|
9489
|
-
dependentParameterNames: [
|
|
9490
|
-
|
|
9491
|
+
dependentParameterNames: [
|
|
9492
|
+
'userMessage',
|
|
9493
|
+
'previousConversationSummary' /* TODO: [🧠][📛], 'knowledge'*/,
|
|
9494
|
+
],
|
|
9495
|
+
// TODO: [🧠][📛] preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
|
|
9491
9496
|
}, {
|
|
9492
9497
|
taskType: 'PROMPT_TASK',
|
|
9493
9498
|
name: 'summarize-the-conversation',
|
|
@@ -9501,19 +9506,22 @@ var QuickChatbotHla = {
|
|
|
9501
9506
|
max: 10,
|
|
9502
9507
|
},
|
|
9503
9508
|
},
|
|
9504
|
-
dependentParameterNames: ['userMessage', 'chatbotResponse' /*
|
|
9505
|
-
//
|
|
9509
|
+
dependentParameterNames: ['userMessage', 'chatbotResponse' /* TODO: [🧠][📛], 'knowledge'*/],
|
|
9510
|
+
// TODO: [🧠][📛] preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
|
|
9506
9511
|
}, {
|
|
9507
9512
|
taskType: 'SIMPLE_TASK',
|
|
9508
9513
|
name: 'title',
|
|
9509
9514
|
title: 'Title',
|
|
9510
9515
|
content: '{conversationSummary}',
|
|
9511
9516
|
resultingParameterName: 'title',
|
|
9512
|
-
dependentParameterNames: ['conversationSummary' /*
|
|
9513
|
-
//
|
|
9517
|
+
dependentParameterNames: ['conversationSummary' /* TODO: [🧠][📛], 'knowledge'*/],
|
|
9518
|
+
// TODO: [🧠][📛] preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
|
|
9514
9519
|
});
|
|
9515
9520
|
},
|
|
9516
9521
|
};
|
|
9522
|
+
/**
|
|
9523
|
+
* TODO: [🧠][📛] Should this be here?
|
|
9524
|
+
*/
|
|
9517
9525
|
|
|
9518
9526
|
/**
|
|
9519
9527
|
* All high-level abstractions
|
|
@@ -9754,13 +9762,13 @@ function flattenMarkdown(markdown) {
|
|
|
9754
9762
|
*/
|
|
9755
9763
|
|
|
9756
9764
|
/**
|
|
9757
|
-
* Removes
|
|
9765
|
+
* Removes Markdown (or HTML) comments
|
|
9758
9766
|
*
|
|
9759
9767
|
* @param {string} content - The string to remove comments from.
|
|
9760
9768
|
* @returns {string} The input string with all comments removed.
|
|
9761
9769
|
* @public exported from `@promptbook/markdown-utils`
|
|
9762
9770
|
*/
|
|
9763
|
-
function
|
|
9771
|
+
function removeMarkdownComments(content) {
|
|
9764
9772
|
return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
|
|
9765
9773
|
}
|
|
9766
9774
|
|
|
@@ -9821,7 +9829,7 @@ function precompilePipeline(pipelineString) {
|
|
|
9821
9829
|
}
|
|
9822
9830
|
pipelineString = restLines.join('\n');
|
|
9823
9831
|
}
|
|
9824
|
-
pipelineString =
|
|
9832
|
+
pipelineString = removeMarkdownComments(pipelineString);
|
|
9825
9833
|
pipelineString = spaceTrim$1(pipelineString);
|
|
9826
9834
|
// ==============
|
|
9827
9835
|
// Note: 1️⃣◽2️⃣ Process flat pipeline
|
|
@@ -9838,7 +9846,7 @@ function precompilePipeline(pipelineString) {
|
|
|
9838
9846
|
var returnStatement_1 = pipelineStringLines.pop();
|
|
9839
9847
|
var prompt_1 = spaceTrim$1(pipelineStringLines.join('\n'));
|
|
9840
9848
|
pipelineString = spaceTrim$1(function (block) { return "\n # ".concat(DEFAULT_TITLE /* <- TODO: !!!!!! Title for flat pipelines */, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt_1), "\n ```\n\n ").concat(returnStatement_1, "\n "); });
|
|
9841
|
-
// <- TODO: !!!!!! Use `
|
|
9849
|
+
// <- TODO: !!!!!! Use book` notation
|
|
9842
9850
|
// console.log(pipelineString);
|
|
9843
9851
|
}
|
|
9844
9852
|
// ==============
|
|
@@ -11891,7 +11899,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
11891
11899
|
return content.replace(sectionRegex, contentToInsert);
|
|
11892
11900
|
}
|
|
11893
11901
|
// Note: Following is the case when the section is not found in the file so we add it there
|
|
11894
|
-
var placeForSection =
|
|
11902
|
+
var placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
|
|
11895
11903
|
if (placeForSection !== null) {
|
|
11896
11904
|
var _a = __read(placeForSection, 1), heading_1 = _a[0];
|
|
11897
11905
|
return content.replace(heading_1, spaceTrim$1(function (block) { return "\n ".concat(block(contentToInsert), "\n\n ").concat(block(heading_1), "\n "); }));
|
|
@@ -12353,7 +12361,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
12353
12361
|
*/
|
|
12354
12362
|
function $getCompiledBook(tools, pipelineSource, options) {
|
|
12355
12363
|
return __awaiter(this, void 0, void 0, function () {
|
|
12356
|
-
var fs, fetch, filePathRaw, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, pipelineString, pipelineJson, e_1_1, rootDirname, _loop_1, i, state_1, response_1, pipelineString, pipelineJson;
|
|
12364
|
+
var fs, fetch, filePathRaw, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, pipelineString, pipelineJson, e_1_1, rootDirname, _loop_1, i, state_1, response_1, pipelineString, pipelineJson, pipelineJson;
|
|
12357
12365
|
var e_1, _a;
|
|
12358
12366
|
var _this = this;
|
|
12359
12367
|
return __generator(this, function (_b) {
|
|
@@ -12361,7 +12369,6 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12361
12369
|
case 0:
|
|
12362
12370
|
fs = tools.fs, fetch = tools.fetch;
|
|
12363
12371
|
if (!isValidFilePath(pipelineSource)) return [3 /*break*/, 10];
|
|
12364
|
-
console.log("Strategy 1\uFE0F\u20E3");
|
|
12365
12372
|
filePathRaw = pipelineSource;
|
|
12366
12373
|
filePath = null;
|
|
12367
12374
|
filePathCandidates = [filePathRaw, "".concat(filePathRaw, ".md"), "".concat(filePathRaw, ".book.md"), "".concat(filePathRaw, ".book.md")];
|
|
@@ -12403,26 +12410,19 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12403
12410
|
return [7 /*endfinally*/];
|
|
12404
12411
|
case 10:
|
|
12405
12412
|
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 14];
|
|
12406
|
-
console.log("Strategy 2\uFE0F\u20E3");
|
|
12407
12413
|
rootDirname = process.cwd();
|
|
12408
12414
|
_loop_1 = function (i) {
|
|
12409
|
-
var booksDirname, collection_1,
|
|
12410
|
-
return __generator(this, function (
|
|
12411
|
-
switch (
|
|
12415
|
+
var booksDirname, collection_1, pipeline;
|
|
12416
|
+
return __generator(this, function (_c) {
|
|
12417
|
+
switch (_c.label) {
|
|
12412
12418
|
case 0:
|
|
12413
12419
|
booksDirname = join(rootDirname, DEFAULT_BOOKS_DIRNAME /* <- TODO: [🕝] Make here more candidates */);
|
|
12414
|
-
console.log({ rootDirname: rootDirname, booksDirname: booksDirname });
|
|
12415
12420
|
return [4 /*yield*/, isDirectoryExisting(booksDirname, fs)];
|
|
12416
12421
|
case 1:
|
|
12417
|
-
if (!
|
|
12422
|
+
if (!_c.sent()) return [3 /*break*/, 4];
|
|
12418
12423
|
return [4 /*yield*/, createCollectionFromDirectory(booksDirname, tools, __assign({ isRecursive: true, rootDirname: booksDirname }, options))];
|
|
12419
12424
|
case 2:
|
|
12420
|
-
collection_1 =
|
|
12421
|
-
_d = (_c = console).log;
|
|
12422
|
-
_e = ['listPipelines'];
|
|
12423
|
-
return [4 /*yield*/, collection_1.listPipelines()];
|
|
12424
|
-
case 3:
|
|
12425
|
-
_d.apply(_c, _e.concat([_f.sent()]));
|
|
12425
|
+
collection_1 = _c.sent();
|
|
12426
12426
|
return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
12427
12427
|
var error_1;
|
|
12428
12428
|
return __generator(this, function (_a) {
|
|
@@ -12442,15 +12442,14 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12442
12442
|
}
|
|
12443
12443
|
});
|
|
12444
12444
|
}); })()];
|
|
12445
|
-
case
|
|
12446
|
-
pipeline =
|
|
12447
|
-
console.log({ pipeline
|
|
12448
|
-
// <- TODO: !!!!!!! Remove
|
|
12445
|
+
case 3:
|
|
12446
|
+
pipeline = _c.sent();
|
|
12447
|
+
// console.log({ pipeline });
|
|
12449
12448
|
if (pipeline !== null) {
|
|
12450
12449
|
return [2 /*return*/, { value: pipeline }];
|
|
12451
12450
|
}
|
|
12452
|
-
|
|
12453
|
-
case
|
|
12451
|
+
_c.label = 4;
|
|
12452
|
+
case 4:
|
|
12454
12453
|
if (isRootPath(rootDirname)) {
|
|
12455
12454
|
return [2 /*return*/, "break-up_to_root"];
|
|
12456
12455
|
}
|
|
@@ -12478,7 +12477,6 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12478
12477
|
return [3 /*break*/, 11];
|
|
12479
12478
|
case 14:
|
|
12480
12479
|
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 18];
|
|
12481
|
-
console.log("Strategy 3\uFE0F\u20E3");
|
|
12482
12480
|
return [4 /*yield*/, fetch(pipelineSource)];
|
|
12483
12481
|
case 15:
|
|
12484
12482
|
response_1 = _b.sent();
|
|
@@ -12488,17 +12486,16 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12488
12486
|
return [4 /*yield*/, response_1.text()];
|
|
12489
12487
|
case 16:
|
|
12490
12488
|
pipelineString = _b.sent();
|
|
12491
|
-
console.log({ pipelineString: pipelineString });
|
|
12492
12489
|
return [4 /*yield*/, compilePipeline(pipelineString /* <- TODO: !!!!!! Remove */, tools, __assign({ rootDirname: null }, options))];
|
|
12493
12490
|
case 17:
|
|
12494
12491
|
pipelineJson = _b.sent();
|
|
12495
12492
|
return [2 /*return*/, pipelineJson];
|
|
12496
12493
|
case 18:
|
|
12497
|
-
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
|
|
12501
|
-
|
|
12494
|
+
return [4 /*yield*/, compilePipeline(pipelineSource, tools, __assign({ rootDirname: null }, options))];
|
|
12495
|
+
case 19:
|
|
12496
|
+
pipelineJson = _b.sent();
|
|
12497
|
+
return [2 /*return*/, pipelineJson];
|
|
12498
|
+
case 20: /* not else */ throw new NotFoundError(spaceTrim(function (block) { return "\n Book not found:\n ".concat(block(pipelineSource), "\n\n Pipelines can be loaded from:\n 1) As a file ./books/write-cv.book.md\n 2) As a URL https://promptbook.studio/hejny/write-cv.book.md found in ./books folder recursively\n 2) As a URL https://promptbook.studio/hejny/write-cv.book.md fetched from the internet\n 3) As a string\n\n\n "); }));
|
|
12502
12499
|
}
|
|
12503
12500
|
});
|
|
12504
12501
|
});
|
|
@@ -16659,7 +16656,10 @@ var websiteScraperMetadata = $deepFreeze({
|
|
|
16659
16656
|
className: 'WebsiteScraper',
|
|
16660
16657
|
mimeTypes: ['text/html'],
|
|
16661
16658
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
16662
|
-
isAvilableInBrowser:
|
|
16659
|
+
isAvilableInBrowser: true,
|
|
16660
|
+
// <- TODO: !!!!!!! Is it available in browser?
|
|
16661
|
+
// <- TODO: !!!!!!! Is toggling this to true enough to make it available in browser?
|
|
16662
|
+
// <- TODO: Maybe make it available in browser
|
|
16663
16663
|
requiredExecutables: [],
|
|
16664
16664
|
}); /* <- Note: [🤛] */
|
|
16665
16665
|
/**
|