@promptbook/website-crawler 0.84.0-16 โ†’ 0.84.0-18

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 CHANGED
@@ -16,7 +16,8 @@
16
16
 
17
17
  ## ๐ŸŒŸ New Features
18
18
 
19
- - ๐Ÿ‹ **Support of [DeepSeek models](https://www.deepseek.com/)**
19
+ - ๐Ÿ’ซ Support of [`o3-mini` model by OpenAI](https://openai.com/index/openai-o3-mini/)
20
+ - ๐Ÿ‹ **Support of [DeepSeek models](https://www.npmjs.com/package/@promptbook/deepseek)**
20
21
  - ๐Ÿ’™ Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
21
22
  - ๐Ÿ–ค Run books from CLI - `npx ptbk run path/to/your/book`
22
23
  - ๐Ÿ“š Support of `.docx`, `.doc` and `.pdf` documents as knowledge
@@ -435,6 +436,10 @@ See [TODO.md](./TODO.md)
435
436
 
436
437
 
437
438
 
439
+ ## ๐Ÿค Partners
440
+
441
+ [![Technology Incubation](./other/partners/CI-Technology-Incubation.png)](https://technologickainkubace.org/en/about-technology-incubation/about-the-project/)
442
+
438
443
  ## ๐Ÿ–‹๏ธ Contributing
439
444
 
440
445
  I am open to pull requests, feedback, and suggestions. Or if you like this utility, you can [โ˜• buy me a coffee](https://www.buymeacoffee.com/hejny) or [donate via cryptocurrencies](https://github.com/hejny/hejny/blob/main/documents/crypto.md).
package/esm/index.es.js CHANGED
@@ -27,7 +27,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-15';
30
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-17';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -236,6 +236,12 @@ var ADMIN_GITHUB_NAME = 'hejny';
236
236
  * @public exported from `@promptbook/core`
237
237
  */
238
238
  var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
239
+ /**
240
+ * Maximum file size limit
241
+ *
242
+ * @public exported from `@promptbook/core`
243
+ */
244
+ var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
239
245
  // <- TODO: [๐Ÿง ] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
240
246
  /**
241
247
  * The maximum number of iterations for a loops
@@ -3636,11 +3642,10 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
3636
3642
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3637
3643
  var _a;
3638
3644
  return __awaiter(this, void 0, void 0, function () {
3639
- var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, _f, _g, _h, _j, _k, filename_1, fileExtension, mimeType;
3640
- return __generator(this, function (_l) {
3641
- switch (_l.label) {
3645
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
3646
+ return __generator(this, function (_h) {
3647
+ switch (_h.label) {
3642
3648
  case 0:
3643
- console.log('!!! makeKnowledgeSourceHandler', knowledgeSource);
3644
3649
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3645
3650
  knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
3646
3651
  name = knowledgeSource.name;
@@ -3652,7 +3657,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3652
3657
  url = knowledgeSourceContent;
3653
3658
  return [4 /*yield*/, fetch(url)];
3654
3659
  case 1:
3655
- response_1 = _l.sent();
3660
+ response_1 = _h.sent();
3656
3661
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
3657
3662
  if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [๐Ÿ’ต] */)) {
3658
3663
  return [2 /*return*/, {
@@ -3702,17 +3707,19 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3702
3707
  filepath = join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [๐ŸŽŽ] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".").concat(mimeTypeToExtension(mimeType))], false));
3703
3708
  return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
3704
3709
  case 2:
3705
- _l.sent();
3706
- _g = (_f = tools.fs).writeFile;
3707
- _h = [join(rootDirname_1, filepath)];
3708
- _k = (_j = Buffer).from;
3710
+ _h.sent();
3711
+ _g = (_f = Buffer).from;
3709
3712
  return [4 /*yield*/, response_1.arrayBuffer()];
3710
- case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
3713
+ case 3:
3714
+ fileContent = _g.apply(_f, [_h.sent()]);
3715
+ if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
3716
+ throw new LimitReachedError("File is too large (".concat(Math.round(fileContent.length / 1024 / 1024), "MB). Maximum allowed size is ").concat(Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024), "MB."));
3717
+ }
3718
+ return [4 /*yield*/, tools.fs.writeFile(join(rootDirname_1, filepath), fileContent)];
3711
3719
  case 4:
3712
- _l.sent();
3720
+ _h.sent();
3713
3721
  // TODO: [๐Ÿ’ต] Check the file security
3714
- // TODO: !!!!!!!! Check the file size (if it is not too big)
3715
- // TODO: !!!!!!!! Delete the file after the scraping is done
3722
+ // TODO: [๐Ÿงน][๐Ÿง ] Delete the file after the scraping is done
3716
3723
  return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
3717
3724
  case 5:
3718
3725
  if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
@@ -3729,7 +3736,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3729
3736
  mimeType = extensionToMimeType(fileExtension || '');
3730
3737
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3731
3738
  case 6:
3732
- if (!(_l.sent())) {
3739
+ if (!(_h.sent())) {
3733
3740
  throw new NotFoundError(spaceTrim$1(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(knowledgeSourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
3734
3741
  }
3735
3742
  // TODO: [๐Ÿง ][๐Ÿ˜ฟ] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)