Fix RAG admin: vectors_count->points_count, remove unindexed order_by, make RAG_COLLECTION env-configurable
This commit is contained in:
@@ -70,7 +70,7 @@ UPLOAD_DIR = os.environ.get("CAIC_UPLOAD_DIR", "/tmp/caic_uploads")
|
|||||||
MAX_UPLOAD_BYTES = 20 * 1024 * 1024
|
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"}
|
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")
|
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
|
UPLOAD_CONTEXT_EXPIRY_HOURS = 1
|
||||||
BODY_LIMIT_UPLOAD_BYTES = MAX_UPLOAD_BYTES
|
BODY_LIMIT_UPLOAD_BYTES = MAX_UPLOAD_BYTES
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -46,7 +46,8 @@ async def get_collection_count() -> int:
|
|||||||
timeout=10.0,
|
timeout=10.0,
|
||||||
)
|
)
|
||||||
if resp.status_code == 200:
|
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:
|
except Exception as e:
|
||||||
log.warning(f"get_collection_count error: {e}")
|
log.warning(f"get_collection_count error: {e}")
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -93,9 +93,6 @@ async def rag_list_points(
|
|||||||
scroll_body["offset"] = offset
|
scroll_body["offset"] = offset
|
||||||
if source:
|
if source:
|
||||||
scroll_body["filter"] = {"must": [{"match": {"key": "source", "value": 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(
|
sr = await client.post(
|
||||||
f"{QDRANT_URL}/collections/{RAG_COLLECTION}/points/scroll",
|
f"{QDRANT_URL}/collections/{RAG_COLLECTION}/points/scroll",
|
||||||
@@ -114,7 +111,8 @@ async def rag_list_points(
|
|||||||
)
|
)
|
||||||
total = 0
|
total = 0
|
||||||
if info_resp.status_code == 200:
|
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 = []
|
points = []
|
||||||
for r in raw_points:
|
for r in raw_points:
|
||||||
|
|||||||
@@ -1379,7 +1379,7 @@ async function loadRagPoints() {
|
|||||||
try {
|
try {
|
||||||
const search = document.getElementById('ragSearchInput').value.trim();
|
const search = document.getElementById('ragSearchInput').value.trim();
|
||||||
const source = document.getElementById('ragSourceFilter').value;
|
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 (search) url += `&search=${encodeURIComponent(search)}`;
|
||||||
if (source) url += `&source=${encodeURIComponent(source)}`;
|
if (source) url += `&source=${encodeURIComponent(source)}`;
|
||||||
if (_ragPageOffset !== null && !search) url += `&offset=${encodeURIComponent(_ragPageOffset)}`;
|
if (_ragPageOffset !== null && !search) url += `&offset=${encodeURIComponent(_ragPageOffset)}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user