[PR #17744] [MERGED] Fix: Prevent RAG queries when all files are in full context #11328

Closed
opened 2025-11-11 19:28:56 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/17744
Author: @Classic298
Created: 9/25/2025
Status: Merged
Merged: 9/25/2025
Merged by: @tjbck

Base: devHead: fix-rag-full-context


📝 Commits (1)

  • 4a7e1b9 Fix: Prevent RAG queries when all files are in full context

📊 Changes

1 file changed (+40 additions, -34 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+40 -34)

📄 Description

This commit fixes an issue where Retrieval-Augmented Generation (RAG) queries were still being generated even when all attached files were set to 'full context' mode. This was inefficient as the full content of the files was already available to the model.

The chat_completion_files_handler in backend/open_webui/utils/middleware.py has been updated to:

  • Check if all attached files have the context: 'full' property.
  • Skip the generate_queries step if all files are in full context mode.
  • Pass a full_context=True flag to the get_sources_from_items function to ensure it fetches the entire document content instead of performing a vector search.

This change ensures that RAG queries are only generated when necessary, improving the efficiency of the system.

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.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/17744 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 9/25/2025 **Status:** ✅ Merged **Merged:** 9/25/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `fix-rag-full-context` --- ### 📝 Commits (1) - [`4a7e1b9`](https://github.com/open-webui/open-webui/commit/4a7e1b93e5f9b2a0474706721e8a57f2b2ee16f5) Fix: Prevent RAG queries when all files are in full context ### 📊 Changes **1 file changed** (+40 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+40 -34) </details> ### 📄 Description This commit fixes an issue where Retrieval-Augmented Generation (RAG) queries were still being generated even when all attached files were set to 'full context' mode. This was inefficient as the full content of the files was already available to the model. The `chat_completion_files_handler` in `backend/open_webui/utils/middleware.py` has been updated to: - Check if all attached files have the `context: 'full'` property. - Skip the `generate_queries` step if all files are in full context mode. - Pass a `full_context=True` flag to the `get_sources_from_items` function to ensure it fetches the entire document content instead of performing a vector search. This change ensures that RAG queries are only generated when necessary, improving the efficiency of the system. ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 19:28:56 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#11328