mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
fix: Handle AttributeError in hybrid search with reranking (#17046)
- Split attribute existence checks from document content checks - Added hasattr() check for metadatas attribute - Prevents AttributeError when collection_result is missing attributes - Maintains all original validation logic Fixes #17046
This commit is contained in:
parent
49d57ae82b
commit
684324ae9e
1 changed files with 9 additions and 1 deletions
|
|
@ -160,10 +160,18 @@ def query_doc_with_hybrid_search(
|
||||||
hybrid_bm25_weight: float,
|
hybrid_bm25_weight: float,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
try:
|
try:
|
||||||
|
# First check if collection_result has the required attributes
|
||||||
if (
|
if (
|
||||||
not collection_result
|
not collection_result
|
||||||
or not hasattr(collection_result, "documents")
|
or not hasattr(collection_result, "documents")
|
||||||
or not collection_result.documents
|
or not hasattr(collection_result, "metadatas")
|
||||||
|
):
|
||||||
|
log.warning(f"query_doc_with_hybrid_search:no_docs {collection_name}")
|
||||||
|
return {"documents": [], "metadatas": [], "distances": []}
|
||||||
|
|
||||||
|
# Now safely check the documents content after confirming attributes exist
|
||||||
|
if (
|
||||||
|
not collection_result.documents
|
||||||
or len(collection_result.documents) == 0
|
or len(collection_result.documents) == 0
|
||||||
or not collection_result.documents[0]
|
or not collection_result.documents[0]
|
||||||
):
|
):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue