mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-15 19:00:33 +01:00
c4eb46ca19
* implement dnd uploader show file upload progress write files to hotdirector build simple flaskAPI to process files one off * move document processor calls to util build out dockerfile to run both procs at the same time update UI to check for document processor before upload * disable pragma update on boot * dockerfile changes * add filetype restrictions based on python app support response and show rejected files in the UI * cleanup * stub migrations on boot to prevent exit condition * update CF template for AWS deploy
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
// When running locally will occupy the 0.0.0.0 hostname space but when deployed inside
|
|
// of docker this endpoint is not exposed so it is only on the Docker instances internal network
|
|
// so no additional security is needed on the endpoint directly. Auth is done however by the express
|
|
// middleware prior to leaving the node-side of the application so that is good enough >:)
|
|
const PYTHON_API = "http://0.0.0.0:8888";
|
|
async function checkPythonAppAlive() {
|
|
return await fetch(`${PYTHON_API}`)
|
|
.then((res) => res.ok)
|
|
.catch((e) => false);
|
|
}
|
|
|
|
async function acceptedFileTypes() {
|
|
return await fetch(`${PYTHON_API}/accepts`)
|
|
.then((res) => {
|
|
if (!res.ok) throw new Error("Could not reach");
|
|
return res.json();
|
|
})
|
|
.then((res) => res)
|
|
.catch(() => null);
|
|
}
|
|
|
|
async function processDocument(filename = "") {
|
|
if (!filename) return false;
|
|
return await fetch(`${PYTHON_API}/process`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({ filename }),
|
|
})
|
|
.then((res) => {
|
|
if (!res.ok) throw new Error("Response could not be completed");
|
|
return res.json();
|
|
})
|
|
.then((res) => res)
|
|
.catch((e) => {
|
|
console.log(e.message);
|
|
return { success: false, reason: e.message };
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
checkPythonAppAlive,
|
|
processDocument,
|
|
acceptedFileTypes,
|
|
};
|