@promptbook/documents 0.84.0-13 → 0.84.0-15

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/LICENSE.md ADDED
@@ -0,0 +1 @@
1
+ [Functional Source License, Version 1.1, ALv2 Future License](https://github.com/getsentry/fsl.software/blob/main/FSL-1.1-ALv2.template.md)
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->
2
2
 
3
- # Promptbook
3
+ # Promptbook
4
4
 
5
5
 
6
6
 
@@ -16,10 +16,10 @@
16
16
 
17
17
  ## ❄ New Features
18
18
 
19
+ - 🐋 **Support of [DeepSeek models](https://www.deepseek.com/)**
19
20
  - 💙 Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
20
21
  - 🖤 Run books from CLI - `npx ptbk run path/to/your/book`
21
- - 📚 Support of `.docx`, `.doc` and `.pdf` documents
22
- - ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
22
+ - 📚 Support of `.docx`, `.doc` and `.pdf` documents as knowledge
23
23
 
24
24
 
25
25
 
package/esm/index.es.js CHANGED
@@ -9,7 +9,7 @@ import { basename, join, dirname } from 'path';
9
9
  import { format } from 'prettier';
10
10
  import parserHtml from 'prettier/parser-html';
11
11
  import sha256 from 'crypto-js/sha256';
12
- import { lookup } from 'mime-types';
12
+ import { lookup, extension } from 'mime-types';
13
13
  import { unparse, parse } from 'papaparse';
14
14
 
15
15
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
@@ -26,7 +26,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-12';
29
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-14';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3731,6 +3731,17 @@ function extensionToMimeType(value) {
3731
3731
  return lookup(value) || 'application/octet-stream';
3732
3732
  }
3733
3733
 
3734
+ /**
3735
+ * Convert mime type to file extension
3736
+ *
3737
+ * Note: If the mime type is invalid, `null` is returned
3738
+ *
3739
+ * @private within the repository
3740
+ */
3741
+ function mimeTypeToExtension(value) {
3742
+ return extension(value) || null;
3743
+ }
3744
+
3734
3745
  /**
3735
3746
  * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
3736
3747
  *
@@ -3784,7 +3795,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3784
3795
  case 1:
3785
3796
  response_1 = _l.sent();
3786
3797
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
3787
- if (tools.fs === undefined || !url.endsWith('.pdf')) {
3798
+ if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [💵] */)) {
3788
3799
  return [2 /*return*/, {
3789
3800
  source: name,
3790
3801
  filename: null,
@@ -3829,7 +3840,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3829
3840
  basename = url.split('/').pop() || titleToName(url);
3830
3841
  hash = sha256(hexEncoder.parse(url)).toString( /* hex */);
3831
3842
  rootDirname_1 = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
3832
- filepath = join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".pdf")], false));
3843
+ 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));
3833
3844
  return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
3834
3845
  case 2:
3835
3846
  _l.sent();
@@ -3840,9 +3851,9 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3840
3851
  case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
3841
3852
  case 4:
3842
3853
  _l.sent();
3843
- // TODO: !!!!!!!! Check the file security
3854
+ // TODO: [💵] Check the file security
3844
3855
  // TODO: !!!!!!!! Check the file size (if it is not too big)
3845
- // TODO: !!!!!!!! Delete the file
3856
+ // TODO: !!!!!!!! Delete the file after the scraping is done
3846
3857
  return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
3847
3858
  case 5:
3848
3859
  if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];