瀏覽代碼

refac/fix: hybrid search

Timothy Jaeryang Baek 1 月之前
父節點
當前提交
23a9731899
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      backend/open_webui/retrieval/utils.py

+ 4 - 0
backend/open_webui/retrieval/utils.py

@@ -124,6 +124,10 @@ def query_doc_with_hybrid_search(
     hybrid_bm25_weight: float,
 ) -> dict:
     try:
+        if not collection_result.documents[0]:
+            log.warning(f"query_doc_with_hybrid_search:no_docs {collection_name}")
+            return {"documents": [], "metadatas": [], "distances": []}
+
         # BM_25 required only if weight is greater than 0
         if hybrid_bm25_weight > 0:
             log.debug(f"query_doc_with_hybrid_search:doc {collection_name}")