@promptbook/cli 0.84.0-12 → 0.84.0-13
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/esm/index.es.js +49 -7
- package/esm/index.es.js.map +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +49 -7
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -38,7 +38,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
38
38
|
* @generated
|
|
39
39
|
* @see https://github.com/webgptorg/promptbook
|
|
40
40
|
*/
|
|
41
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-
|
|
41
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-12';
|
|
42
42
|
/**
|
|
43
43
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
44
44
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6510,7 +6510,7 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
6510
6510
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
6511
6511
|
var _a;
|
|
6512
6512
|
return __awaiter(this, void 0, void 0, function () {
|
|
6513
|
-
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url,
|
|
6513
|
+
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;
|
|
6514
6514
|
return __generator(this, function (_l) {
|
|
6515
6515
|
switch (_l.label) {
|
|
6516
6516
|
case 0:
|
|
@@ -6526,19 +6526,61 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6526
6526
|
url = knowledgeSourceContent;
|
|
6527
6527
|
return [4 /*yield*/, fetch(url)];
|
|
6528
6528
|
case 1:
|
|
6529
|
-
|
|
6530
|
-
mimeType = ((_a =
|
|
6531
|
-
|
|
6529
|
+
response_1 = _l.sent();
|
|
6530
|
+
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
6531
|
+
if (tools.fs === undefined || !url.endsWith('.pdf')) {
|
|
6532
|
+
return [2 /*return*/, {
|
|
6533
|
+
source: name,
|
|
6534
|
+
filename: null,
|
|
6535
|
+
url: url,
|
|
6536
|
+
mimeType: mimeType,
|
|
6537
|
+
/*
|
|
6538
|
+
TODO: [🥽]
|
|
6539
|
+
> async asBlob() {
|
|
6540
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
6541
|
+
> const content = await response.blob();
|
|
6542
|
+
> return content;
|
|
6543
|
+
> },
|
|
6544
|
+
*/
|
|
6545
|
+
asJson: function () {
|
|
6546
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6547
|
+
var content;
|
|
6548
|
+
return __generator(this, function (_a) {
|
|
6549
|
+
switch (_a.label) {
|
|
6550
|
+
case 0: return [4 /*yield*/, response_1.json()];
|
|
6551
|
+
case 1:
|
|
6552
|
+
content = _a.sent();
|
|
6553
|
+
return [2 /*return*/, content];
|
|
6554
|
+
}
|
|
6555
|
+
});
|
|
6556
|
+
});
|
|
6557
|
+
},
|
|
6558
|
+
asText: function () {
|
|
6559
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6560
|
+
var content;
|
|
6561
|
+
return __generator(this, function (_a) {
|
|
6562
|
+
switch (_a.label) {
|
|
6563
|
+
case 0: return [4 /*yield*/, response_1.text()];
|
|
6564
|
+
case 1:
|
|
6565
|
+
content = _a.sent();
|
|
6566
|
+
return [2 /*return*/, content];
|
|
6567
|
+
}
|
|
6568
|
+
});
|
|
6569
|
+
});
|
|
6570
|
+
},
|
|
6571
|
+
}];
|
|
6572
|
+
}
|
|
6573
|
+
basename = url.split('/').pop() || titleToName(url);
|
|
6532
6574
|
hash = sha256(hexEncoder.parse(url)).toString( /* hex */);
|
|
6533
6575
|
rootDirname_1 = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
6534
|
-
filepath = join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(
|
|
6576
|
+
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));
|
|
6535
6577
|
return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
|
|
6536
6578
|
case 2:
|
|
6537
6579
|
_l.sent();
|
|
6538
6580
|
_g = (_f = tools.fs).writeFile;
|
|
6539
6581
|
_h = [join(rootDirname_1, filepath)];
|
|
6540
6582
|
_k = (_j = Buffer).from;
|
|
6541
|
-
return [4 /*yield*/,
|
|
6583
|
+
return [4 /*yield*/, response_1.arrayBuffer()];
|
|
6542
6584
|
case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
|
|
6543
6585
|
case 4:
|
|
6544
6586
|
_l.sent();
|