@promptbook/remote-server 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 +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/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/remote-server`
|
|
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
|
@@ -28,7 +28,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.82.0
|
|
31
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5860,15 +5860,15 @@ function normalizeToKebabCase(text) {
|
|
|
5860
5860
|
/**
|
|
5861
5861
|
* Creates unique name for the source
|
|
5862
5862
|
*
|
|
5863
|
-
* @
|
|
5863
|
+
* @public exported from `@promptbook/editable`
|
|
5864
5864
|
*/
|
|
5865
|
-
function
|
|
5866
|
-
var hash = SHA256(hexEncoder.parse(JSON.stringify(
|
|
5865
|
+
function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
5866
|
+
var hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
|
|
5867
5867
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
5868
5868
|
.toString( /* hex */)
|
|
5869
5869
|
.substring(0, 20);
|
|
5870
5870
|
// <- TODO: [🥬] Make some system for hashes and ids of promptbook
|
|
5871
|
-
var semanticName = normalizeToKebabCase(
|
|
5871
|
+
var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
|
|
5872
5872
|
var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
|
|
5873
5873
|
var name = pieces.join('-').split('--').join('-');
|
|
5874
5874
|
// <- TODO: Use MAX_FILENAME_LENGTH
|
|
@@ -6017,19 +6017,19 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
6017
6017
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
6018
6018
|
var _a;
|
|
6019
6019
|
return __awaiter(this, void 0, void 0, function () {
|
|
6020
|
-
var _b, fetch,
|
|
6020
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
6021
6021
|
return __generator(this, function (_f) {
|
|
6022
6022
|
switch (_f.label) {
|
|
6023
6023
|
case 0:
|
|
6024
6024
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
6025
|
-
|
|
6025
|
+
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
6026
6026
|
name = knowledgeSource.name;
|
|
6027
6027
|
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
6028
6028
|
if (!name) {
|
|
6029
|
-
name =
|
|
6029
|
+
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
6030
6030
|
}
|
|
6031
|
-
if (!isValidUrl(
|
|
6032
|
-
url =
|
|
6031
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
|
|
6032
|
+
url = knowledgeSourceContent;
|
|
6033
6033
|
return [4 /*yield*/, fetch(url)];
|
|
6034
6034
|
case 1:
|
|
6035
6035
|
response_1 = _f.sent();
|
|
@@ -6075,7 +6075,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6075
6075
|
},
|
|
6076
6076
|
}];
|
|
6077
6077
|
case 2:
|
|
6078
|
-
if (!isValidFilePath(
|
|
6078
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
|
|
6079
6079
|
if (tools.fs === undefined) {
|
|
6080
6080
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
6081
6081
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -6084,13 +6084,13 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6084
6084
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
6085
6085
|
// <- TODO: [🧠] What is the best error type here`
|
|
6086
6086
|
}
|
|
6087
|
-
filename_1 = join(rootDirname,
|
|
6087
|
+
filename_1 = join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
6088
6088
|
fileExtension = getFileExtension(filename_1);
|
|
6089
6089
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
6090
6090
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
6091
6091
|
case 3:
|
|
6092
6092
|
if (!(_f.sent())) {
|
|
6093
|
-
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(
|
|
6093
|
+
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 "); }));
|
|
6094
6094
|
}
|
|
6095
6095
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
6096
6096
|
return [2 /*return*/, {
|
|
@@ -6141,7 +6141,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6141
6141
|
url: null,
|
|
6142
6142
|
mimeType: 'text/markdown',
|
|
6143
6143
|
asText: function () {
|
|
6144
|
-
return knowledgeSource.
|
|
6144
|
+
return knowledgeSource.knowledgeSourceContent;
|
|
6145
6145
|
},
|
|
6146
6146
|
asJson: function () {
|
|
6147
6147
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
@@ -6203,7 +6203,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
6203
6203
|
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
6204
6204
|
return [2 /*return*/, "break"];
|
|
6205
6205
|
}
|
|
6206
|
-
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.
|
|
6206
|
+
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
|
|
6207
6207
|
.split('\n')
|
|
6208
6208
|
.map(function (line) { return "> ".concat(line); })
|
|
6209
6209
|
.join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
@@ -6241,7 +6241,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
6241
6241
|
return [7 /*endfinally*/];
|
|
6242
6242
|
case 9:
|
|
6243
6243
|
if (partialPieces === null) {
|
|
6244
|
-
throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.
|
|
6244
|
+
throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
|
|
6245
6245
|
.split('\n')
|
|
6246
6246
|
.map(function (line) { return "> ".concat(line); })
|
|
6247
6247
|
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|