@promptbook/pdf 0.84.0-16 โ†’ 0.84.0-17

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,7 @@
16
16
 
17
17
  ## ๐ŸŒŸ New Features
18
18
 
19
- - ๐Ÿ‹ **Support of [DeepSeek models](https://www.deepseek.com/)**
19
+ - ๐Ÿ‹ **Support of [DeepSeek models](https://www.npmjs.com/package/@promptbook/deepseek)**
20
20
  - ๐Ÿ’™ Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
21
21
  - ๐Ÿ–ค Run books from CLI - `npx ptbk run path/to/your/book`
22
22
  - ๐Ÿ“š Support of `.docx`, `.doc` and `.pdf` documents as knowledge
@@ -437,6 +437,12 @@ See [TODO.md](./TODO.md)
437
437
 
438
438
 
439
439
 
440
+
441
+ ## ๐Ÿค Partners
442
+
443
+ [![Technology Incubation](./other/partners/CI-Technology-Incubation.png)](https://technologickainkubace.org/en/about-technology-incubation/about-the-project/)
444
+
445
+
440
446
  ## ๐Ÿ–‹๏ธ Contributing
441
447
 
442
448
  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
@@ -24,7 +24,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-15';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-16';
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
@@ -195,6 +195,12 @@ var ADMIN_GITHUB_NAME = 'hejny';
195
195
  * @public exported from `@promptbook/core`
196
196
  */
197
197
  var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
198
+ /**
199
+ * Maximum file size limit
200
+ *
201
+ * @public exported from `@promptbook/core`
202
+ */
203
+ var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
198
204
  // <- TODO: [๐Ÿง ] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
199
205
  /**
200
206
  * The maximum number of iterations for a loops
@@ -3626,11 +3632,10 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
3626
3632
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3627
3633
  var _a;
3628
3634
  return __awaiter(this, void 0, void 0, function () {
3629
- 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;
3630
- return __generator(this, function (_l) {
3631
- switch (_l.label) {
3635
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
3636
+ return __generator(this, function (_h) {
3637
+ switch (_h.label) {
3632
3638
  case 0:
3633
- console.log('!!! makeKnowledgeSourceHandler', knowledgeSource);
3634
3639
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3635
3640
  knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
3636
3641
  name = knowledgeSource.name;
@@ -3642,7 +3647,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3642
3647
  url = knowledgeSourceContent;
3643
3648
  return [4 /*yield*/, fetch(url)];
3644
3649
  case 1:
3645
- response_1 = _l.sent();
3650
+ response_1 = _h.sent();
3646
3651
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
3647
3652
  if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [๐Ÿ’ต] */)) {
3648
3653
  return [2 /*return*/, {
@@ -3692,17 +3697,19 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3692
3697
  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));
3693
3698
  return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
3694
3699
  case 2:
3695
- _l.sent();
3696
- _g = (_f = tools.fs).writeFile;
3697
- _h = [join(rootDirname_1, filepath)];
3698
- _k = (_j = Buffer).from;
3700
+ _h.sent();
3701
+ _g = (_f = Buffer).from;
3699
3702
  return [4 /*yield*/, response_1.arrayBuffer()];
3700
- case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
3703
+ case 3:
3704
+ fileContent = _g.apply(_f, [_h.sent()]);
3705
+ if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
3706
+ 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."));
3707
+ }
3708
+ return [4 /*yield*/, tools.fs.writeFile(join(rootDirname_1, filepath), fileContent)];
3701
3709
  case 4:
3702
- _l.sent();
3710
+ _h.sent();
3703
3711
  // TODO: [๐Ÿ’ต] Check the file security
3704
- // TODO: !!!!!!!! Check the file size (if it is not too big)
3705
- // TODO: !!!!!!!! Delete the file after the scraping is done
3712
+ // TODO: [๐Ÿงน][๐Ÿง ] Delete the file after the scraping is done
3706
3713
  return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
3707
3714
  case 5:
3708
3715
  if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
@@ -3719,7 +3726,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3719
3726
  mimeType = extensionToMimeType(fileExtension || '');
3720
3727
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3721
3728
  case 6:
3722
- if (!(_l.sent())) {
3729
+ if (!(_h.sent())) {
3723
3730
  throw new NotFoundError(spaceTrim(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 "); }));
3724
3731
  }
3725
3732
  // TODO: [๐Ÿง ][๐Ÿ˜ฟ] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
@@ -6360,7 +6367,7 @@ var MarkitdownScraper = /** @class */ (function () {
6360
6367
  // Note: Module `markitdown-ts` has no types available, so it is imported using `require`
6361
6368
  // eslint-disable-next-line @typescript-eslint/no-var-requires
6362
6369
  var MarkItDown = require('markitdown-ts').MarkItDown;
6363
- // <- TODO: 'Use Markitdown directly not through this package
6370
+ // <- TODO: [๐Ÿ€] Use Markitdown directly not through this package
6364
6371
  this.markitdown = new MarkItDown();
6365
6372
  }
6366
6373
  Object.defineProperty(MarkitdownScraper.prototype, "metadata", {
@@ -6405,7 +6412,7 @@ var MarkitdownScraper = /** @class */ (function () {
6405
6412
  case 2:
6406
6413
  if (!!(_f.sent())) return [3 /*break*/, 5];
6407
6414
  src = source.filename || source.url || null;
6408
- // console.log('!!!', { src, source, cacheFilehandler });
6415
+ // console.log('!!', { src, source, cacheFilehandler });
6409
6416
  if (src === null) {
6410
6417
  throw new UnexpectedError('Source has no filename or url');
6411
6418
  }
@@ -6418,12 +6425,12 @@ var MarkitdownScraper = /** @class */ (function () {
6418
6425
  result = _f.sent();
6419
6426
  if (result === null || result === undefined) {
6420
6427
  throw new Error("Markitdown could not convert the \"".concat(source.source, "\""));
6421
- // <- TODO: !!! Make MarkitdownError
6428
+ // <- TODO: [๐Ÿ€] Make MarkitdownError
6422
6429
  }
6423
- // console.log('!!!', { result, cacheFilehandler });
6430
+ // console.log('!!', { result, cacheFilehandler });
6424
6431
  return [4 /*yield*/, this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content)];
6425
6432
  case 4:
6426
- // console.log('!!!', { result, cacheFilehandler });
6433
+ // console.log('!!', { result, cacheFilehandler });
6427
6434
  _f.sent();
6428
6435
  _f.label = 5;
6429
6436
  case 5: return [2 /*return*/, cacheFilehandler];