@promptbook/node 0.59.0-21 → 0.59.0-23

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.
Files changed (47) hide show
  1. package/esm/index.es.js +22 -68
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/cli.index.d.ts +2 -2
  4. package/esm/typings/src/_packages/core.index.d.ts +6 -6
  5. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +2 -1
  7. package/esm/typings/src/cli/actions/hello.d.ts +7 -0
  8. package/esm/typings/src/cli/actions/make.d.ts +7 -0
  9. package/esm/typings/src/cli/actions/prettify.d.ts +7 -0
  10. package/esm/typings/src/{conversion/prettify/prettifyPromptbookStringCli.d.ts → cli/promptbookCli.d.ts} +2 -2
  11. package/esm/typings/src/library/SimplePromptbookLibrary.d.ts +3 -1
  12. package/{umd/typings/src/library/constructors/createPromptbookLibraryFromDirectory.d.ts → esm/typings/src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
  13. package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
  14. package/{umd/typings/src/library/constructors/createPromptbookLibraryFromPromise.d.ts → esm/typings/src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
  15. package/{umd/typings/src/library/constructors/createPromptbookLibraryFromUrl.d.ts → esm/typings/src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
  16. package/esm/typings/src/library/constructors/{createPromptbookSublibrary.d.ts → createSublibrary.d.ts} +1 -1
  17. package/esm/typings/src/library/libraryToJson.d.ts +8 -0
  18. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  19. package/package.json +2 -2
  20. package/umd/index.umd.js +22 -68
  21. package/umd/index.umd.js.map +1 -1
  22. package/umd/typings/src/_packages/cli.index.d.ts +2 -2
  23. package/umd/typings/src/_packages/core.index.d.ts +6 -6
  24. package/umd/typings/src/_packages/node.index.d.ts +2 -2
  25. package/umd/typings/src/_packages/types.index.d.ts +2 -1
  26. package/umd/typings/src/cli/actions/hello.d.ts +7 -0
  27. package/umd/typings/src/cli/actions/make.d.ts +7 -0
  28. package/umd/typings/src/cli/actions/prettify.d.ts +7 -0
  29. package/umd/typings/src/{conversion/prettify/prettifyPromptbookStringCli.d.ts → cli/promptbookCli.d.ts} +2 -2
  30. package/umd/typings/src/library/SimplePromptbookLibrary.d.ts +3 -1
  31. package/{esm/typings/src/library/constructors/createPromptbookLibraryFromDirectory.d.ts → umd/typings/src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
  32. package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
  33. package/{esm/typings/src/library/constructors/createPromptbookLibraryFromPromise.d.ts → umd/typings/src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
  34. package/umd/typings/src/library/constructors/createLibraryFromPromise.test.d.ts +1 -0
  35. package/{esm/typings/src/library/constructors/createPromptbookLibraryFromUrl.d.ts → umd/typings/src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
  36. package/umd/typings/src/library/constructors/{createPromptbookSublibrary.d.ts → createSublibrary.d.ts} +1 -1
  37. package/umd/typings/src/library/libraryToJson.d.ts +8 -0
  38. package/umd/typings/src/library/libraryToJson.test.d.ts +1 -0
  39. package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  40. package/esm/typings/src/library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
  41. package/umd/typings/src/library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
  42. /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromDirectory.test.d.ts → createLibraryFromDirectory.test.d.ts} +0 -0
  43. /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromPromise.test.d.ts → createLibraryFromJson.test.d.ts} +0 -0
  44. /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromSources.test.d.ts → createLibraryFromPromise.test.d.ts} +0 -0
  45. /package/{umd/typings/src/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → esm/typings/src/library/libraryToJson.test.d.ts} +0 -0
  46. /package/umd/typings/src/library/constructors/{createPromptbookLibraryFromPromise.test.d.ts → createLibraryFromDirectory.test.d.ts} +0 -0
  47. /package/umd/typings/src/library/constructors/{createPromptbookLibraryFromSources.test.d.ts → createLibraryFromJson.test.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -137,7 +137,7 @@ var PromptbookSyntaxError = /** @class */ (function (_super) {
137
137
  return PromptbookSyntaxError;
138
138
  }(Error));
139
139
 
140
- var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-20",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
140
+ var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-21",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
141
141
 
142
142
  /**
143
143
  * This error indicates errors during the execution of the promptbook
@@ -462,7 +462,7 @@ function isValidJsonString(value /* <-[👨‍⚖️] */) {
462
462
  /**
463
463
  * The version of the Promptbook library
464
464
  */
465
- var PROMPTBOOK_VERSION = '0.59.0-20';
465
+ var PROMPTBOOK_VERSION = '0.59.0-21';
466
466
 
467
467
  /**
468
468
  * Function `addUsage` will add multiple usages into one
@@ -1795,6 +1795,7 @@ var PromptbookReferenceError = /** @class */ (function (_super) {
1795
1795
  * Library of promptbooks that groups together promptbooks for an application.
1796
1796
  * This implementation is a very thin wrapper around the Array / Map of promptbooks.
1797
1797
  *
1798
+ * @private use `createLibraryFromJson` instead
1798
1799
  * @see https://github.com/webgptorg/promptbook#promptbook-library
1799
1800
  */
1800
1801
  var SimplePromptbookLibrary = /** @class */ (function () {
@@ -1803,8 +1804,9 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1803
1804
  *
1804
1805
  * @param promptbooks !!!
1805
1806
  *
1807
+ * @private Use instead `createLibraryFromJson`
1806
1808
  * Note: During the construction logic of all promptbooks are validated
1807
- * Note: It is not recommended to use this constructor directly, use `createPromptbookLibraryFromSources` *(or other variant)* instead
1809
+ * Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
1808
1810
  */
1809
1811
  function SimplePromptbookLibrary() {
1810
1812
  var e_1, _a;
@@ -1873,68 +1875,23 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1873
1875
  /**
1874
1876
  * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
1875
1877
  *
1876
- * Note: You can combine `PromptbookString` (`.ptbk.md`) with `PromptbookJson` BUT it is not recommended
1878
+ * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
1877
1879
  * Note: During the construction syntax and logic of all sources are validated
1878
1880
  *
1879
1881
  * @param promptbookSources
1880
1882
  * @returns PromptbookLibrary
1881
1883
  */
1882
- function createPromptbookLibraryFromSources() {
1883
- var promptbookSources = [];
1884
+ function createLibraryFromJson() {
1885
+ var promptbooks = [];
1884
1886
  for (var _i = 0; _i < arguments.length; _i++) {
1885
- promptbookSources[_i] = arguments[_i];
1887
+ promptbooks[_i] = arguments[_i];
1886
1888
  }
1887
1889
  return __awaiter(this, void 0, void 0, function () {
1888
- var promptbooks, promptbookSources_1, promptbookSources_1_1, source, promptbook, e_1_1;
1889
- var e_1, _a;
1890
- return __generator(this, function (_b) {
1891
- switch (_b.label) {
1892
- case 0:
1893
- promptbooks = new Array();
1894
- _b.label = 1;
1895
- case 1:
1896
- _b.trys.push([1, 8, 9, 10]);
1897
- promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next();
1898
- _b.label = 2;
1899
- case 2:
1900
- if (!!promptbookSources_1_1.done) return [3 /*break*/, 7];
1901
- source = promptbookSources_1_1.value;
1902
- promptbook = void 0;
1903
- if (!(typeof source === 'string')) return [3 /*break*/, 4];
1904
- return [4 /*yield*/, promptbookStringToJson(source)];
1905
- case 3:
1906
- // Note: When directly creating from string, no need to validate the source
1907
- // The validation is performed always before execution
1908
- promptbook = _b.sent();
1909
- return [3 /*break*/, 5];
1910
- case 4:
1911
- promptbook = source;
1912
- _b.label = 5;
1913
- case 5:
1914
- promptbooks.push(promptbook);
1915
- _b.label = 6;
1916
- case 6:
1917
- promptbookSources_1_1 = promptbookSources_1.next();
1918
- return [3 /*break*/, 2];
1919
- case 7: return [3 /*break*/, 10];
1920
- case 8:
1921
- e_1_1 = _b.sent();
1922
- e_1 = { error: e_1_1 };
1923
- return [3 /*break*/, 10];
1924
- case 9:
1925
- try {
1926
- if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
1927
- }
1928
- finally { if (e_1) throw e_1.error; }
1929
- return [7 /*endfinally*/];
1930
- case 10: return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
1931
- }
1890
+ return __generator(this, function (_a) {
1891
+ return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
1932
1892
  });
1933
1893
  });
1934
1894
  }
1935
- /**
1936
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
1937
- */
1938
1895
 
1939
1896
  /* tslint:disable */
1940
1897
  function normalizeToKebabCase(sentence) {
@@ -1999,7 +1956,7 @@ function prepareKnowledgeFromMarkdown(options) {
1999
1956
  switch (_b.label) {
2000
1957
  case 0:
2001
1958
  content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
2002
- return [4 /*yield*/, createPromptbookLibraryFromSources.apply(void 0, __spreadArray([], __read(promptbookLibrary), false))];
1959
+ return [4 /*yield*/, createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false))];
2003
1960
  case 1:
2004
1961
  library = _b.sent();
2005
1962
  promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
@@ -3208,19 +3165,19 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
3208
3165
  * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
3209
3166
  *
3210
3167
  * Note: This is useful as internal tool for other constructor functions like
3211
- * `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
3168
+ * `createLibraryFromUrl` or `createLibraryFromDirectory`
3212
3169
  * Consider using those functions instead of this one
3213
3170
  *
3214
3171
  * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
3215
3172
  * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
3216
3173
  *
3217
- * Note: Consider using `createPromptbookLibraryFromDirectory` or `createPromptbookLibraryFromUrl`
3174
+ * Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
3218
3175
  *
3219
3176
  * @param promptbookSourcesPromiseOrFactory
3220
3177
  * @returns PromptbookLibrary
3221
3178
  * @deprecated Do not use, it will became internal tool for other constructor functions
3222
3179
  */
3223
- function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3180
+ function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3224
3181
  var library;
3225
3182
  function forSources() {
3226
3183
  return __awaiter(this, void 0, void 0, function () {
@@ -3235,7 +3192,7 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3235
3192
  return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
3236
3193
  case 1:
3237
3194
  promptbookSources = _a.sent();
3238
- return [4 /*yield*/, createPromptbookLibraryFromSources.apply(void 0, __spreadArray([], __read(promptbookSources), false))];
3195
+ return [4 /*yield*/, createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false))];
3239
3196
  case 2:
3240
3197
  library = _a.sent();
3241
3198
  return [2 /*return*/];
@@ -3285,9 +3242,6 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3285
3242
  isResponsibleForPrompt: isResponsibleForPrompt,
3286
3243
  };
3287
3244
  }
3288
- /**
3289
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3290
- */
3291
3245
 
3292
3246
  /**
3293
3247
  * Constructs Promptbook from given directory
@@ -3298,7 +3252,7 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3298
3252
  * @param options - Misc options for the library
3299
3253
  * @returns PromptbookLibrary
3300
3254
  */
3301
- function createPromptbookLibraryFromDirectory(path, options) {
3255
+ function createLibraryFromDirectory(path, options) {
3302
3256
  return __awaiter(this, void 0, void 0, function () {
3303
3257
  var _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, library;
3304
3258
  var _this = this;
@@ -3306,10 +3260,10 @@ function createPromptbookLibraryFromDirectory(path, options) {
3306
3260
  switch (_f.label) {
3307
3261
  case 0:
3308
3262
  if (!isRunningInNode()) {
3309
- throw new Error('Function `createPromptbookLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
3263
+ throw new Error('Function `createLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
3310
3264
  }
3311
3265
  _a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? false : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashOnError, isCrashOnError = _e === void 0 ? true : _e;
3312
- library = createPromptbookLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3266
+ library = createLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3313
3267
  var fileNames, promptbooks, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
3314
3268
  var e_1, _a;
3315
3269
  return __generator(this, function (_b) {
@@ -3322,7 +3276,7 @@ function createPromptbookLibraryFromDirectory(path, options) {
3322
3276
  case 1:
3323
3277
  fileNames = _b.sent();
3324
3278
  if (isVerbose) {
3325
- console.info('createPromptbookLibraryFromDirectory', { path: path, isRecursive: isRecursive, fileNames: fileNames });
3279
+ console.info('createLibraryFromDirectory', { path: path, isRecursive: isRecursive, fileNames: fileNames });
3326
3280
  }
3327
3281
  promptbooks = [];
3328
3282
  _loop_1 = function (fileName) {
@@ -3439,7 +3393,7 @@ function createPromptbookLibraryFromDirectory(path, options) {
3439
3393
  * @param path
3440
3394
  * @param isRecursive
3441
3395
  * @returns List of all files in the directory
3442
- * @private internal function for `createPromptbookLibraryFromDirectory`
3396
+ * @private internal function for `createLibraryFromDirectory`
3443
3397
  */
3444
3398
  function listAllFiles(path, isRecursive) {
3445
3399
  return __awaiter(this, void 0, void 0, function () {
@@ -3496,5 +3450,5 @@ function listAllFiles(path, isRecursive) {
3496
3450
  * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3497
3451
  */
3498
3452
 
3499
- export { PROMPTBOOK_VERSION, createPromptbookLibraryFromDirectory };
3453
+ export { PROMPTBOOK_VERSION, createLibraryFromDirectory };
3500
3454
  //# sourceMappingURL=index.es.js.map