Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -199,6 +199,19 @@ def _rag_search(vs, query: str, k: int, article_filter: str, category_filter: st
|
|
| 199 |
want_category = None if category_filter in (None, "", "All categories") else category_filter
|
| 200 |
|
| 201 |
backend_type = type(vs).__name__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
if "FAISS" in backend_type:
|
| 204 |
# FAISS: post-filtering (unchanged)
|
|
|
|
| 199 |
want_category = None if category_filter in (None, "", "All categories") else category_filter
|
| 200 |
|
| 201 |
backend_type = type(vs).__name__
|
| 202 |
+
|
| 203 |
+
## potential security fix as catchall for FAISS search failure
|
| 204 |
+
#if "FAISS" in backend_type:
|
| 205 |
+
#try:
|
| 206 |
+
# pool_size = min(k * 10, 80)
|
| 207 |
+
# pool = vs.similarity_search(query, k=pool_size)
|
| 208 |
+
#
|
| 209 |
+
# # ... rest of your filtering code ...
|
| 210 |
+
#
|
| 211 |
+
#except Exception as e:
|
| 212 |
+
# logger.error("FAISS similarity_search failed: %s", e)
|
| 213 |
+
# # Fallback: try without k limit or return empty
|
| 214 |
+
# return vs.similarity_search(query, k=k)
|
| 215 |
|
| 216 |
if "FAISS" in backend_type:
|
| 217 |
# FAISS: post-filtering (unchanged)
|