mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #17143] issue: Removing a file from knowledge via the API results in the complete removal of the file #33712
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DirkRemmers on GitHub (Sep 2, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/17143
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.6.22
Ollama Version (if applicable)
No response
Operating System
Debian
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
When using the following API endpoint:
POST /api/v1/knowledge/{knowledge_id}/file/remove, the file that is specified in thedatashould be deleted only from the knowledge collection, not from the entire system.Actual Behavior
Instead, when I use the following api endpoint:
POST /api/v1/knowledge/{knowledge_id}/file/remove, the file is removed from the system entirelySteps to Reproduce
To reproduce:
POST /api/v1/files/) and get the id (file_id)GET /api/v1/files/{file_id})POST /api/v1/knowledge/create) and get the id (knowledge_id)POST /api/v1/knowledge/{knowledge_id}/file/addwithdata = {"file_id"=file_id})POST /api/v1/knowledge/{knowledge_id}/file/removewith `data={"file_id"=file_id})GET /api/v1/files/{file_id})Logs & Screenshots
Additional Information
I don't believe this is the intended behaviour, so I guess this should be fixed?
Cheers,
Dirk
@Classic298 commented on GitHub (Sep 2, 2025):
What do you mean by this?
If you remove a file from the knowledge base, of course the file becomes unusable in Open WebUI as there is no longer any active reference to the file.
But the file IS kept on disk and in the vector database for data retention purposes.
But it is unusable from the web ui.
If that is your question, yes it is intended that the file is removed and becomes unusable from the webui after you remove (delete) it from a knowledge collection (and why would it not be?)
@tjbck commented on GitHub (Sep 2, 2025):
22c4ef4fb0@DirkRemmers commented on GitHub (Sep 3, 2025):
@Classic298 , using the API, you can upload files without adding them to any knowledge base. You can then link the file to knowledge bases using the id that the file then gets. This allows you to (for example) link it to multiple knowledge bases.
It should still be possible to remove the file from one knowledge base, and then link it to another knowledge base. For this, the id of the file needs to remain, and therefore the file needs to remain.
Your logic also makes sense in the use case that a document is only added to one knowledge base of course.
I think the fix that @tjbck created is a good one, it will allow users to specify if the entire file needs to be removed or not, providing the user with the possibility to describe what I just explained.
Thanks for the quick fix!
Cheers,
Dirk