@promptbook/core 0.75.1 → 0.75.3

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/esm/index.es.js CHANGED
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
22
22
  *
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.75.0';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.2';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1288,7 +1288,6 @@ function validatePipelineCore(pipeline) {
1288
1288
  while (unresovedTasks.length > 0) {
1289
1289
  _loop_3();
1290
1290
  }
1291
- // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
1292
1291
  }
1293
1292
  /**
1294
1293
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -5115,16 +5114,16 @@ function $registeredScrapersMessage() {
5115
5114
  * Mixes registered scrapers from $scrapersMetadataRegister and $scrapersRegister
5116
5115
  */
5117
5116
  var all = [];
5118
- var _loop_1 = function (packageName, className) {
5117
+ var _loop_1 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
5119
5118
  if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
5120
5119
  return "continue";
5121
5120
  }
5122
- all.push({ packageName: packageName, className: className });
5121
+ all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
5123
5122
  };
5124
5123
  try {
5125
5124
  for (var _c = __values($scrapersMetadataRegister.list()), _d = _c.next(); !_d.done; _d = _c.next()) {
5126
- var _e = _d.value, packageName = _e.packageName, className = _e.className;
5127
- _loop_1(packageName, className);
5125
+ var _e = _d.value, packageName = _e.packageName, className = _e.className, mimeTypes = _e.mimeTypes, documentationUrl = _e.documentationUrl, isAvilableInBrowser = _e.isAvilableInBrowser;
5126
+ _loop_1(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
5128
5127
  }
5129
5128
  }
5130
5129
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -5134,16 +5133,16 @@ function $registeredScrapersMessage() {
5134
5133
  }
5135
5134
  finally { if (e_1) throw e_1.error; }
5136
5135
  }
5137
- var _loop_2 = function (packageName, className) {
5136
+ var _loop_2 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
5138
5137
  if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
5139
5138
  return "continue";
5140
5139
  }
5141
- all.push({ packageName: packageName, className: className });
5140
+ all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
5142
5141
  };
5143
5142
  try {
5144
5143
  for (var _f = __values($scrapersRegister.list()), _g = _f.next(); !_g.done; _g = _f.next()) {
5145
- var _h = _g.value, packageName = _h.packageName, className = _h.className;
5146
- _loop_2(packageName, className);
5144
+ var _h = _g.value, packageName = _h.packageName, className = _h.className, mimeTypes = _h.mimeTypes, documentationUrl = _h.documentationUrl, isAvilableInBrowser = _h.isAvilableInBrowser;
5145
+ _loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
5147
5146
  }
5148
5147
  }
5149
5148
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -5173,29 +5172,33 @@ function $registeredScrapersMessage() {
5173
5172
  }
5174
5173
  return spaceTrim(function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
5175
5174
  .map(function (_a, i) {
5176
- var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled;
5175
+ var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser;
5177
5176
  var more;
5177
+ // TODO: Use documentationUrl
5178
5178
  if (just(false)) {
5179
5179
  more = '';
5180
5180
  }
5181
5181
  else if (!isMetadataAviailable && !isInstalled) {
5182
5182
  // TODO: [�][�] Maybe do allow to do auto-install if package not registered and not found
5183
- more = "(not installed and no metadata, looks like a unexpected behavior)";
5183
+ more = "*(not installed and no metadata, looks like a unexpected behavior)*";
5184
5184
  }
5185
5185
  else if (isMetadataAviailable && !isInstalled) {
5186
5186
  // TODO: [�][�]
5187
- more = "(not installed)";
5187
+ more = "*(not installed)*";
5188
5188
  }
5189
5189
  else if (!isMetadataAviailable && isInstalled) {
5190
- more = "(no metadata, looks like a unexpected behavior)";
5190
+ more = "*(no metadata, looks like a unexpected behavior)*";
5191
5191
  }
5192
5192
  else if (isMetadataAviailable && isInstalled) {
5193
5193
  more = "(installed)";
5194
5194
  }
5195
5195
  else {
5196
- more = "(unknown state, looks like a unexpected behavior)";
5196
+ more = "*(unknown state, looks like a unexpected behavior)*";
5197
5197
  }
5198
- return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` ").concat(more);
5198
+ if (!isAvilableInBrowser) {
5199
+ more += " *(not available in browser)*";
5200
+ }
5201
+ return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes.join(', '), " ").concat(more);
5199
5202
  })
5200
5203
  .join('\n')), "\n "); });
5201
5204
  }
@@ -5580,7 +5583,10 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
5580
5583
  return [7 /*endfinally*/];
5581
5584
  case 9:
5582
5585
  if (partialPieces === null) {
5583
- throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source: ".concat(knowledgeSource.sourceContent, "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage()), "\n\n\n "); }));
5586
+ throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source:\n \n > ".concat(block(knowledgeSource.sourceContent
5587
+ .split('\n')
5588
+ .map(function (line) { return "> ".concat(line); })
5589
+ .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage()), "\n\n\n "); }));
5584
5590
  }
5585
5591
  pieces = partialPieces.map(function (partialPiece) { return (__assign(__assign({}, partialPiece), { sources: [
5586
5592
  {
@@ -10055,6 +10061,7 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
10055
10061
  /**
10056
10062
  * @@@
10057
10063
  *
10064
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
10058
10065
  * @see https://github.com/webgptorg/promptbook/discussions/171
10059
10066
  *
10060
10067
  * @public exported from `@promptbook/core`
@@ -10092,8 +10099,6 @@ function getPipelineInterface(pipeline) {
10092
10099
  var name2 = _b.name;
10093
10100
  return name1.localeCompare(name2);
10094
10101
  });
10095
- // <- TODO: [🧠] Should we compare a descriptions?
10096
- // <- TODO: [🧠][🛴] Maybe add type + expectations into the intefrace, like "a person name"
10097
10102
  }
10098
10103
  }
10099
10104
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -10105,29 +10110,72 @@ function getPipelineInterface(pipeline) {
10105
10110
  }
10106
10111
  return $deepFreeze(pipelineInterface);
10107
10112
  }
10108
- /**
10109
- * TODO: !!!!!! Write unit test
10110
- */
10111
10113
 
10112
10114
  /**
10113
10115
  * @@@
10114
10116
  *
10117
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
10115
10118
  * @see https://github.com/webgptorg/promptbook/discussions/171
10116
10119
  *
10117
10120
  * @public exported from `@promptbook/core`
10118
10121
  */
10119
10122
  function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
10120
- // TODO: [🧠] !!! Implement better
10121
- return JSON.stringify(pipelineInterface1) === JSON.stringify(pipelineInterface2);
10123
+ var e_1, _a, e_2, _b;
10124
+ try {
10125
+ for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
10126
+ var whichParameters = _d.value;
10127
+ var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
10128
+ var parameters2 = pipelineInterface2[whichParameters];
10129
+ if (parameters1.length !== parameters2.length) {
10130
+ return false;
10131
+ }
10132
+ var _loop_1 = function (parameter) {
10133
+ var matchingParameter = parameters2.find(function (_a) {
10134
+ var name = _a.name;
10135
+ return name === parameter.name;
10136
+ });
10137
+ if (!matchingParameter) {
10138
+ return { value: false };
10139
+ }
10140
+ // Note: Do not compare description, it is not relevant for compatibility
10141
+ if (matchingParameter.isInput !== parameter.isInput) {
10142
+ return { value: false };
10143
+ }
10144
+ if (matchingParameter.isOutput !== parameter.isOutput) {
10145
+ return { value: false };
10146
+ }
10147
+ };
10148
+ try {
10149
+ for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
10150
+ var parameter = parameters1_1_1.value;
10151
+ var state_1 = _loop_1(parameter);
10152
+ if (typeof state_1 === "object")
10153
+ return state_1.value;
10154
+ }
10155
+ }
10156
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
10157
+ finally {
10158
+ try {
10159
+ if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
10160
+ }
10161
+ finally { if (e_2) throw e_2.error; }
10162
+ }
10163
+ }
10164
+ }
10165
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
10166
+ finally {
10167
+ try {
10168
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
10169
+ }
10170
+ finally { if (e_1) throw e_1.error; }
10171
+ }
10172
+ return true;
10122
10173
  }
10123
- /**
10124
- * TODO: [🧠] !!! Return more states than true/false - 'IDENTICAL' |'IDENTICAL_UNPREPARED' | 'IDENTICAL_INTERFACE' | 'DIFFERENT'
10125
- * TODO: !!! Write unit test
10126
- */
10127
10174
 
10128
10175
  /**
10129
10176
  * @@@
10130
10177
  *
10178
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
10131
10179
  * @see https://github.com/webgptorg/promptbook/discussions/171
10132
10180
  *
10133
10181
  * @public exported from `@promptbook/core`
@@ -10136,10 +10184,6 @@ function isPipelineImplementingInterface(options) {
10136
10184
  var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
10137
10185
  return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
10138
10186
  }
10139
- /**
10140
- * TODO: !!!!!! Test real implementing NOT equality
10141
- * TODO: !!!!!! Write unit test
10142
- */
10143
10187
 
10144
10188
  /**
10145
10189
  * Metadata of the scraper