@promptbook/core 0.53.0 → 0.54.1
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 +1 -1
- package/esm/index.es.js +117 -104
- package/esm/index.es.js.map +1 -1
- package/esm/typings/_packages/core.index.d.ts +10 -0
- package/esm/typings/_packages/types.index.d.ts +0 -1
- package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -1
- package/esm/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +2 -1
- package/esm/typings/types/PromptbookJson/PromptbookJson.d.ts +3 -2
- package/esm/typings/types/execution-report/ExecutionReportJson.d.ts +2 -1
- package/package.json +1 -1
- package/umd/index.umd.js +125 -103
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/_packages/core.index.d.ts +10 -0
- package/umd/typings/_packages/types.index.d.ts +0 -1
- package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -1
- package/umd/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +2 -1
- package/umd/typings/types/PromptbookJson/PromptbookJson.d.ts +3 -2
- package/umd/typings/types/execution-report/ExecutionReportJson.d.ts +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PromptResult } from '../../execution/PromptResult';
|
|
2
2
|
import type { Prompt } from '../Prompt';
|
|
3
|
+
import type { string_markdown_text } from '../typeAliases';
|
|
3
4
|
import type { string_promptbook_url } from '../typeAliases';
|
|
4
5
|
import type { string_version } from '../typeAliases';
|
|
5
6
|
/**
|
|
@@ -32,7 +33,7 @@ export type ExecutionReportJson = {
|
|
|
32
33
|
/**
|
|
33
34
|
* Description of the promptbook which was executed
|
|
34
35
|
*/
|
|
35
|
-
readonly description?:
|
|
36
|
+
readonly description?: string_markdown_text;
|
|
36
37
|
/**
|
|
37
38
|
* Sequence of prompt templates in order which were executed
|
|
38
39
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -454,7 +454,7 @@
|
|
|
454
454
|
/**
|
|
455
455
|
* The version of the Promptbook library
|
|
456
456
|
*/
|
|
457
|
-
var PROMPTBOOK_VERSION = '0.
|
|
457
|
+
var PROMPTBOOK_VERSION = '0.54.0';
|
|
458
458
|
|
|
459
459
|
/**
|
|
460
460
|
* Parses the template and returns the list of all parameter names
|
|
@@ -1777,7 +1777,7 @@
|
|
|
1777
1777
|
* @returns Promptbook in string format (.ptbk.md)
|
|
1778
1778
|
*/
|
|
1779
1779
|
function promptbookJsonToString(promptbookJson) {
|
|
1780
|
-
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
|
|
1780
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
1781
1781
|
var title = promptbookJson.title, promptbookUrl = promptbookJson.promptbookUrl, promptbookVersion = promptbookJson.promptbookVersion, description = promptbookJson.description, parameters = promptbookJson.parameters, promptTemplates = promptbookJson.promptTemplates;
|
|
1782
1782
|
var promptbookString = "# ".concat(title);
|
|
1783
1783
|
if (description) {
|
|
@@ -1792,24 +1792,37 @@
|
|
|
1792
1792
|
commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
|
|
1793
1793
|
promptbookString = prettifyMarkdown(promptbookString);
|
|
1794
1794
|
try {
|
|
1795
|
-
for (var
|
|
1796
|
-
var
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
else if (isOutput) {
|
|
1802
|
-
commands.push("OUTPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
|
|
1803
|
-
}
|
|
1795
|
+
for (var _g = __values(parameters.filter(function (_a) {
|
|
1796
|
+
var isInput = _a.isInput;
|
|
1797
|
+
return isInput;
|
|
1798
|
+
})), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
1799
|
+
var parameter = _h.value;
|
|
1800
|
+
commands.push("INPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
|
|
1804
1801
|
}
|
|
1805
1802
|
}
|
|
1806
1803
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1807
1804
|
finally {
|
|
1808
1805
|
try {
|
|
1809
|
-
if (
|
|
1806
|
+
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
1810
1807
|
}
|
|
1811
1808
|
finally { if (e_1) throw e_1.error; }
|
|
1812
1809
|
}
|
|
1810
|
+
try {
|
|
1811
|
+
for (var _j = __values(parameters.filter(function (_a) {
|
|
1812
|
+
var isOutput = _a.isOutput;
|
|
1813
|
+
return isOutput;
|
|
1814
|
+
})), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
1815
|
+
var parameter = _k.value;
|
|
1816
|
+
commands.push("OUTPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1820
|
+
finally {
|
|
1821
|
+
try {
|
|
1822
|
+
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
1823
|
+
}
|
|
1824
|
+
finally { if (e_2) throw e_2.error; }
|
|
1825
|
+
}
|
|
1813
1826
|
promptbookString += '\n\n';
|
|
1814
1827
|
promptbookString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
|
|
1815
1828
|
try {
|
|
@@ -1859,38 +1872,38 @@
|
|
|
1859
1872
|
}
|
|
1860
1873
|
if (jokers) {
|
|
1861
1874
|
try {
|
|
1862
|
-
for (var jokers_1 = (
|
|
1875
|
+
for (var jokers_1 = (e_4 = void 0, __values(jokers)), jokers_1_1 = jokers_1.next(); !jokers_1_1.done; jokers_1_1 = jokers_1.next()) {
|
|
1863
1876
|
var joker = jokers_1_1.value;
|
|
1864
1877
|
commands_1.push("JOKER {".concat(joker, "}"));
|
|
1865
1878
|
}
|
|
1866
1879
|
}
|
|
1867
|
-
catch (
|
|
1880
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1868
1881
|
finally {
|
|
1869
1882
|
try {
|
|
1870
|
-
if (jokers_1_1 && !jokers_1_1.done && (
|
|
1883
|
+
if (jokers_1_1 && !jokers_1_1.done && (_d = jokers_1.return)) _d.call(jokers_1);
|
|
1871
1884
|
}
|
|
1872
|
-
finally { if (
|
|
1885
|
+
finally { if (e_4) throw e_4.error; }
|
|
1873
1886
|
}
|
|
1874
1887
|
} /* not else */
|
|
1875
1888
|
if (postprocessing) {
|
|
1876
1889
|
try {
|
|
1877
|
-
for (var postprocessing_1 = (
|
|
1890
|
+
for (var postprocessing_1 = (e_5 = void 0, __values(postprocessing)), postprocessing_1_1 = postprocessing_1.next(); !postprocessing_1_1.done; postprocessing_1_1 = postprocessing_1.next()) {
|
|
1878
1891
|
var postprocessingFunctionName = postprocessing_1_1.value;
|
|
1879
1892
|
commands_1.push("POSTPROCESSING `".concat(postprocessingFunctionName, "`"));
|
|
1880
1893
|
}
|
|
1881
1894
|
}
|
|
1882
|
-
catch (
|
|
1895
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1883
1896
|
finally {
|
|
1884
1897
|
try {
|
|
1885
|
-
if (postprocessing_1_1 && !postprocessing_1_1.done && (
|
|
1898
|
+
if (postprocessing_1_1 && !postprocessing_1_1.done && (_e = postprocessing_1.return)) _e.call(postprocessing_1);
|
|
1886
1899
|
}
|
|
1887
|
-
finally { if (
|
|
1900
|
+
finally { if (e_5) throw e_5.error; }
|
|
1888
1901
|
}
|
|
1889
1902
|
} /* not else */
|
|
1890
1903
|
if (expectations) {
|
|
1891
1904
|
try {
|
|
1892
|
-
for (var
|
|
1893
|
-
var
|
|
1905
|
+
for (var _l = (e_6 = void 0, __values(Object.entries(expectations))), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
1906
|
+
var _o = __read(_m.value, 2), unit = _o[0], _p = _o[1], min = _p.min, max = _p.max;
|
|
1894
1907
|
if (min === max) {
|
|
1895
1908
|
commands_1.push("EXPECT EXACTLY ".concat(min, " ").concat(capitalize(unit + (min > 1 ? 's' : ''))));
|
|
1896
1909
|
}
|
|
@@ -1904,12 +1917,12 @@
|
|
|
1904
1917
|
}
|
|
1905
1918
|
}
|
|
1906
1919
|
}
|
|
1907
|
-
catch (
|
|
1920
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1908
1921
|
finally {
|
|
1909
1922
|
try {
|
|
1910
|
-
if (
|
|
1923
|
+
if (_m && !_m.done && (_f = _l.return)) _f.call(_l);
|
|
1911
1924
|
}
|
|
1912
|
-
finally { if (
|
|
1925
|
+
finally { if (e_6) throw e_6.error; }
|
|
1913
1926
|
}
|
|
1914
1927
|
} /* not else */
|
|
1915
1928
|
if (expectFormat) {
|
|
@@ -1932,12 +1945,12 @@
|
|
|
1932
1945
|
promptbookString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
|
|
1933
1946
|
}
|
|
1934
1947
|
}
|
|
1935
|
-
catch (
|
|
1948
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1936
1949
|
finally {
|
|
1937
1950
|
try {
|
|
1938
|
-
if (promptTemplates_1_1 && !promptTemplates_1_1.done && (
|
|
1951
|
+
if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_c = promptTemplates_1.return)) _c.call(promptTemplates_1);
|
|
1939
1952
|
}
|
|
1940
|
-
finally { if (
|
|
1953
|
+
finally { if (e_3) throw e_3.error; }
|
|
1941
1954
|
}
|
|
1942
1955
|
return promptbookString;
|
|
1943
1956
|
}
|
|
@@ -2182,6 +2195,23 @@
|
|
|
2182
2195
|
* > ex port function validatePromptbookJson(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
2183
2196
|
*/
|
|
2184
2197
|
|
|
2198
|
+
/**
|
|
2199
|
+
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
2200
|
+
*
|
|
2201
|
+
* @private Always catched and rethrown as `PromptbookExecutionError`
|
|
2202
|
+
* Note: This is a kindof subtype of PromptbookExecutionError
|
|
2203
|
+
*/
|
|
2204
|
+
var ExpectError = /** @class */ (function (_super) {
|
|
2205
|
+
__extends(ExpectError, _super);
|
|
2206
|
+
function ExpectError(message) {
|
|
2207
|
+
var _this = _super.call(this, message) || this;
|
|
2208
|
+
_this.name = 'ExpectError';
|
|
2209
|
+
Object.setPrototypeOf(_this, ExpectError.prototype);
|
|
2210
|
+
return _this;
|
|
2211
|
+
}
|
|
2212
|
+
return ExpectError;
|
|
2213
|
+
}(Error));
|
|
2214
|
+
|
|
2185
2215
|
/**
|
|
2186
2216
|
* This error indicates errors during the execution of the promptbook
|
|
2187
2217
|
*/
|
|
@@ -2196,6 +2226,64 @@
|
|
|
2196
2226
|
return PromptbookExecutionError;
|
|
2197
2227
|
}(Error));
|
|
2198
2228
|
|
|
2229
|
+
/**
|
|
2230
|
+
* This error indicates that the promptbook library cannot be propperly loaded
|
|
2231
|
+
*/
|
|
2232
|
+
var PromptbookLibraryError = /** @class */ (function (_super) {
|
|
2233
|
+
__extends(PromptbookLibraryError, _super);
|
|
2234
|
+
function PromptbookLibraryError(message) {
|
|
2235
|
+
var _this = _super.call(this, message) || this;
|
|
2236
|
+
_this.name = 'PromptbookLibraryError';
|
|
2237
|
+
Object.setPrototypeOf(_this, PromptbookLibraryError.prototype);
|
|
2238
|
+
return _this;
|
|
2239
|
+
}
|
|
2240
|
+
return PromptbookLibraryError;
|
|
2241
|
+
}(Error));
|
|
2242
|
+
|
|
2243
|
+
/**
|
|
2244
|
+
* This error indicates that promptbook not found in the library
|
|
2245
|
+
*/
|
|
2246
|
+
var PromptbookNotFoundError = /** @class */ (function (_super) {
|
|
2247
|
+
__extends(PromptbookNotFoundError, _super);
|
|
2248
|
+
function PromptbookNotFoundError(message) {
|
|
2249
|
+
var _this = _super.call(this, message) || this;
|
|
2250
|
+
_this.name = 'PromptbookNotFoundError';
|
|
2251
|
+
Object.setPrototypeOf(_this, PromptbookNotFoundError.prototype);
|
|
2252
|
+
return _this;
|
|
2253
|
+
}
|
|
2254
|
+
return PromptbookNotFoundError;
|
|
2255
|
+
}(Error));
|
|
2256
|
+
|
|
2257
|
+
/**
|
|
2258
|
+
* This error indicates errors in referencing promptbooks between each other
|
|
2259
|
+
*/
|
|
2260
|
+
var PromptbookReferenceError = /** @class */ (function (_super) {
|
|
2261
|
+
__extends(PromptbookReferenceError, _super);
|
|
2262
|
+
function PromptbookReferenceError(message) {
|
|
2263
|
+
var _this = _super.call(this, message) || this;
|
|
2264
|
+
_this.name = 'PromptbookReferenceError';
|
|
2265
|
+
Object.setPrototypeOf(_this, PromptbookReferenceError.prototype);
|
|
2266
|
+
return _this;
|
|
2267
|
+
}
|
|
2268
|
+
return PromptbookReferenceError;
|
|
2269
|
+
}(Error));
|
|
2270
|
+
|
|
2271
|
+
/**
|
|
2272
|
+
* This error occurs during the parameter replacement in the template
|
|
2273
|
+
*
|
|
2274
|
+
* Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
|
|
2275
|
+
*/
|
|
2276
|
+
var TemplateError = /** @class */ (function (_super) {
|
|
2277
|
+
__extends(TemplateError, _super);
|
|
2278
|
+
function TemplateError(message) {
|
|
2279
|
+
var _this = _super.call(this, message) || this;
|
|
2280
|
+
_this.name = 'TemplateError';
|
|
2281
|
+
Object.setPrototypeOf(_this, TemplateError.prototype);
|
|
2282
|
+
return _this;
|
|
2283
|
+
}
|
|
2284
|
+
return TemplateError;
|
|
2285
|
+
}(Error));
|
|
2286
|
+
|
|
2199
2287
|
/**
|
|
2200
2288
|
* Asserts that the execution of a promptnook is successful
|
|
2201
2289
|
*
|
|
@@ -2221,23 +2309,6 @@
|
|
|
2221
2309
|
* TODO: [🧠] Can this return type be better typed than void
|
|
2222
2310
|
*/
|
|
2223
2311
|
|
|
2224
|
-
/**
|
|
2225
|
-
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
2226
|
-
*
|
|
2227
|
-
* @private Always catched and rethrown as `PromptbookExecutionError`
|
|
2228
|
-
* Note: This is a kindof subtype of PromptbookExecutionError
|
|
2229
|
-
*/
|
|
2230
|
-
var ExpectError = /** @class */ (function (_super) {
|
|
2231
|
-
__extends(ExpectError, _super);
|
|
2232
|
-
function ExpectError(message) {
|
|
2233
|
-
var _this = _super.call(this, message) || this;
|
|
2234
|
-
_this.name = 'ExpectError';
|
|
2235
|
-
Object.setPrototypeOf(_this, ExpectError.prototype);
|
|
2236
|
-
return _this;
|
|
2237
|
-
}
|
|
2238
|
-
return ExpectError;
|
|
2239
|
-
}(Error));
|
|
2240
|
-
|
|
2241
2312
|
/**
|
|
2242
2313
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
2243
2314
|
*/
|
|
@@ -2388,22 +2459,6 @@
|
|
|
2388
2459
|
* TODO: [💝] Unite object for expecting amount and format
|
|
2389
2460
|
*/
|
|
2390
2461
|
|
|
2391
|
-
/**
|
|
2392
|
-
* This error occurs during the parameter replacement in the template
|
|
2393
|
-
*
|
|
2394
|
-
* Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
|
|
2395
|
-
*/
|
|
2396
|
-
var TemplateError = /** @class */ (function (_super) {
|
|
2397
|
-
__extends(TemplateError, _super);
|
|
2398
|
-
function TemplateError(message) {
|
|
2399
|
-
var _this = _super.call(this, message) || this;
|
|
2400
|
-
_this.name = 'TemplateError';
|
|
2401
|
-
Object.setPrototypeOf(_this, TemplateError.prototype);
|
|
2402
|
-
return _this;
|
|
2403
|
-
}
|
|
2404
|
-
return TemplateError;
|
|
2405
|
-
}(Error));
|
|
2406
|
-
|
|
2407
2462
|
/**
|
|
2408
2463
|
* Replaces parameters in template with values from parameters object
|
|
2409
2464
|
*
|
|
@@ -3175,20 +3230,6 @@
|
|
|
3175
3230
|
return SimplePromptInterfaceTools;
|
|
3176
3231
|
}());
|
|
3177
3232
|
|
|
3178
|
-
/**
|
|
3179
|
-
* This error indicates that the promptbook library cannot be propperly loaded
|
|
3180
|
-
*/
|
|
3181
|
-
var PromptbookLibraryError = /** @class */ (function (_super) {
|
|
3182
|
-
__extends(PromptbookLibraryError, _super);
|
|
3183
|
-
function PromptbookLibraryError(message) {
|
|
3184
|
-
var _this = _super.call(this, message) || this;
|
|
3185
|
-
_this.name = 'PromptbookLibraryError';
|
|
3186
|
-
Object.setPrototypeOf(_this, PromptbookLibraryError.prototype);
|
|
3187
|
-
return _this;
|
|
3188
|
-
}
|
|
3189
|
-
return PromptbookLibraryError;
|
|
3190
|
-
}(Error));
|
|
3191
|
-
|
|
3192
3233
|
/**
|
|
3193
3234
|
* Detects if the code is running in a browser environment in main thread (Not in a web worker)
|
|
3194
3235
|
*/
|
|
@@ -3219,34 +3260,6 @@
|
|
|
3219
3260
|
return value;
|
|
3220
3261
|
}
|
|
3221
3262
|
|
|
3222
|
-
/**
|
|
3223
|
-
* This error indicates that promptbook not found in the library
|
|
3224
|
-
*/
|
|
3225
|
-
var PromptbookNotFoundError = /** @class */ (function (_super) {
|
|
3226
|
-
__extends(PromptbookNotFoundError, _super);
|
|
3227
|
-
function PromptbookNotFoundError(message) {
|
|
3228
|
-
var _this = _super.call(this, message) || this;
|
|
3229
|
-
_this.name = 'PromptbookNotFoundError';
|
|
3230
|
-
Object.setPrototypeOf(_this, PromptbookNotFoundError.prototype);
|
|
3231
|
-
return _this;
|
|
3232
|
-
}
|
|
3233
|
-
return PromptbookNotFoundError;
|
|
3234
|
-
}(Error));
|
|
3235
|
-
|
|
3236
|
-
/**
|
|
3237
|
-
* This error indicates errors in referencing promptbooks between each other
|
|
3238
|
-
*/
|
|
3239
|
-
var PromptbookReferenceError = /** @class */ (function (_super) {
|
|
3240
|
-
__extends(PromptbookReferenceError, _super);
|
|
3241
|
-
function PromptbookReferenceError(message) {
|
|
3242
|
-
var _this = _super.call(this, message) || this;
|
|
3243
|
-
_this.name = 'PromptbookReferenceError';
|
|
3244
|
-
Object.setPrototypeOf(_this, PromptbookReferenceError.prototype);
|
|
3245
|
-
return _this;
|
|
3246
|
-
}
|
|
3247
|
-
return PromptbookReferenceError;
|
|
3248
|
-
}(Error));
|
|
3249
|
-
|
|
3250
3263
|
/**
|
|
3251
3264
|
* Library of promptbooks that groups together promptbooks for an application.
|
|
3252
3265
|
* This implementation is a very thin wrapper around the Array / Map of promptbooks.
|
|
@@ -4119,10 +4132,19 @@
|
|
|
4119
4132
|
exports.CallbackInterfaceTools = CallbackInterfaceTools;
|
|
4120
4133
|
exports.ExecutionReportStringOptionsDefaults = ExecutionReportStringOptionsDefaults;
|
|
4121
4134
|
exports.ExecutionTypes = ExecutionTypes;
|
|
4135
|
+
exports.ExpectError = ExpectError;
|
|
4122
4136
|
exports.MultipleLlmExecutionTools = MultipleLlmExecutionTools;
|
|
4123
4137
|
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
|
|
4138
|
+
exports.PromptbookExecutionError = PromptbookExecutionError;
|
|
4139
|
+
exports.PromptbookLibraryError = PromptbookLibraryError;
|
|
4140
|
+
exports.PromptbookLogicError = PromptbookLogicError;
|
|
4141
|
+
exports.PromptbookNotFoundError = PromptbookNotFoundError;
|
|
4142
|
+
exports.PromptbookReferenceError = PromptbookReferenceError;
|
|
4143
|
+
exports.PromptbookSyntaxError = PromptbookSyntaxError;
|
|
4124
4144
|
exports.SimplePromptInterfaceTools = SimplePromptInterfaceTools;
|
|
4125
4145
|
exports.SimplePromptbookLibrary = SimplePromptbookLibrary;
|
|
4146
|
+
exports.TemplateError = TemplateError;
|
|
4147
|
+
exports.UnexpectedError = UnexpectedError;
|
|
4126
4148
|
exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
|
|
4127
4149
|
exports.checkExpectations = checkExpectations;
|
|
4128
4150
|
exports.createPromptbookExecutor = createPromptbookExecutor;
|