@promptbook/core 0.75.3 → 0.75.5

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/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.75.2';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.4';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -836,7 +836,17 @@
836
836
  *
837
837
  * @public exported from `@promptbook/core`
838
838
  */
839
- var DEFAULT_IS_VERBOSE = false;
839
+ exports.DEFAULT_IS_VERBOSE = false;
840
+ /**
841
+ * @@@
842
+ *
843
+ * Note: This is experimental feature
844
+ *
845
+ * @public exported from `@promptbook/core`
846
+ */
847
+ function SET_IS_VERBOSE(isVerbose) {
848
+ exports.DEFAULT_IS_VERBOSE = isVerbose;
849
+ }
840
850
  /**
841
851
  * @@@
842
852
  *
@@ -1602,7 +1612,7 @@
1602
1612
  return __generator(this, function (_d) {
1603
1613
  switch (_d.label) {
1604
1614
  case 0:
1605
- _a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
1615
+ _a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? exports.DEFAULT_IS_VERBOSE : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
1606
1616
  collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
1607
1617
  return __generator(this, function (_a) {
1608
1618
  if (isVerbose) {
@@ -2345,6 +2355,42 @@
2345
2355
 
2346
2356
  var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-persona.book.md"}];
2347
2357
 
2358
+ /**
2359
+ * This error indicates problems parsing the format value
2360
+ *
2361
+ * For example, when the format value is not a valid JSON or CSV
2362
+ * This is not thrown directly but in extended classes
2363
+ *
2364
+ * @public exported from `@promptbook/core`
2365
+ */
2366
+ var AbstractFormatError = /** @class */ (function (_super) {
2367
+ __extends(AbstractFormatError, _super);
2368
+ // Note: To allow instanceof do not put here error `name`
2369
+ // public readonly name = 'AbstractFormatError';
2370
+ function AbstractFormatError(message) {
2371
+ var _this = _super.call(this, message) || this;
2372
+ Object.setPrototypeOf(_this, AbstractFormatError.prototype);
2373
+ return _this;
2374
+ }
2375
+ return AbstractFormatError;
2376
+ }(Error));
2377
+
2378
+ /**
2379
+ * This error indicates problem with parsing of CSV
2380
+ *
2381
+ * @public exported from `@promptbook/core`
2382
+ */
2383
+ var CsvFormatError = /** @class */ (function (_super) {
2384
+ __extends(CsvFormatError, _super);
2385
+ function CsvFormatError(message) {
2386
+ var _this = _super.call(this, message) || this;
2387
+ _this.name = 'CsvFormatError';
2388
+ Object.setPrototypeOf(_this, CsvFormatError.prototype);
2389
+ return _this;
2390
+ }
2391
+ return CsvFormatError;
2392
+ }(AbstractFormatError));
2393
+
2348
2394
  /**
2349
2395
  * This error indicates that the pipeline collection cannot be propperly loaded
2350
2396
  *
@@ -2396,6 +2442,22 @@
2396
2442
  return ExpectError;
2397
2443
  }(Error));
2398
2444
 
2445
+ /**
2446
+ * This error indicates that the promptbook can not retrieve knowledge from external sources
2447
+ *
2448
+ * @public exported from `@promptbook/core`
2449
+ */
2450
+ var KnowledgeScrapeError = /** @class */ (function (_super) {
2451
+ __extends(KnowledgeScrapeError, _super);
2452
+ function KnowledgeScrapeError(message) {
2453
+ var _this = _super.call(this, message) || this;
2454
+ _this.name = 'KnowledgeScrapeError';
2455
+ Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
2456
+ return _this;
2457
+ }
2458
+ return KnowledgeScrapeError;
2459
+ }(Error));
2460
+
2399
2461
  /**
2400
2462
  * This error type indicates that some limit was reached
2401
2463
  *
@@ -2434,10 +2496,14 @@
2434
2496
  * @public exported from `@promptbook/core`
2435
2497
  */
2436
2498
  var ERRORS = {
2437
- ExpectError: ExpectError,
2499
+ AbstractFormatError: AbstractFormatError,
2500
+ CsvFormatError: CsvFormatError,
2438
2501
  CollectionError: CollectionError,
2439
2502
  EnvironmentMismatchError: EnvironmentMismatchError,
2503
+ ExpectError: ExpectError,
2504
+ KnowledgeScrapeError: KnowledgeScrapeError,
2440
2505
  LimitReachedError: LimitReachedError,
2506
+ MissingToolsError: MissingToolsError,
2441
2507
  NotFoundError: NotFoundError,
2442
2508
  NotYetImplementedError: NotYetImplementedError,
2443
2509
  ParseError: ParseError,
@@ -2750,42 +2816,6 @@
2750
2816
  return union;
2751
2817
  }
2752
2818
 
2753
- /**
2754
- * This error indicates problems parsing the format value
2755
- *
2756
- * For example, when the format value is not a valid JSON or CSV
2757
- * This is not thrown directly but in extended classes
2758
- *
2759
- * @public exported from `@promptbook/core`
2760
- */
2761
- var AbstractFormatError = /** @class */ (function (_super) {
2762
- __extends(AbstractFormatError, _super);
2763
- // Note: To allow instanceof do not put here error `name`
2764
- // public readonly name = 'AbstractFormatError';
2765
- function AbstractFormatError(message) {
2766
- var _this = _super.call(this, message) || this;
2767
- Object.setPrototypeOf(_this, AbstractFormatError.prototype);
2768
- return _this;
2769
- }
2770
- return AbstractFormatError;
2771
- }(Error));
2772
-
2773
- /**
2774
- * This error indicates problem with parsing of CSV
2775
- *
2776
- * @public exported from `@promptbook/core`
2777
- */
2778
- var CsvFormatError = /** @class */ (function (_super) {
2779
- __extends(CsvFormatError, _super);
2780
- function CsvFormatError(message) {
2781
- var _this = _super.call(this, message) || this;
2782
- _this.name = 'CsvFormatError';
2783
- Object.setPrototypeOf(_this, CsvFormatError.prototype);
2784
- return _this;
2785
- }
2786
- return CsvFormatError;
2787
- }(AbstractFormatError));
2788
-
2789
2819
  /**
2790
2820
  * @@@
2791
2821
  *
@@ -2826,7 +2856,7 @@
2826
2856
  case 0:
2827
2857
  csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2828
2858
  if (csv.errors.length !== 0) {
2829
- throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
2859
+ throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
2830
2860
  }
2831
2861
  return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
2832
2862
  var _a, _b;
@@ -2864,7 +2894,7 @@
2864
2894
  case 0:
2865
2895
  csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2866
2896
  if (csv.errors.length !== 0) {
2867
- throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
2897
+ throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
2868
2898
  }
2869
2899
  return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
2870
2900
  var _this = this;
@@ -4498,7 +4528,7 @@
4498
4528
  return __generator(this, function (_h) {
4499
4529
  switch (_h.label) {
4500
4530
  case 0:
4501
- inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, maxParallelCount = options.maxParallelCount, rootDirname = options.rootDirname, _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
4531
+ inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, maxParallelCount = options.maxParallelCount, rootDirname = options.rootDirname, _a = options.isVerbose, isVerbose = _a === void 0 ? exports.DEFAULT_IS_VERBOSE : _a;
4502
4532
  preparedPipeline = options.preparedPipeline;
4503
4533
  if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
4504
4534
  return [4 /*yield*/, preparePipeline(pipeline, tools, {
@@ -4807,7 +4837,7 @@
4807
4837
  */
4808
4838
  function createPipelineExecutor(options) {
4809
4839
  var _this = this;
4810
- var pipeline = options.pipeline, tools = options.tools, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a, _b = options.maxParallelCount, maxParallelCount = _b === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _b, _c = options.csvSettings, csvSettings = _c === void 0 ? DEFAULT_CSV_SETTINGS : _c, _d = options.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d, _e = options.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _e === void 0 ? false : _e, _f = options.rootDirname, rootDirname = _f === void 0 ? null : _f;
4840
+ var pipeline = options.pipeline, tools = options.tools, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a, _b = options.maxParallelCount, maxParallelCount = _b === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _b, _c = options.csvSettings, csvSettings = _c === void 0 ? DEFAULT_CSV_SETTINGS : _c, _d = options.isVerbose, isVerbose = _d === void 0 ? exports.DEFAULT_IS_VERBOSE : _d, _e = options.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _e === void 0 ? false : _e, _f = options.rootDirname, rootDirname = _f === void 0 ? null : _f;
4811
4841
  validatePipeline(pipeline);
4812
4842
  var pipelineIdentification = (function () {
4813
4843
  // Note: This is a 😐 implementation of [🚞]
@@ -4869,7 +4899,7 @@
4869
4899
  return __generator(this, function (_d) {
4870
4900
  switch (_d.label) {
4871
4901
  case 0:
4872
- _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
4902
+ _a = options.isVerbose, isVerbose = _a === void 0 ? exports.DEFAULT_IS_VERBOSE : _a;
4873
4903
  if (tools === undefined || tools.llm === undefined) {
4874
4904
  throw new MissingToolsError('LLM tools are required for preparing persona');
4875
4905
  }
@@ -4924,22 +4954,6 @@
4924
4954
  * TODO: [🏢] !! Check validity of `temperature` in pipeline
4925
4955
  */
4926
4956
 
4927
- /**
4928
- * This error indicates that the promptbook can not retrieve knowledge from external sources
4929
- *
4930
- * @public exported from `@promptbook/core`
4931
- */
4932
- var KnowledgeScrapeError = /** @class */ (function (_super) {
4933
- __extends(KnowledgeScrapeError, _super);
4934
- function KnowledgeScrapeError(message) {
4935
- var _this = _super.call(this, message) || this;
4936
- _this.name = 'KnowledgeScrapeError';
4937
- Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
4938
- return _this;
4939
- }
4940
- return KnowledgeScrapeError;
4941
- }(Error));
4942
-
4943
4957
  /**
4944
4958
  * @@@
4945
4959
  *
@@ -5059,9 +5073,15 @@
5059
5073
  var existingRegistrationIndex = this.storage.findIndex(function (item) { return item.packageName === packageName && item.className === className; });
5060
5074
  var existingRegistration = this.storage[existingRegistrationIndex];
5061
5075
  if (!existingRegistration) {
5076
+ if (exports.DEFAULT_IS_VERBOSE) {
5077
+ console.warn("[\uD83D\uDCE6] Registering `".concat(packageName, ".").concat(className, "` to `").concat(this.registerName, "`"));
5078
+ }
5062
5079
  this.storage.push(registered);
5063
5080
  }
5064
5081
  else {
5082
+ if (exports.DEFAULT_IS_VERBOSE) {
5083
+ console.warn("[\uD83D\uDCE6] Re-registering `".concat(packageName, ".").concat(className, "` to `").concat(this.registerName, "`"));
5084
+ }
5065
5085
  this.storage[existingRegistrationIndex] = registered;
5066
5086
  }
5067
5087
  return {
@@ -5110,8 +5130,8 @@
5110
5130
  *
5111
5131
  * @private internal function of `createScrapersFromConfiguration` and `createScrapersFromEnv`
5112
5132
  */
5113
- function $registeredScrapersMessage() {
5114
- var e_1, _a, e_2, _b;
5133
+ function $registeredScrapersMessage(availableScrapers) {
5134
+ var e_1, _a, e_2, _b, e_3, _c;
5115
5135
  /**
5116
5136
  * Mixes registered scrapers from $scrapersMetadataRegister and $scrapersRegister
5117
5137
  */
@@ -5123,15 +5143,15 @@
5123
5143
  all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
5124
5144
  };
5125
5145
  try {
5126
- for (var _c = __values($scrapersMetadataRegister.list()), _d = _c.next(); !_d.done; _d = _c.next()) {
5127
- var _e = _d.value, packageName = _e.packageName, className = _e.className, mimeTypes = _e.mimeTypes, documentationUrl = _e.documentationUrl, isAvilableInBrowser = _e.isAvilableInBrowser;
5146
+ for (var _d = __values($scrapersMetadataRegister.list()), _e = _d.next(); !_e.done; _e = _d.next()) {
5147
+ var _f = _e.value, packageName = _f.packageName, className = _f.className, mimeTypes = _f.mimeTypes, documentationUrl = _f.documentationUrl, isAvilableInBrowser = _f.isAvilableInBrowser;
5128
5148
  _loop_1(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
5129
5149
  }
5130
5150
  }
5131
5151
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
5132
5152
  finally {
5133
5153
  try {
5134
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
5154
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
5135
5155
  }
5136
5156
  finally { if (e_1) throw e_1.error; }
5137
5157
  }
@@ -5142,18 +5162,31 @@
5142
5162
  all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
5143
5163
  };
5144
5164
  try {
5145
- for (var _f = __values($scrapersRegister.list()), _g = _f.next(); !_g.done; _g = _f.next()) {
5146
- var _h = _g.value, packageName = _h.packageName, className = _h.className, mimeTypes = _h.mimeTypes, documentationUrl = _h.documentationUrl, isAvilableInBrowser = _h.isAvilableInBrowser;
5165
+ for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
5166
+ var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
5147
5167
  _loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
5148
5168
  }
5149
5169
  }
5150
5170
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
5151
5171
  finally {
5152
5172
  try {
5153
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
5173
+ if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
5154
5174
  }
5155
5175
  finally { if (e_2) throw e_2.error; }
5156
5176
  }
5177
+ try {
5178
+ for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
5179
+ var metadata_1 = availableScrapers_1_1.value.metadata;
5180
+ all.push(metadata_1);
5181
+ }
5182
+ }
5183
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
5184
+ finally {
5185
+ try {
5186
+ if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
5187
+ }
5188
+ finally { if (e_3) throw e_3.error; }
5189
+ }
5157
5190
  var metadata = all.map(function (metadata) {
5158
5191
  var isMetadataAviailable = $scrapersMetadataRegister
5159
5192
  .list()
@@ -5167,42 +5200,44 @@
5167
5200
  var packageName = _a.packageName, className = _a.className;
5168
5201
  return metadata.packageName === packageName && metadata.className === className;
5169
5202
  });
5170
- return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled });
5203
+ var isAvilableInTools = availableScrapers.some(function (_a) {
5204
+ var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
5205
+ return metadata.packageName === packageName && metadata.className === className;
5206
+ });
5207
+ return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
5171
5208
  });
5172
5209
  if (metadata.length === 0) {
5173
- return "No scrapers are available";
5210
+ return spaceTrim__default["default"]("\n **No scrapers are available**\n\n This is a unexpected behavior, you are probably using some broken version of Promptbook\n At least there should be available the metadata of the scrapers\n ");
5174
5211
  }
5175
5212
  return spaceTrim__default["default"](function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
5176
5213
  .map(function (_a, i) {
5177
- var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser;
5178
- var more;
5179
- // TODO: Use documentationUrl
5180
- if (just(false)) {
5181
- more = '';
5182
- }
5183
- else if (!isMetadataAviailable && !isInstalled) {
5184
- // TODO: [�][�] Maybe do allow to do auto-install if package not registered and not found
5185
- more = "*(not installed and no metadata, looks like a unexpected behavior)*";
5186
- }
5187
- else if (isMetadataAviailable && !isInstalled) {
5188
- // TODO: [�][�]
5189
- more = "*(not installed)*";
5190
- }
5191
- else if (!isMetadataAviailable && isInstalled) {
5192
- more = "*(no metadata, looks like a unexpected behavior)*";
5193
- }
5194
- else if (isMetadataAviailable && isInstalled) {
5195
- more = "(installed)";
5196
- }
5197
- else {
5198
- more = "*(unknown state, looks like a unexpected behavior)*";
5199
- }
5214
+ var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
5215
+ var more = [];
5216
+ // TODO: [🧠] Maybe use `documentationUrl`
5217
+ if (isMetadataAviailable) {
5218
+ more.push("\u2B1C Metadata registered");
5219
+ } // not else
5220
+ if (isInstalled) {
5221
+ more.push("\uD83D\uDFE9 Installed");
5222
+ } // not else
5223
+ if (isAvilableInTools) {
5224
+ more.push("\uD83D\uDFE6 Available in tools");
5225
+ } // not else
5226
+ if (!isMetadataAviailable && isInstalled) {
5227
+ more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
5228
+ } // not else
5229
+ if (!isInstalled && isAvilableInTools) {
5230
+ more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
5231
+ } // not else
5200
5232
  if (!isAvilableInBrowser) {
5201
- more += " *(not available in browser)*";
5233
+ more.push("Not usable in browser");
5202
5234
  }
5203
- return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes.join(', '), " ").concat(more);
5235
+ var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
5236
+ return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
5237
+ .map(function (mimeType) { return "\"".concat(mimeType, "\""); })
5238
+ .join(', ')).concat(moreText);
5204
5239
  })
5205
- .join('\n')), "\n "); });
5240
+ .join('\n')), "\n\n Legend:\n - \u2B1C **Metadata registered** means that Promptbook knows about the scraper, it is similar to registration in some registry\n - \uD83D\uDFE9 **Installed** means that you have imported package with particular scraper\n - \uD83D\uDFE6 **Available in tools** means that you have passed scraper as dependency into prepare or execution process\n\n "); });
5206
5241
  }
5207
5242
  /**
5208
5243
  * TODO: [®] DRY Register logic
@@ -5535,60 +5570,78 @@
5535
5570
  return __generator(this, function (_c) {
5536
5571
  switch (_c.label) {
5537
5572
  case 0:
5538
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
5573
+ _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? exports.DEFAULT_IS_VERBOSE : _b;
5539
5574
  knowledgePreparedUnflatten = new Array(knowledgeSources.length);
5540
5575
  return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
5541
- var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
5542
- var e_1, _c;
5543
- return __generator(this, function (_d) {
5544
- switch (_d.label) {
5576
+ var partialPieces, sourceHandler, scrapers, _loop_1, scrapers_1, scrapers_1_1, scraper, state_1, e_1_1, pieces;
5577
+ var e_1, _a;
5578
+ return __generator(this, function (_b) {
5579
+ switch (_b.label) {
5545
5580
  case 0:
5546
5581
  partialPieces = null;
5547
5582
  return [4 /*yield*/, makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname: rootDirname, isVerbose: isVerbose })];
5548
5583
  case 1:
5549
- sourceHandler = _d.sent();
5550
- _d.label = 2;
5584
+ sourceHandler = _b.sent();
5585
+ scrapers = arrayableToArray(tools.scrapers);
5586
+ _loop_1 = function (scraper) {
5587
+ var partialPiecesUnchecked;
5588
+ return __generator(this, function (_c) {
5589
+ switch (_c.label) {
5590
+ case 0:
5591
+ if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
5592
+ // <- TODO: [🦔] Implement mime-type wildcards
5593
+ ) {
5594
+ return [2 /*return*/, "continue"];
5595
+ }
5596
+ return [4 /*yield*/, scraper.scrape(sourceHandler)];
5597
+ case 1:
5598
+ partialPiecesUnchecked = _c.sent();
5599
+ if (partialPiecesUnchecked !== null) {
5600
+ partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
5601
+ return [2 /*return*/, "break"];
5602
+ }
5603
+ console.warn(spaceTrim__default["default"](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.sourceContent
5604
+ .split('\n')
5605
+ .map(function (line) { return "> ".concat(line); })
5606
+ .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
5607
+ return [2 /*return*/];
5608
+ }
5609
+ });
5610
+ };
5611
+ _b.label = 2;
5551
5612
  case 2:
5552
- _d.trys.push([2, 7, 8, 9]);
5553
- _a = __values(arrayableToArray(tools.scrapers)), _b = _a.next();
5554
- _d.label = 3;
5613
+ _b.trys.push([2, 7, 8, 9]);
5614
+ scrapers_1 = __values(scrapers), scrapers_1_1 = scrapers_1.next();
5615
+ _b.label = 3;
5555
5616
  case 3:
5556
- if (!!_b.done) return [3 /*break*/, 6];
5557
- scraper = _b.value;
5558
- if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
5559
- // <- TODO: [🦔] Implement mime-type wildcards
5560
- ) {
5561
- return [3 /*break*/, 5];
5562
- }
5563
- return [4 /*yield*/, scraper.scrape(sourceHandler)];
5617
+ if (!!scrapers_1_1.done) return [3 /*break*/, 6];
5618
+ scraper = scrapers_1_1.value;
5619
+ return [5 /*yield**/, _loop_1(scraper)];
5564
5620
  case 4:
5565
- partialPiecesUnchecked = _d.sent();
5566
- if (partialPiecesUnchecked !== null) {
5567
- partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
5568
- // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
5621
+ state_1 = _b.sent();
5622
+ if (state_1 === "break")
5569
5623
  return [3 /*break*/, 6];
5570
- }
5571
- _d.label = 5;
5624
+ _b.label = 5;
5572
5625
  case 5:
5573
- _b = _a.next();
5626
+ scrapers_1_1 = scrapers_1.next();
5574
5627
  return [3 /*break*/, 3];
5575
5628
  case 6: return [3 /*break*/, 9];
5576
5629
  case 7:
5577
- e_1_1 = _d.sent();
5630
+ e_1_1 = _b.sent();
5578
5631
  e_1 = { error: e_1_1 };
5579
5632
  return [3 /*break*/, 9];
5580
5633
  case 8:
5581
5634
  try {
5582
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
5635
+ if (scrapers_1_1 && !scrapers_1_1.done && (_a = scrapers_1.return)) _a.call(scrapers_1);
5583
5636
  }
5584
5637
  finally { if (e_1) throw e_1.error; }
5585
5638
  return [7 /*endfinally*/];
5586
5639
  case 9:
5587
5640
  if (partialPieces === null) {
5588
- throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge from source:\n \n > ".concat(block(knowledgeSource.sourceContent
5641
+ throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n \n The source:\n > ".concat(block(knowledgeSource.sourceContent
5589
5642
  .split('\n')
5590
5643
  .map(function (line) { return "> ".concat(line); })
5591
- .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage()), "\n\n\n "); }));
5644
+ .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
5592
5645
  }
5593
5646
  pieces = partialPieces.map(function (partialPiece) { return (__assign(__assign({}, partialPiece), { sources: [
5594
5647
  {
@@ -5735,7 +5788,7 @@
5735
5788
  if (isPipelinePrepared(pipeline)) {
5736
5789
  return [2 /*return*/, pipeline];
5737
5790
  }
5738
- rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
5791
+ rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? exports.DEFAULT_IS_VERBOSE : _b;
5739
5792
  parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5740
5793
  if (tools === undefined || tools.llm === undefined) {
5741
5794
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
@@ -9084,6 +9137,25 @@
9084
9137
  return CallbackInterfaceTools;
9085
9138
  }());
9086
9139
 
9140
+ /**
9141
+ * This error indicates @@@
9142
+ *
9143
+ * @public exported from `@promptbook/core`
9144
+ */
9145
+ var BoilerplateError = /** @class */ (function (_super) {
9146
+ __extends(BoilerplateError, _super);
9147
+ function BoilerplateError(message) {
9148
+ var _this = _super.call(this, message) || this;
9149
+ _this.name = 'BoilerplateError';
9150
+ Object.setPrototypeOf(_this, BoilerplateError.prototype);
9151
+ return _this;
9152
+ }
9153
+ return BoilerplateError;
9154
+ }(Error));
9155
+ /**
9156
+ * TODO: @@@ Do not forget to add the error into `0-index.ts` ERRORS
9157
+ */
9158
+
9087
9159
  /**
9088
9160
  * Pretty print an embedding vector for logging
9089
9161
  *
@@ -9632,7 +9704,7 @@
9632
9704
  */
9633
9705
  function createLlmToolsFromConfiguration(configuration, options) {
9634
9706
  if (options === void 0) { options = {}; }
9635
- var _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a, userId = options.userId;
9707
+ var _a = options.isVerbose, isVerbose = _a === void 0 ? exports.DEFAULT_IS_VERBOSE : _a, userId = options.userId;
9636
9708
  var llmTools = configuration.map(function (llmConfiguration) {
9637
9709
  var registeredItem = $llmToolsRegister
9638
9710
  .list()
@@ -10414,6 +10486,7 @@
10414
10486
  exports.AbstractFormatError = AbstractFormatError;
10415
10487
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
10416
10488
  exports.BlackholeStorage = BlackholeStorage;
10489
+ exports.BoilerplateError = BoilerplateError;
10417
10490
  exports.BoilerplateFormfactorDefinition = BoilerplateFormfactorDefinition;
10418
10491
  exports.CLAIM = CLAIM;
10419
10492
  exports.CallbackInterfaceTools = CallbackInterfaceTools;
@@ -10426,7 +10499,6 @@
10426
10499
  exports.DEFAULT_EXECUTIONS_CACHE_DIRNAME = DEFAULT_EXECUTIONS_CACHE_DIRNAME;
10427
10500
  exports.DEFAULT_INTERMEDIATE_FILES_STRATEGY = DEFAULT_INTERMEDIATE_FILES_STRATEGY;
10428
10501
  exports.DEFAULT_IS_AUTO_INSTALLED = DEFAULT_IS_AUTO_INSTALLED;
10429
- exports.DEFAULT_IS_VERBOSE = DEFAULT_IS_VERBOSE;
10430
10502
  exports.DEFAULT_MAX_EXECUTION_ATTEMPTS = DEFAULT_MAX_EXECUTION_ATTEMPTS;
10431
10503
  exports.DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH;
10432
10504
  exports.DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL;
@@ -10467,6 +10539,7 @@
10467
10539
  exports.PipelineUrlError = PipelineUrlError;
10468
10540
  exports.PrefixStorage = PrefixStorage;
10469
10541
  exports.RESERVED_PARAMETER_NAMES = RESERVED_PARAMETER_NAMES;
10542
+ exports.SET_IS_VERBOSE = SET_IS_VERBOSE;
10470
10543
  exports.SectionTypes = SectionTypes;
10471
10544
  exports.SheetsFormfactorDefinition = SheetsFormfactorDefinition;
10472
10545
  exports.TaskTypes = TaskTypes;