@promptbook/legacy-documents 0.82.0 → 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/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 +2 -2
- 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/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.82.0
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3648,15 +3648,15 @@
|
|
|
3648
3648
|
/**
|
|
3649
3649
|
* Creates unique name for the source
|
|
3650
3650
|
*
|
|
3651
|
-
* @
|
|
3651
|
+
* @public exported from `@promptbook/editable`
|
|
3652
3652
|
*/
|
|
3653
|
-
function
|
|
3654
|
-
var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(
|
|
3653
|
+
function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
3654
|
+
var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(knowledgeSourceContent)))
|
|
3655
3655
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
3656
3656
|
.toString( /* hex */)
|
|
3657
3657
|
.substring(0, 20);
|
|
3658
3658
|
// <- TODO: [🥬] Make some system for hashes and ids of promptbook
|
|
3659
|
-
var semanticName = normalizeToKebabCase(
|
|
3659
|
+
var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
|
|
3660
3660
|
var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
|
|
3661
3661
|
var name = pieces.join('-').split('--').join('-');
|
|
3662
3662
|
// <- TODO: Use MAX_FILENAME_LENGTH
|
|
@@ -3710,19 +3710,19 @@
|
|
|
3710
3710
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3711
3711
|
var _a;
|
|
3712
3712
|
return __awaiter(this, void 0, void 0, function () {
|
|
3713
|
-
var _b, fetch,
|
|
3713
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3714
3714
|
return __generator(this, function (_f) {
|
|
3715
3715
|
switch (_f.label) {
|
|
3716
3716
|
case 0:
|
|
3717
3717
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3718
|
-
|
|
3718
|
+
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
3719
3719
|
name = knowledgeSource.name;
|
|
3720
3720
|
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3721
3721
|
if (!name) {
|
|
3722
|
-
name =
|
|
3722
|
+
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
3723
3723
|
}
|
|
3724
|
-
if (!isValidUrl(
|
|
3725
|
-
url =
|
|
3724
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
|
|
3725
|
+
url = knowledgeSourceContent;
|
|
3726
3726
|
return [4 /*yield*/, fetch(url)];
|
|
3727
3727
|
case 1:
|
|
3728
3728
|
response_1 = _f.sent();
|
|
@@ -3768,7 +3768,7 @@
|
|
|
3768
3768
|
},
|
|
3769
3769
|
}];
|
|
3770
3770
|
case 2:
|
|
3771
|
-
if (!isValidFilePath(
|
|
3771
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
|
|
3772
3772
|
if (tools.fs === undefined) {
|
|
3773
3773
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3774
3774
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3777,13 +3777,13 @@
|
|
|
3777
3777
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
3778
3778
|
// <- TODO: [🧠] What is the best error type here`
|
|
3779
3779
|
}
|
|
3780
|
-
filename_1 = path.join(rootDirname,
|
|
3780
|
+
filename_1 = path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
3781
3781
|
fileExtension = getFileExtension(filename_1);
|
|
3782
3782
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3783
3783
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3784
3784
|
case 3:
|
|
3785
3785
|
if (!(_f.sent())) {
|
|
3786
|
-
throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(
|
|
3786
|
+
throw new NotFoundError(spaceTrim__default["default"](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 "); }));
|
|
3787
3787
|
}
|
|
3788
3788
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3789
3789
|
return [2 /*return*/, {
|
|
@@ -3834,7 +3834,7 @@
|
|
|
3834
3834
|
url: null,
|
|
3835
3835
|
mimeType: 'text/markdown',
|
|
3836
3836
|
asText: function () {
|
|
3837
|
-
return knowledgeSource.
|
|
3837
|
+
return knowledgeSource.knowledgeSourceContent;
|
|
3838
3838
|
},
|
|
3839
3839
|
asJson: function () {
|
|
3840
3840
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
@@ -3896,7 +3896,7 @@
|
|
|
3896
3896
|
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
3897
3897
|
return [2 /*return*/, "break"];
|
|
3898
3898
|
}
|
|
3899
|
-
console.warn(spaceTrim__default["default"](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.
|
|
3899
|
+
console.warn(spaceTrim__default["default"](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
|
|
3900
3900
|
.split('\n')
|
|
3901
3901
|
.map(function (line) { return "> ".concat(line); })
|
|
3902
3902
|
.join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
@@ -3934,7 +3934,7 @@
|
|
|
3934
3934
|
return [7 /*endfinally*/];
|
|
3935
3935
|
case 9:
|
|
3936
3936
|
if (partialPieces === null) {
|
|
3937
|
-
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.
|
|
3937
|
+
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
|
|
3938
3938
|
.split('\n')
|
|
3939
3939
|
.map(function (line) { return "> ".concat(line); })
|
|
3940
3940
|
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|