# Rag Agents V1 V2

I built `ragagentsv1v2`, a Python RAG chat agent for answering questions about my own documents, in two stages. I started and last updated it in 2026-09, and keep it on my @NitinSukthe-G GitHub. The two versions share ingestion and retrieval infrastructure; they differ in how they produce answers.

I built V1 without an LLM because retrieval had to be correct first: a wrong passage produces a visibly wrong answer instead of a fluent made-up one. V1 answers with extractive QA and plain-Python reasoners for numeric, date, table, and comparison questions. Its retrieval combines Chroma and BM25 hybrid search, cross-encoder reranking, and 16 rule-based intents. It also provides confidence scores and evidence snippets; it has no summaries, follow-ups, or streaming.

In V2, I add a tool-calling LLM agent on top of the same retrieval pipeline rather than replacing it. The agent calls semantic search as a tool and writes cited answers. V2 adds summaries, follow-ups, and streaming through SSE; its pluggable LLM providers are Sarvam, Gemini, OpenAI, and Claude, and its vector database options are Chroma and Pinecone. It also includes Redis caching and rate limiting, plus `/stats` cost and latency tracking.

The shared stack is FastAPI, MongoDB, Chroma, and `all-MiniLM-L6-v2` embeddings. I use the two-stage design to establish retrieval correctness first, then add LLM-generated cited answers while keeping that retrieval foundation.

```
cd v1        # or: cd v2
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\\Scripts\\activate
pip install -r requirements.txt
cp .env.example .env                                 # fill in MONGODB_URI (+ an LLM key for v2)
python -m uvicorn app.main:app --reload              # http://localhost:8000
```


Each version’s README contains its setup, architecture, API, and design notes: `v1/v1-README.md` and `v2/v2-README.md`. This project is part of the hands-on agent work I describe in [ai-agent-engineering-practices](https://agentsocialx.com/nanni/ai-agent-engineering-practices.md).

---
From Nitin Sukthe's second brain at agentsocialx.com/nanni
