@promptbook/markdown-utils 0.84.0-15 โ†’ 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
@@ -14,9 +14,9 @@
14
14
 
15
15
 
16
16
 
17
- ## โ„ New Features
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
@@ -263,8 +263,9 @@ Or you can install them separately:
263
263
  - **[@promptbook/anthropic-claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)** - Execution tools for Anthropic Claude API, wrapper around Anthropic Claude SDK
264
264
  - **[@promptbook/vercel](https://www.npmjs.com/package/@promptbook/vercel)** - Adapter for Vercel functionalities
265
265
  - **[@promptbook/google](https://www.npmjs.com/package/@promptbook/google)** - Integration with Google's Gemini API
266
+ - **[@promptbook/deepseek](https://www.npmjs.com/package/@promptbook/deepseek)** - Integration with [DeepSeek API](https://www.deepseek.com/)
266
267
  - **[@promptbook/azure-openai](https://www.npmjs.com/package/@promptbook/azure-openai)** - Execution tools for Azure OpenAI API
267
- - **[@promptbook/langtail](https://www.npmjs.com/package/@promptbook/langtail)** - Execution tools for Langtail API, wrapper around Langtail SDK
268
+
268
269
  - **[@promptbook/fake-llm](https://www.npmjs.com/package/@promptbook/fake-llm)** - Mocked execution tools for testing the library and saving the tokens
269
270
  - **[@promptbook/remote-client](https://www.npmjs.com/package/@promptbook/remote-client)** - Remote client for remote execution of promptbooks
270
271
  - **[@promptbook/remote-server](https://www.npmjs.com/package/@promptbook/remote-server)** - Remote server for remote execution of promptbooks
@@ -434,6 +435,12 @@ See [TODO.md](./TODO.md)
434
435
 
435
436
 
436
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
+
443
+
437
444
  ## ๐Ÿ–‹๏ธ Contributing
438
445
 
439
446
  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
@@ -23,7 +23,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-14';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-16';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -776,6 +776,12 @@ var ADMIN_GITHUB_NAME = 'hejny';
776
776
  * @public exported from `@promptbook/core`
777
777
  */
778
778
  var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
779
+ /**
780
+ * Maximum file size limit
781
+ *
782
+ * @public exported from `@promptbook/core`
783
+ */
784
+ var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
779
785
  // <- TODO: [๐Ÿง ] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
780
786
  /**
781
787
  * The maximum number of iterations for a loops
@@ -3700,11 +3706,10 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
3700
3706
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3701
3707
  var _a;
3702
3708
  return __awaiter(this, void 0, void 0, function () {
3703
- 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;
3704
- return __generator(this, function (_l) {
3705
- switch (_l.label) {
3709
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
3710
+ return __generator(this, function (_h) {
3711
+ switch (_h.label) {
3706
3712
  case 0:
3707
- console.log('!!! makeKnowledgeSourceHandler', knowledgeSource);
3708
3713
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3709
3714
  knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
3710
3715
  name = knowledgeSource.name;
@@ -3716,7 +3721,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3716
3721
  url = knowledgeSourceContent;
3717
3722
  return [4 /*yield*/, fetch(url)];
3718
3723
  case 1:
3719
- response_1 = _l.sent();
3724
+ response_1 = _h.sent();
3720
3725
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
3721
3726
  if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [๐Ÿ’ต] */)) {
3722
3727
  return [2 /*return*/, {
@@ -3766,17 +3771,19 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3766
3771
  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));
3767
3772
  return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
3768
3773
  case 2:
3769
- _l.sent();
3770
- _g = (_f = tools.fs).writeFile;
3771
- _h = [join(rootDirname_1, filepath)];
3772
- _k = (_j = Buffer).from;
3774
+ _h.sent();
3775
+ _g = (_f = Buffer).from;
3773
3776
  return [4 /*yield*/, response_1.arrayBuffer()];
3774
- case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
3777
+ case 3:
3778
+ fileContent = _g.apply(_f, [_h.sent()]);
3779
+ if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
3780
+ 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."));
3781
+ }
3782
+ return [4 /*yield*/, tools.fs.writeFile(join(rootDirname_1, filepath), fileContent)];
3775
3783
  case 4:
3776
- _l.sent();
3784
+ _h.sent();
3777
3785
  // TODO: [๐Ÿ’ต] Check the file security
3778
- // TODO: !!!!!!!! Check the file size (if it is not too big)
3779
- // TODO: !!!!!!!! Delete the file after the scraping is done
3786
+ // TODO: [๐Ÿงน][๐Ÿง ] Delete the file after the scraping is done
3780
3787
  return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
3781
3788
  case 5:
3782
3789
  if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
@@ -3793,7 +3800,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3793
3800
  mimeType = extensionToMimeType(fileExtension || '');
3794
3801
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3795
3802
  case 6:
3796
- if (!(_l.sent())) {
3803
+ if (!(_h.sent())) {
3797
3804
  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 "); }));
3798
3805
  }
3799
3806
  // TODO: [๐Ÿง ][๐Ÿ˜ฟ] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)