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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 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:
dev← Head:fix-rag-full-context📝 Commits (1)
4a7e1b9Fix: 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_handlerinbackend/open_webui/utils/middleware.pyhas been updated to:context: 'full'property.generate_queriesstep if all files are in full context mode.full_context=Trueflag to theget_sources_from_itemsfunction 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.