open-webui/backend
Classic298 ecd0ff67e1
fix: apply the duplicate-content check to knowledge batch add (#31336)
Adding files through `POST /api/v1/knowledge/{id}/files/batch/add` accepted a file whose extracted text was already in the knowledge base under another file, and linked both, while the single-file add rejects the same file with "Duplicate content detected". The same text was then embedded twice and retrieval returned the same passages twice.

The batch path now runs each file's content hash through the same check the single-file path uses, now shared by both, and also against the earlier files of the same batch. A duplicate is reported as a failed file in the batch result and is not linked, while the other files of the batch still go through. Batch-added chunks now carry the content hash in their metadata, so later adds through either endpoint detect them.

Chunks written by batch add before this change have no hash, so content added that way earlier is still not detected as a duplicate.

Verified on a running instance: two files with identical text now end up with exactly one linked in every order and combination (one batch call, separate batch calls, batch mixed with single add), and re-adding the same file is still accepted.

Fixes #31333
2026-10-01 07:53:06 +04:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
open_webui fix: apply the duplicate-content check to knowledge batch add (#31336) 2026-10-01 07:53:06 +04:00
.dockerignore fix: litellm config issue 2024-02-24 22:35:11 -08:00
.gitignore refac 2024-09-06 04:59:20 +02:00
dev.sh perf: allow disabling websocket per-message-deflate (#28613) 2026-08-24 18:46:07 -04:00
requirements-slim.txt chore: bump pycrdt to 0.14.8 (#31636) 2026-09-30 19:00:23 +04:00
requirements.txt chore: bump pycrdt to 0.14.8 (#31636) 2026-09-30 19:00:23 +04:00
start.sh refac 2026-09-06 16:48:30 -04:00
start_windows.bat chore: drop nltk, unused at the pinned versions (#29725) 2026-09-06 16:39:05 -04:00