Spaces:
Running
Running
Download sinetti_api/routers/knowledge_admin.py from Couscouskabyle/iscc-app: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/Couscouskabyle/iscc-app/resolve/main/sinetti_api/routers/knowledge_admin.py
- Command line
-
hf download hf://spaces/Couscouskabyle/iscc-app/sinetti_api/routers/knowledge_admin.py
-
curl -L -o knowledge_admin.py https://huggingface.co/spaces/Couscouskabyle/iscc-app/resolve/main/sinetti_api/routers/knowledge_admin.py
1.1 kB
| """Admin "Ask knowledge" page: the document catalog of the Ask retrieval corpus. | |
| Read-only. Serves the committed `rag_catalog.json` written by `rag_index.py` at index | |
| build time — the server never reads the gitignored knowledge/ corpus files. Mounted with | |
| dependencies=[Depends(require_admin)] in sinetti_api/app.py (same pattern as admin_sources). | |
| """ | |
| from __future__ import annotations | |
| from fastapi import APIRouter | |
| import rag_catalog | |
| from sinetti_api.schemas import KnowledgeCorpusResponse | |
| router = APIRouter(prefix="/api/admin/knowledge", tags=["knowledge_admin"]) | |
| def knowledge_corpus() -> dict: | |
| catalog = rag_catalog.load_catalog() | |
| if not catalog.get("documents"): | |
| return {"ok": False, "message": "No corpus catalog on this build."} | |
| return { | |
| "ok": True, | |
| "built_at": catalog.get("built_at", ""), | |
| "embedding_model": catalog.get("embedding_model", ""), | |
| "total_chunks": catalog.get("total_chunks", 0), | |
| "documents": catalog["documents"], | |
| } | |