@promptbook/legacy-documents 0.77.0 → 0.78.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 +74 -45
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +8 -2
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -8
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandType.d.ts +17 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +1 -1
- package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/removePipelineCommand.d.ts +22 -0
- package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts} +3 -3
- package/esm/typings/src/errors/0-index.d.ts +46 -1
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +74 -45
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/conversion/utils/{extractVariables.test.d.ts → extractVariablesFromScript.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{renameParameter.test.d.ts → removePipelineCommand.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{titleToName.test.d.ts → renamePipelineParameter.test.d.ts} +0 -0
- /package/esm/typings/src/{conversion/utils → utils/normalization}/titleToName.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/legacy-documents`
|
|
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
|
@@ -23,7 +23,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.
|
|
26
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.1';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -740,32 +740,12 @@ function isFileExisting(filename, fs) {
|
|
|
740
740
|
*/
|
|
741
741
|
|
|
742
742
|
/**
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
* Note: Dataurl are considered perfectly valid.
|
|
746
|
-
* Note: There are two simmilar functions:
|
|
747
|
-
* - `isValidUrl` which tests any URL
|
|
748
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
743
|
+
* @@@
|
|
749
744
|
*
|
|
750
|
-
* @
|
|
745
|
+
* @private for `FileCacheStorage`
|
|
751
746
|
*/
|
|
752
|
-
function
|
|
753
|
-
|
|
754
|
-
return false;
|
|
755
|
-
}
|
|
756
|
-
try {
|
|
757
|
-
if (url.startsWith('blob:')) {
|
|
758
|
-
url = url.replace(/^blob:/, '');
|
|
759
|
-
}
|
|
760
|
-
var urlObject = new URL(url /* because fail is handled */);
|
|
761
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
762
|
-
return false;
|
|
763
|
-
}
|
|
764
|
-
return true;
|
|
765
|
-
}
|
|
766
|
-
catch (error) {
|
|
767
|
-
return false;
|
|
768
|
-
}
|
|
747
|
+
function nameToSubfolderPath(name) {
|
|
748
|
+
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
769
749
|
}
|
|
770
750
|
|
|
771
751
|
var defaultDiacriticsRemovalMap = [
|
|
@@ -1133,6 +1113,35 @@ function isValidFilePath(filename) {
|
|
|
1133
1113
|
return false;
|
|
1134
1114
|
}
|
|
1135
1115
|
|
|
1116
|
+
/**
|
|
1117
|
+
* Tests if given string is valid URL.
|
|
1118
|
+
*
|
|
1119
|
+
* Note: Dataurl are considered perfectly valid.
|
|
1120
|
+
* Note: There are two simmilar functions:
|
|
1121
|
+
* - `isValidUrl` which tests any URL
|
|
1122
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
1123
|
+
*
|
|
1124
|
+
* @public exported from `@promptbook/utils`
|
|
1125
|
+
*/
|
|
1126
|
+
function isValidUrl(url) {
|
|
1127
|
+
if (typeof url !== 'string') {
|
|
1128
|
+
return false;
|
|
1129
|
+
}
|
|
1130
|
+
try {
|
|
1131
|
+
if (url.startsWith('blob:')) {
|
|
1132
|
+
url = url.replace(/^blob:/, '');
|
|
1133
|
+
}
|
|
1134
|
+
var urlObject = new URL(url /* because fail is handled */);
|
|
1135
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
1136
|
+
return false;
|
|
1137
|
+
}
|
|
1138
|
+
return true;
|
|
1139
|
+
}
|
|
1140
|
+
catch (error) {
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1136
1145
|
/**
|
|
1137
1146
|
* @@@
|
|
1138
1147
|
*
|
|
@@ -1157,15 +1166,6 @@ function titleToName(value) {
|
|
|
1157
1166
|
return value;
|
|
1158
1167
|
}
|
|
1159
1168
|
|
|
1160
|
-
/**
|
|
1161
|
-
* @@@
|
|
1162
|
-
*
|
|
1163
|
-
* @private for `FileCacheStorage`
|
|
1164
|
-
*/
|
|
1165
|
-
function nameToSubfolderPath(name) {
|
|
1166
|
-
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
1169
|
/**
|
|
1170
1170
|
* Create a filename for intermediate cache for scrapers
|
|
1171
1171
|
*
|
|
@@ -2228,7 +2228,7 @@ var NotYetImplementedError = /** @class */ (function (_super) {
|
|
|
2228
2228
|
*
|
|
2229
2229
|
* @public exported from `@promptbook/core`
|
|
2230
2230
|
*/
|
|
2231
|
-
var
|
|
2231
|
+
var PROMPTBOOK_ERRORS = {
|
|
2232
2232
|
AbstractFormatError: AbstractFormatError,
|
|
2233
2233
|
CsvFormatError: CsvFormatError,
|
|
2234
2234
|
CollectionError: CollectionError,
|
|
@@ -2246,6 +2246,35 @@ var ERRORS = {
|
|
|
2246
2246
|
UnexpectedError: UnexpectedError,
|
|
2247
2247
|
// TODO: [🪑]> VersionMismatchError,
|
|
2248
2248
|
};
|
|
2249
|
+
/**
|
|
2250
|
+
* Index of all javascript errors
|
|
2251
|
+
*
|
|
2252
|
+
* @private for internal usage
|
|
2253
|
+
*/
|
|
2254
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
2255
|
+
Error: Error,
|
|
2256
|
+
EvalError: EvalError,
|
|
2257
|
+
RangeError: RangeError,
|
|
2258
|
+
ReferenceError: ReferenceError,
|
|
2259
|
+
SyntaxError: SyntaxError,
|
|
2260
|
+
TypeError: TypeError,
|
|
2261
|
+
URIError: URIError,
|
|
2262
|
+
AggregateError: AggregateError,
|
|
2263
|
+
/*
|
|
2264
|
+
Note: Not widely supported
|
|
2265
|
+
> InternalError,
|
|
2266
|
+
> ModuleError,
|
|
2267
|
+
> HeapError,
|
|
2268
|
+
> WebAssemblyCompileError,
|
|
2269
|
+
> WebAssemblyRuntimeError,
|
|
2270
|
+
*/
|
|
2271
|
+
};
|
|
2272
|
+
/**
|
|
2273
|
+
* Index of all errors
|
|
2274
|
+
*
|
|
2275
|
+
* @private for internal usage
|
|
2276
|
+
*/
|
|
2277
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
2249
2278
|
/**
|
|
2250
2279
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2251
2280
|
*/
|
|
@@ -2256,11 +2285,11 @@ var ERRORS = {
|
|
|
2256
2285
|
* @public exported from `@promptbook/utils`
|
|
2257
2286
|
*/
|
|
2258
2287
|
function deserializeError(error) {
|
|
2259
|
-
|
|
2260
|
-
|
|
2288
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
2289
|
+
if (ErrorClass === undefined) {
|
|
2290
|
+
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
2261
2291
|
}
|
|
2262
|
-
|
|
2263
|
-
return new CustomError(error.message);
|
|
2292
|
+
return new ErrorClass(error.message);
|
|
2264
2293
|
}
|
|
2265
2294
|
|
|
2266
2295
|
/**
|
|
@@ -2334,8 +2363,8 @@ function isPipelinePrepared(pipeline) {
|
|
|
2334
2363
|
*/
|
|
2335
2364
|
function serializeError(error) {
|
|
2336
2365
|
var name = error.name, message = error.message, stack = error.stack;
|
|
2337
|
-
if (!
|
|
2338
|
-
|
|
2366
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2367
|
+
console.error(spaceTrim$1(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2339
2368
|
}
|
|
2340
2369
|
return {
|
|
2341
2370
|
name: name,
|
|
@@ -3811,9 +3840,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3811
3840
|
* @param script from which to extract the variables
|
|
3812
3841
|
* @returns the list of variable names
|
|
3813
3842
|
* @throws {ParseError} if the script is invalid
|
|
3814
|
-
* @public exported from `@promptbook/utils`
|
|
3843
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
3815
3844
|
*/
|
|
3816
|
-
function
|
|
3845
|
+
function extractVariablesFromScript(script) {
|
|
3817
3846
|
var variables = new Set();
|
|
3818
3847
|
script = "(()=>{".concat(script, "})()");
|
|
3819
3848
|
try {
|
|
@@ -3860,7 +3889,7 @@ function extractVariables(script) {
|
|
|
3860
3889
|
* @param task the task with used parameters
|
|
3861
3890
|
* @returns the set of parameter names
|
|
3862
3891
|
* @throws {ParseError} if the script is invalid
|
|
3863
|
-
* @public exported from `@promptbook/
|
|
3892
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
3864
3893
|
*/
|
|
3865
3894
|
function extractParameterNamesFromTask(task) {
|
|
3866
3895
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
@@ -3881,7 +3910,7 @@ function extractParameterNamesFromTask(task) {
|
|
|
3881
3910
|
}
|
|
3882
3911
|
if (taskType === 'SCRIPT_TASK') {
|
|
3883
3912
|
try {
|
|
3884
|
-
for (var _g = __values(
|
|
3913
|
+
for (var _g = __values(extractVariablesFromScript(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3885
3914
|
var parameterName = _h.value;
|
|
3886
3915
|
parameterNames.add(parameterName);
|
|
3887
3916
|
}
|