Spaces:
Sleeping
Sleeping
quanho114 commited on
Commit ·
f3ea897
1
Parent(s): a78ed19
Add Qdrant stats endpoint for DataView
Browse files
api.py
CHANGED
|
@@ -12,6 +12,7 @@ from src.graph import get_graph
|
|
| 12 |
from src.graph import get_graph
|
| 13 |
from src.utils.llm import set_large_model_override, get_available_large_models
|
| 14 |
from src.utils.firebase import delete_user_permanently, verify_id_token
|
|
|
|
| 15 |
from fastapi import Header
|
| 16 |
|
| 17 |
|
|
@@ -201,6 +202,44 @@ async def delete_user(req: DeleteUserRequest, authorization: str = Header(None))
|
|
| 201 |
raise HTTPException(500, str(e))
|
| 202 |
|
| 203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
if __name__ == "__main__":
|
| 205 |
import uvicorn
|
| 206 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
| 12 |
from src.graph import get_graph
|
| 13 |
from src.utils.llm import set_large_model_override, get_available_large_models
|
| 14 |
from src.utils.firebase import delete_user_permanently, verify_id_token
|
| 15 |
+
from src.utils.ingestion import get_qdrant_client
|
| 16 |
from fastapi import Header
|
| 17 |
|
| 18 |
|
|
|
|
| 202 |
raise HTTPException(500, str(e))
|
| 203 |
|
| 204 |
|
| 205 |
+
@app.get("/api/qdrant/stats")
|
| 206 |
+
async def get_qdrant_stats():
|
| 207 |
+
"""Get Qdrant database statistics."""
|
| 208 |
+
try:
|
| 209 |
+
client = get_qdrant_client()
|
| 210 |
+
collections = client.get_collections().collections
|
| 211 |
+
|
| 212 |
+
stats = {
|
| 213 |
+
"collections": [],
|
| 214 |
+
"total_vectors": 0,
|
| 215 |
+
"total_size_bytes": 0
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
for collection in collections:
|
| 219 |
+
try:
|
| 220 |
+
collection_info = client.get_collection(collection.name)
|
| 221 |
+
vector_count = collection_info.points_count or 0
|
| 222 |
+
|
| 223 |
+
stats["collections"].append({
|
| 224 |
+
"name": collection.name,
|
| 225 |
+
"vectors": vector_count,
|
| 226 |
+
"status": "healthy"
|
| 227 |
+
})
|
| 228 |
+
stats["total_vectors"] += vector_count
|
| 229 |
+
except Exception as e:
|
| 230 |
+
print(f"Error getting collection {collection.name}: {e}")
|
| 231 |
+
stats["collections"].append({
|
| 232 |
+
"name": collection.name,
|
| 233 |
+
"vectors": 0,
|
| 234 |
+
"status": "error"
|
| 235 |
+
})
|
| 236 |
+
|
| 237 |
+
return stats
|
| 238 |
+
except Exception as e:
|
| 239 |
+
print(f"Qdrant stats error: {e}")
|
| 240 |
+
raise HTTPException(500, f"Failed to get Qdrant stats: {str(e)}")
|
| 241 |
+
|
| 242 |
+
|
| 243 |
if __name__ == "__main__":
|
| 244 |
import uvicorn
|
| 245 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|