How pankaj-2708/self-rag-on-indian-constitution works
This repository is a legal-question answering product for the Indian Constitution and IPC. A user submits a question in the web app; the API streams progress from a LangGraph workflow, which routes among local retrieval, web search, and direct generation, then validates and may correct its answer before returning it. The workflow also maintains conversational memory. The README documents a separate three-tier evaluation capability. Some backend and workflow source is excerpted, so uncertain runtime links are omitted or marked unverified.
Main entry points: __init__.py Workflow orchestrator · App.jsx Chat app · nodes.py Retrieve passages · Exchange.jsx Answer exchange
Components 25
Web client
- Chat app
frontend/src/App.jsx - Thread list
frontend/src/components/ThreadRail.jsx - Question composer
frontend/src/components/Composer.jsx - Prompt suggestions
frontend/src/components/Opening.jsx - Answer exchange
frontend/src/components/Exchange.jsx - Progress ledger
frontend/src/components/MarginLedger.jsx - Passage display
frontend/src/components/Passages.jsx - Streaming API client
frontend/src/lib/api.js - Event stream reader
frontend/src/lib/sse.js
Answer workflow
- Workflow orchestrator
src/workflow/__init__.py - Route and query
src/workflow/nodes.py - Retrieve passages
src/workflow/nodes.py - Filter relevance
src/workflow/nodes.py - Generate answer
src/workflow/nodes.py - Ground and correct
src/workflow/nodes.py - Conversation memory
src/workflow/nodes.py - Workflow state
src/workflow/state.py
Legal knowledge
- Chroma legal index
data/constitution_and_ipc.chroma - Web search service
Evaluation
- Dataset generation
evals/DatasetGeneration - Component evaluation
evals/Component_level - Pipeline evaluation
evals/PipelineLevel/eval.py
Other components
- Questioner
Connections 32
- Questioner → Chat app: asks
- Chat app → Thread list: renders
frontend/src/App.jsx - Chat app → Question composer: renders
frontend/src/App.jsx - Chat app → Prompt suggestions: renders
frontend/src/App.jsx - Chat app → Answer exchange: renders
frontend/src/App.jsx - Answer exchange → Progress ledger: renders
frontend/src/components/Exchange.jsx - Answer exchange → Passage display: renders
frontend/src/components/Exchange.jsx - Chat app → Streaming API client: requests answers
frontend/src/App.jsx - Streaming API client → Event stream reader: reads events
frontend/src/lib/api.js - Streaming API client → HTTP API: calls HTTP API
- HTTP API → Workflow orchestrator: loads workflow
Backend/main.py - A2A agent → Workflow orchestrator: runs workflow
A2A/agent.py - Workflow orchestrator → Route and query: dispatches stages
src/workflow/__init__.py - Workflow orchestrator → Retrieve passages: dispatches
src/workflow/__init__.py - Workflow orchestrator → Filter relevance: dispatches
src/workflow/__init__.py - Workflow orchestrator → Generate answer: dispatches
src/workflow/__init__.py - Workflow orchestrator → Ground and correct: dispatches
src/workflow/__init__.py - Workflow orchestrator → Conversation memory: dispatches
src/workflow/__init__.py - Route and query → Retrieve passages: routes retrieval
src/workflow/__init__.py - Retrieve passages → Chroma legal index: searches
src/workflow/nodes.py - Retrieve passages → Filter relevance: supplies passages
src/workflow/__init__.py - Filter relevance → Generate answer: passes relevant context
src/workflow/__init__.py - Filter relevance → Web search service: falls back to search
- Route and query → Web search service: routes web search
- Generate answer → Ground and correct: checks grounding
src/workflow/__init__.py - Ground and correct → Generate answer: revises answer
src/workflow/__init__.py - Ground and correct → Conversation memory: passes accepted answer
src/workflow/__init__.py - Conversation memory → Workflow state: updates conversation
src/workflow/nodes.py - Workflow orchestrator → Workflow state: uses shared state
src/workflow/__init__.py - Dataset generation → Component evaluation: prepares test set
README.md - Component evaluation → Pipeline evaluation: extends evaluation
README.md - Pipeline evaluation → Workflow orchestrator: evaluates workflow
evals/PipelineLevel/eval.py