@promptbook/node 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
@@ -439,6 +440,10 @@ See [TODO.md](./TODO.md)
439
440
 
440
441
 
441
442
 
443
+ ## ๐Ÿค Partners
444
+
445
+ [![Technology Incubation](./other/partners/CI-Technology-Incubation.png)](https://technologickainkubace.org/en/about-technology-incubation/about-the-project/)
446
+
442
447
  ## ๐Ÿ–‹๏ธ Contributing
443
448
 
444
449
  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
@@ -210,6 +210,12 @@ var DEFAULT_TASK_TITLE = "Task";
210
210
  * @public exported from `@promptbook/core`
211
211
  */
212
212
  var DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
213
+ /**
214
+ * Maximum file size limit
215
+ *
216
+ * @public exported from `@promptbook/core`
217
+ */
218
+ var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
213
219
  // <- TODO: [๐Ÿง ] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
214
220
  /**
215
221
  * The maximum number of iterations for a loops
@@ -5561,11 +5567,10 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
5561
5567
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5562
5568
  var _a;
5563
5569
  return __awaiter(this, void 0, void 0, function () {
5564
- 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;
5565
- return __generator(this, function (_l) {
5566
- switch (_l.label) {
5570
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
5571
+ return __generator(this, function (_h) {
5572
+ switch (_h.label) {
5567
5573
  case 0:
5568
- console.log('!!! makeKnowledgeSourceHandler', knowledgeSource);
5569
5574
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
5570
5575
  knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
5571
5576
  name = knowledgeSource.name;
@@ -5577,7 +5582,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5577
5582
  url = knowledgeSourceContent;
5578
5583
  return [4 /*yield*/, fetch(url)];
5579
5584
  case 1:
5580
- response_1 = _l.sent();
5585
+ response_1 = _h.sent();
5581
5586
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
5582
5587
  if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [๐Ÿ’ต] */)) {
5583
5588
  return [2 /*return*/, {
@@ -5627,17 +5632,19 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5627
5632
  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));
5628
5633
  return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
5629
5634
  case 2:
5630
- _l.sent();
5631
- _g = (_f = tools.fs).writeFile;
5632
- _h = [join(rootDirname_1, filepath)];
5633
- _k = (_j = Buffer).from;
5635
+ _h.sent();
5636
+ _g = (_f = Buffer).from;
5634
5637
  return [4 /*yield*/, response_1.arrayBuffer()];
5635
- case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
5638
+ case 3:
5639
+ fileContent = _g.apply(_f, [_h.sent()]);
5640
+ if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
5641
+ 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."));
5642
+ }
5643
+ return [4 /*yield*/, tools.fs.writeFile(join(rootDirname_1, filepath), fileContent)];
5636
5644
  case 4:
5637
- _l.sent();
5645
+ _h.sent();
5638
5646
  // TODO: [๐Ÿ’ต] Check the file security
5639
- // TODO: !!!!!!!! Check the file size (if it is not too big)
5640
- // TODO: !!!!!!!! Delete the file after the scraping is done
5647
+ // TODO: [๐Ÿงน][๐Ÿง ] Delete the file after the scraping is done
5641
5648
  return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
5642
5649
  case 5:
5643
5650
  if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
@@ -5654,7 +5661,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5654
5661
  mimeType = extensionToMimeType(fileExtension || '');
5655
5662
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
5656
5663
  case 6:
5657
- if (!(_l.sent())) {
5664
+ if (!(_h.sent())) {
5658
5665
  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 "); }));
5659
5666
  }
5660
5667
  // TODO: [๐Ÿง ][๐Ÿ˜ฟ] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)