Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- app/main.py +4 -0
- app/vector_store.py +6 -3
app/main.py
CHANGED
|
@@ -133,6 +133,10 @@ def chat(request: ChatRequest) -> ChatResponse:
|
|
| 133 |
)
|
| 134 |
except RuntimeError as exc:
|
| 135 |
raise HTTPException(status_code=503, detail=str(exc))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
|
| 138 |
# --- Minimal web UI (served at /) ---
|
|
|
|
| 133 |
)
|
| 134 |
except RuntimeError as exc:
|
| 135 |
raise HTTPException(status_code=503, detail=str(exc))
|
| 136 |
+
except Exception as exc: # noqa: BLE001 — always return JSON so the UI can show it
|
| 137 |
+
import traceback
|
| 138 |
+
traceback.print_exc()
|
| 139 |
+
raise HTTPException(status_code=502, detail=f"{type(exc).__name__}: {exc}")
|
| 140 |
|
| 141 |
|
| 142 |
# --- Minimal web UI (served at /) ---
|
app/vector_store.py
CHANGED
|
@@ -75,13 +75,16 @@ def search(
|
|
| 75 |
must=[qm.FieldCondition(key="document_id", match=qm.MatchAny(any=document_ids))]
|
| 76 |
)
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
| 79 |
collection_name=settings.qdrant_collection,
|
| 80 |
-
|
| 81 |
limit=top_k,
|
| 82 |
query_filter=query_filter,
|
| 83 |
with_payload=True,
|
| 84 |
-
)
|
| 85 |
|
| 86 |
|
| 87 |
def delete_document(document_id: str) -> None:
|
|
|
|
| 75 |
must=[qm.FieldCondition(key="document_id", match=qm.MatchAny(any=document_ids))]
|
| 76 |
)
|
| 77 |
|
| 78 |
+
# query_points is the current API (works on qdrant-client >=1.10; the old
|
| 79 |
+
# .search() was removed in 1.18). Returns a QueryResponse; .points is the
|
| 80 |
+
# list of ScoredPoint (each has .payload and .score), matching prior usage.
|
| 81 |
+
return client.query_points(
|
| 82 |
collection_name=settings.qdrant_collection,
|
| 83 |
+
query=query_vector,
|
| 84 |
limit=top_k,
|
| 85 |
query_filter=query_filter,
|
| 86 |
with_payload=True,
|
| 87 |
+
).points
|
| 88 |
|
| 89 |
|
| 90 |
def delete_document(document_id: str) -> None:
|