mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 11:28:35 -05:00
[PR #22892] [CLOSED] fix: use hybrid search and reranking in builtin query_knowledge_files tool #42545
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/22892
Author: @daudo
Created: 3/20/2026
Status: ❌ Closed
Base:
dev← Head:fix/builtin-knowledge-hybrid-search📝 Commits (1)
8954487fix: use hybrid search and reranking in builtin query_knowledge_files tool📊 Changes
1 file changed (+35 additions, -7 deletions)
View changed files
📝
backend/open_webui/tools/builtin.py(+35 -7)📄 Description
Pull Request Checklist
devdevfix:Changelog Entry
Description
The builtin
query_knowledge_filestool (used when native function calling is enabled) callsquery_collection()directly — plain vector search only. The middleware RAG pipeline (get_sources_from_items) usesquery_collection_with_hybrid_search()with BM25 hybrid search, reranking, and relevance threshold filtering.This means that when a model has attached knowledge and native function calling is enabled, the admin-configured RAG quality settings (hybrid search, reranking, relevance threshold,
TOP_K_RERANKER) have no effect on knowledge retrieval.This fix makes
query_knowledge_filesuse the same hybrid search + reranking pipeline as the middleware path, controlled by the same existing config flags.Added
Changed
query_knowledge_filesinbuiltin.pynow usesquery_collection_with_hybrid_search()whenENABLE_RAG_HYBRID_SEARCHis enabled, with reranking function,TOP_K_RERANKER,RELEVANCE_THRESHOLD,HYBRID_BM25_WEIGHT, and enriched texts supportDeprecated
Removed
Fixed
query_knowledge_filestool now respects hybrid search and reranking settings, matching the behavior of the middleware RAG pipelineSecurity
Breaking Changes
Additional Information
builtin.py) were introduced in commit5c1d5223(Jan 2026) and the knowledge tools added inc8622adc, usingquery_collection()from the start. The hybrid search + reranking infrastructure inretrieval/utils.pypredates the builtin tools but was never wired in.query_collection_with_hybrid_search()is identical toquery_collection()(both usemerge_and_sort_query_results()), so no changes to result processing were needed.RERANKING_FUNCTION,TOP_K_RERANKER,RELEVANCE_THRESHOLD,HYBRID_BM25_WEIGHT,ENABLE_RAG_HYBRID_SEARCH_ENRICHED_TEXTS) are accessed via__request__.app.state, which is already available in the tool function.Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.