@promptbook/markdown-utils 0.82.0-3 → 0.83.0
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/README.md +0 -4
- package/esm/index.es.js +16 -16
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/editable.index.d.ts +74 -0
- package/esm/typings/src/_packages/types.index.d.ts +26 -0
- package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
- package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +1 -1
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +1 -1
- package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
- package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.d.ts → knowledgeSourceContentToName.d.ts} +2 -2
- package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -1
- package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -1
- package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +1 -1
- package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +1 -1
- package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +1 -1
- package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
- package/esm/typings/src/commands/SECTION/sectionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/URL/UrlCommand.d.ts +1 -1
- package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +1 -1
- package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +1 -1
- package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +8 -0
- package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +2 -0
- package/esm/typings/src/commands/index.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +16 -16
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.test.d.ts → knowledgeSourceContentToName.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
<blockquote style="color: #ff8811">
|
|
27
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
-
</blockquote>
|
|
29
|
-
|
|
30
26
|
## 📦 Package `@promptbook/markdown-utils`
|
|
31
27
|
|
|
32
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
22
22
|
* @generated
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.82.0
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3427,15 +3427,15 @@ function normalizeToKebabCase(text) {
|
|
|
3427
3427
|
/**
|
|
3428
3428
|
* Creates unique name for the source
|
|
3429
3429
|
*
|
|
3430
|
-
* @
|
|
3430
|
+
* @public exported from `@promptbook/editable`
|
|
3431
3431
|
*/
|
|
3432
|
-
function
|
|
3433
|
-
var hash = SHA256(hexEncoder.parse(JSON.stringify(
|
|
3432
|
+
function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
3433
|
+
var hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
|
|
3434
3434
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
3435
3435
|
.toString( /* hex */)
|
|
3436
3436
|
.substring(0, 20);
|
|
3437
3437
|
// <- TODO: [🥬] Make some system for hashes and ids of promptbook
|
|
3438
|
-
var semanticName = normalizeToKebabCase(
|
|
3438
|
+
var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
|
|
3439
3439
|
var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
|
|
3440
3440
|
var name = pieces.join('-').split('--').join('-');
|
|
3441
3441
|
// <- TODO: Use MAX_FILENAME_LENGTH
|
|
@@ -3584,19 +3584,19 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
3584
3584
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3585
3585
|
var _a;
|
|
3586
3586
|
return __awaiter(this, void 0, void 0, function () {
|
|
3587
|
-
var _b, fetch,
|
|
3587
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3588
3588
|
return __generator(this, function (_f) {
|
|
3589
3589
|
switch (_f.label) {
|
|
3590
3590
|
case 0:
|
|
3591
3591
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3592
|
-
|
|
3592
|
+
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
3593
3593
|
name = knowledgeSource.name;
|
|
3594
3594
|
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3595
3595
|
if (!name) {
|
|
3596
|
-
name =
|
|
3596
|
+
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
3597
3597
|
}
|
|
3598
|
-
if (!isValidUrl(
|
|
3599
|
-
url =
|
|
3598
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
|
|
3599
|
+
url = knowledgeSourceContent;
|
|
3600
3600
|
return [4 /*yield*/, fetch(url)];
|
|
3601
3601
|
case 1:
|
|
3602
3602
|
response_1 = _f.sent();
|
|
@@ -3642,7 +3642,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3642
3642
|
},
|
|
3643
3643
|
}];
|
|
3644
3644
|
case 2:
|
|
3645
|
-
if (!isValidFilePath(
|
|
3645
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
|
|
3646
3646
|
if (tools.fs === undefined) {
|
|
3647
3647
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3648
3648
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3651,13 +3651,13 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3651
3651
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
3652
3652
|
// <- TODO: [🧠] What is the best error type here`
|
|
3653
3653
|
}
|
|
3654
|
-
filename_1 = join(rootDirname,
|
|
3654
|
+
filename_1 = join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
3655
3655
|
fileExtension = getFileExtension(filename_1);
|
|
3656
3656
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3657
3657
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3658
3658
|
case 3:
|
|
3659
3659
|
if (!(_f.sent())) {
|
|
3660
|
-
throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(
|
|
3660
|
+
throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(knowledgeSourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
|
|
3661
3661
|
}
|
|
3662
3662
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3663
3663
|
return [2 /*return*/, {
|
|
@@ -3708,7 +3708,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3708
3708
|
url: null,
|
|
3709
3709
|
mimeType: 'text/markdown',
|
|
3710
3710
|
asText: function () {
|
|
3711
|
-
return knowledgeSource.
|
|
3711
|
+
return knowledgeSource.knowledgeSourceContent;
|
|
3712
3712
|
},
|
|
3713
3713
|
asJson: function () {
|
|
3714
3714
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
@@ -3770,7 +3770,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3770
3770
|
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
3771
3771
|
return [2 /*return*/, "break"];
|
|
3772
3772
|
}
|
|
3773
|
-
console.warn(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n\n The source:\n ").concat(block(knowledgeSource.
|
|
3773
|
+
console.warn(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n\n The source:\n ").concat(block(knowledgeSource.knowledgeSourceContent
|
|
3774
3774
|
.split('\n')
|
|
3775
3775
|
.map(function (line) { return "> ".concat(line); })
|
|
3776
3776
|
.join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
@@ -3808,7 +3808,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3808
3808
|
return [7 /*endfinally*/];
|
|
3809
3809
|
case 9:
|
|
3810
3810
|
if (partialPieces === null) {
|
|
3811
|
-
throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.
|
|
3811
|
+
throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
|
|
3812
3812
|
.split('\n')
|
|
3813
3813
|
.map(function (line) { return "> ".concat(line); })
|
|
3814
3814
|
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|