mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 19:38:46 -05:00
[PR #14255] [CLOSED] feat: Enhance RAG context with detailed source attributes #62280
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/14255
Author: @decent-engineer-decent-datascientist
Created: 5/23/2025
Status: ❌ Closed
Base:
dev← Head:dev📝 Commits (1)
721d9f0Enhance RAG context with detailed source attributes📊 Changes
1 file changed (+35 additions, -12 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+35 -12)📄 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.- BREAKING CHANGE: Significant changes that may affect compatibility
- build: Changes that affect the build system or external dependencies
- ci: Changes to our continuous integration processes or workflows
- chore: Refactor, cleanup, or other non-functional code changes
- docs: Documentation update or addition
- feat: Introduces a new feature or enhancement to the codebase
- fix: Bug fix or error correction
- i18n: Internationalization or localization changes
- perf: Performance improvement
- refactor: Code restructuring for better maintainability, readability, or scalability
- style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
- test: Adding missing tests or correcting existing tests
- WIP: Work in progress, a temporary label for incomplete or ongoing work
Changelog Entry
Description
middleware.py. The motivation is to provide richer, more structured metadata to the language model by adding descriptive attributes to the<source>tags. Specifically, it introducesname(for the display name of the file/tool) andsource_identifier(for the specific underlying source string or ID) alongside the existing numericid. This change aims to improve the LLM's ability to comprehend and accurately cite the sources of its information.Added
nameandsource_identifierto the<source>tags within the RAGcontext_stringgenerated inmiddleware.py.nameattribute stores the human-readable display name of the parent file or tool (e.g., "annual_report.pdf").source_identifierattribute stores the specific string used to identify the source of the content (e.g., filename from metadata, file ID, tool name).Changed
process_chat_payloadfunction withinmiddleware.pyto construct the RAGcontext_stringto include the newnameandsource_identifierattributes in each<source>tag, alongside the existingidattribute.Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
<source>tags.Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.