utilitas 1999.1.16 → 1999.1.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 +2 -1
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/manifest.mjs +1 -1
- package/lib/web.mjs +28 -2
- package/package.json +1 -1
package/lib/manifest.mjs
CHANGED
package/lib/web.mjs
CHANGED
|
@@ -215,7 +215,7 @@ const search = async (query, options = {}) => {
|
|
|
215
215
|
];
|
|
216
216
|
var url = `https://s.jina.ai/?q=${encodeURIComponent(query)}`
|
|
217
217
|
+ `&page=${encodeURIComponent(start - 1)}`
|
|
218
|
-
+ `&num=${encodeURIComponent(num)}
|
|
218
|
+
+ `&num=${encodeURIComponent(num)}`;
|
|
219
219
|
var resp = await get(url, {
|
|
220
220
|
encode: options?.aiFriendly ? 'TEXT' : _JSON,
|
|
221
221
|
fetch: {
|
|
@@ -313,7 +313,32 @@ const distillYoutube = async url => {
|
|
|
313
313
|
};
|
|
314
314
|
};
|
|
315
315
|
|
|
316
|
-
const
|
|
316
|
+
const initDistill = async (options = {}) => {
|
|
317
|
+
assert(options.apiKey, 'API key is required.');
|
|
318
|
+
switch (ensureString(options.provider, { case: 'UP' })) {
|
|
319
|
+
case 'JINA':
|
|
320
|
+
jinaApiKey = options.apiKey;
|
|
321
|
+
break;
|
|
322
|
+
default:
|
|
323
|
+
throwError(`Invalid web-fetch provider: "${options.provider}".`);
|
|
324
|
+
}
|
|
325
|
+
return distill;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
const distill = async (url, options = {}) => {
|
|
329
|
+
if (ensureString(options.provider, { case: 'UP' }) === 'JINA') {
|
|
330
|
+
const key = options.apiKey || jinaApiKey;
|
|
331
|
+
assert(key, 'Jina API key is required.');
|
|
332
|
+
var url = `https://r.jina.ai/${encodeURIComponent(url)}`;
|
|
333
|
+
var resp = await get(url, {
|
|
334
|
+
fetch: { headers: { 'Authorization': `Bearer ${key}` } },
|
|
335
|
+
...options || {},
|
|
336
|
+
});
|
|
337
|
+
return {
|
|
338
|
+
content: null,
|
|
339
|
+
summary: resp?.content
|
|
340
|
+
};
|
|
341
|
+
}
|
|
317
342
|
let content;
|
|
318
343
|
if (isYoutubeUrl(url)) {
|
|
319
344
|
content = await distillYoutube(url);
|
|
@@ -373,6 +398,7 @@ export {
|
|
|
373
398
|
getVersionOnNpm,
|
|
374
399
|
getYoutubeMetadata,
|
|
375
400
|
getYoutubeTranscript,
|
|
401
|
+
initDistill,
|
|
376
402
|
initSearch,
|
|
377
403
|
isYoutubeUrl,
|
|
378
404
|
search,
|