@promptbook/remote-client 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 +38 -36
- 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 +38 -36
- 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-client`
|
|
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
|
@@ -19,7 +19,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
19
19
|
* @generated
|
|
20
20
|
* @see https://github.com/webgptorg/promptbook
|
|
21
21
|
*/
|
|
22
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.82.0
|
|
22
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
|
|
23
23
|
/**
|
|
24
24
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
25
25
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -618,8 +618,7 @@ function preparePipelineOnRemoteServer(pipeline, options) {
|
|
|
618
618
|
var socket, preparedPipeline;
|
|
619
619
|
return __generator(this, function (_a) {
|
|
620
620
|
switch (_a.label) {
|
|
621
|
-
case 0:
|
|
622
|
-
return [4 /*yield*/, createRemoteClient(options)];
|
|
621
|
+
case 0: return [4 /*yield*/, createRemoteClient(options)];
|
|
623
622
|
case 1:
|
|
624
623
|
socket = _a.sent();
|
|
625
624
|
socket.emit('preparePipeline-request', {
|
|
@@ -639,7 +638,7 @@ function preparePipelineOnRemoteServer(pipeline, options) {
|
|
|
639
638
|
case 2:
|
|
640
639
|
preparedPipeline = _a.sent();
|
|
641
640
|
socket.disconnect();
|
|
642
|
-
// TODO:
|
|
641
|
+
// TODO: [🧠] Maybe do $exportJson
|
|
643
642
|
return [2 /*return*/, preparedPipeline];
|
|
644
643
|
}
|
|
645
644
|
});
|
|
@@ -1087,15 +1086,15 @@ function normalizeToKebabCase(text) {
|
|
|
1087
1086
|
/**
|
|
1088
1087
|
* Creates unique name for the source
|
|
1089
1088
|
*
|
|
1090
|
-
* @
|
|
1089
|
+
* @public exported from `@promptbook/editable`
|
|
1091
1090
|
*/
|
|
1092
|
-
function
|
|
1093
|
-
var hash = SHA256(hexEncoder.parse(JSON.stringify(
|
|
1091
|
+
function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
1092
|
+
var hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
|
|
1094
1093
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
1095
1094
|
.toString( /* hex */)
|
|
1096
1095
|
.substring(0, 20);
|
|
1097
1096
|
// <- TODO: [🥬] Make some system for hashes and ids of promptbook
|
|
1098
|
-
var semanticName = normalizeToKebabCase(
|
|
1097
|
+
var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
|
|
1099
1098
|
var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
|
|
1100
1099
|
var name = pieces.join('-').split('--').join('-');
|
|
1101
1100
|
// <- TODO: Use MAX_FILENAME_LENGTH
|
|
@@ -1109,7 +1108,7 @@ function sourceContentToName(sourceContent) {
|
|
|
1109
1108
|
* Parses the knowledge command
|
|
1110
1109
|
*
|
|
1111
1110
|
* @see `documentationUrl` for more details
|
|
1112
|
-
* @
|
|
1111
|
+
* @public exported from `@promptbook/editable`
|
|
1113
1112
|
*/
|
|
1114
1113
|
var knowledgeCommandParser = {
|
|
1115
1114
|
/**
|
|
@@ -1145,23 +1144,25 @@ var knowledgeCommandParser = {
|
|
|
1145
1144
|
*/
|
|
1146
1145
|
parse: function (input) {
|
|
1147
1146
|
var args = input.args;
|
|
1148
|
-
var
|
|
1149
|
-
if (
|
|
1147
|
+
var knowledgeSourceContent = spaceTrim$1(args[0] || '');
|
|
1148
|
+
if (knowledgeSourceContent === '') {
|
|
1150
1149
|
throw new ParseError("Source is not defined");
|
|
1151
1150
|
}
|
|
1152
1151
|
// TODO: [main] !!4 Following checks should be applied every link in the `sourceContent`
|
|
1153
|
-
if (
|
|
1152
|
+
if (knowledgeSourceContent.startsWith('http://')) {
|
|
1154
1153
|
throw new ParseError("Source is not secure");
|
|
1155
1154
|
}
|
|
1156
|
-
if (!(isValidFilePath(
|
|
1155
|
+
if (!(isValidFilePath(knowledgeSourceContent) || isValidUrl(knowledgeSourceContent))) {
|
|
1157
1156
|
throw new ParseError("Source not valid");
|
|
1158
1157
|
}
|
|
1159
|
-
if (
|
|
1158
|
+
if (knowledgeSourceContent.startsWith('../') ||
|
|
1159
|
+
knowledgeSourceContent.startsWith('/') ||
|
|
1160
|
+
/^[A-Z]:[\\/]+/i.test(knowledgeSourceContent)) {
|
|
1160
1161
|
throw new ParseError("Source cannot be outside of the .book.md folder");
|
|
1161
1162
|
}
|
|
1162
1163
|
return {
|
|
1163
1164
|
type: 'KNOWLEDGE',
|
|
1164
|
-
|
|
1165
|
+
knowledgeSourceContent: knowledgeSourceContent,
|
|
1165
1166
|
};
|
|
1166
1167
|
},
|
|
1167
1168
|
/**
|
|
@@ -1170,10 +1171,10 @@ var knowledgeCommandParser = {
|
|
|
1170
1171
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
1171
1172
|
*/
|
|
1172
1173
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
1173
|
-
var
|
|
1174
|
+
var knowledgeSourceContent = command.knowledgeSourceContent;
|
|
1174
1175
|
$pipelineJson.knowledgeSources.push({
|
|
1175
|
-
name:
|
|
1176
|
-
|
|
1176
|
+
name: knowledgeSourceContentToName(knowledgeSourceContent),
|
|
1177
|
+
knowledgeSourceContent: knowledgeSourceContent,
|
|
1177
1178
|
});
|
|
1178
1179
|
},
|
|
1179
1180
|
/**
|
|
@@ -1201,7 +1202,7 @@ var knowledgeCommandParser = {
|
|
|
1201
1202
|
* Parses the section command
|
|
1202
1203
|
*
|
|
1203
1204
|
* @see `documentationUrl` for more details
|
|
1204
|
-
* @
|
|
1205
|
+
* @public exported from `@promptbook/editable`
|
|
1205
1206
|
*/
|
|
1206
1207
|
var sectionCommandParser = {
|
|
1207
1208
|
/**
|
|
@@ -1332,7 +1333,7 @@ var sectionCommandParser = {
|
|
|
1332
1333
|
if (command.taskType === 'KNOWLEDGE') {
|
|
1333
1334
|
knowledgeCommandParser.$applyToPipelineJson({
|
|
1334
1335
|
type: 'KNOWLEDGE',
|
|
1335
|
-
|
|
1336
|
+
knowledgeSourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
1336
1337
|
}, $pipelineJson);
|
|
1337
1338
|
$taskJson.isTask = false;
|
|
1338
1339
|
return;
|
|
@@ -1519,7 +1520,7 @@ function isValidPromptbookVersion(version) {
|
|
|
1519
1520
|
* Parses the BOOK_VERSION command
|
|
1520
1521
|
*
|
|
1521
1522
|
* @see `documentationUrl` for more details
|
|
1522
|
-
* @
|
|
1523
|
+
* @public exported from `@promptbook/editable`
|
|
1523
1524
|
*/
|
|
1524
1525
|
var bookVersionCommandParser = {
|
|
1525
1526
|
/**
|
|
@@ -1674,7 +1675,7 @@ function parseNumber(value) {
|
|
|
1674
1675
|
* Parses the expect command
|
|
1675
1676
|
*
|
|
1676
1677
|
* @see `documentationUrl` for more details
|
|
1677
|
-
* @
|
|
1678
|
+
* @public exported from `@promptbook/editable`
|
|
1678
1679
|
*/
|
|
1679
1680
|
var expectCommandParser = {
|
|
1680
1681
|
/**
|
|
@@ -2615,7 +2616,7 @@ function validateParameterName(parameterName) {
|
|
|
2615
2616
|
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
|
|
2616
2617
|
*
|
|
2617
2618
|
* @see `documentationUrl` for more details
|
|
2618
|
-
* @
|
|
2619
|
+
* @public exported from `@promptbook/editable`
|
|
2619
2620
|
*/
|
|
2620
2621
|
var foreachCommandParser = {
|
|
2621
2622
|
/**
|
|
@@ -2769,7 +2770,7 @@ var foreachCommandParser = {
|
|
|
2769
2770
|
* Parses the format command
|
|
2770
2771
|
*
|
|
2771
2772
|
* @see `documentationUrl` for more details
|
|
2772
|
-
* @
|
|
2773
|
+
* @public exported from `@promptbook/editable`
|
|
2773
2774
|
*/
|
|
2774
2775
|
var formatCommandParser = {
|
|
2775
2776
|
/**
|
|
@@ -3066,7 +3067,7 @@ var FORMFACTOR_DEFINITIONS = [
|
|
|
3066
3067
|
* Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
|
|
3067
3068
|
*
|
|
3068
3069
|
* @see `documentationUrl` for more details
|
|
3069
|
-
* @
|
|
3070
|
+
* @public exported from `@promptbook/editable`
|
|
3070
3071
|
*/
|
|
3071
3072
|
var formfactorCommandParser = {
|
|
3072
3073
|
/**
|
|
@@ -3155,7 +3156,7 @@ var formfactorCommandParser = {
|
|
|
3155
3156
|
* Parses the joker command
|
|
3156
3157
|
*
|
|
3157
3158
|
* @see `documentationUrl` for more details
|
|
3158
|
-
* @
|
|
3159
|
+
* @public exported from `@promptbook/editable`
|
|
3159
3160
|
*/
|
|
3160
3161
|
var jokerCommandParser = {
|
|
3161
3162
|
/**
|
|
@@ -3232,7 +3233,8 @@ var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /*
|
|
|
3232
3233
|
* Parses the model command
|
|
3233
3234
|
*
|
|
3234
3235
|
* @see `documentationUrl` for more details
|
|
3235
|
-
* @
|
|
3236
|
+
* @deprecated Option to manually set the model requirements is not recommended to use, use `PERSONA` instead
|
|
3237
|
+
* @public exported from `@promptbook/editable`
|
|
3236
3238
|
*/
|
|
3237
3239
|
var modelCommandParser = {
|
|
3238
3240
|
/**
|
|
@@ -3376,7 +3378,7 @@ var modelCommandParser = {
|
|
|
3376
3378
|
* Parses the parameter command
|
|
3377
3379
|
*
|
|
3378
3380
|
* @see `documentationUrl` for more details
|
|
3379
|
-
* @
|
|
3381
|
+
* @public exported from `@promptbook/editable`
|
|
3380
3382
|
*/
|
|
3381
3383
|
var parameterCommandParser = {
|
|
3382
3384
|
/**
|
|
@@ -3481,7 +3483,7 @@ var parameterCommandParser = {
|
|
|
3481
3483
|
* Parses the persona command
|
|
3482
3484
|
*
|
|
3483
3485
|
* @see `documentationUrl` for more details
|
|
3484
|
-
* @
|
|
3486
|
+
* @public exported from `@promptbook/editable`
|
|
3485
3487
|
*/
|
|
3486
3488
|
var personaCommandParser = {
|
|
3487
3489
|
/**
|
|
@@ -3616,7 +3618,7 @@ function isValidJavascriptName(javascriptName) {
|
|
|
3616
3618
|
* Parses the postprocess command
|
|
3617
3619
|
*
|
|
3618
3620
|
* @see `documentationUrl` for more details
|
|
3619
|
-
* @
|
|
3621
|
+
* @public exported from `@promptbook/editable`
|
|
3620
3622
|
*/
|
|
3621
3623
|
var postprocessCommandParser = {
|
|
3622
3624
|
/**
|
|
@@ -3774,7 +3776,7 @@ function isValidPipelineUrl(url) {
|
|
|
3774
3776
|
* Parses the url command
|
|
3775
3777
|
*
|
|
3776
3778
|
* @see `documentationUrl` for more details
|
|
3777
|
-
* @
|
|
3779
|
+
* @public exported from `@promptbook/editable`
|
|
3778
3780
|
*/
|
|
3779
3781
|
var urlCommandParser = {
|
|
3780
3782
|
/**
|
|
@@ -3875,7 +3877,7 @@ var urlCommandParser = {
|
|
|
3875
3877
|
* Parses the action command
|
|
3876
3878
|
*
|
|
3877
3879
|
* @see `documentationUrl` for more details
|
|
3878
|
-
* @
|
|
3880
|
+
* @public exported from `@promptbook/editable`
|
|
3879
3881
|
*/
|
|
3880
3882
|
var actionCommandParser = {
|
|
3881
3883
|
/**
|
|
@@ -3941,7 +3943,7 @@ var actionCommandParser = {
|
|
|
3941
3943
|
* Parses the instrument command
|
|
3942
3944
|
*
|
|
3943
3945
|
* @see `documentationUrl` for more details
|
|
3944
|
-
* @
|
|
3946
|
+
* @public exported from `@promptbook/editable`
|
|
3945
3947
|
*/
|
|
3946
3948
|
var instrumentCommandParser = {
|
|
3947
3949
|
/**
|
|
@@ -4006,7 +4008,7 @@ var instrumentCommandParser = {
|
|
|
4006
4008
|
/**
|
|
4007
4009
|
* All available command parsers
|
|
4008
4010
|
*
|
|
4009
|
-
* @
|
|
4011
|
+
* @public exported from `@promptbook/editable`
|
|
4010
4012
|
*/
|
|
4011
4013
|
var COMMANDS = [
|
|
4012
4014
|
sectionCommandParser,
|
|
@@ -4037,7 +4039,7 @@ var COMMANDS = [
|
|
|
4037
4039
|
* @returns the parser for the command
|
|
4038
4040
|
* @throws {UnexpectedError} if the parser is not found
|
|
4039
4041
|
*
|
|
4040
|
-
* @
|
|
4042
|
+
* @public exported from `@promptbook/editable`
|
|
4041
4043
|
*/
|
|
4042
4044
|
function getParserForCommand(command) {
|
|
4043
4045
|
var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
|
|
@@ -4073,7 +4075,7 @@ function removeMarkdownFormatting(str) {
|
|
|
4073
4075
|
* @returns parsed command object
|
|
4074
4076
|
* @throws {ParseError} if the command is invalid
|
|
4075
4077
|
*
|
|
4076
|
-
* @
|
|
4078
|
+
* @public exported from `@promptbook/editable`
|
|
4077
4079
|
*/
|
|
4078
4080
|
function parseCommand(raw, usagePlace) {
|
|
4079
4081
|
if (raw.includes('\n') || raw.includes('\r')) {
|