mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-10 03:27:57 +00:00
fix: reranker gets no user info headers in chat and knowledge search (#32061)
With ENABLE_FORWARD_USER_INFO_HEADERS on and hybrid search enabled, rerank requests went out without the user headers when a chat searched attached knowledge, when a model used the built-in knowledge search tool, and when the collection query API was called with hybrid turned off for that one request. The embedding requests of the same search did carry them, so external rerankers that use these headers for per-user auth, rate limits or auditing saw anonymous calls. Rerank requests now carry the signed-in user, the same as embedding requests. Fixes #32060
This commit is contained in:
parent
c15f5c8155
commit
c04c7ddae0
3 changed files with 5 additions and 1 deletions
|
|
@ -703,6 +703,7 @@ async def query_collection(
|
|||
queries: list[str],
|
||||
embedding_function,
|
||||
k: int,
|
||||
user: UserModel | None = None,
|
||||
) -> dict:
|
||||
config = await Config.get_many(
|
||||
'rag.enable_hybrid_search',
|
||||
|
|
@ -715,7 +716,7 @@ async def query_collection(
|
|||
if request and config.get('rag.enable_hybrid_search'):
|
||||
try:
|
||||
reranking_function = (
|
||||
(lambda query, documents: request.app.state.RERANKING_FUNCTION(query, documents))
|
||||
(lambda query, documents: request.app.state.RERANKING_FUNCTION(query, documents, user=user))
|
||||
if request.app.state.RERANKING_FUNCTION
|
||||
else None
|
||||
)
|
||||
|
|
@ -1692,6 +1693,7 @@ async def get_sources_from_items(
|
|||
queries=queries,
|
||||
embedding_function=embedding_function,
|
||||
k=k,
|
||||
user=user,
|
||||
)
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
|
|
|
|||
|
|
@ -3221,6 +3221,7 @@ async def query_collection_handler(
|
|||
query, prefix=prefix, user=user
|
||||
),
|
||||
k=form_data.k if form_data.k else config.TOP_K,
|
||||
user=user,
|
||||
)
|
||||
|
||||
except HTTPException:
|
||||
|
|
|
|||
|
|
@ -3316,6 +3316,7 @@ async def query_knowledge_files(
|
|||
queries=[query],
|
||||
embedding_function=lambda queries, prefix: embedding_function(queries, prefix=prefix, user=user_model),
|
||||
k=count,
|
||||
user=user_model,
|
||||
)
|
||||
|
||||
if query_results and 'documents' in query_results:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue