Logo Lanfrica

NahumDm/LexiAI

Domain:

natural language processing

Record type:

software
Creator:
Nah
Host:
AI Legal assistance for Ethiopian Law. # LexiAI A production-grade **Retrieval-Augmented Generation (RAG)** stack for legal and tax documents. The **Django + DRF** service ingests user-uploaded documents, chunks and embeds them with sentence-transformers, and answers natural-language questions by retrieving the most relevant passages and grounding a Mistral LLM completion on them — with strict citation rules, observability, and graceful degradation. This repository contains that **Django API** plus an optional **React (Vite) frontend** with a **staff-only admin dashboard** (`/admin` in the SPA) that talks to the same versioned REST API over JWT. Django’s built-in `/admin/` site remains available for model CRUD; the SPA is a separate convenience UI for operators. --- ## Features - **Stateless Q&A endpoint** — `POST /api/v1/ask/` returns a grounded answer plus the source chunks used to construct it. - **RAG pipeline** — query → embedding → cosine search → context assembly → LLM completion → citations. - **Pluggable LLM backend** — Mistral by default, swappable to any OpenAI-compatible endpoint or an offline stub via `AI_LLM_BACKEND`. - **Background model warmup** — the embedding model loads in a daemon thread at startup, eliminating ~45 s cold-start latency on the first request. - **Operational health probe** — `GET /api/v1/health/` reports DB, LLM, and embedding-model status for orchestrators and uptime monitors. - **Per-user request observability** — every `/ask/` call logs `user_id`, query size, `top_k`, retrieval confidence, LLM latency, token usage, and a 60-second rolling request counter. - **Hardened configuration** — env-driven settings, weak-`SECRET_KEY` detection in production, no hardcoded credentials, sensitive files gitignored. - **Reproducible deployment** — all runtime dependencies are pinned and installed at Docker build time; no runtime `pip install`. - **Staff admin API + SPA** — JWT-authenticated React routes under `/admin` backed by DRF views with `IsAdminUser`: global analytics, d …