Graph Policy is an enterprise-grade AI assistant capable of processing complex government schemes, modeling them dynamically using Knowledge Graphs, and conducting natural language Retrieval Augmented Generation (RAG) search combined with deterministic Eligibility Evaluation.
This is a production-ready rewrite supporting completely dynamic, data-driven reasoning.
- Ingestion Pipeline (
ingestion/pipeline.py)- Downloads, parses, and chunks raw PDF, HTML, and TXT data natively using
LangChainloaders. - Leverages Heuristics or Google Gemini (if configured in
.env) to parse explicit Scheme Nodes, Benefits, Criterions, and State structures into our Knowledge Graph without hardcoding anything.
- Downloads, parses, and chunks raw PDF, HTML, and TXT data natively using
- Retrieval Engine (
retrieval/vector_store.py)- Implements native FAISS Vector indexing using HuggingFaceEmbeddings (
all-MiniLM-L6-v2) to capture context semantics and exact document sources.
- Implements native FAISS Vector indexing using HuggingFaceEmbeddings (
- Dynamic Knowledge Graph (
kg/graph_store.py)- Maintains an
InMemoryGraphStorevia NetworkX mapping relationships likeHAS_ELIGIBILITYandPROVIDES_BENEFIT. - Serializes directly to
data/indices/graph.jsonso memory states persist.
- Maintains an
- Data-Driven Eligibility (
eligibility/engine.py)- Completely removes hardcoded evaluations.
- Evaluates a User Profile dynamically by fetching raw
CriterionNodes directly from the Knowledge Graph on a per-scheme basis and parsing relational operators (e.g.<=,in).
- Modern API Backend (
api/server.py)- Offers robust endpoints like
/query(runs combined graph traversal + FAISS retrieval + LLM synthesis) and/eligibility(dynamic rule checking).
- Offers robust endpoints like
- Next-Generation React UI
- Built with Vite, Tailwind CSS v4, Framer Motion, and Recharts.
- Includes real dashboard analytics, knowledge graph visualizations via
react-force-graph, full Perplexity-like Search, and multi-colored Eligibility trace outputs.
# Install dependencies
pip install -r requirements.txt pydantic-settings
# Start the Ingestion Pipeline. If no data exists, this will auto-seed
# the data/raw/ directory with PM-KISAN, Ayushman Bharat, PMAY, Startup India etc.,
# completely process them, build FAISS embeddings, and construct the KG.
python ingestion/run_ingest.py
# Optional: Ensure Gemini API is available for superior extractions and synthesize
# Add variable back into .env file if necessary.
echo "GEMINI_API_KEY=your_key" > .env
# Run the FastAPI server
uvicorn api.server:app --reloadAPI will run on http://localhost:8000
cd ui/frontend
npm run devVite Server will run cleanly on http://localhost:5173
# Measure precision, recall, and F1 on document retrieval
python evaluation/eval.pyThe repo contains a Dockerfile.
docker build -t graph-policy-backend .docker run -p 8000:8000 graph-policy-backend
- Standard Uvicorn initialization.
- Build Command:
pip install -r requirements.txt - Start Command:
uvicorn api.server:app --host 0.0.0.0 --port $PORT
- Build Command:
cd ui/frontend && npm install && npm run build - Output Directory:
dist