@promptbook/pdf 0.82.0 → 0.84.0-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 +4 -0
- package/esm/index.es.js +16 -16
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/editable.index.d.ts +82 -2
- 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/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +17 -0
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +10 -0
- package/esm/typings/src/utils/editable/{utils → edit-pipeline-string}/removePipelineCommand.d.ts +1 -1
- package/esm/typings/src/utils/editable/edit-pipeline-string/removePipelineCommand.test.d.ts +1 -0
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +7 -0
- package/esm/typings/src/utils/editable/utils/renamePipelineParameter.d.ts +3 -0
- 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/esm/typings/src/utils/editable/{utils/removePipelineCommand.test.d.ts → edit-pipeline-string/addPipelineCommand.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,10 @@
|
|
|
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
|
+
|
|
26
30
|
## 📦 Package `@promptbook/pdf`
|
|
27
31
|
|
|
28
32
|
- 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.
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.83.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
|
|
@@ -3272,15 +3272,15 @@ function normalizeToKebabCase(text) {
|
|
|
3272
3272
|
/**
|
|
3273
3273
|
* Creates unique name for the source
|
|
3274
3274
|
*
|
|
3275
|
-
* @
|
|
3275
|
+
* @public exported from `@promptbook/editable`
|
|
3276
3276
|
*/
|
|
3277
|
-
function
|
|
3278
|
-
var hash = SHA256(hexEncoder.parse(JSON.stringify(
|
|
3277
|
+
function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
3278
|
+
var hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
|
|
3279
3279
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
3280
3280
|
.toString( /* hex */)
|
|
3281
3281
|
.substring(0, 20);
|
|
3282
3282
|
// <- TODO: [🥬] Make some system for hashes and ids of promptbook
|
|
3283
|
-
var semanticName = normalizeToKebabCase(
|
|
3283
|
+
var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
|
|
3284
3284
|
var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
|
|
3285
3285
|
var name = pieces.join('-').split('--').join('-');
|
|
3286
3286
|
// <- TODO: Use MAX_FILENAME_LENGTH
|
|
@@ -3429,19 +3429,19 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
3429
3429
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3430
3430
|
var _a;
|
|
3431
3431
|
return __awaiter(this, void 0, void 0, function () {
|
|
3432
|
-
var _b, fetch,
|
|
3432
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3433
3433
|
return __generator(this, function (_f) {
|
|
3434
3434
|
switch (_f.label) {
|
|
3435
3435
|
case 0:
|
|
3436
3436
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3437
|
-
|
|
3437
|
+
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
3438
3438
|
name = knowledgeSource.name;
|
|
3439
3439
|
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3440
3440
|
if (!name) {
|
|
3441
|
-
name =
|
|
3441
|
+
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
3442
3442
|
}
|
|
3443
|
-
if (!isValidUrl(
|
|
3444
|
-
url =
|
|
3443
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
|
|
3444
|
+
url = knowledgeSourceContent;
|
|
3445
3445
|
return [4 /*yield*/, fetch(url)];
|
|
3446
3446
|
case 1:
|
|
3447
3447
|
response_1 = _f.sent();
|
|
@@ -3487,7 +3487,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3487
3487
|
},
|
|
3488
3488
|
}];
|
|
3489
3489
|
case 2:
|
|
3490
|
-
if (!isValidFilePath(
|
|
3490
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
|
|
3491
3491
|
if (tools.fs === undefined) {
|
|
3492
3492
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3493
3493
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3496,13 +3496,13 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3496
3496
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
3497
3497
|
// <- TODO: [🧠] What is the best error type here`
|
|
3498
3498
|
}
|
|
3499
|
-
filename_1 = join(rootDirname,
|
|
3499
|
+
filename_1 = join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
3500
3500
|
fileExtension = getFileExtension(filename_1);
|
|
3501
3501
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3502
3502
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3503
3503
|
case 3:
|
|
3504
3504
|
if (!(_f.sent())) {
|
|
3505
|
-
throw new NotFoundError(spaceTrim$1(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(
|
|
3505
|
+
throw new NotFoundError(spaceTrim$1(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 "); }));
|
|
3506
3506
|
}
|
|
3507
3507
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3508
3508
|
return [2 /*return*/, {
|
|
@@ -3553,7 +3553,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3553
3553
|
url: null,
|
|
3554
3554
|
mimeType: 'text/markdown',
|
|
3555
3555
|
asText: function () {
|
|
3556
|
-
return knowledgeSource.
|
|
3556
|
+
return knowledgeSource.knowledgeSourceContent;
|
|
3557
3557
|
},
|
|
3558
3558
|
asJson: function () {
|
|
3559
3559
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
@@ -3615,7 +3615,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3615
3615
|
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
3616
3616
|
return [2 /*return*/, "break"];
|
|
3617
3617
|
}
|
|
3618
|
-
console.warn(spaceTrim$1(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.
|
|
3618
|
+
console.warn(spaceTrim$1(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
|
|
3619
3619
|
.split('\n')
|
|
3620
3620
|
.map(function (line) { return "> ".concat(line); })
|
|
3621
3621
|
.join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
@@ -3653,7 +3653,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3653
3653
|
return [7 /*endfinally*/];
|
|
3654
3654
|
case 9:
|
|
3655
3655
|
if (partialPieces === null) {
|
|
3656
|
-
throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.
|
|
3656
|
+
throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
|
|
3657
3657
|
.split('\n')
|
|
3658
3658
|
.map(function (line) { return "> ".concat(line); })
|
|
3659
3659
|
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|