mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-10 17:00:11 +01:00
move vector db debug endpoint to dev only
This commit is contained in:
parent
99cfee1e70
commit
bf8df60c02
@ -51,34 +51,6 @@ developerEndpoints(app, apiRouter);
|
||||
// Externally facing embedder endpoints
|
||||
embeddedEndpoints(apiRouter);
|
||||
|
||||
apiRouter.post("/v/:command", async (request, response) => {
|
||||
try {
|
||||
const VectorDb = getVectorDbClass();
|
||||
const { command } = request.params;
|
||||
if (!Object.getOwnPropertyNames(VectorDb).includes(command)) {
|
||||
response.status(500).json({
|
||||
message: "invalid interface command",
|
||||
commands: Object.getOwnPropertyNames(VectorDb),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const body = reqBody(request);
|
||||
const resBody = await VectorDb[command](body);
|
||||
response.status(200).json({ ...resBody });
|
||||
} catch (e) {
|
||||
// console.error(e)
|
||||
console.error(JSON.stringify(e));
|
||||
response.status(500).json({ error: e.message });
|
||||
}
|
||||
return;
|
||||
} catch (e) {
|
||||
console.log(e.message, e);
|
||||
response.sendStatus(500).end();
|
||||
}
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== "development") {
|
||||
app.use(
|
||||
express.static(path.resolve(__dirname, "public"), { extensions: ["js"] })
|
||||
@ -92,6 +64,35 @@ if (process.env.NODE_ENV !== "development") {
|
||||
response.type("text/plain");
|
||||
response.send("User-agent: *\nDisallow: /").end();
|
||||
});
|
||||
} else {
|
||||
// Debug route for development connections to vectorDBs
|
||||
apiRouter.post("/v/:command", async (request, response) => {
|
||||
try {
|
||||
const VectorDb = getVectorDbClass();
|
||||
const { command } = request.params;
|
||||
if (!Object.getOwnPropertyNames(VectorDb).includes(command)) {
|
||||
response.status(500).json({
|
||||
message: "invalid interface command",
|
||||
commands: Object.getOwnPropertyNames(VectorDb),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const body = reqBody(request);
|
||||
const resBody = await VectorDb[command](body);
|
||||
response.status(200).json({ ...resBody });
|
||||
} catch (e) {
|
||||
// console.error(e)
|
||||
console.error(JSON.stringify(e));
|
||||
response.status(500).json({ error: e.message });
|
||||
}
|
||||
return;
|
||||
} catch (e) {
|
||||
console.log(e.message, e);
|
||||
response.sendStatus(500).end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
app.all("*", function (_, response) {
|
||||
|
Loading…
Reference in New Issue
Block a user