How arunkumar-201/judicial_rag_bot works
This is a Streamlit assistant for explaining court procedures from legal documents. Users can upload TXT/PDF files for ingestion, or use the bundled court document; they ask a question and receive an answer with retrieved source snippets. Ingestion extracts and chunks text, embeds it, and persists a FAISS index and document store. The answering path validates the query, retrieves matching chunks, applies an optional category filter, then generates an explanation using Gemini when a key is supplied or the local FLAN-T5 model otherwise. Source excerpts show the main calls; unsampled document and vector-store contents are treated only as data.
Main entry points: rag.py Answer orchestration · app.py Streamlit chat and uploads · ingest.py File ingestion · index.faiss FAISS index and documents
Components 14
User interface
- Streamlit chat and uploads
app.py
Document ingestion
- File ingestion
ingest.py - TXT/PDF extraction
ingest.py - Chunk and embed
ingest.py - Bundled court text
data/court_docs.txt
Question answering
- Answer orchestration
rag.py - Judicial query validation
rag.py - Semantic retrieval and filtering
rag.py - Explanation generation
rag.py
Knowledge store
- FAISS index and documents
vectorstore/index.faiss
Other components
- User
- Sentence Transformer
- Local FLAN-T5
- Gemini API
Connections 17
- User → Streamlit chat and uploads: asks or uploads
app.py - Streamlit chat and uploads → File ingestion: ingests uploads
app.py - Streamlit chat and uploads → File ingestion: initializes defaults
app.py - File ingestion → TXT/PDF extraction: extracts text
ingest.py - TXT/PDF extraction → Chunk and embed: chunks text
ingest.py - Chunk and embed → Sentence Transformer: encodes chunks
ingest.py - File ingestion → Bundled court text: reads default file
ingest.py - Chunk and embed → FAISS index and documents: writes embeddings and chunks
ingest.py - Streamlit chat and uploads → Answer orchestration: submits question
app.py - Answer orchestration → Judicial query validation: validates query
rag.py - Answer orchestration → Semantic retrieval and filtering: retrieves context
rag.py - Semantic retrieval and filtering → Sentence Transformer: encodes query
rag.py - Semantic retrieval and filtering → FAISS index and documents: searches index and reads documents
rag.py - Answer orchestration → Explanation generation: generates response
rag.py - Explanation generation → Local FLAN-T5: uses local model
rag.py - Explanation generation → Gemini API: uses keyed API
rag.py - Answer orchestration → Streamlit chat and uploads: returns answer and sources
app.py