mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-10 17:00:11 +01:00
fix: "remove document system api"
This commit is contained in:
parent
c24b79c9d1
commit
b7c3f3d7ab
@ -1,5 +1,6 @@
|
||||
const { EventLogs } = require("../../../models/eventLogs");
|
||||
const { SystemSettings } = require("../../../models/systemSettings");
|
||||
const { purgeDocument } = require("../../../utils/files/purgeDocument");
|
||||
const { getVectorDbClass } = require("../../../utils/helpers");
|
||||
const {
|
||||
prepareWorkspaceChatsForExport,
|
||||
@ -206,6 +207,70 @@ function apiSystemEndpoints(app) {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/v1/system/remove-documents",
|
||||
[validApiKey],
|
||||
async (request, response) => {
|
||||
/*
|
||||
#swagger.tags = ['System']
|
||||
#swagger.description = 'Permanently remove documents from the system.'
|
||||
#swagger.requestBody = {
|
||||
description: 'Array of document names to be removed permanently.',
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
names: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
example: [
|
||||
"custom-documents/file.txt-fc4beeeb-e436-454d-8bb4-e5b8979cb48f.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#swagger.responses[200] = {
|
||||
description: 'Documents removed successfully.',
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: 'object',
|
||||
example: {
|
||||
success: true,
|
||||
message: 'Documents removed successfully'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#swagger.responses[403] = {
|
||||
description: 'Forbidden',
|
||||
schema: {
|
||||
"$ref": "#/definitions/InvalidAPIKey"
|
||||
}
|
||||
}
|
||||
#swagger.responses[500] = {
|
||||
description: 'Internal Server Error'
|
||||
}
|
||||
*/
|
||||
try {
|
||||
const { names } = reqBody(request);
|
||||
for await (const name of names) await purgeDocument(name);
|
||||
response.status(200).json({ success: true, message: 'Documents removed successfully' }).end();
|
||||
} catch (e) {
|
||||
console.log(e.message, e);
|
||||
response.sendStatus(500).end();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { apiSystemEndpoints };
|
||||
|
@ -2241,6 +2241,84 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/system/remove-documents": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"System Settings"
|
||||
],
|
||||
"description": "Permanently remove documents from the system.",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"example": {
|
||||
"success": true,
|
||||
"message": "Documents removed successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InvalidAPIKey"
|
||||
}
|
||||
},
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InvalidAPIKey"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"description": "Array of document names to be removed permanently.",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"names": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"example": [
|
||||
"custom-documents/file.txt-fc4beeeb-e436-454d-8bb4-e5b8979cb48f.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"InvalidAPIKey": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string",
|
||||
"example": "Invalid API Key"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
|
Loading…
Reference in New Issue
Block a user