[GH-ISSUE #7698] Parameter mismatch in query_doc function call #30376

Closed
opened 2026-04-25 04:35:52 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @juananpe on GitHub (Dec 8, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/7698

Issue Description

I think that there is a parameter mismatch in the call to the query_doc function in backend/open_webui/apps/retrieval/main.py. The query_doc in utils.py:
29a2719595/backend/open_webui/apps/retrieval/utils.py (L61-L65)
function currently expects three parameters (collection_name, query_embedding, and k), but four parameters (collection_name, query, embedding_function, and k) are being passed here:
29a2719595/backend/open_webui/apps/retrieval/main.py (L1371-L1376)

Proposed Solution

Modify the call to query_doc to compute the query_embedding using the embedding_function before passing it to query_doc. Something like this:

query_embedding = app.state.EMBEDDING_FUNCTION(form_data.query)
return query_doc(
    collection_name=form_data.collection_name,
    query_embedding=query_embedding,
    k=form_data.k if form_data.k else app.state.config.TOP_K,
)
Originally created by @juananpe on GitHub (Dec 8, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/7698 ### Issue Description I think that there is a parameter mismatch in the call to the `query_doc` function in `backend/open_webui/apps/retrieval/main.py`. The `query_doc` in `utils.py`: https://github.com/open-webui/open-webui/blob/29a271959556743e6deb4d55a5a982983335d7ab/backend/open_webui/apps/retrieval/utils.py#L61-L65 function currently expects three parameters (`collection_name`, `query_embedding`, and `k`), but four parameters (`collection_name`, `query`, `embedding_function`, and `k`) are being passed here: https://github.com/open-webui/open-webui/blob/29a271959556743e6deb4d55a5a982983335d7ab/backend/open_webui/apps/retrieval/main.py#L1371-L1376 ### Proposed Solution Modify the call to `query_doc` to compute the `query_embedding` using the `embedding_function` before passing it to `query_doc`. Something like this: ```python query_embedding = app.state.EMBEDDING_FUNCTION(form_data.query) return query_doc( collection_name=form_data.collection_name, query_embedding=query_embedding, k=form_data.k if form_data.k else app.state.config.TOP_K, ) ```
Author
Owner

@tjbck commented on GitHub (Dec 10, 2024):

Good catch, fixed on dev!

<!-- gh-comment-id:2530671354 --> @tjbck commented on GitHub (Dec 10, 2024): Good catch, fixed on dev!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#30376