A Graph-based AI Agent for detecting election misinformation, verifying EVM/VVPAT claims, and providing personalized assistance to election officials using Visual Forensics and Persistent Memory.
This system is not just a chatbot; it is a Stateful Multi-Agent System that maintains a psychological profile of the user (Long-Term Memory). It uses Hybrid Search (Dense + Sparse) to cross-reference claims against official Election Commission manuals and performs Visual Search to detect tampered devices from user-uploaded images.
For a detailed deep-dive into the embedding strategies and Qdrant configuration, open docs/index.html in your browser.
Key Capabilities:
- Role-Based Memory: Remembers if you are a "Presiding Officer" (needs technical rules) or a "Citizen" (needs reassurance) and adapts answers accordingly.
- Visual Forensics: Upload an image of an EVM control unit or VVPAT to verify its authenticity against a database of reference images.
- Hybrid RAG: Combines Semantic Search (Vector) and Keyword Search (BM25) for high-precision retrieval from legal manuals.
- Self-Correction: The agent generates a search plan, executes it, and can refine its search if initial results are poor.
The system is built on LangGraph, treating the conversation as a directed graph of functional nodes.
graph LR A[Start] --> B(Loader Node); B --> C{Query Generator}; C -- Text Claim --> D[Hybrid Search]; C -- Image Upload --> E[Visual Search]; D --> F[Responder]; E --> F; F --> G(Memory Writer); G --> H[End];
| Node | Function |
|---|---|
| Loader | Fetches the user's persistent profile (Persona, Style, Preferences) from Qdrant. |
| Query Gen | Analyzes the input and decides whether to use search_hybrid (text) or search_image (visual). |
| Search Tools | Executes the retrieval against the election_manuals Qdrant collection. |
| Responder | Synthesizes the answer using the retrieved evidence and the user's specific context. |
| Memory Writer | Uses an LLM to extract new facts/preferences and updates the user_profiles collection. |
-
Orchestration: LangGraph, LangChain
-
Vector Database: Qdrant (Self-hosted or Cloud) for memory and data.
-
Embeddings:
-
Text:
intfloat/multilingual-e5-base(768d) -
Image:
clip-ViT-B-32(512d) -
Sparse: FastEmbed (BM25)
-
LLM: Google Gemini 2.5 Flash
-
CLI: Typer & Rich (for the interactive terminal UI)
- Clone the repository
git clone [https://github.com/yourusername/mas-election-agent.git](https://github.com/yourusername/mas-election-agent.git)
cd mas-election-agent
- Install Dependencies
python3 -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
-
Environment Setup Change the
env.examplefile to.envand fill in the values: -
Initialize Database Run the setup scripts to create collections and load initial manuals.
cd setup
python create_memory.py # Creates 'user_profiles'
python populate_qdrant.py # Creates 'data points'Run the Interactive CLI Application:
log yourself in and hide raw logs behind a spinner.
cd ../
python cli.py
Shows the internal thought process (Nodes, Plans, Search Results) in real-time. Great for judging/demos.
python cli.py --logs
Inside the chat, you can use:
/new- Start a fresh session (clears chat history, keeps memory)./login <name>- Switch user identity (loads a different memory profile)./image <path>- Attach an image to your query.- Example:
/image assets/broken_seal.jpg Is this seal valid?
- https://github.com/Keshav-CUJ/Qdrant-convole/raw/main/images/EVMbackpack.png is this man stealing evm.
- A digital news channel claimed that during Presidential Elections 2022, votes casted for Smt. Droupadi Murmu were declared invalid, give me proper evidence.
We use a Deterministic ID approach for Long-Term Memory (LTM).
- We do not "search" for users.
- We generate a UUID based on the username:
uuid5(NAMESPACE, "officer_keshav"). - This ensures instant, O(1) retrieval of the user profile without similarity search overhead.
- Decay/Update: The
Memory Writernode acts as a "Scribe", summarizing the latest interaction and merging it with the existing profile, naturally discarding irrelevant details over time.
- Just give your email, you will recieve and OTP, put it there.
- User: agent_guest
- password: 1234
- And you are in my application, here you can keep user name differnet than agent_guest.
- You are getting a ssh shell with low priveleges.
Inside the chat, you can use:
/new- Start a fresh session (clears chat history, keeps memory)./login <name>- Switch user identity (loads a different memory profile)./image <path>- Attach an image to your query.- Example:
/image assets/broken_seal.jpg Is this seal valid?
-
My name is I am from I heard recently that EVM can be hacked??
-
is this man stealing evm /image https://github.com/Keshav-CUJ/Qdrant-convole/raw/main/images/EVMbackpack.png
-
A digital news channel claimed that during Presidential Elections 2022, votes casted for Smt. Droupadi Murmu were declared invalid, give me proper evidence.
Keshav Bhatt

