From 02d1b0432cc46a76d463c27af7b1a586b9eb5f2a Mon Sep 17 00:00:00 2001 From: gramps Date: Tue, 14 Jul 2026 15:18:05 -0700 Subject: [PATCH] Fix RAG admin: vectors_count->points_count, remove unindexed order_by, make RAG_COLLECTION env-configurable --- config.py | 2 +- eviction.py | 3 ++- routers/rag_admin.py | 6 ++---- templates/index.html | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index 68809dc..559cd92 100644 --- a/config.py +++ b/config.py @@ -70,7 +70,7 @@ UPLOAD_DIR = os.environ.get("CAIC_UPLOAD_DIR", "/tmp/caic_uploads") MAX_UPLOAD_BYTES = 20 * 1024 * 1024 SUPPORTED_UPLOAD_TYPES = {"text/plain", "text/markdown", "application/pdf", "application/json", "text/x-python", "text/html", "image/png", "image/jpeg", "image/gif", "image/svg+xml", "image/webp"} QDRANT_URL = os.environ.get("CAIC_QDRANT_URL", "http://192.168.50.108:6333") -RAG_COLLECTION = "caic_rag" +RAG_COLLECTION = os.environ.get("CAIC_RAG_COLLECTION", "caic_rag") UPLOAD_CONTEXT_EXPIRY_HOURS = 1 BODY_LIMIT_UPLOAD_BYTES = MAX_UPLOAD_BYTES diff --git a/eviction.py b/eviction.py index b9ed754..6a51fd3 100644 --- a/eviction.py +++ b/eviction.py @@ -46,7 +46,8 @@ async def get_collection_count() -> int: timeout=10.0, ) if resp.status_code == 200: - return resp.json().get("result", {}).get("vectors_count", 0) + info = resp.json().get("result", {}) + return info.get("points_count", info.get("vectors_count", 0)) except Exception as e: log.warning(f"get_collection_count error: {e}") return 0 diff --git a/routers/rag_admin.py b/routers/rag_admin.py index 7ff87f8..6171f53 100644 --- a/routers/rag_admin.py +++ b/routers/rag_admin.py @@ -93,9 +93,6 @@ async def rag_list_points( scroll_body["offset"] = offset if source: scroll_body["filter"] = {"must": [{"match": {"key": "source", "value": source}}]} - if sort: - direction = "asc" if order == "asc" else "desc" - scroll_body["order_by"] = {"key": sort, "direction": direction} sr = await client.post( f"{QDRANT_URL}/collections/{RAG_COLLECTION}/points/scroll", @@ -114,7 +111,8 @@ async def rag_list_points( ) total = 0 if info_resp.status_code == 200: - total = info_resp.json().get("result", {}).get("vectors_count", 0) + info = info_resp.json().get("result", {}) + total = info.get("points_count", info.get("vectors_count", 0)) points = [] for r in raw_points: diff --git a/templates/index.html b/templates/index.html index 87fec63..9f4244b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1379,7 +1379,7 @@ async function loadRagPoints() { try { const search = document.getElementById('ragSearchInput').value.trim(); const source = document.getElementById('ragSourceFilter').value; - let url = `/api/rag/points?limit=20&sort=date&order=desc`; + let url = `/api/rag/points?limit=20`; if (search) url += `&search=${encodeURIComponent(search)}`; if (source) url += `&source=${encodeURIComponent(source)}`; if (_ragPageOffset !== null && !search) url += `&offset=${encodeURIComponent(_ragPageOffset)}`;