mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-10-05 18:30:09 +02:00
hoist var in extensions
This commit is contained in:
parent
31ff4f0832
commit
daadad3859
@ -18,7 +18,7 @@ async function scrapeGenericUrl(link) {
|
|||||||
const url = new URL(link);
|
const url = new URL(link);
|
||||||
const filename = (url.host + "-" + url.pathname).replace(".", "_");
|
const filename = (url.host + "-" + url.pathname).replace(".", "_");
|
||||||
|
|
||||||
data = {
|
const data = {
|
||||||
id: v4(),
|
id: v4(),
|
||||||
url: "file://" + slugify(filename) + ".html",
|
url: "file://" + slugify(filename) + ".html",
|
||||||
title: slugify(filename) + ".html",
|
title: slugify(filename) + ".html",
|
||||||
|
@ -46,7 +46,7 @@ async function asAudio({ fullFilePath = "", filename = "" }) {
|
|||||||
return { success: false, reason: `No text content found in ${filename}.` };
|
return { success: false, reason: `No text content found in ${filename}.` };
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
const data = {
|
||||||
id: v4(),
|
id: v4(),
|
||||||
url: "file://" + fullFilePath,
|
url: "file://" + fullFilePath,
|
||||||
title: filename,
|
title: filename,
|
||||||
|
@ -28,7 +28,7 @@ async function asDocX({ fullFilePath = "", filename = "" }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const content = pageContent.join("");
|
const content = pageContent.join("");
|
||||||
data = {
|
const data = {
|
||||||
id: v4(),
|
id: v4(),
|
||||||
url: "file://" + fullFilePath,
|
url: "file://" + fullFilePath,
|
||||||
title: filename,
|
title: filename,
|
||||||
|
@ -35,7 +35,7 @@ async function asMbox({ fullFilePath = "", filename = "" }) {
|
|||||||
`-- Working on message "${mail.subject || "Unknown subject"}" --`
|
`-- Working on message "${mail.subject || "Unknown subject"}" --`
|
||||||
);
|
);
|
||||||
|
|
||||||
data = {
|
const data = {
|
||||||
id: v4(),
|
id: v4(),
|
||||||
url: "file://" + fullFilePath,
|
url: "file://" + fullFilePath,
|
||||||
title: mail?.subject
|
title: mail?.subject
|
||||||
|
@ -23,7 +23,7 @@ async function asOfficeMime({ fullFilePath = "", filename = "" }) {
|
|||||||
return { success: false, reason: `No text content found in ${filename}.` };
|
return { success: false, reason: `No text content found in ${filename}.` };
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
const data = {
|
||||||
id: v4(),
|
id: v4(),
|
||||||
url: "file://" + fullFilePath,
|
url: "file://" + fullFilePath,
|
||||||
title: filename,
|
title: filename,
|
||||||
|
@ -18,8 +18,7 @@ async function asPDF({ fullFilePath = "", filename = "" }) {
|
|||||||
const docs = await pdfLoader.load();
|
const docs = await pdfLoader.load();
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
console.log(
|
console.log(
|
||||||
`-- Parsing content from pg ${
|
`-- Parsing content from pg ${doc.metadata?.loc?.pageNumber || "unknown"
|
||||||
doc.metadata?.loc?.pageNumber || "unknown"
|
|
||||||
} --`
|
} --`
|
||||||
);
|
);
|
||||||
if (!doc.pageContent.length) continue;
|
if (!doc.pageContent.length) continue;
|
||||||
@ -33,7 +32,7 @@ async function asPDF({ fullFilePath = "", filename = "" }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const content = pageContent.join("");
|
const content = pageContent.join("");
|
||||||
data = {
|
const data = {
|
||||||
id: v4(),
|
id: v4(),
|
||||||
url: "file://" + fullFilePath,
|
url: "file://" + fullFilePath,
|
||||||
title: docs[0]?.metadata?.pdf?.info?.Title || filename,
|
title: docs[0]?.metadata?.pdf?.info?.Title || filename,
|
||||||
|
@ -23,7 +23,7 @@ async function asTxt({ fullFilePath = "", filename = "" }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`-- Working ${filename} --`);
|
console.log(`-- Working ${filename} --`);
|
||||||
data = {
|
const data = {
|
||||||
id: v4(),
|
id: v4(),
|
||||||
url: "file://" + fullFilePath,
|
url: "file://" + fullFilePath,
|
||||||
title: filename,
|
title: filename,
|
||||||
|
@ -5,8 +5,7 @@ const {
|
|||||||
SUPPORTED_FILETYPE_CONVERTERS,
|
SUPPORTED_FILETYPE_CONVERTERS,
|
||||||
} = require("../utils/constants");
|
} = require("../utils/constants");
|
||||||
const { trashFile } = require("../utils/files");
|
const { trashFile } = require("../utils/files");
|
||||||
|
const RESERVED_FILES = ["__HOTDIR__.md"];
|
||||||
RESERVED_FILES = ["__HOTDIR__.md"];
|
|
||||||
|
|
||||||
async function processSingleFile(targetFilename) {
|
async function processSingleFile(targetFilename) {
|
||||||
const fullFilePath = path.resolve(WATCH_DIRECTORY, targetFilename);
|
const fullFilePath = path.resolve(WATCH_DIRECTORY, targetFilename);
|
||||||
|
Loading…
Reference in New Issue
Block a user