mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 23:21:44 -05:00
[PR #12562] [MERGED] fix: Correct Citations for knowledge base models #77844
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?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/12562
Author: @almajo
Created: 4/7/2025
Status: ✅ Merged
Merged: 4/10/2025
Merged by: @tjbck
Base:
dev← Head:fix/agrimm/correct_knowledge_base_citations📝 Commits (2)
d8a7e9cfix: correct document citation1e7a364~ update to latest change📊 Changes
1 file changed (+7 additions, -3 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+7 -3)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
The RAG-pipeline was not citing correctly when using a model equipped with one or more knowledge bases. This small change corrects the citations by giving the model the actual document id of the chunk-context-source (instead of the knowledge base id). This works all the way through frontend citation parsing due to the consistent order of the source objects.
Cases citation might break: When the metadata.name is not unique within the sources (e.g. multiple files with the same ' name'). Then the deduplication step in citation rendering takes some sources out and the numbers are not aligned any more.
Fixed
Manual tests:
All manual tests used correct citations of the relevant source.
Breaking Changes
Additional Information
This has been topic of this discussion https://github.com/open-webui/open-webui/discussions/11599 but was not furtherly taken care of.
Additional discussion: https://github.com/open-webui/open-webui/discussions/10595
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.