AI-powered Indian Business Compliance & Advisory Agent.
Evolve from a GST RAG chatbot into a Business Compliance & Advisory Agent that diagnoses business problems, gathers missing facts, reasons over them, retrieves evidence, and produces actionable plans.
RAG answers questions. An agent diagnoses a business problem, gathers missing facts, reasons over them, retrieves evidence, and produces an actionable plan.
Business Owner
│
▼
┌─────────────────┐
│ Business Agent │
│ Orchestrator │
└────────┬────────┘
│
┌──────────────┼──────────────┐
▼ ▼ ▼
Problem Business Knowledge
Detection Context Retrieval
│ │ │
▼ ▼ ▼
┌──────────┐ ┌─────────────┐ ┌──────────────┐
│ GST RAG │ │ User/Business│ │ Gov / Legal │
│ │ │ Profile │ │ Documents │
└──────────┘ └─────────────┘ └──────────────┘
│ │ │
└──────────────┼──────────────┘
▼
┌─────────────┐
│ Reasoning / │
│ Planning │
└──────┬──────┘
▼
┌─────────────┐
│ Action Plan │
└─────────────┘
- GST registration, composition scheme, input tax credit, GST returns
- E-invoicing, e-way bills, HSN/SAC, reverse charge
- GST notices, registration amendments, cancellation, refunds
- MCA, Udyam, Income Tax, GST, Shops & Establishments
- EPFO, ESIC, FSSAI, DGFT, state-specific registrations, local licenses
- Revenue/margin analysis, hiring affordability, EMI calculations
- Tools:
calculator,financial_analysis,tax_calculator
- Subsidies, incentives, loans, and schemes based on industry, location, company size, investment, employment
- GST: GSTR-1, GSTR-3B, Annual return
- Income Tax: Advance tax
- MCA: AOC-4, MGT-7
- Labour: PF, ESIC
NagrikAI operates with a finite context window determined by the LLM's capacity (typically 8K-32K tokens). Rather than attempting to retrieve and reason over unlimited documents, we:
- Retrieve top-K chunks (configurable, default 5) after reranking from Fetch-K candidates (default 20)
- Apply strict token limits to context construction
- Truncate overly long documents during parsing
- Accept that some niche queries may require refinement or fallback to web search
This constraint ensures predictable latency, prevents context overflow errors, and focuses the LLM on the most relevant information – mirroring how human researchers work with limited cognitive bandwidth.
# Clone and install
git clone https://github.com/your-org/nagrik-ai.git
cd nagrik-ai
# Install with UV (recommended)
uv sync
# Or with pip
pip install -e .
# Verify installation
uv run nagrik-ai --help# 1. Crawl official government sources (runs scrapy spiders)
uv run nagrik-ai crawl sites
# 2. Parse HTML to Markdown
uv run nagrik-ai parse all
# 3. Vectorize documents into ChromaDB
uv run nagrik-ai vectorize
# 4. Launch the Gradio web interface
uv run nagrik-ai app-command
# Optional: Use OpenRouter instead of local Ollama
uv run nagrik-ai app-command --llm-provider openrouter| Command | Description |
|---|---|
nagrik-ai crawl sites |
Crawl all configured government sites |
nagrik-ai parse all |
Convert crawled HTML to clean Markdown |
nagrik-ai vectorize |
Generate embeddings and populate ChromaDB |
nagrik-ai app-command |
Launch the Gradio web UI |
nagrik-ai trace test "Your question" |
Test with LangSmith tracing enabled |
uv run pytest tests/ -v |
Run the test suite |
Add this to your shell profile (~/.bashrc, ~/.zshrc, etc.) for quick access:
# Quick NagrikAI access
alias nagrik='uv run nagrik-ai app-command'Then simply type nagrik in your terminal to launch the assistant.
| Provider | Setup | Notes |
|---|---|---|
| Ollama (default) | ollama serve + ollama pull mistral:latest |
Fully private, local inference |
| OpenRouter | Set NAGRIKAI_OPENROUTER_API_KEY env var |
Access to 100+ cloud LLMs |
Create .env file (or set environment variables):
# LLM Provider (ollama or openrouter)
NAGRIKAI_LLM_PROVIDER=ollama
# Ollama settings (used when provider=ollama)
NAGRIKAI_OLLAMA_BASE_URL=http://localhost:11434
NAGRIKAI_OLLAMA_MODEL=mistral:latest
# OpenRouter settings (used when provider=openrouter)
NAGRIKAI_OPENROUTER_API_KEY=your-key-here
NAGRIKAI_OPENROUTER_MODEL=anthropic/claude-3.5-sonnet
# Embedding and reranking
NAGRIKAI_EMBEDDING_MODEL=BAAI/bge-m3
NAGRIKAI_RERANKER_MODEL=BAAI/bge-reranker-large
NAGRIKAI_RERANKER_ENABLED=true
NAGRIKAI_HYBRID_SEARCH_ENABLED=true
# Retrieval tuning
NAGRIKAI_TOP_K=5
NAGRIKAI_FETCH_K=20
NAGRIKAI_LAMBDA_MULT=0.7
NAGRIKAI_BM25_K1=1.5
NAGRIKAI_BM25_B=0.75
NAGRIKAI_RRF_K=60
# Observability
LANGSMITH_TRACING_ENABLED=true
LANGSMITH_API_KEY=your-langsmith-key
LANGSMITH_PROJECT=nagrik-aiMIT
- LangChain and LangGraph for LLM orchestration
- ChromaDB for vector storage
- Sentence Transformers for embedding models
- BM25 via rank-bm25 for keyword search
- Gradio for the web interface
- Typer for the CLI
- Pydantic for configuration management
- Ruff and MyPy for code quality
- Official Indian government websites (india.gov.in, gst.gov.in, tutorial.gst.gov.in) as knowledge sources